Skip to content

Commit 3c2c5ca

Browse files
committed
fix(cli): clip welcome logo in narrow terminals
1 parent b35bdf1 commit 3c2c5ca

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎packages/cli/src/tests/welcome-screen.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,30 @@ import { test } from "node:test";
22
import assert from "node:assert/strict";
33
import * as os from "os";
44
import * as path from "path";
5+
import React from "react";
6+
import { renderToString } from "ink";
7+
import { resolveSettingsSources } from "../../../core/src/settings";
58
import { buildWelcomeTips, formatHomeRelativePath } from "../ui";
9+
import { AsciiLogo } from "../ui/ascii-art";
10+
import { WelcomeScreen } from "../ui/views/WelcomeScreen";
11+
import { stripTerminalControls } from "./terminal-output";
12+
13+
test("welcome logo clips its right edge without wrapping in narrow terminals", () => {
14+
const settings = resolveSettingsSources({}, {}, { model: "deepseek-flash", baseURL: "https://example.com" }, {});
15+
for (const width of [40, 60, 70, 72, 80, 120]) {
16+
const output = stripTerminalControls(
17+
renderToString(React.createElement(WelcomeScreen, { projectRoot: "/project", settings, skills: [], width }), {
18+
columns: width,
19+
})
20+
);
21+
const logo = output.split(/\n\s*╭─/)[0].trim();
22+
assert.deepEqual(
23+
logo.split("\n").map((line) => line.trim()),
24+
AsciiLogo.split("\n").map((line) => line.slice(0, width - 3).trim()),
25+
`terminal width: ${width}`
26+
);
27+
}
28+
});
629

730
test("formatHomeRelativePath returns tilde for the home directory", () => {
831
const home = path.resolve("/Users/example");

‎packages/cli/src/ui/views/WelcomeScreen.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export function WelcomeScreen({ projectRoot, settings, skills, width }: WelcomeS
4343
<Box flexDirection="column" marginY={1}>
4444
<Box flexDirection="column" width={panelWidth}>
4545
<Box flexDirection="column" paddingX={1}>
46-
<Box flexDirection="column" justifyContent="center" paddingX={1}>
47-
<Box justifyContent="center" width={compact ? undefined : TITLE_PANEL_WIDTH}>
46+
<Box flexDirection="column" justifyContent="center" paddingX={1} overflowX="hidden">
47+
<Box justifyContent="center" width={TITLE_PANEL_WIDTH} flexShrink={0}>
4848
<ThemedGradient>{AsciiLogo}</ThemedGradient>
4949
</Box>
5050
</Box>

0 commit comments

Comments
 (0)