fix(webui): keep search activity summaries on one line

This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-18 01:45:53 +08:00
1 parent c91e2bd553
commit 7edd377352
3 files changed
+90 -2

No files matched your search

@@ -830,7 +830,7 @@ function ActivityTraceRow({
tone={status === "error" ? "error" : status === "done" ? "success" : "active"}
label={trace.kind === "search" ? trace.label : formatActivityTarget(t, trace.label, trace.detail)}
detail={trace.kind === "search" ? trace.detail : trace.aside}
detailClassName={trace.kind === "search" ? "whitespace-pre-line" : undefined}
labelClassName={trace.kind === "search" && trace.detail ? "max-w-[50%]" : undefined}
/>
);
}
@@ -25,7 +25,7 @@ export function WebSearchRun({ run, turnActive }: { run: WebSearchRunModel; turn
tone={status === "error" ? "error" : status === "done" ? "success" : "active"}
label={presentation.label}
detail={presentation.detail}
detailClassName="whitespace-pre-line"
labelClassName={presentation.detail ? "max-w-[50%]" : undefined}
/>
{run.sources.map((source) => (
<WebActivityRow
@@ -0,0 +1,88 @@
import { cleanup, fireEvent, render, screen, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { afterEach, expect, it } from "vitest";
import { AgentActivityCluster } from "@/components/thread/AgentActivityCluster";
const entrypoints = ["structured event", "trace-only"] as const;
afterEach(cleanup);
it.each(entrypoints)("keeps multiline search summaries single-line with full hover details (%s)", async (entrypoint) => {
const domain = "research-and-development.platform.example.com";
const query = "nanobot release notes\nweb search activity regression coverage";
const args = { query: `site:${domain} ${query}` };
const line = `web_search(${JSON.stringify(args)})`;
const label = `Searched ${domain}`;
render(
<AgentActivityCluster
messages={[{
id: "t-multiline-search",
role: "tool",
kind: "trace",
content: line,
traces: [line],
...(entrypoint === "structured event" ? {
toolEvents: [{
phase: "end" as const,
call_id: "call-multiline-search",
name: "web_search",
arguments: args,
result: "No results found.",
}],
} : {}),
createdAt: 1,
}]}
isTurnStreaming={false}
hasBodyBelow={false}
/>,
);
fireEvent.click(screen.getByRole("button", { name: /^Worked/ }));
const activityLine = screen.getByTestId("activity-line");
const searchLabel = within(activityLine).getByText(label).parentElement!;
const detail = within(activityLine).getByText(query, { collapseWhitespace: false });
expect(screen.getAllByTestId("activity-step")).toHaveLength(1);
expect(activityLine).toHaveClass("overflow-hidden", "whitespace-nowrap");
expect(detail).toHaveClass("min-w-0", "flex-1", "truncate");
expect(detail).not.toHaveClass("whitespace-pre-line");
expect(detail.textContent).toBe(query);
expect(searchLabel).toHaveClass("truncate", "max-w-[50%]");
expect(searchLabel).not.toHaveClass("max-w-[70%]");
// Model truncation only; the browser check proves actual layout and available width.
for (const text of [searchLabel, detail]) {
Object.defineProperties(text, {
scrollWidth: { value: 480 },
clientWidth: { value: 120 },
});
}
expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
await userEvent.hover(activityLine);
const tooltip = await screen.findByRole("tooltip");
expect(tooltip.textContent).toBe(`${label}\n${query}`);
expect(tooltip.closest(".whitespace-pre-wrap")).toBeInTheDocument();
});
it.each(entrypoints)("does not reserve query width before a hosted search query arrives (%s)", (entrypoint) => {
render(
<AgentActivityCluster
messages={[{
id: "t-search-start",
role: "tool",
kind: "trace",
content: "web_search()",
traces: ["web_search()"],
...(entrypoint === "structured event" ? {
toolEvents: [{ phase: "start" as const, call_id: "call-search-start", name: "web_search", arguments: {} }],
} : {}),
createdAt: 1,
}]}
isTurnStreaming
hasBodyBelow={false}
/>,
);
const label = screen.getByText("Searching the web").parentElement!;
expect(label).toHaveClass("flex-1");
expect(label).not.toHaveClass("max-w-[50%]");
});