fix: unify chat process and reply presentation

This commit is contained in:
2026-10-29 17:54:34 +08:00
parent 7621bf0f86
commit 9474788db6
46 changed files with 3160 additions and 500 deletions
@@ -0,0 +1,26 @@
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, expect, it, vi } from "vitest";
import { AgentToolProgress } from "./agent-tool-progress";
vi.mock("use-stick-to-bottom", () => ({ useStickToBottomContext: () => ({ scrollRef: { current: null }, stopScroll: vi.fn() }) }));
afterEach(cleanup);
it("keeps full structured parameters collapsed until the tool row opens", () => {
const address = "完整地址".repeat(70);
const { container } = render(<AgentToolProgress item={{ id: "tool", phase: "tool", status: "completed", title: "已完成", tool: { name: "mcp_tjwater_geocode", input: { address, radius: 500 } }, detail: "legacy secret summary" }} />);
const details = container.querySelector("details")!;
expect(details.open).toBe(false);
expect(screen.getByText("mcp_tjwater_geocode")).toBeTruthy();
expect(container.querySelector("pre")?.textContent).toContain(address);
expect(screen.queryByText("legacy secret summary")).toBeNull();
fireEvent.click(container.querySelector("summary")!);
expect(details.open).toBe(true);
});
it("retains historical details and removes the old status text from the tool label", () => {
const { container } = render(<AgentToolProgress item={{ id: "old", phase: "tool", status: "running", title: "正在调用 mcp_tjwater_query_nearby_elements", detail: "历史参数:radius=500" }} />);
expect(screen.getByText("mcp_tjwater_query_nearby_elements")).toBeTruthy();
expect(screen.getByText("历史参数:radius=500")).toBeTruthy();
expect(container.querySelector("details")?.open).toBe(false);
});