toolCallBlocks.test.ts 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378
  1. // @vitest-environment jsdom
  2. import { createElement } from "react";
  3. import { renderToStaticMarkup } from "react-dom/server";
  4. import { cleanup, fireEvent, render, screen } from "@testing-library/react";
  5. import { afterEach, describe, expect, it, vi } from "vitest";
  6. import { ZCodeIntlProvider } from "@/i18n/IntlProvider.js";
  7. import { TooltipProvider } from "@/components/ui/tooltip.js";
  8. import type { ToolCallRow } from "@zcode/shared/zcode-protocol-v4";
  9. import { ToolCallBlock } from "../src/ToolCallBlocks.js";
  10. import { ToolCallBody } from "../src/ToolCallBlocks/ToolCallBody.js";
  11. import { readRawToolCallFileSummaries } from "../src/ToolCallBlocks/shared.js";
  12. import { isExploreToolCall } from "../src/lib/exploreToolCall.js";
  13. import { buildToolDisplayModel } from "../src/lib/toolDisplay.js";
  14. import { toolCallRowToLegacyNode } from "../src/v4/toolCallRowAdapter.js";
  15. vi.mock("@/ToolCallBlocks/renderers/switch-mode.js", () => ({
  16. SwitchModeToolCallBlock: ({
  17. toolCallNode,
  18. }: {
  19. toolCallNode: {
  20. toolCall: {
  21. toolId: string;
  22. title?: string;
  23. kind: string;
  24. };
  25. };
  26. }) =>
  27. createElement(
  28. "div",
  29. { "data-testid": "mock-switch-mode-panel" },
  30. `switch-mode:${toolCallNode.toolCall.toolId}:${toolCallNode.toolCall.title ?? ""}:${toolCallNode.toolCall.kind}`,
  31. ),
  32. }));
  33. // CreateWorkflow renderer 只回显它**收到的上下文**:这条 mock 存在的理由是一个真实 bug——
  34. // onOpenWorkflowRun 曾经被透传给子工具卡却从未进 renderContext,于是聊天卡永远拿不到
  35. // run 详情入口(表现是「入口找不到」,成因却在这层装配里)。
  36. vi.mock("@/ToolCallBlocks/renderers/create-workflow.js", () => ({
  37. CreateWorkflowToolCallBlock: ({
  38. onOpenWorkflowRun,
  39. workflowRun,
  40. }: {
  41. onOpenWorkflowRun?: () => void;
  42. workflowRun?: { runId: string };
  43. }) =>
  44. createElement("div", {
  45. "data-testid": "mock-create-workflow-panel",
  46. "data-has-open-run": String(typeof onOpenWorkflowRun === "function"),
  47. "data-run-id": workflowRun?.runId ?? "",
  48. }),
  49. }));
  50. vi.mock("@/ToolCallBlocks/renderers/plan-guidance.js", () => ({
  51. PlanGuidanceToolCallBlock: ({
  52. toolCallNode,
  53. }: {
  54. toolCallNode: {
  55. toolCall: {
  56. toolId: string;
  57. title?: string;
  58. kind: string;
  59. };
  60. };
  61. }) =>
  62. createElement(
  63. "div",
  64. { "data-testid": "mock-plan-guidance-panel" },
  65. `plan-guidance:${toolCallNode.toolCall.toolId}:${toolCallNode.toolCall.title ?? ""}:${toolCallNode.toolCall.kind}`,
  66. ),
  67. }));
  68. vi.mock("@/ToolCallBlocks/renderers/agent.js", () => ({
  69. AgentToolCallBlock: ({
  70. toolCallNode,
  71. sourceLabel,
  72. }: {
  73. toolCallNode: {
  74. toolCall: {
  75. toolId: string;
  76. title?: string;
  77. kind: string;
  78. };
  79. };
  80. sourceLabel?: string;
  81. }) =>
  82. createElement(
  83. "div",
  84. { "data-testid": "mock-agent-panel" },
  85. `agent:${toolCallNode.toolCall.toolId}:${toolCallNode.toolCall.title ?? ""}:${toolCallNode.toolCall.kind}:source:${sourceLabel ?? "none"}`,
  86. ),
  87. }));
  88. afterEach(cleanup);
  89. describe("isExploreToolCall", () => {
  90. it("does not classify redirect write commands as explore", () => {
  91. const result = isExploreToolCall({
  92. kind: "execute",
  93. input: {
  94. command: ["/bin/zsh", "-lc", "cat > index.html <<'EOF' <!doctype html>"],
  95. },
  96. });
  97. expect(result).toBe(false);
  98. });
  99. });
  100. describe("ToolCallBlock agent routing", () => {
  101. it("renders compact trusted MCP labels from the real plugin-scoped payload", () => {
  102. const row: ToolCallRow = {
  103. rowId: 3,
  104. turnId: "turn-1",
  105. createdAt: 1_700_000_000_002,
  106. createdAtSeq: 3,
  107. kind: "toolCall",
  108. toolCallId: "call-mcp",
  109. toolName: "mcp__plugin_firebase_firebase__firebase_get_environment",
  110. status: "success",
  111. inputText: '{"query":"is:open"}',
  112. input: { query: "is:open" },
  113. output: { text: "12 issues" },
  114. display: {
  115. kind: "mcp_tool",
  116. serverName: "plugin:firebase:firebase",
  117. toolName: "firebase_get_environment",
  118. description: "Retrieve the current Firebase environment configuration.",
  119. },
  120. };
  121. const html = renderToStaticMarkup(
  122. createElement(
  123. ZCodeIntlProvider,
  124. { initialLocale: "zh-CN" },
  125. createElement(
  126. TooltipProvider,
  127. null,
  128. createElement(ToolCallBlock, {
  129. toolCallNode: toolCallRowToLegacyNode(row),
  130. workspacePath: "/workspace",
  131. }),
  132. ),
  133. ),
  134. );
  135. expect(html).toContain(">MCP<");
  136. expect(html).toContain("Get environment");
  137. expect(html).toContain('class="text-foreground-subtle">Firebase</span>');
  138. expect(html).not.toContain('class="text-foreground-subtlest">·</span><span class="text-foreground-subtle">Firebase</span>');
  139. expect(html).not.toMatch(/class="[^"]*(?:border|bg-background-alt)[^"]*">Firebase<\/span>/u);
  140. expect(html).not.toContain("Plugin:firebase:firebase");
  141. expect(html).not.toContain("Firebase get environment");
  142. expect(html).not.toContain(">mcp__plugin_firebase_firebase__firebase_get_environment<");
  143. expect(html).not.toContain("&quot;toolId&quot;");
  144. expect(html).not.toContain("已执行");
  145. });
  146. it("renders historical MCP rows without display through the MCP summary and detail", () => {
  147. const syntheticName = "mcp__plugin_firebase_firebase__firebase_get_environment";
  148. const row: ToolCallRow = {
  149. rowId: 31,
  150. turnId: "turn-legacy",
  151. createdAt: 1_700_000_000_031,
  152. createdAtSeq: 31,
  153. kind: "toolCall",
  154. toolCallId: "call-mcp-legacy-stopped",
  155. toolName: syntheticName,
  156. status: "cancelled",
  157. inputText: "{}",
  158. input: {},
  159. };
  160. render(
  161. createElement(
  162. ZCodeIntlProvider,
  163. { initialLocale: "zh-CN" },
  164. createElement(ToolCallBlock, {
  165. toolCallNode: toolCallRowToLegacyNode(row),
  166. workspacePath: "/workspace",
  167. }),
  168. ),
  169. );
  170. const summary = screen.getByTestId("tool-summary-trigger-call-mcp-legacy-stopped");
  171. expect(summary.textContent).toContain("MCP");
  172. expect(summary.textContent).toContain("Firebase");
  173. expect(summary.textContent).toContain("Get environment");
  174. expect(summary.textContent).toContain("已停止");
  175. expect(summary.innerHTML).toContain(">·</span>");
  176. expect(summary.textContent).not.toContain(syntheticName);
  177. fireEvent.click(summary);
  178. expect(screen.queryByTestId("mcp-expanded-content")).toBeNull();
  179. expect(screen.queryByRole("button", { name: "查看调用详情" })).toBeNull();
  180. expect(screen.queryByText("PARAMETERS")).toBeNull();
  181. expect(screen.queryByText(syntheticName)).toBeNull();
  182. expect(screen.queryByText(/toolId/u)).toBeNull();
  183. });
  184. it("shows only the result first and keeps MCP metadata in secondary call details", () => {
  185. const description = "Retrieve the current Firebase environment configuration.";
  186. const row: ToolCallRow = {
  187. rowId: 4,
  188. turnId: "turn-1",
  189. createdAt: 1_700_000_000_003,
  190. createdAtSeq: 4,
  191. kind: "toolCall",
  192. toolCallId: "call-mcp-detail",
  193. toolName: "mcp__plugin_firebase_firebase__firebase_get_environment",
  194. status: "success",
  195. inputText: '{"projectId":"demo"}',
  196. input: { projectId: "demo" },
  197. output: { text: "No firebase.json file was found." },
  198. display: {
  199. kind: "mcp_tool",
  200. serverName: "plugin:firebase:firebase",
  201. toolName: "firebase_get_environment",
  202. description,
  203. },
  204. };
  205. render(
  206. createElement(
  207. ZCodeIntlProvider,
  208. { initialLocale: "zh-CN" },
  209. createElement(ToolCallBlock, {
  210. toolCallNode: toolCallRowToLegacyNode(row),
  211. workspacePath: "/workspace",
  212. }),
  213. ),
  214. );
  215. expect(screen.queryByText(description)).toBeNull();
  216. const summary = screen.getByTestId("tool-summary-trigger-call-mcp-detail");
  217. fireEvent.click(summary);
  218. expect(screen.getByTestId("mcp-result-surface").className).toContain("rounded-xl");
  219. expect(screen.getByTestId("mcp-result-surface").className).toContain("border-border");
  220. expect(screen.queryByText("Result")).toBeNull();
  221. expect(screen.queryByText("Parameters")).toBeNull();
  222. expect(screen.queryByText(description)).toBeNull();
  223. fireEvent.click(screen.getByRole("button", { name: "查看调用详情" }));
  224. expect(screen.getByText(description)).toBeTruthy();
  225. expect(screen.getByText("调用参数")).toBeTruthy();
  226. });
  227. it.each([
  228. ["inputStreaming", "等待中", false],
  229. ["pendingApproval", "等待中", false],
  230. ["running", "执行中", true],
  231. ["cancelled", "已停止", false],
  232. ] as const)("controls %s MCP detail availability", (status, label, canExpand) => {
  233. const row: ToolCallRow = {
  234. rowId: 5,
  235. turnId: "turn-1",
  236. createdAt: 1_700_000_000_004,
  237. createdAtSeq: 5,
  238. kind: "toolCall",
  239. toolCallId: `call-mcp-${status}`,
  240. toolName: "opaque-provider-name",
  241. status,
  242. inputText: "{}",
  243. input: {},
  244. display: {
  245. kind: "mcp_tool",
  246. serverName: "firebase",
  247. toolName: "get_environment",
  248. },
  249. };
  250. render(
  251. createElement(
  252. ZCodeIntlProvider,
  253. { initialLocale: "zh-CN" },
  254. createElement(ToolCallBlock, {
  255. toolCallNode: toolCallRowToLegacyNode(row),
  256. workspacePath: "/workspace",
  257. }),
  258. ),
  259. );
  260. const summary = screen.getByTestId(`tool-summary-trigger-call-mcp-${status}`);
  261. if (status === "inputStreaming" || status === "pendingApproval" || status === "running") {
  262. expect(summary.textContent).not.toContain(label);
  263. } else {
  264. expect(summary.textContent).toContain(label);
  265. expect(
  266. Array.from(summary.querySelectorAll("span")).filter(
  267. (element) => element.textContent === "·",
  268. ),
  269. ).toHaveLength(2);
  270. }
  271. fireEvent.click(summary);
  272. if (canExpand) {
  273. expect(screen.getByTestId("mcp-expanded-content").textContent).toContain(label);
  274. } else {
  275. expect(screen.queryByTestId("mcp-expanded-content")).toBeNull();
  276. }
  277. });
  278. it("shows the MCP failure result before call details", () => {
  279. const row: ToolCallRow = {
  280. rowId: 6,
  281. turnId: "turn-1",
  282. createdAt: 1_700_000_000_005,
  283. createdAtSeq: 6,
  284. kind: "toolCall",
  285. toolCallId: "call-mcp-failed",
  286. toolName: "opaque-provider-name",
  287. status: "error",
  288. inputText: "{}",
  289. input: {},
  290. error: { code: "tool_failed", message: "Firebase authentication failed." },
  291. display: {
  292. kind: "mcp_tool",
  293. serverName: "firebase",
  294. toolName: "get_environment",
  295. },
  296. };
  297. render(
  298. createElement(
  299. ZCodeIntlProvider,
  300. { initialLocale: "zh-CN" },
  301. createElement(ToolCallBlock, {
  302. toolCallNode: toolCallRowToLegacyNode(row),
  303. workspacePath: "/workspace",
  304. }),
  305. ),
  306. );
  307. const summary = screen.getByTestId("tool-summary-trigger-call-mcp-failed");
  308. expect(
  309. Array.from(summary.querySelectorAll("span")).filter(
  310. (element) => element.textContent === "·",
  311. ),
  312. ).toHaveLength(2);
  313. fireEvent.click(summary);
  314. const detail = screen.getByTestId("mcp-expanded-content");
  315. expect(detail.textContent).toContain("Firebase authentication failed.");
  316. expect(detail.textContent).toContain("查看调用详情");
  317. expect(screen.getByTestId("mcp-error-surface").className).toContain("bg-destructive/10");
  318. });
  319. it("uses the BUA bounded code surface for multiline MCP results", () => {
  320. const row: ToolCallRow = {
  321. rowId: 7,
  322. turnId: "turn-1",
  323. createdAt: 1_700_000_000_006,
  324. createdAtSeq: 7,
  325. kind: "toolCall",
  326. toolCallId: "call-mcp-long-result",
  327. toolName: "opaque-provider-name",
  328. status: "success",
  329. inputText: "{}",
  330. input: {},
  331. output: { text: '{\n "project": "demo"\n}' },
  332. display: {
  333. kind: "mcp_tool",
  334. serverName: "firebase",
  335. toolName: "get_environment",
  336. },
  337. };
  338. render(
  339. createElement(
  340. ZCodeIntlProvider,
  341. { initialLocale: "zh-CN" },
  342. createElement(
  343. TooltipProvider,
  344. null,
  345. createElement(ToolCallBlock, {
  346. toolCallNode: toolCallRowToLegacyNode(row),
  347. workspacePath: "/workspace",
  348. }),
  349. ),
  350. ),
  351. );
  352. fireEvent.click(screen.getByTestId("tool-summary-trigger-call-mcp-long-result"));
  353. const surface = screen.getByTestId("mcp-result-surface");
  354. expect(surface.className).toContain("max-h-72");
  355. expect(screen.getByRole("button", { name: "复制结果" })).toBeTruthy();
  356. expect(screen.getByRole("button", { name: "切换自动换行" })).toBeTruthy();
  357. });
  358. it("renders adapted v4 output-only tool failures as an error surface", () => {
  359. const row: ToolCallRow = {
  360. rowId: 1,
  361. turnId: "turn-1",
  362. createdAt: 1_700_000_000_000,
  363. createdAtSeq: 1,
  364. kind: "toolCall",
  365. toolCallId: "call-failed",
  366. toolName: "Bash",
  367. status: "error",
  368. inputText: '{"command":"cat /workspace/secret.txt"}',
  369. input: { command: "cat /workspace/secret.txt" },
  370. output: {
  371. text: "<tool_use_error>Permission denied: /workspace/secret.txt</tool_use_error>",
  372. },
  373. };
  374. const toolCall = toolCallRowToLegacyNode(row).toolCall;
  375. const html = renderToStaticMarkup(
  376. createElement(
  377. ZCodeIntlProvider,
  378. { initialLocale: "zh-CN" },
  379. createElement(ToolCallBody, {
  380. childToolList: null,
  381. displayModel: buildToolDisplayModel(toolCall),
  382. toolCall,
  383. workspacePath: "/workspace",
  384. }),
  385. ),
  386. );
  387. expect(html).toContain("Error");
  388. expect(html).toContain("Permission denied: /workspace/secret.txt");
  389. expect(html).not.toContain("&lt;tool_use_error&gt;");
  390. });
  391. it("keeps adapted v4 successful tool output on the normal result surface", () => {
  392. const row: ToolCallRow = {
  393. rowId: 2,
  394. turnId: "turn-1",
  395. createdAt: 1_700_000_000_001,
  396. createdAtSeq: 2,
  397. kind: "toolCall",
  398. toolCallId: "call-success",
  399. toolName: "Bash",
  400. status: "success",
  401. inputText: '{"command":"echo ok"}',
  402. input: { command: "echo ok" },
  403. output: { text: "ok" },
  404. };
  405. const toolCall = toolCallRowToLegacyNode(row).toolCall;
  406. const html = renderToStaticMarkup(
  407. createElement(
  408. ZCodeIntlProvider,
  409. { initialLocale: "zh-CN" },
  410. createElement(ToolCallBody, {
  411. childToolList: null,
  412. displayModel: buildToolDisplayModel(toolCall),
  413. toolCall,
  414. workspacePath: "/workspace",
  415. }),
  416. ),
  417. );
  418. expect(html).toContain("Result");
  419. expect(html).not.toContain("Error");
  420. });
  421. it("routes Task tool calls to the agent renderer", () => {
  422. const html = renderToStaticMarkup(
  423. createElement(
  424. ZCodeIntlProvider,
  425. { initialLocale: "zh-CN" },
  426. createElement(ToolCallBlock, {
  427. toolCallNode: {
  428. toolCall: {
  429. toolId: "tool-task-agent",
  430. kind: "think",
  431. title: "Task",
  432. input: {
  433. prompt: "搜索今日新闻",
  434. run_in_background: true,
  435. },
  436. output: [],
  437. status: "completed",
  438. raw: {},
  439. },
  440. childToolCalls: [],
  441. },
  442. workspacePath: "/workspace",
  443. }),
  444. ),
  445. );
  446. expect(html).toContain("agent:tool-task-agent:Task:think:source:none");
  447. });
  448. it("routes GLM Agent tool calls to the agent renderer", () => {
  449. const html = renderToStaticMarkup(
  450. createElement(
  451. ZCodeIntlProvider,
  452. { initialLocale: "zh-CN" },
  453. createElement(ToolCallBlock, {
  454. toolCallNode: {
  455. toolCall: {
  456. toolId: "tool-glm-agent",
  457. kind: "think",
  458. title: "Agent",
  459. input: {
  460. description: "Find runtime loop",
  461. prompt: "Find where the runtime injects tool results.",
  462. },
  463. output: {
  464. status: "completed",
  465. agentId: "agent-glm-explore",
  466. agentType: "Explore",
  467. },
  468. status: "completed",
  469. raw: {},
  470. },
  471. childToolCalls: [],
  472. },
  473. workspacePath: "/workspace",
  474. }),
  475. ),
  476. );
  477. expect(html).toContain("agent:tool-glm-agent:Agent:think:source:none");
  478. });
  479. it("routes spawn_agent tool calls to the agent renderer", () => {
  480. const html = renderToStaticMarkup(
  481. createElement(
  482. ZCodeIntlProvider,
  483. { initialLocale: "zh-CN" },
  484. createElement(ToolCallBlock, {
  485. toolCallNode: {
  486. toolCall: {
  487. toolId: "tool-spawn-agent",
  488. kind: "spawn_agent",
  489. title: "spawn_agent",
  490. input: {
  491. agent_type: "explorer",
  492. message: "检查当前项目结构",
  493. },
  494. output: {
  495. agent_id: "agent-1",
  496. nickname: "Locke",
  497. },
  498. status: "completed",
  499. raw: {
  500. name: "spawn_agent",
  501. _meta: {
  502. zcode: {
  503. toolName: "spawn_agent",
  504. nickname: "Locke",
  505. },
  506. },
  507. },
  508. },
  509. childToolCalls: [],
  510. },
  511. workspacePath: "/workspace",
  512. }),
  513. ),
  514. );
  515. expect(html).toContain("agent:tool-spawn-agent:spawn_agent:spawn_agent:source:none");
  516. });
  517. });
  518. describe("readRawToolCallFileSummaries", () => {
  519. it("does not infer edit summaries from read tool content keywords", () => {
  520. const summaries = readRawToolCallFileSummaries(
  521. {
  522. kind: "read",
  523. status: "completed",
  524. rawInput: {
  525. file_path: "/Users/dev/ZCodeProject/demo/snake/index.html",
  526. },
  527. content: [
  528. {
  529. type: "content",
  530. content: {
  531. type: "text",
  532. text: "function deleteFood() { return writeScore(); }",
  533. },
  534. },
  535. ],
  536. },
  537. {
  538. kind: "read",
  539. title: "Read snake/index.html",
  540. input: {
  541. file_path: "/Users/dev/ZCodeProject/demo/snake/index.html",
  542. },
  543. },
  544. );
  545. expect(summaries).toEqual([]);
  546. });
  547. it("routes read tools to the read renderer even if raw summaries exist", () => {
  548. const html = renderToStaticMarkup(
  549. createElement(
  550. ZCodeIntlProvider,
  551. { initialLocale: "zh-CN" },
  552. createElement(ToolCallBlock, {
  553. toolCallNode: {
  554. toolCall: {
  555. toolId: "tool-read-weird",
  556. kind: "read",
  557. title: "Read snake/index.html",
  558. input: {
  559. file_path: "/Users/dev/ZCodeProject/demo/snake/index.html",
  560. },
  561. output: {
  562. content: "function deleteFood() { return writeScore(); }",
  563. },
  564. status: "completed",
  565. raw: {
  566. kind: "read",
  567. changes: {
  568. "/Users/dev/ZCodeProject/demo/snake/index.html": {
  569. type: "add",
  570. content: "unexpected",
  571. },
  572. },
  573. rawInput: {
  574. file_path: "/Users/dev/ZCodeProject/demo/snake/index.html",
  575. },
  576. },
  577. },
  578. childToolCalls: [],
  579. },
  580. workspacePath: "/workspace",
  581. }),
  582. ),
  583. );
  584. expect(html).toContain("读取");
  585. expect(html).toMatch(
  586. /class="[^"]*tool-summary-kind-label[^"]*@max-\[360px\]\/conversation:hidden/,
  587. );
  588. expect(html).toMatch(/class="[^"]*tool-summary-content[^"]*flex-1[^"]*overflow-hidden/);
  589. expect(html).toMatch(
  590. /class="[^"]*text-foreground-subtlest[^"]*@max-\[360px\]\/conversation:hidden/,
  591. );
  592. expect(html).not.toContain("主 Agent");
  593. expect(html).not.toContain("SubAgent");
  594. expect(html).toContain("index.html");
  595. expect(html).not.toContain("已写入");
  596. expect(html).not.toContain("已删除");
  597. expect(html).not.toContain("已编辑");
  598. });
  599. it("does not infer edit summaries for explore nodes backed by Read tool metadata", () => {
  600. const summaries = readRawToolCallFileSummaries(
  601. {
  602. _meta: {
  603. claudeCode: {
  604. toolName: "Read",
  605. },
  606. },
  607. content: [
  608. {
  609. type: "content",
  610. content: {
  611. type: "text",
  612. text: "function deleteFood() { return writeScore(); }",
  613. },
  614. },
  615. ],
  616. rawOutput: "...",
  617. status: "completed",
  618. sessionUpdate: "tool_call_update",
  619. },
  620. {
  621. kind: "explore",
  622. title: "Read snake/game.ts",
  623. input: {
  624. file_path: "/Users/dev/ZCodeProject/demo/snake/game.ts",
  625. },
  626. },
  627. );
  628. expect(summaries).toEqual([]);
  629. });
  630. it("reads multi-file ZCode tool display summaries", () => {
  631. const summaries = readRawToolCallFileSummaries(
  632. {
  633. display: {
  634. kind: "file_diffs",
  635. files: [
  636. {
  637. filePath: "/workspace/src/a.ts",
  638. additions: 2,
  639. deletions: 1,
  640. structuredPatch: [
  641. {
  642. oldStart: 1,
  643. oldLines: 1,
  644. newStart: 1,
  645. newLines: 1,
  646. lines: ["-old", "+new"],
  647. },
  648. ],
  649. },
  650. {
  651. filePath: "/workspace/src/b.ts",
  652. additions: 3,
  653. deletions: 0,
  654. structuredPatch: [
  655. {
  656. oldStart: 1,
  657. oldLines: 0,
  658. newStart: 1,
  659. newLines: 1,
  660. lines: ["+created"],
  661. },
  662. ],
  663. },
  664. ],
  665. },
  666. },
  667. {
  668. kind: "ApplyPatch",
  669. title: "Edited 2 files",
  670. input: {},
  671. },
  672. );
  673. expect(summaries).toHaveLength(2);
  674. expect(summaries.map((summary) => summary.changeStat)).toEqual([
  675. { added: 2, removed: 1 },
  676. { added: 3, removed: 0 },
  677. ]);
  678. expect(summaries[1]?.patch).toContain("+created");
  679. });
  680. it("does not build delete summaries for non-writable execute tools even with raw changes", () => {
  681. const summaries = readRawToolCallFileSummaries(
  682. {
  683. kind: "execute",
  684. changes: {
  685. "/Users/dev/ZCodeProject/demo/snake/game.ts": {
  686. type: "delete",
  687. oldText: "console.log('legacy');",
  688. },
  689. },
  690. rawInput: {
  691. path: "/Users/dev/ZCodeProject/demo/snake/game.ts",
  692. },
  693. },
  694. {
  695. kind: "execute",
  696. title: "Run cleanup command",
  697. input: {
  698. command: "rm game.ts",
  699. },
  700. },
  701. );
  702. expect(summaries).toEqual([]);
  703. });
  704. it("does not infer delete from explore text without writable tool kind", () => {
  705. const summaries = readRawToolCallFileSummaries(
  706. {
  707. status: "completed",
  708. rawInput: {
  709. file_path: "/Users/dev/ZCodeProject/demo/snake/game.ts",
  710. description: "Delete legacy fallback after inspection",
  711. },
  712. },
  713. {
  714. kind: "explore",
  715. title: "Inspect game.ts",
  716. input: {
  717. file_path: "/Users/dev/ZCodeProject/demo/snake/game.ts",
  718. description: "Delete legacy fallback after inspection",
  719. },
  720. },
  721. );
  722. expect(summaries).toEqual([]);
  723. });
  724. it("normalizes hunk-only add patches as newly created files", () => {
  725. const summaries = readRawToolCallFileSummaries(
  726. {
  727. changes: {
  728. "src/demo.ts": {
  729. type: "add",
  730. unified_diff: "@@ -0,0 +1,2 @@\n+export const value = 1;\n+export { value };",
  731. },
  732. },
  733. },
  734. {
  735. kind: "write",
  736. title: "Write src/demo.ts",
  737. input: {
  738. path: "src/demo.ts",
  739. },
  740. },
  741. );
  742. expect(summaries).toHaveLength(1);
  743. expect(summaries[0]?.patch).toContain("--- /dev/null");
  744. expect(summaries[0]?.patch).toContain("+++ b/demo.ts");
  745. });
  746. it("builds write summaries from ZCode protocol input payloads", () => {
  747. const summaries = readRawToolCallFileSummaries(
  748. {
  749. toolName: "Write",
  750. input: {
  751. file_path: "src/quicksort.js",
  752. content: "export const quicksort = () => [];\n",
  753. },
  754. },
  755. {
  756. kind: "Write",
  757. title: "Write",
  758. raw: {
  759. toolName: "Write",
  760. input: {
  761. file_path: "src/quicksort.js",
  762. content: "export const quicksort = () => [];\n",
  763. },
  764. },
  765. },
  766. );
  767. expect(summaries).toHaveLength(1);
  768. expect(summaries[0]?.path).toBe("src/quicksort.js");
  769. expect(summaries[0]?.operationKind).toBe("write");
  770. expect(summaries[0]?.changeStat).toEqual({ added: 1, removed: 0 });
  771. });
  772. it("builds edit summaries from ZCode protocol input payloads", () => {
  773. const summaries = readRawToolCallFileSummaries(
  774. {
  775. toolName: "Edit",
  776. input: {
  777. file_path: "src/quicksort.js",
  778. old_string: "return left.concat(pivot, right);",
  779. new_string: "return [...left, pivot, ...right];",
  780. },
  781. },
  782. {
  783. kind: "Edit",
  784. title: "Edit",
  785. raw: {
  786. toolName: "Edit",
  787. input: {
  788. file_path: "src/quicksort.js",
  789. old_string: "return left.concat(pivot, right);",
  790. new_string: "return [...left, pivot, ...right];",
  791. },
  792. },
  793. },
  794. );
  795. expect(summaries).toHaveLength(1);
  796. expect(summaries[0]?.path).toBe("src/quicksort.js");
  797. expect(summaries[0]?.operationKind).toBe("edit");
  798. expect(summaries[0]?.changeStat).toEqual({ added: 1, removed: 1 });
  799. });
  800. it("drops multi-file unified diff payloads and falls back to single-file patch", () => {
  801. const summaries = readRawToolCallFileSummaries(
  802. {
  803. changes: {
  804. "src/demo.ts": {
  805. type: "update",
  806. oldText: "const value = 1;\n",
  807. newText: "const value = 2;\n",
  808. unified_diff:
  809. "diff --git a/src/demo.ts b/src/demo.ts\n--- a/src/demo.ts\n+++ b/src/demo.ts\n@@ -1 +1 @@\n-const value = 1;\n+const value = 2;\n" +
  810. "diff --git a/src/other.ts b/src/other.ts\n--- a/src/other.ts\n+++ b/src/other.ts\n@@ -1 +1 @@\n-console.log('a');\n+console.log('b');",
  811. },
  812. },
  813. },
  814. {
  815. kind: "edit",
  816. title: "Edit src/demo.ts",
  817. input: {
  818. path: "src/demo.ts",
  819. },
  820. },
  821. );
  822. expect(summaries).toHaveLength(1);
  823. expect(summaries[0]?.patch).toContain("--- a/demo.ts");
  824. expect(summaries[0]?.patch).toContain("+++ b/demo.ts");
  825. expect(summaries[0]?.patch).not.toContain("src/other.ts");
  826. });
  827. it("drops truncated second-file hunks in multi-file unified diff payloads", () => {
  828. const summaries = readRawToolCallFileSummaries(
  829. {
  830. changes: {
  831. "src/demo.ts": {
  832. type: "update",
  833. oldText: "const value = 1;\n",
  834. newText: "const value = 2;\n",
  835. // 回归场景:第二个文件 hunk 被流式截断时,仍应识别为多文件并触发 fallback。
  836. unified_diff:
  837. "--- a/src/demo.ts\n+++ b/src/demo.ts\n@@ -1 +1 @@\n-const value = 1;\n+const value = 2;\n" +
  838. "--- a/src/other.ts\n+++ b/src/other.ts\n@@ -1 +1 @@\n-console.log('a');",
  839. },
  840. },
  841. },
  842. {
  843. kind: "edit",
  844. title: "Edit src/demo.ts",
  845. input: {
  846. path: "src/demo.ts",
  847. },
  848. },
  849. );
  850. expect(summaries).toHaveLength(1);
  851. expect(summaries[0]?.patch).toContain("--- a/demo.ts");
  852. expect(summaries[0]?.patch).toContain("+++ b/demo.ts");
  853. expect(summaries[0]?.patch).not.toContain("src/other.ts");
  854. });
  855. it("keeps single-file patches when hunk content contains header-like lines", () => {
  856. const summaries = readRawToolCallFileSummaries(
  857. {
  858. changes: {
  859. "src/demo.ts": {
  860. type: "update",
  861. // 回归场景:正文里以 --- / +++ 开头的文本不应被识别成额外文件头。
  862. unified_diff:
  863. "--- a/src/demo.ts\n+++ b/src/demo.ts\n@@ -1,2 +1,2 @@\n const marker = true;\n--- header-like-old-line\n+++ header-like-new-line",
  864. },
  865. },
  866. },
  867. {
  868. kind: "edit",
  869. title: "Edit src/demo.ts",
  870. input: {
  871. path: "src/demo.ts",
  872. },
  873. },
  874. );
  875. expect(summaries).toHaveLength(1);
  876. expect(summaries[0]?.patch).toContain("--- a/src/demo.ts");
  877. expect(summaries[0]?.patch).toContain("+++ b/src/demo.ts");
  878. expect(summaries[0]?.patch).toContain("--- header-like-old-line");
  879. expect(summaries[0]?.patch).toContain("+++ header-like-new-line");
  880. });
  881. it("keeps read-like explore nodes out of edit renderer", () => {
  882. const html = renderToStaticMarkup(
  883. createElement(
  884. ZCodeIntlProvider,
  885. { initialLocale: "zh-CN" },
  886. createElement(ToolCallBlock, {
  887. toolCallNode: {
  888. toolCall: {
  889. toolId: "tool-explore-read-like",
  890. kind: "explore",
  891. title: "Read snake/game.ts",
  892. input: {
  893. file_path: "/Users/dev/ZCodeProject/demo/snake/game.ts",
  894. },
  895. output: "...",
  896. status: "completed",
  897. raw: {
  898. _meta: {
  899. claudeCode: {
  900. toolName: "Read",
  901. },
  902. },
  903. content: [
  904. {
  905. type: "content",
  906. content: {
  907. type: "text",
  908. text: "function deleteFood() { return writeScore(); }",
  909. },
  910. },
  911. ],
  912. rawOutput: "...",
  913. status: "completed",
  914. toolCallId: "call_bcbf3d3258d34b44b3dbc0b4",
  915. sessionUpdate: "tool_call_update",
  916. },
  917. },
  918. childToolCalls: [],
  919. },
  920. workspacePath: "/workspace",
  921. }),
  922. ),
  923. );
  924. expect(html).not.toContain("已写入");
  925. expect(html).not.toContain("已删除");
  926. expect(html).not.toContain("已编辑");
  927. });
  928. it("keeps execute tools with delete-like raw changes out of edit renderer", () => {
  929. const html = renderToStaticMarkup(
  930. createElement(
  931. ZCodeIntlProvider,
  932. { initialLocale: "zh-CN" },
  933. createElement(ToolCallBlock, {
  934. toolCallNode: {
  935. toolCall: {
  936. toolId: "tool-execute-delete-like",
  937. kind: "execute",
  938. title: "Run cleanup",
  939. input: {
  940. command: "rm snake/game.ts",
  941. },
  942. output: {
  943. stdout: "cleanup finished",
  944. },
  945. status: "completed",
  946. raw: {
  947. kind: "execute",
  948. changes: {
  949. "/Users/dev/ZCodeProject/demo/snake/game.ts": {
  950. type: "delete",
  951. oldText: "console.log('legacy');",
  952. },
  953. },
  954. },
  955. },
  956. childToolCalls: [],
  957. },
  958. workspacePath: "/workspace",
  959. }),
  960. ),
  961. );
  962. expect(html).toContain("终端");
  963. expect(html).not.toContain("已删除");
  964. expect(html).not.toContain("已编辑");
  965. expect(html).not.toContain("Deleting");
  966. expect(html).not.toContain("Deleted");
  967. });
  968. it("把 dwf run 入口与 run 摘要交到 CreateWorkflow renderer 手里", () => {
  969. // 回归:这两个 prop 之前只被透传给**子**工具卡,从未进过 renderContext,于是 run 态卡片
  970. // 和它的详情页入口在生产里根本不存在。装配这一层必须自己被钉住。
  971. const html = renderToStaticMarkup(
  972. createElement(
  973. ZCodeIntlProvider,
  974. { initialLocale: "zh-CN" },
  975. createElement(ToolCallBlock, {
  976. toolCallNode: {
  977. toolCall: {
  978. toolId: "tool-create-workflow",
  979. kind: "CreateWorkflow",
  980. title: "CreateWorkflow",
  981. input: { name: "Fan-out review", script: "const x = 1;" },
  982. status: "completed",
  983. },
  984. childToolCalls: [],
  985. },
  986. workspacePath: "/workspace",
  987. onOpenWorkflowRun: () => {},
  988. workflowRun: {
  989. runId: "dwfrun-42",
  990. status: "running" as const,
  991. nodesSettled: 3,
  992. nodesTotal: 7,
  993. },
  994. }),
  995. ),
  996. );
  997. expect(html).toContain("mock-create-workflow-panel");
  998. expect(html).toContain('data-has-open-run="true"');
  999. expect(html).toContain('data-run-id="dwfrun-42"');
  1000. });
  1001. it("routes switch_mode tool calls to the dedicated renderer", () => {
  1002. const html = renderToStaticMarkup(
  1003. createElement(
  1004. ZCodeIntlProvider,
  1005. { initialLocale: "zh-CN" },
  1006. createElement(ToolCallBlock, {
  1007. toolCallNode: {
  1008. toolCall: {
  1009. toolId: "tool-switch-mode",
  1010. kind: "switch_mode",
  1011. title: "Exited Plan Mode",
  1012. input: {
  1013. plan: "# 输出计划\n\n- 渲染 markdown",
  1014. },
  1015. output: "...",
  1016. status: "completed",
  1017. raw: {
  1018. rawOutput: "...",
  1019. },
  1020. },
  1021. childToolCalls: [],
  1022. },
  1023. workspacePath: "/workspace",
  1024. }),
  1025. ),
  1026. );
  1027. expect(html).toContain("mock-switch-mode-panel");
  1028. expect(html).toContain("switch-mode:tool-switch-mode:Exited Plan Mode:switch_mode");
  1029. });
  1030. it("routes Exited Plan Mode titles to the switch mode renderer even when kind is other", () => {
  1031. const html = renderToStaticMarkup(
  1032. createElement(
  1033. ZCodeIntlProvider,
  1034. { initialLocale: "zh-CN" },
  1035. createElement(ToolCallBlock, {
  1036. toolCallNode: {
  1037. toolCall: {
  1038. toolId: "tool-exited-plan-title",
  1039. kind: "other",
  1040. title: "Exited Plan Mode",
  1041. input: {
  1042. plan: "# 输出计划\n\n- 渲染 markdown",
  1043. },
  1044. output: "...",
  1045. status: "completed",
  1046. raw: {
  1047. rawOutput: "...",
  1048. },
  1049. },
  1050. childToolCalls: [],
  1051. },
  1052. workspacePath: "/workspace",
  1053. }),
  1054. ),
  1055. );
  1056. expect(html).toContain("mock-switch-mode-panel");
  1057. expect(html).toContain("switch-mode:tool-exited-plan-title:Exited Plan Mode:other");
  1058. });
  1059. it("routes current ExitPlanMode tool calls to the switch mode renderer", () => {
  1060. const html = renderToStaticMarkup(
  1061. createElement(
  1062. ZCodeIntlProvider,
  1063. { initialLocale: "zh-CN" },
  1064. createElement(ToolCallBlock, {
  1065. toolCallNode: {
  1066. toolCall: {
  1067. toolId: "tool-exit-plan-current",
  1068. kind: "ExitPlanMode",
  1069. title: "ExitPlanMode",
  1070. input: {
  1071. plan: "# 输出计划\n\n- 渲染 markdown",
  1072. },
  1073. output: "...",
  1074. status: "completed",
  1075. raw: {
  1076. toolName: "ExitPlanMode",
  1077. rawOutput: "...",
  1078. },
  1079. },
  1080. childToolCalls: [],
  1081. },
  1082. workspacePath: "/workspace",
  1083. }),
  1084. ),
  1085. );
  1086. expect(html).toContain("mock-switch-mode-panel");
  1087. expect(html).toContain("switch-mode:tool-exit-plan-current:ExitPlanMode:ExitPlanMode");
  1088. });
  1089. it("routes EnterPlanMode titles to the plan guidance renderer", () => {
  1090. const html = renderToStaticMarkup(
  1091. createElement(
  1092. ZCodeIntlProvider,
  1093. { initialLocale: "zh-CN" },
  1094. createElement(ToolCallBlock, {
  1095. toolCallNode: {
  1096. toolCall: {
  1097. toolId: "tool-enter-plan-guidance",
  1098. kind: "other",
  1099. title: "EnterPlanMode",
  1100. input: {},
  1101. output: "Entered plan mode.",
  1102. status: "completed",
  1103. raw: {
  1104. _meta: {
  1105. claudeCode: {
  1106. toolName: "EnterPlanMode",
  1107. },
  1108. },
  1109. rawOutput: "Entered plan mode.",
  1110. },
  1111. },
  1112. childToolCalls: [],
  1113. },
  1114. workspacePath: "/workspace",
  1115. }),
  1116. ),
  1117. );
  1118. expect(html).toContain("mock-plan-guidance-panel");
  1119. expect(html).toContain("plan-guidance:tool-enter-plan-guidance:EnterPlanMode:other");
  1120. });
  1121. it("routes TodoWrite to the todo renderer instead of the file write renderer", () => {
  1122. const html = renderToStaticMarkup(
  1123. createElement(
  1124. ZCodeIntlProvider,
  1125. { initialLocale: "zh-CN" },
  1126. createElement(ToolCallBlock, {
  1127. toolCallNode: {
  1128. toolCall: {
  1129. toolId: "tool-todo-write",
  1130. kind: "TodoWrite",
  1131. title: "TodoWrite",
  1132. input: {
  1133. todos: [
  1134. {
  1135. content: "更新 index.html 标题",
  1136. priority: "high",
  1137. status: "in_progress",
  1138. },
  1139. {
  1140. content: "创建番茄时钟组件",
  1141. priority: "medium",
  1142. status: "pending",
  1143. },
  1144. ],
  1145. },
  1146. output: JSON.stringify({
  1147. oldTodos: [],
  1148. todos: [
  1149. {
  1150. content: "更新 index.html 标题",
  1151. priority: "high",
  1152. status: "in_progress",
  1153. },
  1154. {
  1155. content: "创建番茄时钟组件",
  1156. priority: "medium",
  1157. status: "pending",
  1158. },
  1159. ],
  1160. }),
  1161. status: "completed",
  1162. raw: {
  1163. toolCallId: "tool-todo-write",
  1164. toolName: "TodoWrite",
  1165. },
  1166. },
  1167. childToolCalls: [],
  1168. },
  1169. workspacePath: "/workspace",
  1170. }),
  1171. ),
  1172. );
  1173. expect(html).toContain("待办");
  1174. expect(html).toContain("更新 index.html 标题");
  1175. expect(html).toContain("0/2");
  1176. expect(html).not.toContain("已写入");
  1177. });
  1178. it("routes fixed AskUserQuestion tools without renaming the tool identity", () => {
  1179. const html = renderToStaticMarkup(
  1180. createElement(
  1181. ZCodeIntlProvider,
  1182. { initialLocale: "zh-CN" },
  1183. createElement(ToolCallBlock, {
  1184. toolCallNode: {
  1185. toolCall: {
  1186. toolId: "tool-ask-user-question",
  1187. toolName: "AskUserQuestion",
  1188. kind: "AskUserQuestion",
  1189. title: "AskUserQuestion",
  1190. input: {
  1191. questions: [
  1192. {
  1193. id: "q1",
  1194. question: "选择实现方向?",
  1195. options: [
  1196. { id: "safe", label: "稳妥" },
  1197. { id: "fast", label: "快速" },
  1198. ],
  1199. },
  1200. ],
  1201. answers: {
  1202. "选择实现方向?": "稳妥",
  1203. },
  1204. },
  1205. status: "completed",
  1206. raw: {
  1207. toolName: "AskUserQuestion",
  1208. },
  1209. },
  1210. childToolCalls: [],
  1211. },
  1212. workspacePath: "/workspace",
  1213. }),
  1214. ),
  1215. );
  1216. expect(html).toContain("已询问");
  1217. expect(html).toContain("1 个问题");
  1218. expect(html).toContain("AskUserQuestion");
  1219. expect(html).not.toContain("AskQuestion");
  1220. expect(html).not.toContain("已写入");
  1221. });
  1222. it("shows an automatic-continuation history label for explicit empty answers", () => {
  1223. const html = renderToStaticMarkup(
  1224. createElement(
  1225. ZCodeIntlProvider,
  1226. { initialLocale: "zh-CN" },
  1227. createElement(ToolCallBlock, {
  1228. toolCallNode: {
  1229. toolCall: {
  1230. toolId: "tool-ask-auto-continued",
  1231. toolName: "AskUserQuestion",
  1232. kind: "AskUserQuestion",
  1233. title: "AskUserQuestion",
  1234. input: {
  1235. questions: [
  1236. {
  1237. id: "q1",
  1238. question: "选择实现方向?",
  1239. options: [
  1240. { id: "safe", label: "稳妥" },
  1241. { id: "fast", label: "快速" },
  1242. ],
  1243. },
  1244. ],
  1245. },
  1246. output: { questions: [], answers: {} },
  1247. status: "completed",
  1248. raw: { toolName: "AskUserQuestion" },
  1249. },
  1250. childToolCalls: [],
  1251. },
  1252. workspacePath: "/workspace",
  1253. }),
  1254. ),
  1255. );
  1256. expect(html).toContain("未回答,已自动继续");
  1257. expect(html).not.toContain("未提供回答");
  1258. });
  1259. it("routes Agent tool calls to the dedicated renderer", () => {
  1260. const html = renderToStaticMarkup(
  1261. createElement(
  1262. ZCodeIntlProvider,
  1263. { initialLocale: "zh-CN" },
  1264. createElement(ToolCallBlock, {
  1265. toolCallNode: {
  1266. toolCall: {
  1267. toolId: "tool-agent",
  1268. kind: "think",
  1269. title: "Explore project structure",
  1270. input: {
  1271. description: "Explore project structure",
  1272. subagent_type: "Explore",
  1273. },
  1274. output: "...",
  1275. status: "completed",
  1276. raw: {
  1277. _meta: {
  1278. claudeCode: {
  1279. toolName: "Agent",
  1280. },
  1281. },
  1282. },
  1283. },
  1284. childToolCalls: [],
  1285. },
  1286. workspacePath: "/workspace",
  1287. }),
  1288. ),
  1289. );
  1290. expect(html).toContain("mock-agent-panel");
  1291. expect(html).toContain("agent:tool-agent:Explore project structure:think");
  1292. });
  1293. });