diff --git a/packages/cli/src/cli-args.ts b/packages/cli/src/cli-args.ts index 780869c0..b86eda41 100644 --- a/packages/cli/src/cli-args.ts +++ b/packages/cli/src/cli-args.ts @@ -6,7 +6,7 @@ import type { Argv } from "yargs"; import Yargs from "yargs"; import { getCliVersion } from "./utils/version"; -import { writeStderrLine } from "./utils/stdioHelpers"; +import { writeStderrLine } from "./utils/stdio-helpers"; import { hideBin } from "yargs/helpers"; // UUID v4 regex pattern for validation diff --git a/packages/cli/src/cli.tsx b/packages/cli/src/cli.tsx index af33bc42..80b11f08 100644 --- a/packages/cli/src/cli.tsx +++ b/packages/cli/src/cli.tsx @@ -7,7 +7,7 @@ import { setShellIfWindows, getProjectCode } from "@vegamo/deepcode-core"; import { checkForNpmUpdate, promptForPendingUpdate } from "./common/update-check"; import { AppContainer } from "./ui"; import { parseArguments } from "./cli-args"; -import { writeStderrLine, writeStdoutLine } from "./utils/stdioHelpers"; +import { writeStderrLine, writeStdoutLine } from "./utils/stdio-helpers"; import { getPackageJson } from "./utils/package"; import { CLI_VERSION } from "./generated/git-commit"; diff --git a/packages/cli/src/tests/message-view.test.ts b/packages/cli/src/tests/message-view.test.ts index fbd2b097..c1c2d69d 100644 --- a/packages/cli/src/tests/message-view.test.ts +++ b/packages/cli/src/tests/message-view.test.ts @@ -127,12 +127,19 @@ test("renderMessageToStdout shows (no content) for empty user messages", () => { }); test("MessageView echoes submitted user prompts with live prompt wrapping width", () => { - assert.equal(getPromptEchoContentWidth(8), 6); + assert.equal(getPromptEchoContentWidth(8), 5); const msg = makeSessionMessage({ role: "user", content: "abcdefg" }); const output = renderToString(React.createElement(MessageView, { message: msg, width: 8 }), { columns: 8 }); - assert.equal(stripAnsi(output), "> abcdef\n g\n"); + const text = stripAnsi(output); + assert.equal(text, " > abcde\n fg\n"); + assert.ok( + text + .trimEnd() + .split("\n") + .every((line) => line.length <= 8) + ); }); test("MessageView echoes model changes with submitted prompt wrapping", () => { @@ -143,7 +150,14 @@ test("MessageView echoes model changes with submitted prompt wrapping", () => { }); const output = renderToString(React.createElement(MessageView, { message: msg, width: 8 }), { columns: 8 }); - assert.equal(stripAnsi(output), "> abcdef\n gh\n"); + const text = stripAnsi(output); + assert.equal(text, " > abcde\n fgh\n"); + assert.ok( + text + .trimEnd() + .split("\n") + .every((line) => line.length <= 8) + ); }); test("renderMessageToStdout renders assistant non-thinking messages with ✦", () => { diff --git a/packages/cli/src/ui/components/MessageView/index.tsx b/packages/cli/src/ui/components/MessageView/index.tsx index 66df9625..12b8229d 100644 --- a/packages/cli/src/ui/components/MessageView/index.tsx +++ b/packages/cli/src/ui/components/MessageView/index.tsx @@ -13,6 +13,7 @@ import type { DiffPreviewLine, MessageViewProps } from "./types"; import { RawMode, useRawModeContext } from "../../contexts"; const PROMPT_ECHO_PREFIX_WIDTH = 2; +const PROMPT_ECHO_MARGIN_LEFT = 1; export function MessageView({ message, collapsed, width = 80 }: MessageViewProps): React.ReactElement | null { const { mode } = useRawModeContext(); @@ -131,7 +132,7 @@ export function MessageView({ message, collapsed, width = 80 }: MessageViewProps } export function getPromptEchoContentWidth(width: number): number { - return Math.max(1, width - PROMPT_ECHO_PREFIX_WIDTH); + return Math.max(1, width - PROMPT_ECHO_MARGIN_LEFT - PROMPT_ECHO_PREFIX_WIDTH); } function PromptEchoLine({ @@ -144,8 +145,9 @@ function PromptEchoLine({ attachmentCount?: number; }): React.ReactElement { const contentWidth = getPromptEchoContentWidth(width); + const containerWidth = Math.max(1, width - PROMPT_ECHO_MARGIN_LEFT); return ( - + {"> "} diff --git a/packages/cli/src/utils/package.ts b/packages/cli/src/utils/package.ts index 1f195294..3c1401af 100644 --- a/packages/cli/src/utils/package.ts +++ b/packages/cli/src/utils/package.ts @@ -3,11 +3,7 @@ import { fileURLToPath } from "node:url"; import path from "node:path"; import { CLI_VERSION } from "../generated/git-commit"; -export type PackageJson = BasePackageJson & { - config?: { - sandboxImageUri?: string; - }; -}; +export type PackageJson = BasePackageJson; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); diff --git a/packages/cli/src/utils/stdioHelpers.ts b/packages/cli/src/utils/stdio-helpers.ts similarity index 100% rename from packages/cli/src/utils/stdioHelpers.ts rename to packages/cli/src/utils/stdio-helpers.ts