feat(webui): localize agent activity
Localize frontend-owned activity presentation while preserving raw tool data and current controls. Include locale-aware model memoization and integration with current main. Co-authored-by: Xubin Ren <52506698+Re-bin@users.noreply.github.com>
This commit is contained in:
1 parent
f57cc3aad2
commit
796e1cb0e6
23 files changed
+1704
-128
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { describeMcpActivity } from "@/components/thread/activity/mcp-activity-model";
|
||||
import i18n, { setAppLanguage } from "@/i18n";
|
||||
|
||||
describe("describeMcpActivity", () => {
|
||||
it.each([
|
||||
@@ -10,7 +11,7 @@ describe("describeMcpActivity", () => {
|
||||
["browser_screenshot", {}, "done", "Captured screenshot", undefined],
|
||||
["browser_press_key", { key: "Enter" }, "error", "Could not press", "Enter"],
|
||||
] as const)("turns %s into user-facing activity copy", (tool, args, status, action, target) => {
|
||||
expect(describeMcpActivity(tool, args, status)).toEqual({ action, target });
|
||||
expect(describeMcpActivity(tool, args, status, i18n.t)).toEqual({ action, target });
|
||||
});
|
||||
|
||||
it("does not expose entered text in the activity timeline", () => {
|
||||
@@ -18,6 +19,7 @@ describe("describeMcpActivity", () => {
|
||||
"browser_fill",
|
||||
{ element: "Password", text: "not-for-the-timeline" },
|
||||
"done",
|
||||
i18n.t,
|
||||
)).toEqual({ action: "Entered text", target: "in Password" });
|
||||
});
|
||||
|
||||
@@ -26,12 +28,24 @@ describe("describeMcpActivity", () => {
|
||||
"browser_navigate",
|
||||
{ url: "https://user:password@example.com/docs?token=private#section" },
|
||||
"done",
|
||||
i18n.t,
|
||||
)).toEqual({ action: "Opened", target: "example.com/docs" });
|
||||
});
|
||||
|
||||
it("humanizes unknown tool names instead of exposing function syntax", () => {
|
||||
expect(describeMcpActivity("browser_export_report", {}, "done")).toEqual({
|
||||
expect(describeMcpActivity("browser_export_report", {}, "done", i18n.t)).toEqual({
|
||||
action: "Export report completed",
|
||||
});
|
||||
});
|
||||
|
||||
it("localizes browser actions without translating targets", async () => {
|
||||
await setAppLanguage("zh-CN");
|
||||
|
||||
expect(describeMcpActivity(
|
||||
"browser_fill",
|
||||
{ element: "Password", text: "not-for-the-timeline" },
|
||||
"done",
|
||||
i18n.t,
|
||||
)).toEqual({ action: "已输入文本", target: "至 Password" });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user