Skip to content

Your lightweight open-source personal agent.

fix(webui): keep working timer consistent across first output

chengyongrudd3d2970a70b
diff --git a/webui/src/components/thread/ThreadMessages.tsx b/webui/src/components/thread/ThreadMessages.tsx
index 8c1667b2a..24211c5da 100644
--- a/webui/src/components/thread/ThreadMessages.tsx
+++ b/webui/src/components/thread/ThreadMessages.tsx
@@ -188,9 +188,8 @@ export function ThreadMessages({
hasBodyBelow={false}
retryStatus={retryStatus}
startedAtMs={
- runStartedAt != null
- ? runStartedAt * 1000
- : pendingActivity.startedAtMs
+ // Match the activity timeline's prompt-based clock across the first output.
+ pendingActivity.startedAtMs ?? (runStartedAt != null ? runStartedAt * 1000 : undefined)
}
/>
</div>
diff --git a/webui/src/tests/thread-messages.test.tsx b/webui/src/tests/thread-messages.test.tsx
index 0793769d1..d893e3d32 100644
--- a/webui/src/tests/thread-messages.test.tsx
+++ b/webui/src/tests/thread-messages.test.tsx
@@ -16,52 +16,89 @@ afterEach(() => {
});
describe("ThreadMessages", () => {
- it("shows optimistic turn progress in the thread before the first agent output", () => {
+ it.each([0, -13_000, -14_000, -15_000, 15_000])(
+ "keeps the optimistic timer through acknowledgement and output with %i ms server clock skew",
+ (clockSkewMs) => {
+ vi.useFakeTimers();
+ const now = new Date("2026-08-13T10:00:05.000Z").getTime();
+ vi.setSystemTime(now);
+ const prompt: UIMessage = {
+ id: "u-optimistic",
+ role: "user",
+ content: "check this",
+ turnId: "turn-optimistic",
+ turnPhase: "user",
+ deliveryStatus: "sending",
+ createdAt: now,
+ };
+ const { rerender } = render(
+ <ThreadMessages
+ messages={[prompt]}
+ isStreaming
+ activeTurnId="turn-optimistic"
+ />,
+ );
+
+ expect(screen.getByRole("status", { name: "Working for 0s" })).toBeInTheDocument();
+
+ rerender(
+ <ThreadMessages
+ messages={[{ ...prompt, deliveryStatus: "accepted" }]}
+ isStreaming
+ activeTurnId="turn-optimistic"
+ runStartedAt={(now + clockSkewMs) / 1000}
+ />,
+ );
+ expect(screen.getByRole("status", { name: "Working for 0s" })).toBeInTheDocument();
+ act(() => { vi.advanceTimersByTime(1000); });
+
+ rerender(
+ <ThreadMessages
+ messages={[
+ { ...prompt, deliveryStatus: "accepted" },
+ {
+ id: "t-optimistic",
+ role: "tool",
+ kind: "trace",
+ content: "web_search()",
+ traces: ["web_search()"],
+ turnId: "turn-optimistic",
+ turnPhase: "activity",
+ createdAt: now,
+ },
+ ]}
+ isStreaming
+ activeTurnId="turn-optimistic"
+ runStartedAt={(now + clockSkewMs) / 1000}
+ />,
+ );
+
+ expect(screen.getByRole("button", { name: "Working for 1s" })).toBeInTheDocument();
+ },
+ );
+
+ it("restores pending progress from the original prompt when guidance arrives", () => {
vi.useFakeTimers();
- const now = new Date("2026-08-13T10:00:05.000Z").getTime();
+ const now = 1_800_000_000_000;
vi.setSystemTime(now);
- const prompt: UIMessage = {
- id: "u-optimistic",
- role: "user",
- content: "check this",
- turnId: "turn-optimistic",
- turnPhase: "user",
- deliveryStatus: "sending",
- createdAt: now - 5_000,
- };
- const { rerender } = render(
- <ThreadMessages
- messages={[prompt]}
- isStreaming
- activeTurnId="turn-optimistic"
- runStartedAt={(now - 5_000) / 1000}
- />,
- );
-
- expect(screen.getByRole("status", { name: "Working for 5s" })).toBeInTheDocument();
-
- rerender(
+ render(
<ThreadMessages
messages={[
- { ...prompt, deliveryStatus: "accepted" },
{
- id: "t-optimistic",
- role: "tool",
- kind: "trace",
- content: "web_search()",
- traces: ["web_search()"],
- turnId: "turn-optimistic",
- turnPhase: "activity",
- createdAt: now,
+ id: "original", role: "user", content: "research this",
+ turnId: "original-turn", createdAt: now - 30_000,
+ },
+ {
+ id: "guidance", role: "user", content: "also check this",
+ turnId: "guidance-turn", createdAt: now,
},
]}
isStreaming
- activeTurnId="turn-optimistic"
- runStartedAt={(now - 5_000) / 1000}
+ activeTurnId="original-turn"
+ runStartedAt={(now - 43_000) / 1000}
/>,
);
-
- expect(screen.getByRole("button", { name: "Working for 5s" })).toBeInTheDocument();
+ expect(screen.getByRole("status", { name: "Working for 30s" })).toBeInTheDocument();
});
it("does not move a mounted tail answer into offscreen rendering on the next turn", () => {