Skip to content

Commit 1050e65

Browse files
authored
Merge pull request #197 from hqwlkj/main
style(MessageView): 在消息视图组件中添加左边距
2 parents da9f099 + 377e041 commit 1050e65

6 files changed

Lines changed: 24 additions & 12 deletions

File tree

packages/cli/src/cli-args.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import type { Argv } from "yargs";
77
import Yargs from "yargs";
88
import { getCliVersion } from "./utils/version";
9-
import { writeStderrLine } from "./utils/stdioHelpers";
9+
import { writeStderrLine } from "./utils/stdio-helpers";
1010
import { hideBin } from "yargs/helpers";
1111

1212
// UUID v4 regex pattern for validation

packages/cli/src/cli.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { setShellIfWindows, getProjectCode } from "@vegamo/deepcode-core";
77
import { checkForNpmUpdate, promptForPendingUpdate } from "./common/update-check";
88
import { AppContainer } from "./ui";
99
import { parseArguments } from "./cli-args";
10-
import { writeStderrLine, writeStdoutLine } from "./utils/stdioHelpers";
10+
import { writeStderrLine, writeStdoutLine } from "./utils/stdio-helpers";
1111
import { getPackageJson } from "./utils/package";
1212
import { CLI_VERSION } from "./generated/git-commit";
1313

packages/cli/src/tests/message-view.test.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,19 @@ test("renderMessageToStdout shows (no content) for empty user messages", () => {
127127
});
128128

129129
test("MessageView echoes submitted user prompts with live prompt wrapping width", () => {
130-
assert.equal(getPromptEchoContentWidth(8), 6);
130+
assert.equal(getPromptEchoContentWidth(8), 5);
131131

132132
const msg = makeSessionMessage({ role: "user", content: "abcdefg" });
133133
const output = renderToString(React.createElement(MessageView, { message: msg, width: 8 }), { columns: 8 });
134134

135-
assert.equal(stripAnsi(output), "> abcdef\n g\n");
135+
const text = stripAnsi(output);
136+
assert.equal(text, " > abcde\n fg\n");
137+
assert.ok(
138+
text
139+
.trimEnd()
140+
.split("\n")
141+
.every((line) => line.length <= 8)
142+
);
136143
});
137144

138145
test("MessageView echoes model changes with submitted prompt wrapping", () => {
@@ -143,7 +150,14 @@ test("MessageView echoes model changes with submitted prompt wrapping", () => {
143150
});
144151
const output = renderToString(React.createElement(MessageView, { message: msg, width: 8 }), { columns: 8 });
145152

146-
assert.equal(stripAnsi(output), "> abcdef\n gh\n");
153+
const text = stripAnsi(output);
154+
assert.equal(text, " > abcde\n fgh\n");
155+
assert.ok(
156+
text
157+
.trimEnd()
158+
.split("\n")
159+
.every((line) => line.length <= 8)
160+
);
147161
});
148162

149163
test("renderMessageToStdout renders assistant non-thinking messages with ✦", () => {

packages/cli/src/ui/components/MessageView/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type { DiffPreviewLine, MessageViewProps } from "./types";
1313
import { RawMode, useRawModeContext } from "../../contexts";
1414

1515
const PROMPT_ECHO_PREFIX_WIDTH = 2;
16+
const PROMPT_ECHO_MARGIN_LEFT = 1;
1617

1718
export function MessageView({ message, collapsed, width = 80 }: MessageViewProps): React.ReactElement | null {
1819
const { mode } = useRawModeContext();
@@ -131,7 +132,7 @@ export function MessageView({ message, collapsed, width = 80 }: MessageViewProps
131132
}
132133

133134
export function getPromptEchoContentWidth(width: number): number {
134-
return Math.max(1, width - PROMPT_ECHO_PREFIX_WIDTH);
135+
return Math.max(1, width - PROMPT_ECHO_MARGIN_LEFT - PROMPT_ECHO_PREFIX_WIDTH);
135136
}
136137

137138
function PromptEchoLine({
@@ -144,8 +145,9 @@ function PromptEchoLine({
144145
attachmentCount?: number;
145146
}): React.ReactElement {
146147
const contentWidth = getPromptEchoContentWidth(width);
148+
const containerWidth = Math.max(1, width - PROMPT_ECHO_MARGIN_LEFT);
147149
return (
148-
<Box marginBottom={1} marginY={0} width={Math.max(1, width)} flexDirection="row">
150+
<Box marginBottom={1} marginLeft={PROMPT_ECHO_MARGIN_LEFT} marginY={0} width={containerWidth} flexDirection="row">
149151
<Box width={PROMPT_ECHO_PREFIX_WIDTH}>
150152
<Text color="#229ac3">{"> "}</Text>
151153
</Box>

packages/cli/src/utils/package.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import { fileURLToPath } from "node:url";
33
import path from "node:path";
44
import { CLI_VERSION } from "../generated/git-commit";
55

6-
export type PackageJson = BasePackageJson & {
7-
config?: {
8-
sandboxImageUri?: string;
9-
};
10-
};
6+
export type PackageJson = BasePackageJson;
117

128
const __filename = fileURLToPath(import.meta.url);
139
const __dirname = path.dirname(__filename);

0 commit comments

Comments
 (0)