Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

perf(frontend/copilot): tick the thinking timer from one shared clock (#15685)

Abhimanyu Yadav6c89b1607fd7
diff --git a/autogpt_platform/frontend/scripts/perf/fixtures/tool-call-wait.sse b/autogpt_platform/frontend/scripts/perf/fixtures/tool-call-wait.sse
new file mode 100644
index 0000000000..eeae0c1ae0
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/fixtures/tool-call-wait.sse
@@ -0,0 +1,128 @@
+data: {"type":"start","messageId":"perf-tool-call-wait"}
+
+data: {"type":"start-step"}
+
+data: {"type":"tool-input-start","toolCallId":"call_perf_wait","toolName":"perf_lookup"}
+
+data: {"type":"tool-input-available","toolCallId":"call_perf_wait","toolName":"perf_lookup","input":{"query":"weekly sales report","page":1}}
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
+: heartbeat
+
diff --git a/autogpt_platform/frontend/scripts/perf/scenarios/copilot-tool-wait.ts b/autogpt_platform/frontend/scripts/perf/scenarios/copilot-tool-wait.ts
new file mode 100644
index 0000000000..24c1d01ebb
--- /dev/null
+++ b/autogpt_platform/frontend/scripts/perf/scenarios/copilot-tool-wait.ts
@@ -0,0 +1,51 @@
+import { CopilotPage } from "../../../src/playwright/pages/copilot.page";
+import {
+ COPILOT_SESSIONS,
+ createCopilotFixture,
+ SESSION_L,
+} from "../lib/copilot-fixture";
+import { sendMessage } from "../lib/copilot-page";
+import { installRoutes } from "../lib/routes";
+import { noInteraction, settle, type Scenario } from "../lib/scenario";
+
+/** Opens a tool call, then sends only `: heartbeat` comments, one a second. */
+const TOOL_WAIT_FIXTURE = "tool-call-wait.sse";
+const TOOL_WAIT_PACE_MS = 1_000;
+const READY_TIMEOUT_MS = 60_000;
+const SETTLE_MS = 1_000;
+
+export const copilotToolWait: Scenario = {
+ name: "copilot-tool-wait",
+ description:
+ 'Send "go" in the 200-message chat; the reply opens one tool call and then sends no tokens, so the turn sits on a long-running tool.',
+ readyWhen:
+ 'the newest user message and the composer are visible, then network idle + 1 s; then "go" is sent and its "Running Perf lookup…" row is on screen, + 1 s',
+ windowMs: 20_000,
+ async setup(ctx) {
+ const fixture = createCopilotFixture({
+ userID: ctx.userID,
+ sessions: COPILOT_SESSIONS,
+ stream: ctx.stream,
+ replyFixture: TOOL_WAIT_FIXTURE,
+ paceMs: TOOL_WAIT_PACE_MS,
+ });
+ await installRoutes(ctx.page, fixture.handlers);
+ const copilot = new CopilotPage(ctx.page);
+ await copilot.open(SESSION_L);
+ await copilot
+ .getChatInput()
+ .waitFor({ state: "visible", timeout: READY_TIMEOUT_MS });
+ await ctx.page
+ .getByText(/^Turn \d+: can you help/)
+ .last()
+ .waitFor({ state: "visible", timeout: READY_TIMEOUT_MS });
+ await settle(ctx.page);
+ await sendMessage(copilot, "go");
+ await ctx.page
+ .getByText(/^Running Perf lookup/)
+ .first()
+ .waitFor({ state: "visible", timeout: READY_TIMEOUT_MS });
+ await ctx.page.waitForTimeout(SETTLE_MS);
+ return noInteraction;
+ },
+};
diff --git a/autogpt_platform/frontend/scripts/perf/scenarios/registry.ts b/autogpt_platform/frontend/scripts/perf/scenarios/registry.ts
index ba9a315452..7979d1637c 100644
--- a/autogpt_platform/frontend/scripts/perf/scenarios/registry.ts
+++ b/autogpt_platform/frontend/scripts/perf/scenarios/registry.ts
@@ -7,6 +7,7 @@ import { copilotIdle } from "./copilot-idle";
import { copilotStreamCode } from "./copilot-stream-code";
import { copilotStreamReply } from "./copilot-stream-reply";
import { copilotSwitchThreads } from "./copilot-switch-threads";
+import { copilotToolWait } from "./copilot-tool-wait";
import { copilotType } from "./copilot-type";
import { libraryRunning } from "./library-running";
import { libraryRunningEvents } from "./library-running-events";
@@ -23,6 +24,7 @@ export const SCENARIOS: Scenario[] = [
builderConnectEdge,
libraryRunningEvents,
builderRunEvents,
+ copilotToolWait,
];
export function findScenario(name: string) {
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/expert-threads.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/expert-threads.test.tsx
index b2361d2ccc..a6df5845eb 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/expert-threads.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/expert-threads.test.tsx
@@ -161,6 +161,7 @@ vi.mock("../components/JobStatsBar/TurnStatsBar", () => ({
}));
vi.mock("../components/JobStatsBar/useElapsedTimer", () => ({
useElapsedTimer: () => ({ elapsedSeconds: 0 }),
+ useElapsedAnchor: () => ({ startedAtMs: null, frozenSeconds: 0 }),
}));
vi.mock("../components/CopilotPendingReviews/CopilotPendingReviews", () => ({
CopilotPendingReviews: () => null,
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx
index 9022a50d6a..0f39bd83c1 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx
@@ -19,7 +19,7 @@ import { useEffect, useLayoutEffect, useRef } from "react";
import { useStickToBottomContext } from "use-stick-to-bottom";
import { TOOL_PART_PREFIX } from "../JobStatsBar/constants";
import { TurnStatsBar } from "../JobStatsBar/TurnStatsBar";
-import { useElapsedTimer } from "../JobStatsBar/useElapsedTimer";
+import { useElapsedAnchor } from "../JobStatsBar/useElapsedTimer";
import { CopilotPendingReviews } from "../CopilotPendingReviews/CopilotPendingReviews";
import type { TurnStatsMap } from "../../helpers/convertChatSessionToUiMessages";
import { hideKickoffMessages } from "../../expertKickoff";
@@ -432,12 +432,17 @@ export function ChatMessagesContainer({
!isRestoringActiveSession &&
liveCompactionPhase === null &&
(status === "submitted" || (status === "streaming" && !hasInflight));
- const { elapsedSeconds } = useElapsedTimer(
+ // Only the start time lives here: the indicator ticks its own label, so
+ // the transcript does not re-render every second for the whole turn.
+ const streamClock = useElapsedAnchor(
isActivelyStreaming,
activeStreamStartedAt,
);
const indicator = (
- <ThinkingIndicator active={showThinking} elapsedSeconds={elapsedSeconds} />
+ <ThinkingIndicator
+ active={showThinking}
+ startedAtMs={streamClock.startedAtMs}
+ />
);
// Public viewers of a shared chat never see a live turn, so the indicator
// stays out of the transcript for them wherever it would render.
@@ -454,24 +459,7 @@ export function ChatMessagesContainer({
);
return () => clearTimeout(timer);
}, [isRestoringActiveSession]);
- const { elapsedSeconds: restoreElapsedSeconds } =
- useElapsedTimer(showRestoreFallback);
-
- // Freeze elapsed time when streaming ends so TurnStatsBar shows the final value.
- // Reset when a new streaming turn begins.
- const frozenElapsedRef = useRef(0);
- const wasStreamingRef = useRef(false);
- useEffect(() => {
- if (isActivelyStreaming) {
- if (!wasStreamingRef.current) {
- frozenElapsedRef.current = 0;
- }
- if (elapsedSeconds > 0) {
- frozenElapsedRef.current = elapsedSeconds;
- }
- }
- wasStreamingRef.current = isActivelyStreaming;
- });
+ const restoreClock = useElapsedAnchor(showRestoreFallback);
const thread = (
<>
@@ -705,7 +693,7 @@ export function ChatMessagesContainer({
turnMessages={turnMessagesForRow(messages, message)}
elapsedSeconds={
rowIndex === renderRows.length - 1
- ? frozenElapsedRef.current
+ ? streamClock.frozenSeconds
: undefined
}
stats={turnStats?.get(message.id)}
@@ -809,7 +797,7 @@ export function ChatMessagesContainer({
<div className="flex flex-col gap-1 text-sm text-slate-500">
<ThinkingIndicator
active
- elapsedSeconds={restoreElapsedSeconds}
+ startedAtMs={restoreClock.startedAtMs}
statusMessage={restoreStatusMessage ?? "Reconnecting…"}
/>
<span className="pl-6 text-xs text-slate-400">
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/__tests__/ChatMessagesContainer.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/__tests__/ChatMessagesContainer.test.tsx
index 61c3244399..97a4e880ff 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/__tests__/ChatMessagesContainer.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/__tests__/ChatMessagesContainer.test.tsx
@@ -129,6 +129,7 @@ vi.mock("../../JobStatsBar/TurnStatsBar", () => ({
}));
vi.mock("../../JobStatsBar/useElapsedTimer", () => ({
useElapsedTimer: () => ({ elapsedSeconds: 0 }),
+ useElapsedAnchor: () => ({ startedAtMs: null, frozenSeconds: 0 }),
}));
vi.mock("../../CopilotPendingReviews/CopilotPendingReviews", () => ({
CopilotPendingReviews: (props: object) => (
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/__tests__/thinkingClock.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/__tests__/thinkingClock.test.tsx
new file mode 100644
index 0000000000..826adffd0a
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/__tests__/thinkingClock.test.tsx
@@ -0,0 +1,218 @@
+import type { ComponentProps, ReactNode } from "react";
+import type { UIDataTypes, UIMessage, UITools } from "ai";
+import { act, cleanup, render, screen } from "@/tests/integrations/test-utils";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { ChatMessagesContainer } from "../ChatMessagesContainer";
+
+type Message = UIMessage<unknown, UIDataTypes, UITools>;
+
+// The transcript's clock is the subject here, so the timer hooks and the
+// ThinkingIndicator stay real; everything that only adds noise is stubbed.
+const chainRenders = { count: 0 };
+
+vi.mock("@/services/feature-flags/use-get-flag", async (importOriginal) => {
+ const actual =
+ await importOriginal<
+ typeof import("@/services/feature-flags/use-get-flag")
+ >();
+ return { ...actual, useGetFlag: () => false };
+});
+
+vi.mock("use-stick-to-bottom", () => ({
+ useStickToBottomContext: () => ({
+ scrollRef: {
+ current: { scrollHeight: 100, scrollTop: 0, clientHeight: 500 },
+ },
+ }),
+}));
+
+vi.mock("@/components/ai-elements/conversation", () => ({
+ Conversation: ({ children }: { children: ReactNode }) => (
+ <div>{children}</div>
+ ),
+ ConversationContent: ({ children }: { children: ReactNode }) => (
+ <div>{children}</div>
+ ),
+ ConversationScrollButton: () => null,
+}));
+
+vi.mock("@/components/ai-elements/message", () => ({
+ Message: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ MessageActions: ({ children }: { children: ReactNode }) => (
+ <div>{children}</div>
+ ),
+ MessageContent: ({ children }: { children: ReactNode }) => (
+ <div>{children}</div>
+ ),
+}));
+
+vi.mock("../components/AssistantMessageActions", () => ({
+ AssistantMessageActions: () => null,
+}));
+vi.mock("../components/ChainMessageParts", () => ({
+ ChainMessageParts: () => {
+ chainRenders.count++;
+ return <div data-testid="chain-message-parts" />;
+ },
+}));
+vi.mock("../components/CopyButton", () => ({
+ CopyButton: () => null,
+}));
+vi.mock("../components/QueueBadge", () => ({
+ QueueBadge: () => null,
+}));
+vi.mock("../components/MessageAttachments", () => ({
+ MessageAttachments: () => null,
+}));
+vi.mock("../components/MessagePartRenderer", () => ({
+ MessagePartRenderer: ({ part }: { part: { type: string; text?: string } }) =>
+ part.type === "text" ? <span>{part.text}</span> : null,
+}));
+vi.mock("../../ToolChain/SwapText", () => ({
+ SwapText: ({ text }: { text: string }) => <span>{text}</span>,
+}));
+vi.mock("../../PixelGridLoader/PixelGridLoader", () => ({
+ PixelGridLoader: () => null,
+}));
+vi.mock("../../JobStatsBar/TurnStatsBar", () => ({
+ TurnStatsBar: ({ elapsedSeconds }: { elapsedSeconds?: number }) => (
+ <div data-testid="turn-stats-bar">{String(elapsedSeconds)}</div>
+ ),
+}));
+vi.mock("../../CopilotPendingReviews/CopilotPendingReviews", () => ({
+ CopilotPendingReviews: () => null,
+}));
+vi.mock("../../ChatMinimap/ChatMinimap", () => ({
+ ChatMinimap: () => null,
+}));
+
+class MockIntersectionObserver {
+ observe() {}
+ disconnect() {}
+ unobserve() {}
+ takeRecords() {
+ return [];
+ }
+ root = null;
+ rootMargin = "";
+ thresholds = [];
+}
+
+const NOW = new Date("2026-04-23T10:00:00.000Z");
+
+const userMessage: Message = {
+ id: "user-1",
+ role: "user",
+ parts: [{ type: "text", text: "go" }],
+};
+
+const runningTool: Message = {
+ id: "assistant-1",
+ role: "assistant",
+ parts: [
+ {
+ type: "tool-run_block",
+ toolCallId: "call-1",
+ state: "input-available",
+ input: {},
+ },
+ ] as Message["parts"],
+};
+
+const answer: Message = {
+ id: "assistant-1",
+ role: "assistant",
+ parts: [{ type: "text", text: "Done" }],
+};
+
+const baseProps = {
+ messages: [userMessage, runningTool],
+ status: "streaming",
+ error: undefined,
+ isLoading: false,
+ sessionID: "sess-1",
+ queuedMessages: [] as string[],
+ hasMoreMessages: false,
+ isLoadingMore: false,
+ onLoadMore: vi.fn(),
+ onRetry: vi.fn(),
+} satisfies ComponentProps<typeof ChatMessagesContainer>;
+
+function advanceSeconds(seconds: number) {
+ for (let i = 0; i < seconds; i++) {
+ act(() => {
+ vi.advanceTimersByTime(1_000);
+ });
+ }
+}
+
+describe("ChatMessagesContainer — thinking clock", () => {
+ beforeEach(() => {
+ vi.useFakeTimers({ shouldAdvanceTime: false });
+ vi.setSystemTime(NOW);
+ vi.stubGlobal("IntersectionObserver", MockIntersectionObserver);
+ chainRenders.count = 0;
+ });
+ afterEach(() => {
+ cleanup();
+ vi.useRealTimers();
+ vi.unstubAllGlobals();
+ });
+
+ it("does not re-render the transcript every second while a tool runs", () => {
+ render(<ChatMessagesContainer {...baseProps} />);
+ act(() => {
+ vi.advanceTimersByTime(100);
+ });
+ const settled = chainRenders.count;
+ expect(settled).toBeGreaterThan(0);
+
+ advanceSeconds(10);
+
+ expect(chainRenders.count).toBe(settled);
+ });
+
+ it("shows the elapsed time in the thinking indicator after 20 s, without re-rendering the transcript", () => {
+ const startedAt = new Date(NOW.getTime() - 15_000).toISOString();
+ render(
+ <ChatMessagesContainer
+ {...baseProps}
+ messages={[userMessage, { ...runningTool, parts: [] }]}
+ status="submitted"
+ activeStreamStartedAt={startedAt}
+ />,
+ );
+ act(() => {
+ vi.advanceTimersByTime(100);
+ });
+ const settled = chainRenders.count;
+ expect(screen.getByRole("status").textContent).toBe("Thinking…");
+
+ advanceSeconds(4);
+ expect(screen.getByRole("status").textContent).toBe("Thinking…");
+
+ advanceSeconds(1);
+ expect(screen.getByRole("status").textContent).toBe("Thinking…20s");
+
+ advanceSeconds(3);
+ expect(screen.getByRole("status").textContent).toBe("Thinking…23s");
+ expect(chainRenders.count).toBe(settled);
+ });
+
+ it("hands the finished turn's elapsed time to its stats bar", () => {
+ const { rerender } = render(<ChatMessagesContainer {...baseProps} />);
+ advanceSeconds(7);
+
+ rerender(
+ <ChatMessagesContainer
+ {...baseProps}
+ messages={[userMessage, answer]}
+ status="ready"
+ />,
+ );
+ expect(screen.getByTestId("turn-stats-bar").textContent).toBe("7");
+
+ advanceSeconds(5);
+ expect(screen.getByTestId("turn-stats-bar").textContent).toBe("7");
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/ThinkingIndicator.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/ThinkingIndicator.tsx
index b5ee32738a..8675ddd319 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/ThinkingIndicator.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/ThinkingIndicator.tsx
@@ -1,4 +1,6 @@
+import { useNowSecond } from "@/hooks/useNowSecond";
import { formatElapsed } from "../../JobStatsBar/formatElapsed";
+import { getElapsedSeconds } from "../../JobStatsBar/useElapsedTimer";
import { PixelGridLoader } from "../../PixelGridLoader/PixelGridLoader";
import { SwapText } from "../../ToolChain/SwapText";
@@ -7,7 +9,14 @@ const SHOW_TIME_AFTER_SECONDS = 20;
interface Props {
active: boolean;
- elapsedSeconds: number;
+ /**
+ * Epoch ms the wait started. When set, the indicator runs its own clock
+ * (the shared `useNowSecond` ticker, only while `active`), so the parent
+ * does not re-render every second.
+ */
+ startedAtMs?: number | null;
+ /** Elapsed seconds from a parent that already owns a clock. */
+ elapsedSeconds?: number;
/**
* Plain-language label for a wait the UI itself narrates (e.g. "Uploading
* 2 files…"). Defaults to "Thinking…". The backend's own `data-status`
@@ -19,10 +28,16 @@ interface Props {
export function ThinkingIndicator({
active,
- elapsedSeconds,
+ startedAtMs,
+ elapsedSeconds = 0,
statusMessage,
}: Props) {
- const showTime = active && elapsedSeconds >= SHOW_TIME_AFTER_SECONDS;
+ const hasClock = startedAtMs !== null && startedAtMs !== undefined;
+ const nowMs = useNowSecond(active && hasClock);
+ const seconds = hasClock
+ ? getElapsedSeconds(startedAtMs, nowMs)
+ : elapsedSeconds;
+ const showTime = active && seconds >= SHOW_TIME_AFTER_SECONDS;
return (
<span
@@ -38,7 +53,7 @@ export function ThinkingIndicator({
/>
{showTime && (
<span className="font-mono text-xs tabular-nums text-zinc-400">
- {formatElapsed(elapsedSeconds)}
+ {formatElapsed(seconds)}
</span>
)}
</span>
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/__tests__/ThinkingIndicator.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/__tests__/ThinkingIndicator.test.tsx
new file mode 100644
index 0000000000..f466322030
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/components/__tests__/ThinkingIndicator.test.tsx
@@ -0,0 +1,83 @@
+import { act, cleanup, render, screen } from "@/tests/integrations/test-utils";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { ThinkingIndicator } from "../ThinkingIndicator";
+
+vi.mock("../../../ToolChain/SwapText", () => ({
+ SwapText: ({ text }: { text: string }) => <span>{text}</span>,
+}));
+vi.mock("../../../PixelGridLoader/PixelGridLoader", () => ({
+ PixelGridLoader: () => null,
+}));
+
+const NOW = new Date("2026-04-23T10:00:00.000Z").getTime();
+
+function advanceSeconds(seconds: number) {
+ for (let i = 0; i < seconds; i++) {
+ act(() => {
+ vi.advanceTimersByTime(1_000);
+ });
+ }
+}
+
+function statusText() {
+ return screen.getByRole("status").textContent;
+}
+
+describe("ThinkingIndicator", () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ vi.setSystemTime(NOW);
+ });
+ afterEach(() => {
+ cleanup();
+ vi.useRealTimers();
+ });
+
+ it("shows the elapsed time from startedAtMs only after 20 s", () => {
+ render(<ThinkingIndicator active startedAtMs={NOW - 18_000} />);
+ expect(statusText()).toBe("Thinking…");
+
+ advanceSeconds(1);
+ expect(statusText()).toBe("Thinking…");
+
+ advanceSeconds(1);
+ expect(statusText()).toBe("Thinking…20s");
+
+ advanceSeconds(45);
+ expect(statusText()).toBe("Thinking…1m 5s");
+ });
+
+ it("runs no clock while inactive", () => {
+ render(<ThinkingIndicator active={false} startedAtMs={NOW - 60_000} />);
+ expect(statusText()).toBe("Thinking…");
+ expect(vi.getTimerCount()).toBe(0);
+ });
+
+ it("stops its clock when it unmounts", () => {
+ const { unmount } = render(<ThinkingIndicator active startedAtMs={NOW} />);
+ expect(vi.getTimerCount()).toBe(1);
+ unmount();
+ expect(vi.getTimerCount()).toBe(0);
+ });
+
+ it("still shows a parent-owned elapsedSeconds, with no clock of its own", () => {
+ const { rerender } = render(
+ <ThinkingIndicator
+ active
+ elapsedSeconds={19}
+ statusMessage="Uploading"
+ />,
+ );
+ expect(statusText()).toBe("Uploading");
+ expect(vi.getTimerCount()).toBe(0);
+
+ rerender(
+ <ThinkingIndicator
+ active
+ elapsedSeconds={21}
+ statusMessage="Uploading"
+ />,
+ );
+ expect(statusText()).toBe("Uploading21s");
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/JobStatsBar/__tests__/useElapsedTimer.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/JobStatsBar/__tests__/useElapsedTimer.test.tsx
new file mode 100644
index 0000000000..1d0648cd92
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/JobStatsBar/__tests__/useElapsedTimer.test.tsx
@@ -0,0 +1,140 @@
+import { act, cleanup, render, screen } from "@/tests/integrations/test-utils";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { useElapsedAnchor, useElapsedTimer } from "../useElapsedTimer";
+
+const NOW = new Date("2026-04-23T10:00:00.000Z").getTime();
+const renders: Record<string, number> = {};
+
+interface HarnessProps {
+ id: string;
+ isRunning: boolean;
+ anchor?: string | null;
+}
+
+function TimerHarness({ id, isRunning, anchor }: HarnessProps) {
+ const { elapsedSeconds } = useElapsedTimer(isRunning, anchor);
+ renders[id] = (renders[id] ?? 0) + 1;
+ return <span data-testid={id}>{elapsedSeconds}</span>;
+}
+
+function AnchorHarness({ id, isRunning, anchor }: HarnessProps) {
+ const { startedAtMs, frozenSeconds } = useElapsedAnchor(isRunning, anchor);
+ renders[id] = (renders[id] ?? 0) + 1;
+ return (
+ <span data-testid={id}>{`${startedAtMs ?? "none"}|${frozenSeconds}`}</span>
+ );
+}
+
+function text(id: string) {
+ return screen.getByTestId(id).textContent;
+}
+
+function advanceSeconds(seconds: number) {
+ for (let i = 0; i < seconds; i++) {
+ act(() => {
+ vi.advanceTimersByTime(1_000);
+ });
+ }
+}
+
+beforeEach(() => {
+ vi.useFakeTimers();
+ vi.setSystemTime(NOW);
+ Object.keys(renders).forEach((key) => delete renders[key]);
+});
+afterEach(() => {
+ cleanup();
+ vi.useRealTimers();
+});
+
+describe("useElapsedTimer", () => {
+ it("ticks every running timer from one shared clock, in the same tick", () => {
+ render(
+ <>
+ <TimerHarness id="a" isRunning />
+ <TimerHarness
+ id="b"
+ isRunning
+ anchor={new Date(NOW - 30_000).toISOString()}
+ />
+ </>,
+ );
+ expect(vi.getTimerCount()).toBe(1);
+
+ advanceSeconds(2);
+ expect(text("a")).toBe("2");
+ expect(text("b")).toBe("32");
+ expect(renders).toEqual({ a: 3, b: 3 });
+ });
+
+ it("releases the shared clock once no timer is running", () => {
+ const { rerender } = render(<TimerHarness id="a" isRunning />);
+ expect(vi.getTimerCount()).toBe(1);
+ rerender(<TimerHarness id="a" isRunning={false} />);
+ expect(vi.getTimerCount()).toBe(0);
+ });
+});
+
+describe("useElapsedAnchor", () => {
+ it("holds the run's start without re-rendering every second", () => {
+ render(<AnchorHarness id="a" isRunning />);
+ expect(text("a")).toBe(`${NOW}|0`);
+
+ advanceSeconds(5);
+ expect(renders.a).toBe(1);
+ expect(vi.getTimerCount()).toBe(0);
+ });
+
+ it("starts from the server anchor and re-syncs when a later one arrives", () => {
+ const { rerender } = render(
+ <AnchorHarness id="a" isRunning anchor={null} />,
+ );
+ expect(text("a")).toBe(`${NOW}|0`);
+
+ const anchor = new Date(NOW - 60_000).toISOString();
+ rerender(<AnchorHarness id="a" isRunning anchor={anchor} />);
+ expect(text("a")).toBe(`${NOW - 60_000}|0`);
+ });
+
+ it("freezes the elapsed reading when the run stops and keeps it until the next one", () => {
+ const { rerender } = render(<AnchorHarness id="a" isRunning />);
+ advanceSeconds(7);
+
+ rerender(<AnchorHarness id="a" isRunning={false} />);
+ expect(text("a")).toBe("none|7");
+
+ advanceSeconds(3);
+ rerender(<AnchorHarness id="a" isRunning />);
+ expect(text("a")).toBe(`${NOW + 10_000}|7`);
+
+ advanceSeconds(2);
+ rerender(<AnchorHarness id="a" isRunning={false} />);
+ expect(text("a")).toBe("none|2");
+ });
+
+ it("freezes the exact whole seconds of a run that did not start on a second", () => {
+ vi.setSystemTime(NOW + 700);
+ const { rerender } = render(<AnchorHarness id="a" isRunning />);
+
+ act(() => {
+ vi.advanceTimersByTime(5_100);
+ });
+ rerender(<AnchorHarness id="a" isRunning={false} />);
+ expect(text("a")).toBe("none|5");
+ });
+
+ it("keeps the run's start when the anchor drops out mid-run", () => {
+ const anchor = new Date(NOW - 60_000).toISOString();
+ const { rerender } = render(
+ <AnchorHarness id="a" isRunning anchor={anchor} />,
+ );
+ expect(text("a")).toBe(`${NOW - 60_000}|0`);
+
+ advanceSeconds(5);
+ rerender(<AnchorHarness id="a" isRunning anchor={null} />);
+ expect(text("a")).toBe(`${NOW - 60_000}|0`);
+
+ rerender(<AnchorHarness id="a" isRunning={false} anchor={null} />);
+ expect(text("a")).toBe("none|65");
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/JobStatsBar/useElapsedTimer.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/JobStatsBar/useElapsedTimer.ts
index 8e025631af..7588ce9fa0 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/JobStatsBar/useElapsedTimer.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/JobStatsBar/useElapsedTimer.ts
@@ -1,7 +1,29 @@
-import { useEffect, useRef, useState } from "react";
+import { useNowSecond } from "@/hooks/useNowSecond";
+import { useState } from "react";
+
+interface Run {
+ isRunning: boolean;
+ anchorIso: string | null | undefined;
+ startedAtMs: number | null;
+ frozenSeconds: number;
+}
+
+function resolveStartMs(
+ anchorIso: string | null | undefined,
+ fallbackMs: number,
+) {
+ const anchorMs = anchorIso ? Date.parse(anchorIso) : NaN;
+ return Number.isFinite(anchorMs) ? anchorMs : fallbackMs;
+}
+
+export function getElapsedSeconds(startedAtMs: number, nowMs: number) {
+ return Math.max(0, Math.floor((nowMs - startedAtMs) / 1000));
+}
/**
- * Ticks once per second while `isRunning` is true.
+ * When the current run started, without ticking. `startedAtMs` is set while
+ * `isRunning` is true and null otherwise; `frozenSeconds` holds the elapsed
+ * reading at the moment the last run stopped (0 before any run).
*
* Pass `anchorIso` (a server-issued ISO timestamp, e.g. the active stream's
* `started_at` or the last user/tool message's `createdAt`) to count from
@@ -11,36 +33,62 @@ import { useEffect, useRef, useState } from "react";
* the turn's last recorded activity, not the moment the current browser
* tab mounted.
*/
-export function useElapsedTimer(isRunning: boolean, anchorIso?: string | null) {
- const [elapsedSeconds, setElapsedSeconds] = useState(0);
- const startTimeRef = useRef<number | null>(null);
- const intervalRef = useRef<ReturnType<typeof setInterval>>();
+export function useElapsedAnchor(
+ isRunning: boolean,
+ anchorIso?: string | null,
+) {
+ const [run, setRun] = useState<Run>(() => ({
+ isRunning,
+ anchorIso,
+ startedAtMs: isRunning ? resolveStartMs(anchorIso, Date.now()) : null,
+ frozenSeconds: 0,
+ }));
- useEffect(() => {
- if (isRunning) {
- // Re-sync on every re-run so a late-arriving anchorIso (e.g. session
- // data loads after the timer started on page refresh) updates the
- // start time instead of being ignored.
- const anchorMs = anchorIso ? Date.parse(anchorIso) : NaN;
- startTimeRef.current = Number.isFinite(anchorMs) ? anchorMs : Date.now();
- setElapsedSeconds(
- Math.max(0, Math.floor((Date.now() - startTimeRef.current) / 1000)),
- );
+ // Re-sync whenever the run starts or stops, and whenever a late-arriving
+ // anchorIso (e.g. session data loads after the timer started on page
+ // refresh) replaces the one the run started from. An anchor that drops
+ // out mid-run (a session refetch clears it) keeps the start it had.
+ let current = run;
+ if (
+ run.isRunning !== isRunning ||
+ (isRunning && run.anchorIso !== anchorIso)
+ ) {
+ current = {
+ isRunning,
+ anchorIso,
+ startedAtMs: isRunning
+ ? resolveStartMs(
+ anchorIso,
+ run.isRunning && run.startedAtMs !== null
+ ? run.startedAtMs
+ : Date.now(),
+ )
+ : null,
+ frozenSeconds:
+ !isRunning && run.startedAtMs !== null
+ ? getElapsedSeconds(run.startedAtMs, Date.now())
+ : run.frozenSeconds,
+ };
+ setRun(current);
+ }
- intervalRef.current = setInterval(() => {
- if (startTimeRef.current !== null) {
- setElapsedSeconds(
- Math.max(0, Math.floor((Date.now() - startTimeRef.current) / 1000)),
- );
- }
- }, 1000);
-
- return () => clearInterval(intervalRef.current);
- }
-
- clearInterval(intervalRef.current);
- startTimeRef.current = null;
- }, [isRunning, anchorIso]);
+ return {
+ startedAtMs: current.startedAtMs,
+ frozenSeconds: current.frozenSeconds,
+ };
+}
+/**
+ * Elapsed whole seconds of the current run, ticking once per second on the
+ * shared wall-clock second while `isRunning` is true and holding the last
+ * reading once it stops. See `useElapsedAnchor` for `anchorIso`.
+ */
+export function useElapsedTimer(isRunning: boolean, anchorIso?: string | null) {
+ const { startedAtMs, frozenSeconds } = useElapsedAnchor(isRunning, anchorIso);
+ const nowMs = useNowSecond(isRunning);
+ const elapsedSeconds =
+ startedAtMs === null
+ ? frozenSeconds
+ : getElapsedSeconds(startedAtMs, nowMs);
return { elapsedSeconds };
}
diff --git a/autogpt_platform/frontend/src/hooks/__tests__/useNowSecond.test.tsx b/autogpt_platform/frontend/src/hooks/__tests__/useNowSecond.test.tsx
new file mode 100644
index 0000000000..516d36229c
--- /dev/null
+++ b/autogpt_platform/frontend/src/hooks/__tests__/useNowSecond.test.tsx
@@ -0,0 +1,152 @@
+import { act, cleanup, render, screen } from "@testing-library/react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { useNowMinute } from "../useNowMinute";
+import { useNowSecond } from "../useNowSecond";
+
+const renders: Record<string, number> = {};
+
+function SecondLabel({ id, enabled }: { id: string; enabled?: boolean }) {
+ const now = useNowSecond(enabled);
+ renders[id] = (renders[id] ?? 0) + 1;
+ return <span data-testid={id}>{new Date(now).toISOString()}</span>;
+}
+
+function MinuteLabel({ id }: { id: string }) {
+ const now = useNowMinute();
+ renders[id] = (renders[id] ?? 0) + 1;
+ return <span data-testid={id}>{new Date(now).toISOString()}</span>;
+}
+
+function label(id: string) {
+ return screen.getByTestId(id).textContent;
+}
+
+describe("useNowSecond", () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ vi.setSystemTime(new Date("2026-04-23T10:00:00.400Z"));
+ Object.keys(renders).forEach((key) => delete renders[key]);
+ });
+ afterEach(() => {
+ cleanup();
+ vi.useRealTimers();
+ });
+
+ it("gives every subscriber the same second, in the same tick", () => {
+ render(
+ <>
+ <SecondLabel id="a" />
+ <SecondLabel id="b" />
+ </>,
+ );
+ expect(label("a")).toBe("2026-04-23T10:00:00.000Z");
+ expect(label("b")).toBe("2026-04-23T10:00:00.000Z");
+ expect(vi.getTimerCount()).toBe(1);
+
+ act(() => {
+ vi.advanceTimersByTime(600);
+ });
+ expect(label("a")).toBe("2026-04-23T10:00:01.000Z");
+ expect(label("b")).toBe("2026-04-23T10:00:01.000Z");
+ expect(renders).toEqual({ a: 2, b: 2 });
+ });
+
+ it("ticks on the wall-clock second boundary, once a second", () => {
+ render(<SecondLabel id="a" />);
+ act(() => {
+ vi.advanceTimersByTime(599);
+ });
+ expect(label("a")).toBe("2026-04-23T10:00:00.000Z");
+ act(() => {
+ vi.advanceTimersByTime(1);
+ });
+ expect(label("a")).toBe("2026-04-23T10:00:01.000Z");
+ for (let i = 0; i < 3; i++) {
+ act(() => {
+ vi.advanceTimersByTime(1_000);
+ });
+ }
+ expect(label("a")).toBe("2026-04-23T10:00:04.000Z");
+ expect(renders.a).toBe(5);
+ });
+
+ it("stops the timer when the last subscriber unmounts", () => {
+ const first = render(<SecondLabel id="a" />);
+ const second = render(<SecondLabel id="b" />);
+ expect(vi.getTimerCount()).toBe(1);
+
+ first.unmount();
+ expect(vi.getTimerCount()).toBe(1);
+ act(() => {
+ vi.advanceTimersByTime(1_000);
+ });
+ expect(label("b")).toBe("2026-04-23T10:00:01.000Z");
+
+ second.unmount();
+ expect(vi.getTimerCount()).toBe(0);
+ });
+
+ it("restarts from the current second for a new subscriber", () => {
+ const first = render(<SecondLabel id="a" />);
+ first.unmount();
+ act(() => {
+ vi.advanceTimersByTime(5_000);
+ });
+ render(<SecondLabel id="b" />);
+ expect(label("b")).toBe("2026-04-23T10:00:05.000Z");
+ expect(vi.getTimerCount()).toBe(1);
+ });
+
+ it("neither subscribes nor re-renders while disabled", () => {
+ const { rerender } = render(<SecondLabel id="a" enabled={false} />);
+ expect(vi.getTimerCount()).toBe(0);
+ act(() => {
+ vi.advanceTimersByTime(5_000);
+ });
+ expect(renders.a).toBe(1);
+
+ rerender(<SecondLabel id="a" enabled />);
+ expect(label("a")).toBe("2026-04-23T10:00:05.000Z");
+ expect(vi.getTimerCount()).toBe(1);
+
+ rerender(<SecondLabel id="a" enabled={false} />);
+ expect(vi.getTimerCount()).toBe(0);
+ });
+});
+
+describe("useNowMinute", () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ vi.setSystemTime(new Date("2026-04-23T10:00:30.000Z"));
+ Object.keys(renders).forEach((key) => delete renders[key]);
+ });
+ afterEach(() => {
+ cleanup();
+ vi.useRealTimers();
+ });
+
+ it("ticks once a minute on the wall-clock minute, shared by every subscriber", () => {
+ const { unmount } = render(
+ <>
+ <MinuteLabel id="a" />
+ <MinuteLabel id="b" />
+ </>,
+ );
+ expect(label("a")).toBe("2026-04-23T10:00:00.000Z");
+ expect(vi.getTimerCount()).toBe(1);
+
+ act(() => {
+ vi.advanceTimersByTime(29_999);
+ });
+ expect(renders).toEqual({ a: 1, b: 1 });
+ act(() => {
+ vi.advanceTimersByTime(1);
+ });
+ expect(label("a")).toBe("2026-04-23T10:01:00.000Z");
+ expect(label("b")).toBe("2026-04-23T10:01:00.000Z");
+ expect(renders).toEqual({ a: 2, b: 2 });
+
+ unmount();
+ expect(vi.getTimerCount()).toBe(0);
+ });
+});
diff --git a/autogpt_platform/frontend/src/hooks/useNowMinute.ts b/autogpt_platform/frontend/src/hooks/useNowMinute.ts
new file mode 100644
index 0000000000..f1ad1b9c6a
--- /dev/null
+++ b/autogpt_platform/frontend/src/hooks/useNowMinute.ts
@@ -0,0 +1,11 @@
+import { createWallClock, useWallClock } from "./useNowSecond";
+
+const minuteClock = createWallClock(60_000);
+
+/**
+ * Epoch milliseconds of the current wall-clock minute. Re-renders once a
+ * minute, in step with every other `useNowMinute` caller, while `enabled`.
+ */
+export function useNowMinute(enabled = true) {
+ return useWallClock(minuteClock, enabled);
+}
diff --git a/autogpt_platform/frontend/src/hooks/useNowSecond.ts b/autogpt_platform/frontend/src/hooks/useNowSecond.ts
new file mode 100644
index 0000000000..7ecac5469c
--- /dev/null
+++ b/autogpt_platform/frontend/src/hooks/useNowSecond.ts
@@ -0,0 +1,76 @@
+import { useSyncExternalStore } from "react";
+
+interface WallClock {
+ subscribe(listener: () => void): () => void;
+ getSnapshot(): number;
+}
+
+/**
+ * One shared clock that ticks on the wall-clock `periodMs` boundary. A single
+ * `setTimeout` serves every subscriber, so all of them see the same value in
+ * the same tick. The timer starts with the first subscriber and stops with
+ * the last. Values are epoch milliseconds floored to the period, so they only
+ * change once per tick.
+ */
+export function createWallClock(periodMs: number): WallClock {
+ const listeners = new Set<() => void>();
+ let timer: ReturnType<typeof setTimeout> | null = null;
+ let current = 0;
+
+ function floorNow() {
+ return Math.floor(Date.now() / periodMs) * periodMs;
+ }
+
+ function schedule() {
+ timer = setTimeout(tick, periodMs - (Date.now() % periodMs));
+ }
+
+ function tick() {
+ schedule();
+ const next = floorNow();
+ if (next === current) return;
+ current = next;
+ listeners.forEach((listener) => listener());
+ }
+
+ return {
+ subscribe(listener) {
+ listeners.add(listener);
+ if (timer === null) {
+ current = floorNow();
+ schedule();
+ }
+ return () => {
+ listeners.delete(listener);
+ if (listeners.size > 0 || timer === null) return;
+ clearTimeout(timer);
+ timer = null;
+ };
+ },
+ getSnapshot() {
+ return timer === null ? floorNow() : current;
+ },
+ };
+}
+
+function subscribeNever() {
+ return () => {};
+}
+
+export function useWallClock(clock: WallClock, enabled: boolean) {
+ return useSyncExternalStore(
+ enabled ? clock.subscribe : subscribeNever,
+ clock.getSnapshot,
+ clock.getSnapshot,
+ );
+}
+
+const secondClock = createWallClock(1_000);
+
+/**
+ * Epoch milliseconds of the current wall-clock second. Re-renders once a
+ * second, in step with every other `useNowSecond` caller, while `enabled`.
+ */
+export function useNowSecond(enabled = true) {
+ return useWallClock(secondClock, enabled);
+}
diff --git a/docs/engineering/frontend-perf-baseline.md b/docs/engineering/frontend-perf-baseline.md
index 57331664a3..2d88940973 100644
--- a/docs/engineering/frontend-perf-baseline.md
+++ b/docs/engineering/frontend-perf-baseline.md
@@ -533,3 +533,51 @@ Added after the table above was saved: `dev` at `a1578ad9a`, same machine type,
| `PopperAnchor props:children` | 19,676 |
| `Popper props:children` | 19,667 |
| `PopperProvider props:children` | 19,667 |
+
+## copilot-tool-wait · baseline — median of 3 runs
+
+Added with SECRT-2995 and measured on `dev` at `a1578ad9a`, before that change. Each of the 20 long tasks is one tick of the thinking timer, which re-rendered the whole transcript once a second while the tool ran.
+
+| metric | median | range | spread |
+| --- | --- | --- | --- |
+| commits | 45 | 45 – 49 | 8.9% |
+| total renders | 183,109 | 183,109 – 183,145 | 0.0% |
+| renders per commit | 4,069.1 | 3,737.7 – 4,069.1 | 8.1% |
+| max renders in one commit | 9,134 | 9,134 – 9,134 | 0.0% |
+| script time (ms) | 5,475 | 5,448 – 5,719 | 4.9% |
+| task time (ms) | 7,248 | 7,058 – 7,546 | 6.7% |
+| layout time (ms) | 0 | 0 – 0 | 0.0% |
+| style recalc time (ms) | 190 | 168 – 196 | 14.2% |
+| long tasks (≥ 50 ms) | 20 | 20 – 20 | 0.0% |
+| long task total (ms) | 5,439 | 5,412 – 5,693 | 5.2% |
+| heap used after GC (MB) | 91.8 | 89.2 – 96.6 | 8.0% |
+
+**Top components (median renders)**
+
+| name | renders |
+| --- | --- |
+| `Tooltip` | 13,532 |
+| `TooltipContent` | 13,532 |
+| `HugeiconsIcon` | 7,754 |
+| `Icon` | 7,754 |
+| `TooltipProvider` | 6,786 |
+| `Presence` | 6,780 |
+| `Popper` | 6,776 |
+| `PopperAnchor` | 6,776 |
+| `PopperProvider` | 6,776 |
+| `Primitive.button` | 6,776 |
+
+**Top render causes (median renders)**
+
+| name | renders |
+| --- | --- |
+| `Tooltip props:children` | 13,532 |
+| `HugeiconsIcon parent-same-props<-Icon` | 7,754 |
+| `TooltipProvider props:children` | 6,786 |
+| `Presence props:children` | 6,780 |
+| `Primitive.div props:children` | 6,776 |
+| `Primitive.div.Slot props:children` | 6,776 |
+| `Primitive.div.SlotClone props:children` | 6,776 |
+| `Popper props:children` | 6,770 |
+| `PopperAnchor props:children` | 6,770 |
+| `PopperProvider props:children` | 6,770 |
diff --git a/docs/engineering/frontend-perf-measurement.md b/docs/engineering/frontend-perf-measurement.md
index 0a6a00ff5c..f18c890531 100644
--- a/docs/engineering/frontend-perf-measurement.md
+++ b/docs/engineering/frontend-perf-measurement.md
@@ -72,6 +72,17 @@ If `window.__renderCounter` is missing, the script stops and tells you to restar
Leave out `--scenario` to compare every scenario that has runs under both labels.
+When the change adds the scenario it is measured with (as `copilot-tool-wait` was), the commit before it has no such scenario. Stay on the branch, so `scripts/perf/` keeps the scenario and its fixture, and swap only the app files back to the base for the `before` runs:
+
+```bash
+git checkout origin/dev -- <app files the change touches> # e.g. the files under src/
+pnpm perf --scenario copilot-tool-wait --label before
+git checkout HEAD -- <the same files>
+pnpm perf --scenario copilot-tool-wait --label after
+```
+
+The dev server hot-reloads each swap, and the default warm-up run absorbs the recompile. Swap only files under `src/`, never `scripts/perf/`.
+
The output has three tables (metrics, top components and top render causes), each with `before`, `after` and `Δ` columns, followed by the raw runs in a collapsed block. Every value is the median of the runs, not the average.
Tips for numbers you can trust:
@@ -112,6 +123,7 @@ Names come from the component function. Third-party code bundled already minifie
| `builder-connect-edge` | Open the same 50-node workflow with no run (nothing polls) | Drag one new edge from StoreValue node 4's `output` to Calculator node 5's `a` input, 20 pointer moves over 0.6 s | 2 s after the drop |
| `library-running-events` | Open the same library at `/library?sort=updatedAt`, with the websocket mocked | Push a `graph_execution_event` for one of the 20 runs every 250 ms, 80 in all; print the `subscribe_graph_executions` frames and `GET /executions` requests seen | 20 s of events + 2 s |
| `builder-run-events` | Open the same 50-node workflow with its RUNNING run; the harness answers the websocket subscribe for that run itself | 40 node execution events over the websocket, one every 50 ms: the 10 unfinished nodes go RUNNING then COMPLETED, each event sent twice. The execution GET returns what has been sent so far, as the backend would | 2 s after the last event |
+| `copilot-tool-wait` | Open the 200-message chat, send "go", and wait until the reply's one tool call shows "Running Perf lookup…". The reply then sends only `: heartbeat` comments, so the turn stays on that tool | Nothing | 20 s |
Each scenario's `readyWhen` field says exactly what setup waits for before the window opens. Most wait for the page's own content, then for network idle (at most 15 s, because some pages poll), then one more second.