Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/src/cli-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/cli.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
20 changes: 17 additions & 3 deletions packages/cli/src/tests/message-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand All @@ -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 ✦", () => {
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/src/ui/components/MessageView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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({
Expand All @@ -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 (
<Box marginBottom={1} marginY={0} width={Math.max(1, width)} flexDirection="row">
<Box marginBottom={1} marginLeft={PROMPT_ECHO_MARGIN_LEFT} marginY={0} width={containerWidth} flexDirection="row">
<Box width={PROMPT_ECHO_PREFIX_WIDTH}>
<Text color="#229ac3">{"> "}</Text>
</Box>
Expand Down
6 changes: 1 addition & 5 deletions packages/cli/src/utils/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading