feat(webui): show the latest activity in collapsed turns
This commit is contained in:
1 parent
5e9810c1ad
commit
83ad917d6b
26 files changed
+476
-115
No files matched your search
+3
-1
@@ -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.
|
||||
|
||||
|
||||
@@ -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<number>();
|
||||
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 <main className="mx-auto space-y-8 px-5 py-8" style={{ maxWidth: 760 }}>
|
||||
<header className="space-y-3">
|
||||
<p className="text-xs text-muted-foreground">nanobot · 组件预览 / 模拟活动</p>
|
||||
<h1 className="text-xl font-semibold">折叠活动滚轮</h1>
|
||||
<p className="text-sm text-muted-foreground">试试慢速或快速播放。点开「处理中」可以看全部记录。</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button variant="outline" size="sm" onClick={() => play(850)}>慢速播放</Button>
|
||||
<Button variant="outline" size="sm" onClick={() => play(110)}>快速播放</Button>
|
||||
<Button variant="outline" size="sm" onClick={() => { setCadence(undefined); setStep((value) => Math.min(value + 1, updates.length)); }}>下一条</Button>
|
||||
<Button variant="ghost" size="sm" onClick={() => setDark(!dark)}>切换主题</Button>
|
||||
</div>
|
||||
</header>
|
||||
<ThreadMessages messages={messages} isStreaming activeTurnId={turnId} runStartedAt={startedAt} />
|
||||
</main>;
|
||||
}
|
||||
@@ -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: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><rect width="16" height="16" rx="3" fill="#17624c"/></svg>',
|
||||
}));
|
||||
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<HTMLElement>('[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);
|
||||
}
|
||||
});
|
||||
@@ -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([]);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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(<TooltipProvider>
|
||||
? <AnswerOrderFixture />
|
||||
: parameters.get("case") === "activity-logos"
|
||||
? <ActivityLogosFixture parameters={parameters} />
|
||||
: parameters.get("case") === "activity-wheel"
|
||||
? <ActivityWheelFixture />
|
||||
: parameters.get("case") === "exec-session"
|
||||
? <ExecSessionFixture />
|
||||
: parameters.get("case") === "sidebar-activity"
|
||||
|
||||
@@ -89,7 +89,7 @@ export function AppearanceSettingsView({ themePreference, onChangeTheme, localPr
|
||||
description={t(`settings.appearance.${localPrefs.activityMode === "auto" ? "autoHelp" : "expandedHelp"}`)}>
|
||||
<SegmentedControl<LocalActivityMode> 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 }))} />
|
||||
</SettingsRow>
|
||||
<div className="settings-group-divider">
|
||||
|
||||
@@ -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<boolean>();
|
||||
const [failedTraceDetailKey, setFailedTraceDetailKey] = useState<string | null>(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 ? (
|
||||
<CollapsedActivityPreview
|
||||
messages={activityMessages}
|
||||
fileEditsByMessage={fileEditsByMessage}
|
||||
cliAppsByName={cliAppsByName}
|
||||
mcpPresetsByName={mcpPresetsByName}
|
||||
visible={pageVisible && threadVisible}
|
||||
/>
|
||||
) : 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<string, FileEditSummary[]>;
|
||||
cliAppsByName: Map<string, CliAppInfo>;
|
||||
mcpPresetsByName: Map<string, McpPresetInfo>;
|
||||
visible: boolean;
|
||||
}) {
|
||||
const row = useMemo(() => {
|
||||
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
||||
const message = messages[index];
|
||||
if (isReasoningOnlyAssistant(message)) {
|
||||
return <ReasoningRow key={message.id} text={message.reasoning ?? ""} streaming={!!message.reasoningStreaming} />;
|
||||
}
|
||||
if (message.activityKind === "model" && message.content.trim()) {
|
||||
return <ActivityStep key={message.id} icon={Layers} label={safeActivityDetail(compactReasoningPreview(message.content))} />;
|
||||
}
|
||||
if (message.kind !== "trace") continue;
|
||||
const edit = fileEditsByMessage.get(message.id)?.at(-1);
|
||||
if (edit) return <FileEditGroup key={edit.key} edits={[edit]} displayMode="summary" />;
|
||||
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 <WebActivityRow key={`${key}:${source.href}`} {...source} />;
|
||||
return <WebSearchActionRow key={key} run={search} turnActive />;
|
||||
}
|
||||
if (matchingEvent && toolEventName(matchingEvent) === "exec_session") {
|
||||
return <ExecSessionRow key={key} event={matchingEvent} turnActive />;
|
||||
}
|
||||
const state = genericToolStateByTraceLine(message).get(traceKey);
|
||||
const cli = cliRunMapByTraceLine(message).get(traceKey) ?? parseCliRunTrace(line, state?.status);
|
||||
if (cli) return <CliRunRow key={key} run={cli} active app={cliAppsByName.get(cli.name.toLowerCase())} />;
|
||||
const mcp = mcpRunMapByTraceLine(message).get(traceKey) ?? parseMcpRunTrace(line, state?.status);
|
||||
if (mcp) return <McpRunRow key={key} run={mcp} active preset={mcpPresetsByName.get(mcp.presetName.toLowerCase())} />;
|
||||
const trace = parseGenericToolTrace(line);
|
||||
if (trace) return <GenericToolRun key={key} items={[{ trace, status: state?.status ?? "running", error: state?.error }]} />;
|
||||
return <ActivityTraceRow key={key} line={line} active state={state} />;
|
||||
}
|
||||
return null;
|
||||
}, [messages, fileEditsByMessage, cliAppsByName, mcpPresetsByName]);
|
||||
|
||||
return row ? <LatestActivityWheel row={row} visible={visible} /> : null;
|
||||
});
|
||||
|
||||
const ActivityMessageTimeline = memo(function ActivityMessageTimeline({
|
||||
messages,
|
||||
active,
|
||||
|
||||
@@ -52,6 +52,7 @@ export function ActivityStep({
|
||||
const textLabel = typeof label === "string" ? [label, detail].filter(Boolean).join("\n") : undefined;
|
||||
const activityMarker = (
|
||||
<span
|
||||
data-activity-marker=""
|
||||
className={cn(
|
||||
"flex h-5 w-[1.125rem] shrink-0 items-start justify-center pt-[3px]",
|
||||
markerLabel && ["rounded-sm", formControlFocusClassName],
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { useLayoutEffect, useRef, useState, type ReactElement } from "react";
|
||||
import { motion, useReducedMotion } from "motion/react";
|
||||
|
||||
const SLOW = 0.24;
|
||||
const FAST = 0.12;
|
||||
const rowClass = "flex h-6 min-w-0 items-center [&>*]:w-full";
|
||||
|
||||
export function LatestActivityWheel({ row, visible }: { row: ReactElement; visible: boolean }) {
|
||||
const reducedMotion = useReducedMotion();
|
||||
const canRoll = visible && !reducedMotion;
|
||||
const last = useRef({ row, time: -Infinity });
|
||||
const [frame, setFrame] = useState<{ key: ReactElement["key"]; previous?: ReactElement; duration?: number }>({ 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 (
|
||||
<div
|
||||
aria-hidden
|
||||
{...{ inert: "" }}
|
||||
data-testid="latest-activity-wheel"
|
||||
className="relative h-6 min-w-0 overflow-hidden pe-1 max-sm:ms-6 sm:flex-1 [mask-image:linear-gradient(transparent,black_10%,black_90%,transparent)] [&_[data-activity-marker]]:self-center [&_[data-activity-marker]]:items-center [&_[data-activity-marker]]:pt-0"
|
||||
>
|
||||
{canRoll ? <motion.div
|
||||
key={frame.key}
|
||||
initial={outgoing ? { y: "100%" } : false}
|
||||
animate={{ y: 0 }}
|
||||
transition={{ duration: outgoing ? frame.duration : 0, ease: [0.22, 0.7, 0.26, 1] }}
|
||||
onAnimationComplete={() => {
|
||||
if (outgoing) setFrame((current) => current === frame ? { key: frame.key } : current);
|
||||
}}
|
||||
>
|
||||
{outgoing ? <div className={`absolute inset-x-0 bottom-full ${rowClass}`}>{outgoing}</div> : null}
|
||||
<div className={rowClass}>{row}</div>
|
||||
</motion.div> : <div className={rowClass}>{row}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -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 = (
|
||||
<span
|
||||
data-sheen-text={active ? label : undefined}
|
||||
className={cn(labelClassName, "text-muted-foreground", active && "streaming-text-sheen")}
|
||||
>
|
||||
{label}
|
||||
</span>
|
||||
);
|
||||
const headerContent = (
|
||||
<>
|
||||
<Activity className={cn("h-3.5 w-3.5 shrink-0", active ? "activity-current" : "text-muted-foreground")} strokeWidth={1.5} aria-hidden>
|
||||
{active ? <path className="activity-current-trace" pathLength={100} d="M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2" /> : null}
|
||||
</Activity>
|
||||
<span
|
||||
data-sheen-text={active ? label : undefined}
|
||||
className={cn(
|
||||
"min-w-0 truncate text-[12px] font-normal leading-4 text-muted-foreground",
|
||||
active && "streaming-text-sheen",
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</span>
|
||||
{reservedLabel ? (
|
||||
<span className="grid min-w-0 tabular-nums [&>span]:col-start-1 [&>span]:row-start-1">
|
||||
{headerLabel}
|
||||
<span className={cn(labelClassName, "invisible")} aria-hidden>{reservedLabel}</span>
|
||||
</span>
|
||||
) : 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 ? <div className="flex min-h-7 items-center gap-1.5">
|
||||
{showHeader ? <div className={cn(
|
||||
"flex min-h-7 items-center gap-1.5",
|
||||
preview && "max-sm:flex-col max-sm:items-stretch max-sm:gap-0",
|
||||
)}>
|
||||
{hasDetails ? (
|
||||
<button
|
||||
type="button"
|
||||
@@ -87,6 +103,7 @@ export function ThinkingReasoningShell({
|
||||
{headerContent}
|
||||
</div>
|
||||
)}
|
||||
{preview}
|
||||
</div> : null}
|
||||
|
||||
{hasDetails ? (
|
||||
|
||||
@@ -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 (
|
||||
<>
|
||||
<ActivityStep
|
||||
icon={status === "error" ? AlertCircle : WebSearchIcon}
|
||||
active={active}
|
||||
tone={status === "error" ? "error" : status === "done" ? "success" : "active"}
|
||||
label={presentation.label}
|
||||
detail={presentation.detail}
|
||||
labelClassName={presentation.detail ? "max-w-[50%]" : undefined}
|
||||
/>
|
||||
<WebSearchActionRow run={run} turnActive={turnActive} />
|
||||
{run.sources.map((source) => (
|
||||
<WebActivityRow
|
||||
key={source.href}
|
||||
@@ -39,3 +27,21 @@ export function WebSearchRun({ run, turnActive }: { run: WebSearchRunModel; turn
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
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 (
|
||||
<ActivityStep
|
||||
icon={status === "error" ? AlertCircle : WebSearchIcon}
|
||||
active={active}
|
||||
tone={status === "error" ? "error" : status === "done" ? "success" : "active"}
|
||||
label={presentation.label}
|
||||
detail={presentation.detail}
|
||||
labelClassName={presentation.detail ? "max-w-[50%]" : undefined}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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é",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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": "概要",
|
||||
|
||||
@@ -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": "요약",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -950,7 +950,7 @@
|
||||
"previewPlaceholder": "接下来,想聊点什么?",
|
||||
"process": "过程展示",
|
||||
"processHelp": "选择 nanobot 工作时展示多少细节。",
|
||||
"autoHelp": "工作时显示进度,结束后保持简洁。",
|
||||
"autoHelp": "默认收起明细,处理中显示最新一条。",
|
||||
"expandedHelp": "默认展开工具活动与子任务详情。",
|
||||
"summaryHelp": "显示修改文件和增删行数。",
|
||||
"diffHelp": "在对话中直接展示代码差异。",
|
||||
@@ -1221,6 +1221,7 @@
|
||||
"defaultWorkspace": "默认工作区",
|
||||
"auto": "自动",
|
||||
"default": "默认",
|
||||
"collapsed": "收起",
|
||||
"expanded": "展开",
|
||||
"summary": "概要",
|
||||
"diff": "修改内容",
|
||||
|
||||
@@ -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": "概要",
|
||||
|
||||
@@ -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<typeof import("@/components/thread/activity/DiffSyntaxHighlight")>();
|
||||
@@ -126,6 +130,7 @@ describe("AgentActivityCluster", () => {
|
||||
<AgentActivityCluster messages={messages} isTurnStreaming hasBodyBelow={false} />
|
||||
</ExecSessionCommandsContext.Provider>,
|
||||
);
|
||||
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(<AgentActivityCluster messages={[message]} isTurnStreaming hasBodyBelow={false} />);
|
||||
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(<AgentActivityCluster messages={[message]} isTurnStreaming hasBodyBelow={false} />);
|
||||
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", () => {
|
||||
</ExecSessionCommandsContext.Provider>;
|
||||
};
|
||||
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(<AgentActivityCluster messages={activityMessages()} isTurnStreaming={false} hasBodyBelow={false} />);
|
||||
const disclosure = screen.getByRole("button", { name: /Worked/ });
|
||||
it.each([false, true])("honors the activity preference and manual overrides (streaming: %s)", (isTurnStreaming) => {
|
||||
render(<AgentActivityCluster messages={activityMessages()} isTurnStreaming={isTurnStreaming} hasBodyBelow={false} />);
|
||||
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(<AgentActivityCluster {...props} />);
|
||||
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(
|
||||
<AgentActivityCluster
|
||||
messages={[liveReasoning]}
|
||||
isTurnStreaming
|
||||
hasBodyBelow
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByTestId("agent-activity-content")).toBeInTheDocument();
|
||||
const { rerender } = render(
|
||||
<AgentActivityCluster messages={[liveReasoning]} isTurnStreaming hasBodyBelow />,
|
||||
);
|
||||
expect(screen.getByRole("button", { name: /^Working for / })).toHaveAttribute("aria-expanded", "false");
|
||||
expect(screen.getByTestId("latest-activity-wheel")).toHaveTextContent("checking files");
|
||||
|
||||
rerender(
|
||||
<AgentActivityCluster
|
||||
messages={[{
|
||||
...liveReasoning,
|
||||
reasoningStreaming: false,
|
||||
isStreaming: false,
|
||||
}]}
|
||||
isTurnStreaming={false}
|
||||
hasBodyBelow
|
||||
/>,
|
||||
);
|
||||
|
||||
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(
|
||||
<AgentActivityCluster
|
||||
messages={[{ ...liveReasoning, reasoningStreaming: false, isStreaming: false }]}
|
||||
isTurnStreaming={false}
|
||||
hasBodyBelow
|
||||
/>,
|
||||
);
|
||||
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(
|
||||
<AgentActivityCluster messages={messages} isTurnStreaming hasBodyBelow={false} />,
|
||||
);
|
||||
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(/<redacted>|••••/);
|
||||
});
|
||||
});
|
||||
@@ -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",
|
||||
|
||||
@@ -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(<ThreadMessages messages={messages} isStreaming />);
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user