Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(chat): keep tool rows rendering when MCP input fields are objects (MUL-7708) (#8883)
Bohan Jiang82847e275175
diff --git a/packages/views/chat/components/chat-message-list.test.tsx b/packages/views/chat/components/chat-message-list.test.tsxindex f8863a8116..93682f9c86 100644--- a/packages/views/chat/components/chat-message-list.test.tsx+++ b/packages/views/chat/components/chat-message-list.test.tsx@@ -6,6 +6,8 @@ import { chatKeys } from "@multica/core/chat/queries";import type { Attachment, TaskMessagePayload } from "@multica/core/types";import type { ReactElement } from "react";import enChat from "../../locales/en/chat.json";+import zhHansAgents from "../../locales/zh-Hans/agents.json";+import zhHansChat from "../../locales/zh-Hans/chat.json";// The live timeline is a real list row rather than Virtuoso chrome (MUL-4922),// so it shares one identity with the persisted assistant row and keeps its@@ -397,6 +399,86 @@ describe("ChatMessageList live timeline (MUL-3960 regression)", () => {});});+describe("ChatMessageList tool rows (#8835 regression)", () => {+ // An HTTP-proxy MCP tool (treg's `call`) passes `query` as an object of URL+ // parameters. The row summary returned it as-is, React threw on an object+ // child, and expanding the settled fold took down the whole chat.+ it("expands a settled fold whose tool input carries non-string summary fields", async () => {+ const qc = new QueryClient();+ qc.setQueryData(chatKeys.taskMessages(TASK_ID), [+ taskMsg(0, "tool_use", {+ tool: "mcp__treg__call",+ input: {+ endpoint_id: "zerobounce.people.email.verify",+ query: { email: "[email protected]" },+ },+ }),+ taskMsg(1, "tool_result", {+ tool: "mcp__treg__call",+ output: "{\"status\": 200, \"body\": {\"email_status\": \"Verified\"}}",+ }),+ taskMsg(2, "tool_use", { tool: "Read", input: { path: { dir: "/tmp" } } }),+ ]);++ render(+ <I18nProvider locale="en" resources={TEST_RESOURCES}>+ <QueryClientProvider client={qc}>+ <ChatMessageList+ messages={[{+ id: "settled-answer",+ chat_session_id: "session-1",+ role: "assistant",+ content: "The email is verified.",+ task_id: TASK_ID,+ created_at: "2026-09-25T00:00:00Z",+ }]}+ pendingTask={null}+ availability="online"+ />+ </QueryClientProvider>+ </I18nProvider>,+ );++ fireEvent.click(await screen.findByText("3 steps"));++ expect(screen.getByText("mcp__treg__call")).toBeInTheDocument();+ expect(screen.getByText("zerobounce.people.email.verify")).toBeInTheDocument();+ expect(screen.getByText("Read")).toBeInTheDocument();+ });++ it("localizes the multi-file patch summary", async () => {+ const qc = new QueryClient();+ qc.setQueryData(chatKeys.taskMessages(TASK_ID), [+ taskMsg(0, "tool_use", {+ tool: "apply_patch",+ input: {+ changes: [+ { path: "src/a.go", kind: "update", diff: "@@\n+x" },+ { path: "src/b.go", kind: "add", content: "y" },+ ],+ },+ }),+ ]);++ render(+ <I18nProvider+ locale="zh-Hans"+ resources={{ "zh-Hans": { chat: zhHansChat, agents: zhHansAgents } }}+ >+ <QueryClientProvider client={qc}>+ <ChatMessageList+ messages={[]}+ pendingTask={{ task_id: TASK_ID, status: "running" }}+ availability="online"+ />+ </QueryClientProvider>+ </I18nProvider>,+ );++ expect(await screen.findByText("src/a.go,另有 1 个文件")).toBeInTheDocument();+ });+});+describe("ChatMessageList footer spacing", () => {it("keeps the bottom inset when no task is pending", () => {const { container } = render(diff --git a/packages/views/chat/components/chat-message-list.tsx b/packages/views/chat/components/chat-message-list.tsxindex 292f55c794..0b382f603e 100644--- a/packages/views/chat/components/chat-message-list.tsx+++ b/packages/views/chat/components/chat-message-list.tsx@@ -44,6 +44,7 @@ import type {} from "@multica/core/types";import type { ChatTimelineItem } from "@multica/core/chat";import { buildTimeline } from "../../common/task-transcript";+import { traceToolArgSummary } from "../../common/task-transcript/trace-event-presenter";import { OnboardingStarterCards } from "./onboarding-starter-cards";import { TaskStatusPill } from "./task-status-pill";import { CHAT_COLUMN, CHAT_GUTTER } from "./chat-column";@@ -1243,38 +1244,15 @@ function ItemRow({ item }: { item: ChatTimelineItem }) {}}-function shortenPath(p: string): string {- const parts = p.split("/");- if (parts.length <= 3) return p;- return ".../" + parts.slice(-2).join("/");-}--function getToolSummary(item: ChatTimelineItem): string {- if (!item.input) return "";- const inp = item.input as Record<string, string>;- if (inp.query) return inp.query;- if (inp.file_path) return shortenPath(inp.file_path);- if (inp.path) return shortenPath(inp.path);- if (inp.pattern) return inp.pattern;- if (inp.description) return String(inp.description);- if (inp.command) {- const cmd = String(inp.command);- return cmd.length > 100 ? cmd.slice(0, 100) + "..." : cmd;- }- if (inp.prompt) {- const p = String(inp.prompt);- return p.length > 100 ? p.slice(0, 100) + "..." : p;- }- if (inp.skill) return String(inp.skill);- for (const v of Object.values(inp)) {- if (typeof v === "string" && v.length > 0 && v.length < 120) return v;- }- return "";-}-function ToolCallRow({ item }: { item: ChatTimelineItem }) {+ const { t } = useT("agents");const [open, setOpen] = useState(false);- const summary = getToolSummary(item);+ // Tool input is arbitrary JSON: an MCP tool can pass `query` or `path` as an+ // object (#8835), so the summary must come from the type-checked presenter.+ const summary = traceToolArgSummary(item.input, {+ morePaths: (path, extraCount) =>+ t(($) => $.transcript.patch_summary_more, { path, extra: extraCount }),+ });const hasInput = item.input && Object.keys(item.input).length > 0;return (