diff --git a/docs/webui.md b/docs/webui.md index 7a79a07e7..1b74c2e47 100644 --- a/docs/webui.md +++ b/docs/webui.md @@ -105,7 +105,9 @@ To use work from another topic, mention it with `@` and tell nanobot what you ne ### Activity and context usage -The message timeline shows replies and agent activity. Expand the **Worked for** section to inspect the reasoning and tool activity for a completed turn. +While nanobot works, **Working for** shows the latest activity beside the timer, or below it on narrow screens. Select the timer to see the full reasoning and tool activity. Set **Settings → Appearance → Activity details** to **Expanded** if you prefer to see the details by default. + +Expand the **Worked for** section to inspect the reasoning and tool activity for a completed turn. Scroll past the oldest loaded message, or pull down and release on touch devices, to load earlier history. A red indicator offers error details and retry; **No earlier messages** marks the history boundary. diff --git a/webui/browser/activity-wheel-fixture.tsx b/webui/browser/activity-wheel-fixture.tsx new file mode 100644 index 000000000..0adc1bec3 --- /dev/null +++ b/webui/browser/activity-wheel-fixture.tsx @@ -0,0 +1,77 @@ +import { useEffect, useState } from "react"; + +import { ThreadMessages } from "@/components/thread/ThreadMessages"; +import { Button } from "@/components/ui/button"; +import { formatToolCallTrace } from "@/lib/tool-traces"; +import type { ToolProgressEvent, UIMessage } from "@/lib/types"; + +const turnId = "activity-wheel-demo"; +const read: ToolProgressEvent = { + phase: "start", call_id: "read-brief", name: "read_file", arguments: { path: "workspace/research/brief.md" }, +}; +const search: ToolProgressEvent = { + phase: "start", call_id: "search", name: "web_search", arguments: { query: "夜间列车旅行指南" }, +}; +const results: ToolProgressEvent = { + ...search, + phase: "end", + result: [ + { title: "Night train routes across Europe", url: "https://www.seat61.com/night-trains.htm" }, + { title: "A field guide to sleeper trains", url: "https://www.bbc.com/travel/train-guide" }, + { title: "Planning an overnight rail trip", url: "https://www.nationalgeographic.com/travel/rail" }, + ], +}; +const updates = [ + { ...read, phase: "end" }, + search, + results, + ...["www.bbc.com", "www.nationalgeographic.com", "www.theguardian.com"].map((host, index): ToolProgressEvent => ({ + phase: "end", call_id: `page-${index}`, name: "web_fetch", arguments: { url: `https://${host}/travel/trains` }, + result: { title: ["How to book a sleeper cabin", "The best overnight rail journeys", "A better way to travel overnight"][index] }, + })), +]; + +export function ActivityWheelFixture() { + const [step, setStep] = useState(0); + const [cadence, setCadence] = useState(); + const [dark, setDark] = useState(false); + const [startedAt] = useState(Date.now); + + useEffect(() => { + if (cadence === undefined || step >= updates.length) return; + const timer = window.setTimeout(() => setStep(step + 1), cadence); + return () => window.clearTimeout(timer); + }, [cadence, step]); + + useEffect(() => { + document.documentElement.classList.toggle("dark", dark); + }, [dark]); + + const tools = new Map([read, ...updates.slice(0, step)].map((event) => [event.call_id, event])); + const toolEvents = [...tools.values()]; + const traces = toolEvents.map((event) => formatToolCallTrace(event)!); + const messages: UIMessage[] = [ + { id: "question", role: "user", content: "帮我搜几条夜间列车的旅行路线", createdAt: startedAt, turnId }, + { id: "trace", role: "tool", kind: "trace", content: traces.at(-1)!, traces, toolEvents, createdAt: startedAt + 1, turnId }, + ]; + + function play(interval: number) { + setStep(0); + setCadence(interval); + } + + return
+
+

nanobot · 组件预览 / 模拟活动

+

折叠活动滚轮

+

试试慢速或快速播放。点开「处理中」可以看全部记录。

+
+ + + + +
+
+ +
; +} diff --git a/webui/browser/activity-wheel.spec.ts b/webui/browser/activity-wheel.spec.ts new file mode 100644 index 000000000..dbb2a8212 --- /dev/null +++ b/webui/browser/activity-wheel.spec.ts @@ -0,0 +1,123 @@ +import { expect, test } from "@playwright/test"; + +const path = "/browser/fixture.html?case=activity-wheel"; + +test.beforeEach(async ({ page }) => { + // Keep network timing out of this test; the real favicon component loads the image. + await page.route(/https:\/\/favicon\.im\//, (route) => route.fulfill({ + contentType: "image/svg+xml", + body: '', + })); + await page.goto(path); +}); + +test("the collapsed row rolls with its icon and a burst lands on the latest activity", async ({ page }) => { + const toggle = page.getByRole("button", { name: /处理中/ }); + const wheel = page.getByTestId("latest-activity-wheel"); + const next = page.getByRole("button", { name: "下一条" }); + await expect(toggle).toHaveAttribute("aria-expanded", "false"); + await expect(page.getByTestId("agent-activity-content")).toHaveCount(0); + await expect(wheel).toContainText("brief.md"); + const headerBox = (await toggle.boundingBox())!; + const wheelBox = (await wheel.boundingBox())!; + expect(wheelBox.x).toBeGreaterThan(headerBox.x + headerBox.width); + expect(wheelBox.y + wheelBox.height / 2).toBeCloseTo(headerBox.y + headerBox.height / 2, 0); + const iconOffset = await wheel.evaluate((element) => { + const icon = element.querySelector("[data-activity-marker] svg")!.getBoundingClientRect(); + const label = element.previousElementSibling!.querySelector("span")!.getBoundingClientRect(); + return icon.top + icon.height / 2 - (label.top + label.height / 2); + }); + expect(Math.abs(iconOffset)).toBeLessThan(0.2); + const height = (await toggle.boundingBox())!.height; + + // This is a status update on the same tool, not a new row. + await next.click(); + await expect(wheel).toContainText("读取文件"); + await expect(wheel.getByTestId("activity-step")).toHaveCount(1); + + // Observe the two real row boxes during the animation, including the incoming logo. + await next.click(); + await expect(wheel).toContainText("夜间列车旅行指南"); + const motion = await wheel.evaluate(async (element) => { + const button = [...document.querySelectorAll("button")].find((item) => item.textContent === "下一条")!; + button.click(); + const end = performance.now() + 600; + do { + await new Promise(requestAnimationFrame); + const rows = element.querySelectorAll('[data-testid="activity-step"]'); + const incoming = rows[1]; + if (!incoming?.querySelector("img")) continue; + const top = incoming.parentElement!.getBoundingClientRect().top - element.getBoundingClientRect().top; + if (top > 1 && top < element.clientHeight) { + return { + gap: top + element.getBoundingClientRect().top - rows[0].parentElement!.getBoundingClientRect().top, + height: element.clientHeight, + }; + } + } while (performance.now() < end); + return null; + }); + expect(motion).not.toBeNull(); + expect(motion!.gap).toBeCloseTo(motion!.height, 0); + await expect(wheel.getByTestId("activity-step")).toHaveCount(1); + await expect(wheel).toContainText("Planning an overnight rail trip"); + await expect(wheel.locator("img")).toHaveJSProperty("complete", true); + expect((await toggle.boundingBox())!.height).toBe(height); + + await page.getByRole("button", { name: "快速播放" }).click(); + await expect(wheel).toContainText("A better way to travel overnight", { timeout: 2200 }); + await expect(wheel.getByTestId("activity-step")).toHaveCount(1, { timeout: 500 }); + await toggle.focus(); + await toggle.press("Enter"); + await expect(toggle).toHaveAttribute("aria-expanded", "true"); + await expect(wheel).toHaveCount(0); + await expect(toggle).toBeFocused(); + await expect(page.getByRole("link", { name: /Night train routes across Europe/ })).toBeVisible(); + await expect(page.getByRole("link", { name: /A better way to travel overnight/ })).toBeVisible(); + await toggle.press("Enter"); + await expect(toggle).toHaveAttribute("aria-expanded", "false"); + await expect(wheel).toContainText("A better way to travel overnight"); +}); + +test("narrow reduced-motion preview replaces the row without scrolling the page", async ({ page }) => { + await page.setViewportSize({ width: 360, height: 740 }); + await page.emulateMedia({ reducedMotion: "reduce" }); + await page.reload(); + await page.getByRole("button", { name: "切换主题" }).click(); + const toggle = page.getByRole("button", { name: /处理中/ }); + const wheel = page.getByTestId("latest-activity-wheel"); + await page.getByRole("button", { name: "下一条" }).click({ clickCount: 3 }); + await expect(wheel).toContainText("Planning an overnight rail trip"); + await expect(wheel.getByTestId("activity-step")).toHaveCount(1); + expect(await wheel.evaluate((element) => { + const row = element.firstElementChild!; + return Math.abs(row.getBoundingClientRect().top - element.getBoundingClientRect().top); + })).toBeLessThan(1); + const header = (await toggle.boundingBox())!; + const row = (await wheel.boundingBox())!; + expect(row.y).toBeGreaterThanOrEqual(header.y + header.height - 0.2); + expect(row.width).toBeGreaterThan(header.width); + expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBe(360); +}); + +test("the elapsed label does not shift the collapsed activity horizontally", async ({ page }) => { + await page.setViewportSize({ width: 960, height: 740 }); + const start = new Date("2026-01-01T00:00:00Z"); + await page.clock.install({ time: start }); + await page.clock.pauseAt(new Date(start.getTime() + 60_000)); + await page.reload(); + const toggle = page.getByRole("button", { name: /处理中/ }); + const wheel = page.getByTestId("latest-activity-wheel"); + await expect(wheel).toBeVisible(); + + let initialX: number | undefined; + let elapsed = 0; + for (const [seconds, label] of [[1, "1s"], [9, "9s"], [10, "10s"], [20, "20s"], [59, "59s"], [60, "1m"], [61, "1m 1s"]] as const) { + await page.clock.fastForward((seconds - elapsed) * 1000); + elapsed = seconds; + await expect(toggle).toHaveAccessibleName(`处理中 ${label}`); + const { x } = (await wheel.boundingBox())!; + initialX ??= x; + expect(Math.abs(x - initialX), `wheel displacement at ${label}`).toBeLessThan(0.2); + } +}); diff --git a/webui/browser/answer-order.spec.ts b/webui/browser/answer-order.spec.ts index 66c387ebb..5bd399371 100644 --- a/webui/browser/answer-order.spec.ts +++ b/webui/browser/answer-order.spec.ts @@ -138,16 +138,18 @@ test.describe("answer order", () => { { event: "stream_end", ...base, stream_id: "live-empty", turn_seq: 4, resuming: true }, { event: "message", ...base, turn_seq: 5, kind: "tool_hint", text: "read_file({\"path\":\"beta\"})" }, ); - await expect(page.getByTestId("agent-activity-content")).toContainText("网页"); + const wheel = page.getByTestId("latest-activity-wheel"); + await expect(wheel).toContainText("beta"); + await expect(page.getByTestId("agent-activity-content")).toHaveCount(0); await expect(page.getByText("思考过程", { exact: true })).toHaveCount(0); await expect(page.getByTestId("activity-reasoning-marker")).toHaveCount(0); await page.getByRole("button", { name: "Switch topic" }).click(); await expect(page.getByText("检查工具", { exact: true })).toHaveCount(0); await page.getByRole("button", { name: "Switch topic" }).click(); - await expect(page.getByTestId("agent-activity-content")).toContainText("网页"); + await expect(wheel).toContainText("beta"); await expect(page.getByTestId("activity-reasoning-marker")).toHaveCount(0); await dropAndReconnect(); - await expect(page.getByTestId("agent-activity-content")).toContainText("网页"); + await expect(wheel).toContainText("beta"); await expect(page.getByTestId("activity-reasoning-marker")).toHaveCount(0); emit( @@ -157,6 +159,8 @@ test.describe("answer order", () => { { event: "delta", ...base, stream_id: "answer", turn_seq: 9, text: "最终答案" }, ); await expect(page.getByText("最终答案", { exact: true })).toHaveCount(1); + await expect(wheel).toContainText("真正的推理"); + await page.getByRole("button", { name: /^处理中/ }).click(); await expect(page.getByText("真正的推理", { exact: true })).toHaveCount(1); const activity = await page.getByTestId("agent-activity-content").textContent(); expect(activity).toContain("网页"); @@ -181,6 +185,8 @@ test.describe("answer order", () => { await expect(page.getByRole("status", { name: /^Working for / })).toBeVisible(); await expect(page.getByTestId("activity-reasoning-marker")).toHaveCount(0); emit({ event: "message", ...base, turn_seq: 2, kind: "tool_hint", text: "web_search({\"query\":\"alpha\"})" }); + await expect(page.getByTestId("latest-activity-wheel")).toContainText("alpha"); + await page.getByRole("button", { name: /^Working for / }).click(); await expect(page.getByTestId("agent-activity-content")).toContainText("web"); await expect(page.getByTestId("activity-reasoning-marker")).toHaveCount(0); expect(errors).toEqual([]); diff --git a/webui/browser/appearance.spec.ts b/webui/browser/appearance.spec.ts index 63fa8f8b3..86ef8f6f1 100644 --- a/webui/browser/appearance.spec.ts +++ b/webui/browser/appearance.spec.ts @@ -98,7 +98,7 @@ test("appearance explanations open on demand and follow the selected display mod const explanations = [ ["Reading text size", "Adjust messages, code and the composer—not navigation."], ["Activity display", "Choose how much detail appears as nanobot works."], - ["Activity details", "Show progress while working; keep finished work compact."], + ["Activity details", "Keep details collapsed by default. Show the latest activity while working."], ["Edit preview", "Show changed files and line counts."], ]; for (const [label, description] of explanations) { @@ -109,12 +109,20 @@ test("appearance explanations open on demand and follow the selected display mod await expect(page.getByRole("tooltip")).toBeHidden(); } - await page.getByRole("button", { name: "Expanded", exact: true }).click(); + const collapsed = page.getByRole("button", { name: "Collapsed", exact: true }); + const expanded = page.getByRole("button", { name: "Expanded", exact: true }); + await expect(collapsed).toHaveAttribute("aria-pressed", "true"); + await expanded.click(); + await page.reload(); + await expect(expanded).toHaveAttribute("aria-pressed", "true"); const activity = page.getByRole("button", { name: "Activity details", exact: true }); await activity.focus(); await expect(page.getByRole("tooltip")).toHaveText("Keep activity details expanded by default."); await activity.press("Escape"); await expect(page.getByRole("tooltip")).toBeHidden(); + await collapsed.click(); + await page.reload(); + await expect(collapsed).toHaveAttribute("aria-pressed", "true"); await page.getByRole("button", { name: "Diff", exact: true }).click(); const edits = page.getByRole("button", { name: "Edit preview", exact: true }); await edits.focus(); diff --git a/webui/browser/exec-session.spec.ts b/webui/browser/exec-session.spec.ts index d6727d03a..fad3751d3 100644 --- a/webui/browser/exec-session.spec.ts +++ b/webui/browser/exec-session.spec.ts @@ -14,6 +14,8 @@ for (const width of [1280, 360]) { await page.getByRole("button", { name: "failed", exact: true }).click(); await expect(activity).toContainText("Command failed (exit code 7) curl -u •••• https://example.invalid"); await page.getByRole("button", { name: "many", exact: true }).click(); + await expect(activity.getByTestId("latest-activity-wheel")).toContainText("Command was still running at the last check"); + await activity.getByRole("button", { name: /^Working for / }).click(); const disclosure = activity.getByRole("button", { name: "Show earlier command checks (24)" }); await expect(activity.getByTestId("activity-step")).toHaveCount(1); await disclosure.click(); diff --git a/webui/browser/fixture.tsx b/webui/browser/fixture.tsx index c9d153fd1..108828a06 100644 --- a/webui/browser/fixture.tsx +++ b/webui/browser/fixture.tsx @@ -33,6 +33,7 @@ import { ThreadLoadingFixture } from "./thread-loading-fixture"; import { AnswerOrderFixture } from "./answer-order-fixture"; import { SidebarActivityFixture } from "./sidebar-activity-fixture"; import { ActivityLogosFixture } from "./activity-logos-fixture"; +import { ActivityWheelFixture } from "./activity-wheel-fixture"; import { ExecSessionFixture } from "./exec-session-fixture"; import { HistoryHydrationFixture } from "./history-hydration-fixture"; import { IdleCompactionFixture, installIdleCompactionApi } from "./idle-compaction-fixture"; @@ -230,6 +231,7 @@ if (parameters.get("case") === "tools-catalog") installToolsCatalogPreviewApi(); if (parameters.get("case") === "idle-compaction") installIdleCompactionApi(); if (parameters.get("case") === "subagent-dock") installSubagentDockApi(); await initializeI18n(); +if (parameters.get("case") === "activity-wheel") await setAppLanguage("zh-CN"); if (parameters.get("case") === "appearance" && parameters.has("lang")) { await setAppLanguage(normalizeLocale(parameters.get("lang"))); } @@ -266,6 +268,8 @@ createRoot(document.getElementById("root")!).render( ? : parameters.get("case") === "activity-logos" ? + : parameters.get("case") === "activity-wheel" + ? : parameters.get("case") === "exec-session" ? : parameters.get("case") === "sidebar-activity" diff --git a/webui/src/components/settings/overview/AppearanceSettingsView.tsx b/webui/src/components/settings/overview/AppearanceSettingsView.tsx index 9ee11587b..073511aeb 100644 --- a/webui/src/components/settings/overview/AppearanceSettingsView.tsx +++ b/webui/src/components/settings/overview/AppearanceSettingsView.tsx @@ -89,7 +89,7 @@ export function AppearanceSettingsView({ themePreference, onChangeTheme, localPr description={t(`settings.appearance.${localPrefs.activityMode === "auto" ? "autoHelp" : "expandedHelp"}`)}> value={localPrefs.activityMode} ariaLabel={t("settings.rows.activityMode")} - options={[{ value: "auto", label: t("settings.values.auto") }, { value: "expanded", label: t("settings.values.expanded") }]} + options={[{ value: "auto", label: t("settings.values.collapsed") }, { value: "expanded", label: t("settings.values.expanded") }]} onChange={(activityMode) => onChangeLocalPrefs((previous) => ({ ...previous, activityMode }))} />
diff --git a/webui/src/components/thread/AgentActivityCluster.tsx b/webui/src/components/thread/AgentActivityCluster.tsx index 4d194d1eb..e215ba3c9 100644 --- a/webui/src/components/thread/AgentActivityCluster.tsx +++ b/webui/src/components/thread/AgentActivityCluster.tsx @@ -11,7 +11,6 @@ import { useContext, useEffect, useMemo, - useRef, useState, type ReactNode, } from "react"; @@ -26,6 +25,7 @@ import { compactActivityPath, formatActivityTarget, redactShellCommand, + safeActivityDetail, } from "@/components/thread/activity/activity-text"; import { FileEditGroup, type FileEditSummary } from "@/components/thread/activity/FileEditRow"; import { GenericToolRun } from "@/components/thread/activity/GenericToolRun"; @@ -37,14 +37,16 @@ import { type GenericToolStatus, parseGenericToolTrace, } from "@/components/thread/activity/generic-tool-model"; +import { LatestActivityWheel } from "@/components/thread/activity/LatestActivityWheel"; import { ReasoningRow } from "@/components/thread/activity/ReasoningRow"; +import { compactReasoningPreview } from "@/components/thread/activity/reasoning-preview"; import { describeMcpActivity } from "@/components/thread/activity/mcp-activity-model"; import { ThinkingReasoningShell } from "@/components/thread/activity/ThinkingReasoningShell"; import { WebActivityRow } from "@/components/thread/activity/WebActivityRow"; import { describeTraceLine, } from "@/components/thread/activity/trace-activity-model"; -import { WebSearchRun } from "@/components/thread/activity/WebSearchRun"; +import { WebSearchActionRow, WebSearchRun } from "@/components/thread/activity/WebSearchRun"; import { webSearchRunsByTraceLine } from "@/components/thread/activity/web-search-model"; import { isReasoningOnlyAssistant, @@ -279,20 +281,12 @@ function FoldedAgentActivity({ fileCount, } = countActivity(activityMessages, fileEdits, cliRuns, mcpRuns); - const [userToggledOuter, setUserToggledOuter] = useState(false); - const [outerOpenLocal, setOuterOpenLocal] = useState(false); - const [completionHoldOpen, setCompletionHoldOpen] = useState(false); + const [outerOpenLocal, setOuterOpenLocal] = useState(); const [failedTraceDetailKey, setFailedTraceDetailKey] = useState(null); const [now, setNow] = useState(() => Date.now()); - const wasTurnStreamingRef = useRef(isTurnStreaming); - const wasTurnStreaming = wasTurnStreamingRef.current; - const outerExpanded = expanded ?? ( - userToggledOuter - ? outerOpenLocal - : activityMode === "expanded" || isTurnStreaming || completionHoldOpen || (wasTurnStreaming && !isTurnStreaming) - ); + const outerExpanded = expanded ?? outerOpenLocal ?? (activityMode === "expanded"); useEffect(() => { - setUserToggledOuter(false); + setOuterOpenLocal(undefined); }, [activityMode]); const deferredTraceRefs = useMemo( () => Array.from(new Set( @@ -327,6 +321,11 @@ function FoldedAgentActivity({ startedAtMs, ); const activityDuration = formatActivityDuration(durationMs); + const showActivityPreview = isTurnStreaming && hasVisibleActivity && !outerExpanded && !hideHeader && !retryStatus; + const workingLabel = (duration: string) => t("message.activityWorkingFor", { + duration, + defaultValue: "Working for {{duration}}", + }); const isCompletedDisclosure = !isTurnStreaming && expanded !== undefined; const retryError = retryStatus?.error_kind === "connection" ? t("message.retryConnection", { defaultValue: "Connection failed" }) @@ -357,10 +356,7 @@ function FoldedAgentActivity({ defaultValue: "{{error}} Retrying", }) : isTurnStreaming - ? t("message.activityWorkingFor", { - duration: activityDuration, - defaultValue: "Working for {{duration}}", - }) + ? workingLabel(activityDuration) : durationMs <= 0 ? t("message.activityWorked", { defaultValue: "Worked" }) : t("message.activityWorkedFor", { @@ -373,9 +369,7 @@ function FoldedAgentActivity({ onExpandedChange?.(!expanded); return; } - const nextOpen = userToggledOuter ? !outerOpenLocal : !outerExpanded; - setUserToggledOuter(true); - setOuterOpenLocal(nextOpen); + setOuterOpenLocal(!outerExpanded); }; useEffect(() => { @@ -391,19 +385,6 @@ function FoldedAgentActivity({ return () => window.clearInterval(interval); }, [isTurnStreaming, pageVisible, threadVisible]); - useEffect(() => { - const wasStreaming = wasTurnStreamingRef.current; - wasTurnStreamingRef.current = isTurnStreaming; - if (isTurnStreaming) { - setCompletionHoldOpen(false); - return undefined; - } - if (!wasStreaming || userToggledOuter) return undefined; - setCompletionHoldOpen(true); - const timeout = window.setTimeout(() => setCompletionHoldOpen(false), 300); - return () => window.clearTimeout(timeout); - }, [isTurnStreaming, userToggledOuter]); - if (!hasVisibleActivity && !isTurnStreaming) return null; if (hasOnlyFileActivity && expanded === undefined) { @@ -428,6 +409,16 @@ function FoldedAgentActivity({ collapseLabel={t("message.collapseActivity")} contentId={detailsId} label={activityLabel} + reservedLabel={showActivityPreview ? workingLabel("00m 00s") : undefined} + preview={showActivityPreview ? ( + + ) : undefined} hasDetails={hasVisibleActivity} onToggle={toggleOuter} > @@ -511,6 +502,62 @@ function traceLines(message: UIMessage): string[] { return message.content.trim() ? [message.content] : []; } +const CollapsedActivityPreview = memo(function CollapsedActivityPreview({ + messages, fileEditsByMessage, cliAppsByName, mcpPresetsByName, visible, +}: { + messages: UIMessage[]; + fileEditsByMessage: Map; + cliAppsByName: Map; + mcpPresetsByName: Map; + visible: boolean; +}) { + const row = useMemo(() => { + for (let index = messages.length - 1; index >= 0; index -= 1) { + const message = messages[index]; + if (isReasoningOnlyAssistant(message)) { + return ; + } + if (message.activityKind === "model" && message.content.trim()) { + return ; + } + if (message.kind !== "trace") continue; + const edit = fileEditsByMessage.get(message.id)?.at(-1); + if (edit) return ; + const entry = activityTraceEntries(message).at(-1); + const event = entry?.sessionEvent ?? message.toolEvents?.at(-1); + const line = entry?.line ?? formatToolCallTrace(event); + if (!line?.trim()) continue; + const traceKey = canonicalToolTrace(line); + const events = message.toolEvents ?? []; + const matchingEvent = entry?.sessionEvent ?? [...events].reverse().find((item) => { + const trace = formatToolCallTrace(item); + return trace !== null && canonicalToolTrace(trace) === traceKey; + }); + const key = `${message.id}:${matchingEvent?.call_id ?? traceKey}`; + const search = webSearchRunsByTraceLine(events).get(traceKey); + if (search) { + const source = search.sources.at(-1); + if (source) return ; + return ; + } + if (matchingEvent && toolEventName(matchingEvent) === "exec_session") { + return ; + } + const state = genericToolStateByTraceLine(message).get(traceKey); + const cli = cliRunMapByTraceLine(message).get(traceKey) ?? parseCliRunTrace(line, state?.status); + if (cli) return ; + const mcp = mcpRunMapByTraceLine(message).get(traceKey) ?? parseMcpRunTrace(line, state?.status); + if (mcp) return ; + const trace = parseGenericToolTrace(line); + if (trace) return ; + return ; + } + return null; + }, [messages, fileEditsByMessage, cliAppsByName, mcpPresetsByName]); + + return row ? : null; +}); + const ActivityMessageTimeline = memo(function ActivityMessageTimeline({ messages, active, diff --git a/webui/src/components/thread/activity/ActivityStep.tsx b/webui/src/components/thread/activity/ActivityStep.tsx index 12cdf690a..9859a1946 100644 --- a/webui/src/components/thread/activity/ActivityStep.tsx +++ b/webui/src/components/thread/activity/ActivityStep.tsx @@ -52,6 +52,7 @@ export function ActivityStep({ const textLabel = typeof label === "string" ? [label, detail].filter(Boolean).join("\n") : undefined; const activityMarker = ( ({ key: row.key }); + + useLayoutEffect(() => { + const previous = last.current; + if (!canRoll) { + last.current = { row, time: -Infinity }; + setFrame({ key: row.key }); + } else if (previous.row.key !== row.key) { + const time = performance.now(); + setFrame({ previous: previous.row, key: row.key, duration: time - previous.time < 280 ? FAST : SLOW }); + last.current = { row, time }; + } else { + // A tool's status or label can change without advancing the wheel. + last.current = { ...previous, row }; + } + }, [canRoll, row]); + + const outgoing = canRoll && frame.key === row.key ? frame.previous : undefined; + return ( +
+ {canRoll ? { + if (outgoing) setFrame((current) => current === frame ? { key: frame.key } : current); + }} + > + {outgoing ?
{outgoing}
: null} +
{row}
+
:
{row}
} +
+ ); +} diff --git a/webui/src/components/thread/activity/ThinkingReasoningShell.tsx b/webui/src/components/thread/activity/ThinkingReasoningShell.tsx index 010af2834..3bc265240 100644 --- a/webui/src/components/thread/activity/ThinkingReasoningShell.tsx +++ b/webui/src/components/thread/activity/ThinkingReasoningShell.tsx @@ -11,6 +11,8 @@ interface ThinkingReasoningShellProps { collapseLabel?: string; contentId?: string; label: string; + reservedLabel?: string; + preview?: ReactNode; children: ReactNode; hasDetails?: boolean; onToggle: () => void; @@ -24,6 +26,8 @@ export function ThinkingReasoningShell({ collapseLabel, contentId: providedContentId, label, + reservedLabel, + preview, children, hasDetails = true, onToggle, @@ -32,21 +36,30 @@ export function ThinkingReasoningShell({ const contentId = providedContentId ?? generatedContentId; const [hasExpanded, setHasExpanded] = useState(expanded); if (expanded && !hasExpanded) setHasExpanded(true); - const headerClassName = "touch-target inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md px-1.5"; + const headerClassName = cn( + "touch-target inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md px-1.5", + preview && "max-sm:self-start", + ); + const labelClassName = "min-w-0 truncate text-[12px] font-normal leading-4"; + const headerLabel = ( + + {label} + + ); const headerContent = ( <> {active ? : null} - - {label} - + {reservedLabel ? ( + + {headerLabel} + {reservedLabel} + + ) : headerLabel} ); return ( @@ -57,7 +70,10 @@ export function ThinkingReasoningShell({ data-block-context-rail={contextual && showHeader || undefined} data-block-context-expanded={contextual && expanded ? true : undefined} > - {showHeader ?
+ {showHeader ?
{hasDetails ? (
: null} {hasDetails ? ( diff --git a/webui/src/components/thread/activity/WebSearchRun.tsx b/webui/src/components/thread/activity/WebSearchRun.tsx index b554016d4..6f212a295 100644 --- a/webui/src/components/thread/activity/WebSearchRun.tsx +++ b/webui/src/components/thread/activity/WebSearchRun.tsx @@ -12,21 +12,9 @@ import { } from "@/components/thread/activity/web-search-model"; export function WebSearchRun({ run, turnActive }: { run: WebSearchRunModel; turnActive: boolean }) { - const { t } = useTranslation(); - const active = run.status === "running" && turnActive; - const status = run.status === "running" && !turnActive ? "done" : run.status; - const presentation = presentWebSearchAction(run.query, status, run.target, t); - return ( <> - + {run.sources.map((source) => ( ); } + +export function WebSearchActionRow({ run, turnActive }: { run: WebSearchRunModel; turnActive: boolean }) { + const { t } = useTranslation(); + const active = run.status === "running" && turnActive; + const status = run.status === "running" && !turnActive ? "done" : run.status; + const presentation = presentWebSearchAction(run.query, status, run.target, t); + + return ( + + ); +} diff --git a/webui/src/i18n/locales/en/common.json b/webui/src/i18n/locales/en/common.json index 9bca388ae..9747b9bd4 100644 --- a/webui/src/i18n/locales/en/common.json +++ b/webui/src/i18n/locales/en/common.json @@ -950,7 +950,7 @@ "previewPlaceholder": "Where should we begin?", "process": "Activity display", "processHelp": "Choose how much detail appears as nanobot works.", - "autoHelp": "Show progress while working; keep finished work compact.", + "autoHelp": "Keep details collapsed by default. Show the latest activity while working.", "expandedHelp": "Keep activity details expanded by default.", "summaryHelp": "Show changed files and line counts.", "diffHelp": "Show code changes directly in the conversation.", @@ -1221,6 +1221,7 @@ "defaultWorkspace": "Default workspace", "auto": "Auto", "default": "Default", + "collapsed": "Collapsed", "expanded": "Expanded", "summary": "Summary", "diff": "Diff", diff --git a/webui/src/i18n/locales/es/common.json b/webui/src/i18n/locales/es/common.json index 98b9f94a5..e975dd1ce 100644 --- a/webui/src/i18n/locales/es/common.json +++ b/webui/src/i18n/locales/es/common.json @@ -713,7 +713,7 @@ "previewPlaceholder": "¿Por dónde empezamos?", "process": "Visualización de actividad", "processHelp": "Elige cuánto detalle se muestra mientras nanobot trabaja.", - "autoHelp": "Muestra el progreso durante el trabajo y una vista compacta al terminar.", + "autoHelp": "Mantén los detalles contraídos por defecto y muestra la actividad más reciente durante el trabajo.", "expandedHelp": "Mantén los detalles de actividad expandidos por defecto.", "summaryHelp": "Muestra los archivos modificados y el número de líneas.", "diffHelp": "Muestra los cambios de código directamente en la conversación.", @@ -830,6 +830,7 @@ "unixSocket": "Socket Unix", "defaultWorkspace": "Espacio predeterminado", "auto": "Automático", + "collapsed": "Contraído", "expanded": "Expandido", "default": "Predeterminado", "summary": "Resumen", diff --git a/webui/src/i18n/locales/fr/common.json b/webui/src/i18n/locales/fr/common.json index a08b82980..cdd047836 100644 --- a/webui/src/i18n/locales/fr/common.json +++ b/webui/src/i18n/locales/fr/common.json @@ -713,7 +713,7 @@ "previewPlaceholder": "Par où commencer ?", "process": "Affichage de l’activité", "processHelp": "Choisissez le niveau de détail affiché pendant que nanobot travaille.", - "autoHelp": "Affichez la progression en cours et gardez les activités terminées compactes.", + "autoHelp": "Repliez les détails par défaut et affichez la dernière activité pendant le traitement.", "expandedHelp": "Gardez les détails de l’activité développés par défaut.", "summaryHelp": "Affichez les fichiers modifiés et le nombre de lignes.", "diffHelp": "Affichez les changements de code directement dans la conversation.", @@ -830,6 +830,7 @@ "unixSocket": "Socket Unix", "defaultWorkspace": "Espace par défaut", "auto": "Automatique", + "collapsed": "Replié", "expanded": "Développé", "default": "Par défaut", "summary": "Résumé", diff --git a/webui/src/i18n/locales/id/common.json b/webui/src/i18n/locales/id/common.json index 389d7f729..2b2355703 100644 --- a/webui/src/i18n/locales/id/common.json +++ b/webui/src/i18n/locales/id/common.json @@ -713,7 +713,7 @@ "previewPlaceholder": "Dari mana kita mulai?", "process": "Tampilan aktivitas", "processHelp": "Pilih seberapa banyak detail yang ditampilkan saat nanobot bekerja.", - "autoHelp": "Tampilkan progres saat bekerja dan tampilan ringkas setelah selesai.", + "autoHelp": "Ringkas detail secara default dan tampilkan aktivitas terbaru saat bekerja.", "expandedHelp": "Perluas detail aktivitas secara default.", "summaryHelp": "Tampilkan berkas yang diubah dan jumlah baris.", "diffHelp": "Tampilkan perubahan kode langsung dalam percakapan.", @@ -830,6 +830,7 @@ "unixSocket": "Soket Unix", "defaultWorkspace": "Ruang kerja bawaan", "auto": "Otomatis", + "collapsed": "Diringkas", "expanded": "Diperluas", "default": "Bawaan", "summary": "Ringkasan", diff --git a/webui/src/i18n/locales/ja/common.json b/webui/src/i18n/locales/ja/common.json index 16af7d028..d5675540e 100644 --- a/webui/src/i18n/locales/ja/common.json +++ b/webui/src/i18n/locales/ja/common.json @@ -713,7 +713,7 @@ "previewPlaceholder": "何から始めましょうか?", "process": "処理状況の表示", "processHelp": "nanobot の作業中に表示する詳細の量を選びます。", - "autoHelp": "作業中は進捗を表示し、完了後はコンパクトにまとめます。", + "autoHelp": "詳細は既定で折りたたみ、作業中は最新のアクティビティを表示します。", "expandedHelp": "処理の詳細を既定で展開します。", "summaryHelp": "変更されたファイルと行数を表示します。", "diffHelp": "コードの変更を会話内に直接表示します。", @@ -830,6 +830,7 @@ "unixSocket": "Unix ソケット", "defaultWorkspace": "既定のワークスペース", "auto": "自動", + "collapsed": "折りたたむ", "expanded": "展開", "default": "既定", "summary": "概要", diff --git a/webui/src/i18n/locales/ko/common.json b/webui/src/i18n/locales/ko/common.json index 83e675781..1700aad1e 100644 --- a/webui/src/i18n/locales/ko/common.json +++ b/webui/src/i18n/locales/ko/common.json @@ -713,7 +713,7 @@ "previewPlaceholder": "어디서부터 시작할까요?", "process": "활동 표시", "processHelp": "nanobot이 작업하는 동안 표시할 세부 정보의 양을 선택하세요.", - "autoHelp": "작업 중에는 진행 상황을 표시하고, 완료 후에는 간결하게 표시합니다.", + "autoHelp": "세부 정보는 기본으로 접고, 작업 중에는 최신 활동을 표시합니다.", "expandedHelp": "활동 세부 정보를 기본으로 펼쳐 둡니다.", "summaryHelp": "변경된 파일과 줄 수를 표시합니다.", "diffHelp": "코드 변경 내용을 대화에 바로 표시합니다.", @@ -830,6 +830,7 @@ "unixSocket": "Unix 소켓", "defaultWorkspace": "기본 작업 공간", "auto": "자동", + "collapsed": "접힘", "expanded": "펼침", "default": "기본값", "summary": "요약", diff --git a/webui/src/i18n/locales/pt-BR/common.json b/webui/src/i18n/locales/pt-BR/common.json index 17008785c..e2e382cbc 100644 --- a/webui/src/i18n/locales/pt-BR/common.json +++ b/webui/src/i18n/locales/pt-BR/common.json @@ -770,7 +770,7 @@ "previewPlaceholder": "Por onde começamos?", "process": "Exibição de atividade", "processHelp": "Escolha o nível de detalhe exibido enquanto o nanobot trabalha.", - "autoHelp": "Mostre o progresso durante o trabalho e uma visão compacta ao terminar.", + "autoHelp": "Mantenha os detalhes recolhidos por padrão e mostre a atividade mais recente durante o trabalho.", "expandedHelp": "Mantenha os detalhes de atividade expandidos por padrão.", "summaryHelp": "Mostre os arquivos alterados e a contagem de linhas.", "diffHelp": "Mostre as alterações de código diretamente na conversa.", @@ -1040,6 +1040,7 @@ "unixSocket": "Socket Unix", "defaultWorkspace": "Espaço de trabalho padrão", "auto": "Automático", + "collapsed": "Recolhido", "expanded": "Expandido", "default": "Padrão", "summary": "Resumo", diff --git a/webui/src/i18n/locales/vi/common.json b/webui/src/i18n/locales/vi/common.json index 4e4f5c6df..0738d63de 100644 --- a/webui/src/i18n/locales/vi/common.json +++ b/webui/src/i18n/locales/vi/common.json @@ -713,7 +713,7 @@ "previewPlaceholder": "Chúng ta nên bắt đầu từ đâu?", "process": "Hiển thị hoạt động", "processHelp": "Chọn mức độ chi tiết hiển thị khi nanobot làm việc.", - "autoHelp": "Hiển thị tiến độ khi đang làm việc và thu gọn khi hoàn tất.", + "autoHelp": "Mặc định thu gọn chi tiết và chỉ hiện hoạt động mới nhất khi đang làm việc.", "expandedHelp": "Mặc định mở rộng chi tiết hoạt động.", "summaryHelp": "Hiển thị các tệp đã thay đổi và số dòng.", "diffHelp": "Hiển thị thay đổi mã ngay trong cuộc trò chuyện.", @@ -830,6 +830,7 @@ "unixSocket": "Socket Unix", "defaultWorkspace": "Không gian làm việc mặc định", "auto": "Tự động", + "collapsed": "Thu gọn", "expanded": "Mở rộng", "default": "Mặc định", "summary": "Tóm tắt", diff --git a/webui/src/i18n/locales/zh-CN/common.json b/webui/src/i18n/locales/zh-CN/common.json index 6a4fb5dd7..f76f196fb 100644 --- a/webui/src/i18n/locales/zh-CN/common.json +++ b/webui/src/i18n/locales/zh-CN/common.json @@ -950,7 +950,7 @@ "previewPlaceholder": "接下来,想聊点什么?", "process": "过程展示", "processHelp": "选择 nanobot 工作时展示多少细节。", - "autoHelp": "工作时显示进度,结束后保持简洁。", + "autoHelp": "默认收起明细,处理中显示最新一条。", "expandedHelp": "默认展开工具活动与子任务详情。", "summaryHelp": "显示修改文件和增删行数。", "diffHelp": "在对话中直接展示代码差异。", @@ -1221,6 +1221,7 @@ "defaultWorkspace": "默认工作区", "auto": "自动", "default": "默认", + "collapsed": "收起", "expanded": "展开", "summary": "概要", "diff": "修改内容", diff --git a/webui/src/i18n/locales/zh-TW/common.json b/webui/src/i18n/locales/zh-TW/common.json index 61a33ada2..599e642c3 100644 --- a/webui/src/i18n/locales/zh-TW/common.json +++ b/webui/src/i18n/locales/zh-TW/common.json @@ -713,7 +713,7 @@ "previewPlaceholder": "接下來,想聊點什麼?", "process": "過程展示", "processHelp": "選擇 nanobot 工作時展示多少細節。", - "autoHelp": "工作時顯示進度,結束後保持簡潔。", + "autoHelp": "預設收合明細,處理中顯示最新一筆。", "expandedHelp": "預設展開工具活動與子任務詳情。", "summaryHelp": "顯示修改檔案和增刪行數。", "diffHelp": "在對話中直接展示程式碼差異。", @@ -830,6 +830,7 @@ "unixSocket": "Unix 通訊端", "defaultWorkspace": "預設工作區", "auto": "自動", + "collapsed": "收合", "expanded": "展開", "default": "預設", "summary": "概要", diff --git a/webui/src/tests/agent-activity-cluster.test.tsx b/webui/src/tests/agent-activity-cluster.test.tsx index 18dd7c8b2..26755daa5 100644 --- a/webui/src/tests/agent-activity-cluster.test.tsx +++ b/webui/src/tests/agent-activity-cluster.test.tsx @@ -8,6 +8,10 @@ import { setAppLanguage } from "@/i18n"; import { DEFAULT_LOCAL_PREFS, LOCAL_PREFS_STORAGE_KEY, writeLocalPreferences } from "@/lib/local-preferences"; import type { CliAppInfo, McpPresetInfo, UIMessage } from "@/lib/types"; +function openLiveActivity() { + fireEvent.click(screen.getByRole("button", { name: /^Working for / })); +} + // These DOM tests exercise disclosure/source contracts; the real shadow renderer runs in browser tests. vi.mock("@/components/thread/activity/DiffSyntaxHighlight", async (importOriginal) => { const actual = await importOriginal(); @@ -126,6 +130,7 @@ describe("AgentActivityCluster", () => { , ); + openLiveActivity(); const rows = screen.getAllByTestId("activity-step").map((row) => row.textContent); expect(rows).toEqual([ "Command was still running at the last check npm test --token ••••", @@ -144,6 +149,7 @@ describe("AgentActivityCluster", () => { traces: [line, legacy], createdAt: 1, toolEvents: [{ name: "exec_session", call_id: "check", arguments: { session_id: id }, phase: "end", result: "Exit code: 0\nElapsed: 2.0s" }] }; render(); + openLiveActivity(); expect(screen.getAllByTestId("activity-step").map((row) => row.textContent)).toEqual([ "Command completed", "Reading file later.txt", ]); @@ -160,6 +166,7 @@ describe("AgentActivityCluster", () => { { name: "exec_session", call_id: "check-2", arguments: { session_id: id }, phase: "end", result: "Exit code: 0\nElapsed: 2.0s" }, ] }; render(); + openLiveActivity(); expect(screen.getAllByTestId("activity-step").map((row) => row.textContent)).toEqual([ "Command was still running at the last check", "Command completed", "Reading file later.txt", ]); @@ -195,6 +202,7 @@ describe("AgentActivityCluster", () => { ; }; const { rerender, container } = render(view(10)); + openLiveActivity(); expect(screen.getAllByTestId("activity-step")).toHaveLength(5); expect(container).toHaveTextContent("Sent input test-a"); expect(container).toHaveTextContent("Could not check command test-b"); @@ -230,9 +238,9 @@ describe("AgentActivityCluster", () => { expect(container.innerHTML).not.toContain(id); }); - it("honors the activity preference for standalone completed activity with manual overrides", () => { - render(); - const disclosure = screen.getByRole("button", { name: /Worked/ }); + it.each([false, true])("honors the activity preference and manual overrides (streaming: %s)", (isTurnStreaming) => { + render(); + const disclosure = screen.getByRole("button", { name: /^(Working|Worked)/ }); expect(disclosure).toHaveAttribute("aria-expanded", "false"); act(() => { writeLocalPreferences({ ...DEFAULT_LOCAL_PREFS, activityMode: "expanded" }); }); expect(disclosure).toHaveAttribute("aria-expanded", "true"); @@ -288,6 +296,7 @@ describe("AgentActivityCluster", () => { />, ); + openLiveActivity(); expect(screen.getByText(`Searched files “${query}”`)).toBeInTheDocument(); expect(screen.getByText(`Reading file ${path}`)).toBeInTheDocument(); expect(screen.getByLabelText("Using Blender, --json --background scene.blend")).toBeInTheDocument(); @@ -416,6 +425,7 @@ describe("AgentActivityCluster", () => { />, ); + openLiveActivity(); const block = screen.getByTestId("activity-model-message"); await waitFor(() => expect(block.querySelector("strong")).not.toBeNull()); expect(block.querySelector("strong")).toHaveTextContent("partial answer"); @@ -433,6 +443,7 @@ describe("AgentActivityCluster", () => { }; const view = render(); const header = screen.getByRole("button", { name: /^(Working|Worked)/ }); + if (isTurnStreaming) fireEvent.click(header); const content = screen.getByTestId("agent-activity-content"); expect(header).toHaveClass("h-7", "gap-1.5", "px-1.5"); @@ -474,6 +485,7 @@ describe("AgentActivityCluster", () => { />, ); + openLiveActivity(); expect(screen.getByTestId("activity-reasoning-marker")).toHaveAttribute("data-state", "thinking"); rerender( @@ -494,8 +506,7 @@ describe("AgentActivityCluster", () => { await waitFor(() => expect(marker).toHaveClass("animate-in")); }); - it("briefly shows completed activity, then auto-collapses before the answer", () => { - vi.useFakeTimers(); + it("keeps untouched live details folded when work completes", () => { const liveReasoning: UIMessage = { id: "r-collapse", role: "assistant", @@ -505,40 +516,25 @@ describe("AgentActivityCluster", () => { isStreaming: true, createdAt: 1, }; - try { - const { rerender } = render( - , - ); - expect(screen.getByTestId("agent-activity-content")).toBeInTheDocument(); + const { rerender } = render( + , + ); + expect(screen.getByRole("button", { name: /^Working for / })).toHaveAttribute("aria-expanded", "false"); + expect(screen.getByTestId("latest-activity-wheel")).toHaveTextContent("checking files"); - rerender( - , - ); - - expect(screen.getByTestId("agent-activity-content")).toBeInTheDocument(); - act(() => { - vi.advanceTimersByTime(301); - }); - expect(screen.queryByTestId("agent-activity-content")).not.toBeInTheDocument(); - expect(screen.getByRole("button", { name: "Worked" })).toHaveAttribute( - "aria-expanded", - "false", - ); - } finally { - vi.useRealTimers(); - } + rerender( + , + ); + expect(screen.queryByTestId("latest-activity-wheel")).not.toBeInTheDocument(); + expect(screen.queryByTestId("agent-activity-content")).not.toBeInTheDocument(); + const disclosure = screen.getByRole("button", { name: "Worked" }); + expect(disclosure).toHaveAttribute("aria-expanded", "false"); + fireEvent.click(disclosure); + expect(screen.getByTestId("agent-activity-content")).toHaveTextContent("checking files"); }); @@ -691,6 +687,7 @@ describe("AgentActivityCluster", () => { />, ); + openLiveActivity(); assertBetween(screen.getByRole("img", { name: "Editing" })); rerender( @@ -1323,6 +1320,7 @@ describe("AgentActivityCluster", () => { />, ); + openLiveActivity(); const searchRow = screen.getByLabelText("Searched the web, nanobot architecture").closest('[data-testid="activity-step"]'); const cliRow = screen.getByLabelText("Used Blender, --json project new").closest('[data-testid="activity-step"]'); const fetchRow = screen.getByText("example.com/diagram").closest('[data-testid="activity-step"]'); @@ -1369,6 +1367,7 @@ describe("AgentActivityCluster", () => { />, ); + openLiveActivity(); expect(screen.getByLabelText("Searched the web, agent frameworks")).toBeInTheDocument(); expect(screen.queryByText("2 sources")).not.toBeInTheDocument(); @@ -1732,6 +1731,7 @@ describe("AgentActivityCluster", () => { />, ); + openLiveActivity(); expect(screen.getByText("File search complete *.tsx")).toBeInTheDocument(); expect(screen.getByText("Listed files memory")).toBeInTheDocument(); expect(screen.getByText("Searching files “dream_cursor”")).toBeInTheDocument(); @@ -1760,6 +1760,7 @@ describe("AgentActivityCluster", () => { const view = render( , ); + openLiveActivity(); const header = screen.getByText(/^Working for /); expect(header).toHaveAttribute("data-sheen-text", header.textContent); const tool = screen.getByText("Read file skills/weather/SKILL.md"); @@ -2304,6 +2305,7 @@ describe("AgentActivityCluster", () => { />, ); + fireEvent.click(screen.getByRole("button", { name: /^Worked/ })); expect(screen.getByText("Generated image")).toBeInTheDocument(); expect(screen.queryByRole("img", { name: "generated.png" })).not.toBeInTheDocument(); }); @@ -2461,6 +2463,9 @@ describe("AgentActivityCluster", () => { expect(container.innerHTML).not.toContain("sk-proj-1234567890-secret"); expect(container.innerHTML).not.toContain("private-payload"); expect(container.textContent).not.toMatch(/run_cli_app\(|browser_fill\(|third_party_sync\(/); + openLiveActivity(); + expect(container.innerHTML).not.toMatch(/xoxb-1234567890-secret|mcp-private-value|sk-proj-1234567890-secret|private-payload/); + expect(container.textContent).not.toMatch(/run_cli_app\(|browser_fill\(|third_party_sync\(/); expect(container.textContent).toMatch(/|••••/); }); }); diff --git a/webui/src/tests/i18n.test.tsx b/webui/src/tests/i18n.test.tsx index 5f3449571..4efcf4d9a 100644 --- a/webui/src/tests/i18n.test.tsx +++ b/webui/src/tests/i18n.test.tsx @@ -212,6 +212,7 @@ const LOCALIZED_SETTINGS_COPY_KEYS = [ "settings.help.webuiDefaultAccess", "settings.values.light", "settings.values.dark", + "settings.values.collapsed", "settings.values.expanded", "settings.values.enabled", "settings.values.disabled", diff --git a/webui/src/tests/thread-messages.test.tsx b/webui/src/tests/thread-messages.test.tsx index 02d3bfedc..633b7f6d9 100644 --- a/webui/src/tests/thread-messages.test.tsx +++ b/webui/src/tests/thread-messages.test.tsx @@ -418,7 +418,7 @@ describe("ThreadMessages", () => { ); expect(screen.getByText("I will check that.")).toBe(paragraph); - expect(screen.getByText(/working/i)).toBeInTheDocument(); + expect(screen.getByRole("button", { name: /^Working for / })).toBeInTheDocument(); }); it("projects a turn in causal order independently of streaming state", () => { @@ -717,8 +717,8 @@ describe("ThreadMessages", () => { ...messages, { id: "tool", role: "tool", kind: "trace", content: "web_search(query)", turnId: "automation", createdAt: now }, ]} isStreaming activeTurnId="automation" runStartedAt={(now - 3_000) / 1000} />); - expect(screen.getByTestId("agent-activity-content")).toBeInTheDocument(); - expect(screen.getByRole("button", { name: /^Working for 3s/ })).toBeInTheDocument(); + expect(screen.getByRole("button", { name: "Working for 3s" })).toHaveAttribute("aria-expanded", "false"); + expect(screen.getByTestId("latest-activity-wheel")).toBeInTheDocument(); expect(screen.queryByTestId("activity-reasoning-marker")).not.toBeInTheDocument(); }); @@ -1502,6 +1502,7 @@ describe("ThreadMessages", () => { render(); + fireEvent.click(screen.getByRole("button", { name: /^Working for / })); expect(screen.getByLabelText(/editing foo\.txt/i)).toBeInTheDocument(); expect(screen.queryByLabelText(/edited foo\.txt/i)).not.toBeInTheDocument(); });