From 7edd377352d7dd1f1da82cf406a8dcc80a76bb0d Mon Sep 17 00:00:00 2001 From: chengyongru <2755839590@qq.com> Date: Sun, 18 Oct 2026 01:36:53 +0800 Subject: [PATCH] fix(webui): keep search activity summaries on one line --- .../thread/AgentActivityCluster.tsx | 2 +- .../thread/activity/WebSearchRun.tsx | 2 +- webui/src/tests/web-search-summary.test.tsx | 88 +++++++++++++++++++ 3 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 webui/src/tests/web-search-summary.test.tsx diff --git a/webui/src/components/thread/AgentActivityCluster.tsx b/webui/src/components/thread/AgentActivityCluster.tsx index e0e65e7bb..d9d337885 100644 --- a/webui/src/components/thread/AgentActivityCluster.tsx +++ b/webui/src/components/thread/AgentActivityCluster.tsx @@ -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} /> ); } diff --git a/webui/src/components/thread/activity/WebSearchRun.tsx b/webui/src/components/thread/activity/WebSearchRun.tsx index a703e630c..b554016d4 100644 --- a/webui/src/components/thread/activity/WebSearchRun.tsx +++ b/webui/src/components/thread/activity/WebSearchRun.tsx @@ -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) => ( { + 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( + , + ); + 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( + , + ); + const label = screen.getByText("Searching the web").parentElement!; + expect(label).toHaveClass("flex-1"); + expect(label).not.toHaveClass("max-w-[50%]"); +});