fix(webui): refine reasoning shell activity copy across locales (#6689)
This commit is contained in:
1 parent
b77e9592af
commit
966ed5e0bd
19 files changed
+535
-535
No files matched your search
@@ -133,9 +133,9 @@ describe("AgentActivityCluster", () => {
|
||||
openLiveActivity();
|
||||
const rows = screen.getAllByTestId("activity-step").map((row) => row.textContent);
|
||||
expect(rows).toEqual([
|
||||
"Command was still running at the last check npm test --token ••••",
|
||||
"Command still running npm test --token ••••",
|
||||
"Read file README.md",
|
||||
"Command failed (exit code 7) npm test --token ••••",
|
||||
"Command failed (exit 7) npm test --token ••••",
|
||||
]);
|
||||
expect(container.innerHTML).not.toContain(id);
|
||||
expect(container.innerHTML).not.toContain("secret-value");
|
||||
@@ -168,7 +168,7 @@ describe("AgentActivityCluster", () => {
|
||||
render(<AgentActivityCluster messages={[message]} isTurnStreaming hasBodyBelow={false} />);
|
||||
openLiveActivity();
|
||||
expect(screen.getAllByTestId("activity-step").map((row) => row.textContent)).toEqual([
|
||||
"Command was still running at the last check", "Command completed", "Reading file later.txt",
|
||||
"Command still running", "Command completed", "Reading file later.txt",
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -208,14 +208,14 @@ describe("AgentActivityCluster", () => {
|
||||
expect(container).toHaveTextContent("Could not check command test-b");
|
||||
expect(container).toHaveTextContent("Command completed test-a");
|
||||
expect(container).not.toHaveTextContent("private");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Show earlier command checks (9)" }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Show 9 earlier checks" }));
|
||||
expect(screen.getAllByTestId("activity-step")).toHaveLength(14);
|
||||
expect(screen.getByRole("button", { name: "Hide earlier command checks (9)" })).toHaveAttribute("aria-expanded", "true");
|
||||
expect(screen.getByRole("button", { name: "Hide 9 earlier checks" })).toHaveAttribute("aria-expanded", "true");
|
||||
rerender(view(11));
|
||||
expect(screen.getAllByTestId("activity-step")).toHaveLength(15);
|
||||
fireEvent.click(screen.getByRole("button", { name: "Hide earlier command checks (10)" }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Hide 10 earlier checks" }));
|
||||
expect(screen.getAllByTestId("activity-step")).toHaveLength(5);
|
||||
expect(screen.getByRole("button", { name: "Show earlier command checks (6)" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "Show 6 earlier checks" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows a generic session label until its source command becomes available", () => {
|
||||
@@ -306,11 +306,11 @@ describe("AgentActivityCluster", () => {
|
||||
|
||||
await act(async () => setAppLanguage("zh-CN"));
|
||||
|
||||
expect(screen.getByText(`文件搜索完成 “${query}”`)).toBeInTheDocument();
|
||||
expect(screen.getByText(`已搜索文件 “${query}”`)).toBeInTheDocument();
|
||||
expect(screen.getByText(`正在读取文件 ${path}`)).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("正在使用 Blender, --json --background scene.blend")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("正在打开 example.com, Browserbase")).toBeInTheDocument();
|
||||
expect(screen.getByRole("img", { name: "编辑" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("img", { name: "已编辑" })).toBeInTheDocument();
|
||||
expect(screen.getByTestId("activity-file-reference")).toHaveTextContent(path);
|
||||
|
||||
await act(async () => setAppLanguage("ja"));
|
||||
@@ -357,15 +357,15 @@ describe("AgentActivityCluster", () => {
|
||||
it.each([
|
||||
{
|
||||
locale: "en" as const,
|
||||
waiting: "Connection failed Retrying in 5s",
|
||||
retrying: "Connection failed Retrying",
|
||||
exhausted: "Connection failed Ending turn",
|
||||
waiting: "Connection failed. Retrying in 5s",
|
||||
retrying: "Connection failed. Retrying",
|
||||
exhausted: "Connection failed. Ending turn",
|
||||
},
|
||||
{
|
||||
locale: "zh-CN" as const,
|
||||
waiting: "连接失败 5 秒后重试",
|
||||
retrying: "连接失败 正在重试",
|
||||
exhausted: "连接失败 正在结束本次任务",
|
||||
waiting: "连接失败,5 秒后重试",
|
||||
retrying: "连接失败,正在重试",
|
||||
exhausted: "连接失败,正在结束本轮",
|
||||
},
|
||||
])("shows localized model retry progress in the activity header ($locale)", async ({
|
||||
locale, waiting, retrying, exhausted,
|
||||
@@ -771,7 +771,7 @@ describe("AgentActivityCluster", () => {
|
||||
retryStatus={{ state: "waiting", attempt: 1, max_attempts: 4, error_kind: "connection" }}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByRole("status", { name: "Connection failed Retrying" }))
|
||||
expect(screen.getByRole("status", { name: "Connection failed. Retrying" }))
|
||||
.toBeVisible();
|
||||
unmount();
|
||||
render(<AgentActivityCluster messages={messages} isTurnStreaming={false} hasBodyBelow />);
|
||||
@@ -1732,7 +1732,7 @@ describe("AgentActivityCluster", () => {
|
||||
);
|
||||
|
||||
openLiveActivity();
|
||||
expect(screen.getByText("File search complete *.tsx")).toBeInTheDocument();
|
||||
expect(screen.getByText("Found files *.tsx")).toBeInTheDocument();
|
||||
expect(screen.getByText("Listed files memory")).toBeInTheDocument();
|
||||
expect(screen.getByText("Searching files “dream_cursor”")).toBeInTheDocument();
|
||||
expect(screen.queryByText("Technical details")).not.toBeInTheDocument();
|
||||
@@ -1903,7 +1903,7 @@ describe("AgentActivityCluster", () => {
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Worked" }));
|
||||
|
||||
expect(screen.getByLabelText("Ran command cat << 'EOF' | bash, script, 6 lines")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("Ran command cat << 'EOF' | bash, script (6 lines)")).toBeInTheDocument();
|
||||
expect(screen.queryByText(/SECRET_TOKEN/)).not.toBeInTheDocument();
|
||||
expect(screen.queryByText(/for id in/)).not.toBeInTheDocument();
|
||||
expect(screen.queryByText(/^Done$/)).not.toBeInTheDocument();
|
||||
@@ -1926,7 +1926,7 @@ describe("AgentActivityCluster", () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.getByText("Checking current time")).toBeInTheDocument();
|
||||
expect(screen.getByText("Checking time")).toBeInTheDocument();
|
||||
expect(screen.queryByText(/%Y-%m-%d/)).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("Web")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -34,11 +34,11 @@ describe("exec session activity", () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[{}, "Waiting for command result"],
|
||||
[{}, "Waiting for command"],
|
||||
[{ wait_for: "private output" }, "Waiting for command output"],
|
||||
[{ input: "private input" }, "Sending input"],
|
||||
[{ close_stdin: true }, "Closing command input"],
|
||||
[{ input: "private input", close_stdin: true }, "Sending and closing command input"],
|
||||
[{ input: "private input", close_stdin: true }, "Sending and closing input"],
|
||||
[{ terminate: true }, "Stopping command"],
|
||||
])("describes an in-flight operation without displaying its arguments", (args, label) => {
|
||||
const model = present(event(args, "start"));
|
||||
@@ -52,11 +52,11 @@ describe("exec session activity", () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[running, "Command was still running at the last check"],
|
||||
[`${running}\nWait timed out after 1s; session remains active.`, "Wait timed out; command was still running at the last check"],
|
||||
[running, "Command still running"],
|
||||
[`${running}\nWait timed out after 1s; session remains active.`, "Wait timed out (still running)"],
|
||||
[exit(0), "Command completed"],
|
||||
[exit(7), "Command failed (exit code 7)"],
|
||||
[`Session terminated. Reason: cancelled.\nExit code: -15\nElapsed: 3.0s`, "Command exited (exit code -15)"],
|
||||
[exit(7), "Command failed (exit 7)"],
|
||||
[`Session terminated. Reason: cancelled.\nExit code: -15\nElapsed: 3.0s`, "Command exited (exit -15)"],
|
||||
])("shows the observed command state rather than tool-return success", (result, label) => {
|
||||
expect(present(event({}, "end", result))).toMatchObject({ label, active: false });
|
||||
});
|
||||
@@ -73,8 +73,8 @@ describe("exec session activity", () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
["Error: Command timed out; session was terminated. Reason: max_runtime.\nExit code: -9\nElapsed: 3.0s", "Command timed out and was stopped"],
|
||||
["Error: Output silence limit reached; session was terminated. Reason: idle_timeout.\nExit code: -9\nElapsed: 3.0s", "Command stopped after output silence"],
|
||||
["Error: Command timed out; session was terminated. Reason: max_runtime.\nExit code: -9\nElapsed: 3.0s", "Command timed out (stopped)"],
|
||||
["Error: Output silence limit reached; session was terminated. Reason: idle_timeout.\nExit code: -9\nElapsed: 3.0s", "Command stopped (no output)"],
|
||||
])("distinguishes command timeout from a failed tool call", (result, label) => {
|
||||
expect(present(event({}, "error", result)).label).toBe(label);
|
||||
});
|
||||
@@ -83,7 +83,7 @@ describe("exec session activity", () => {
|
||||
[{}, "Could not check command"],
|
||||
[{ input: "private" }, "Could not send input"],
|
||||
[{ close_stdin: true }, "Could not close command input"],
|
||||
[{ input: "private", close_stdin: true }, "Could not send or close command input"],
|
||||
[{ input: "private", close_stdin: true }, "Could not send or close input"],
|
||||
[{ terminate: true }, "Could not stop command"],
|
||||
])("reports operation errors without displaying error content", (args, label) => {
|
||||
const model = present(event(args, "error", `Error: exec session not found: '${id}'`));
|
||||
@@ -105,23 +105,23 @@ describe("exec session activity", () => {
|
||||
|
||||
it("reports input and the observed result without exposing input text", () => {
|
||||
const model = present(event({ input: "private input", close_stdin: true }, "end", exit(7)));
|
||||
expect(model.label).toBe("Sent and closed command input");
|
||||
expect(model.observation).toBe("Command failed (exit code 7)");
|
||||
expect(model.label).toBe("Sent and closed input");
|
||||
expect(model.observation).toBe("Command failed (exit 7)");
|
||||
expect(JSON.stringify(model)).not.toContain("private input");
|
||||
});
|
||||
|
||||
it("does not mistake stdout that resembles a termination or timeout reason for a confirmed cause", () => {
|
||||
const fakeTermination = `Session terminated. Reason: cancelled.\nExit code: 7\nElapsed: 3.0s`;
|
||||
expect(present(event({}, "end", fakeTermination)).label).toBe("Command exited (exit code 7)");
|
||||
expect(present(event({}, "end", fakeTermination)).label).toBe("Command exited (exit 7)");
|
||||
const fakeTimeout = `Error: Command timed out; session was terminated. Reason: max_runtime.\nExit code: 0\nElapsed: 3.0s`;
|
||||
expect(present(event({}, "end", fakeTimeout)).label).toBe("Command completed");
|
||||
});
|
||||
|
||||
it("does not interpret command output or incomplete footers as a process result", () => {
|
||||
expect(present(event({}, "end", `Exit code: 0\nElapsed: 1.0s\n${running}`)).label)
|
||||
.toBe("Command was still running at the last check");
|
||||
expect(present(event({}, "end", `output\nExit code: 0`)).label).toBe("Command checked; status unknown");
|
||||
.toBe("Command still running");
|
||||
expect(present(event({}, "end", `output\nExit code: 0`)).label).toBe("Checked command (status unknown)");
|
||||
expect(present(event({}, "end", `Process running. session_id: deadbeefdead\nRuntime remaining: 2.0s\nElapsed: 1.0s`)).label)
|
||||
.toBe("Command checked; status unknown");
|
||||
.toBe("Checked command (status unknown)");
|
||||
});
|
||||
});
|
||||
@@ -34,18 +34,18 @@ describe("generic tool activity semantics", () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
['find_files({"glob":"*.tsx"})', "File search complete", "*.tsx"],
|
||||
['find_files({"glob":"*.tsx"})', "Found files", "*.tsx"],
|
||||
['grep({"pattern":"dream_cursor"})', "Searched files", "“dream_cursor”"],
|
||||
['list_dir({"path":"memory"})', "Listed files", "memory"],
|
||||
['read_file({"path":"docs/guide.md"})', "Read file", "docs/guide.md"],
|
||||
['memory_search({"query":"launch date"})', "Searched memory", "“launch date”"],
|
||||
['generate_image({"prompt":"private launch art"})', "Generated image", ""],
|
||||
['spawn({"label":"Research competitors","task":"private task"})', "Subtask created", "Research competitors"],
|
||||
['subagent("create")', "Subtask created", ""],
|
||||
['subagent({"action":"create","label":"Research competitors","task":"private task"})', "Subtask created", "Research competitors"],
|
||||
['subagent("check")', "Subtask status retrieved", ""],
|
||||
['subagent("send")', "Message queued for subtask", ""],
|
||||
['subagent("cancel")', "Stop request processed", ""],
|
||||
['spawn({"label":"Research competitors","task":"private task"})', "Created subtask", "Research competitors"],
|
||||
['subagent("create")', "Created subtask", ""],
|
||||
['subagent({"action":"create","label":"Research competitors","task":"private task"})', "Created subtask", "Research competitors"],
|
||||
['subagent("check")', "Checked subtask", ""],
|
||||
['subagent("send")', "Queued subtask message", ""],
|
||||
['subagent("cancel")', "Subtask stop requested", ""],
|
||||
['message({"channel":"telegram","content":"private message"})', "Sent message", "telegram"],
|
||||
['my({"action":"check","key":"context_window_tokens"})', "Checked agent settings", "context_window_tokens"],
|
||||
['my({"action":"set","key":"model","value":"private-model"})', "Updated agent settings", "model"],
|
||||
@@ -113,8 +113,8 @@ describe("generic tool activity semantics", () => {
|
||||
{ trace: first, status: "done" },
|
||||
{ trace: second, status: "done" },
|
||||
], i18n.t)).toMatchObject({
|
||||
label: "文件搜索完成",
|
||||
aside: "2 次",
|
||||
label: "已搜索文件",
|
||||
aside: "2 次搜索",
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ describe("localized agent activity contracts", () => {
|
||||
|
||||
await act(async () => setAppLanguage("zh-CN"));
|
||||
expect(screen.getByText("已运行命令 bun run test")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("无法搜索 网页, release notes")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("搜索 网页 失败, release notes")).toBeInTheDocument();
|
||||
await act(async () => setAppLanguage("en"));
|
||||
expect(screen.getByLabelText("Could not search the web, release notes")).toBeInTheDocument();
|
||||
expect(JSON.stringify(messages)).toBe(original);
|
||||
@@ -124,12 +124,12 @@ describe("localized agent activity contracts", () => {
|
||||
const original = JSON.stringify(messages);
|
||||
await setAppLanguage("zh-CN");
|
||||
render(<AgentActivityCluster messages={messages} isTurnStreaming={false} hasBodyBelow expanded />);
|
||||
for (const label of ["子任务已创建", "已获取子任务状态", "消息已加入子任务队列", "已处理停止请求"]) {
|
||||
for (const label of ["已创建子任务", "已检查子任务", "子任务消息已入队", "已请求停止子任务"]) {
|
||||
expect(screen.getByText(label)).toBeInTheDocument();
|
||||
}
|
||||
expect(screen.queryByText("已完成 Subagent")).not.toBeInTheDocument();
|
||||
await act(async () => setAppLanguage("en"));
|
||||
for (const label of ["Subtask created", "Subtask status retrieved", "Message queued for subtask", "Stop request processed"]) {
|
||||
for (const label of ["Created subtask", "Checked subtask", "Queued subtask message", "Subtask stop requested"]) {
|
||||
expect(screen.getByText(label)).toBeInTheDocument();
|
||||
}
|
||||
expect(JSON.stringify(messages)).toBe(original);
|
||||
|
||||
@@ -46,6 +46,6 @@ describe("describeMcpActivity", () => {
|
||||
{ element: "Password", text: "not-for-the-timeline" },
|
||||
"done",
|
||||
i18n.t,
|
||||
)).toEqual({ action: "已输入文本", target: "至 Password" });
|
||||
)).toEqual({ action: "已输入", target: "在 Password" });
|
||||
});
|
||||
});
|
||||
@@ -1262,9 +1262,9 @@ describe("ThreadMessages", () => {
|
||||
openAssistantBlockMenu();
|
||||
fireEvent.click(await screen.findByRole("button", { name: /worked/i }));
|
||||
expect(screen.getByText(/could not create subtask/i)).toBeVisible();
|
||||
expect(screen.getByText(/subtask status retrieved/i)).toBeVisible();
|
||||
expect(screen.getByText(/checked subtask/i)).toBeVisible();
|
||||
expect(screen.getByText(/ran command/i)).toBeVisible();
|
||||
expect(screen.queryByText(/^subtask created/i)).not.toBeInTheDocument();
|
||||
expect(screen.queryByText(/^created subtask/i)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("keeps the fork boundary after a hidden subagent create activity", () => {
|
||||
|
||||
@@ -17,7 +17,7 @@ describe("trace activity semantics", () => {
|
||||
['web_search({"query":"nanobot latest release"})', "done", "Searched the web", "nanobot latest release"],
|
||||
['web_fetch({"url":"https://example.com/docs?token=private"})', "done", "Read", "example.com/docs"],
|
||||
['read_file({"path":"/Users/alice/project/README.md"})', "done", "Read", "~/project/README.md"],
|
||||
['exec({"command":"date +%Y-%m-%d"})', "done", "Checked current time", ""],
|
||||
['exec({"command":"date +%Y-%m-%d"})', "done", "Checked time", ""],
|
||||
['exec_command({"cmd":"API_KEY=secret npm test"})', "running", "Running command", "API_KEY=•••• npm test"],
|
||||
['write_file({"path":"/home/alice/project/output.txt"})', "done", "Wrote file", "~/project/output.txt"],
|
||||
['apply_patch({"file_path":"src/app.tsx","patch":"private"})', "error", "Could not edit file", "src/app.tsx"],
|
||||
@@ -72,7 +72,7 @@ describe("trace activity semantics", () => {
|
||||
expect(result).toMatchObject({
|
||||
label: "Ran command",
|
||||
detail: "npm test",
|
||||
aside: "script, 3 lines",
|
||||
aside: "script (3 lines)",
|
||||
});
|
||||
expect(result.detail).not.toContain("second-secret-line");
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user