fix(webui): keep working timer consistent across first output
This commit is contained in:
1 parent
26027e6d37
commit
dd3d2970a7
2 files changed
+75
-39
No files matched your search
@@ -188,9 +188,8 @@ export function ThreadMessages({
|
|||||||
hasBodyBelow={false}
|
hasBodyBelow={false}
|
||||||
retryStatus={retryStatus}
|
retryStatus={retryStatus}
|
||||||
startedAtMs={
|
startedAtMs={
|
||||||
runStartedAt != null
|
// Match the activity timeline's prompt-based clock across the first output.
|
||||||
? runStartedAt * 1000
|
pendingActivity.startedAtMs ?? (runStartedAt != null ? runStartedAt * 1000 : undefined)
|
||||||
: pendingActivity.startedAtMs
|
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -16,52 +16,89 @@ afterEach(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("ThreadMessages", () => {
|
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();
|
vi.useFakeTimers();
|
||||||
const now = new Date("2026-08-13T10:00:05.000Z").getTime();
|
const now = 1_800_000_000_000;
|
||||||
vi.setSystemTime(now);
|
vi.setSystemTime(now);
|
||||||
const prompt: UIMessage = {
|
render(
|
||||||
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(
|
|
||||||
<ThreadMessages
|
<ThreadMessages
|
||||||
messages={[
|
messages={[
|
||||||
{ ...prompt, deliveryStatus: "accepted" },
|
|
||||||
{
|
{
|
||||||
id: "t-optimistic",
|
id: "original", role: "user", content: "research this",
|
||||||
role: "tool",
|
turnId: "original-turn", createdAt: now - 30_000,
|
||||||
kind: "trace",
|
},
|
||||||
content: "web_search()",
|
{
|
||||||
traces: ["web_search()"],
|
id: "guidance", role: "user", content: "also check this",
|
||||||
turnId: "turn-optimistic",
|
turnId: "guidance-turn", createdAt: now,
|
||||||
turnPhase: "activity",
|
|
||||||
createdAt: now,
|
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
isStreaming
|
isStreaming
|
||||||
activeTurnId="turn-optimistic"
|
activeTurnId="original-turn"
|
||||||
runStartedAt={(now - 5_000) / 1000}
|
runStartedAt={(now - 43_000) / 1000}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
expect(screen.getByRole("status", { name: "Working for 30s" })).toBeInTheDocument();
|
||||||
expect(screen.getByRole("button", { name: "Working for 5s" })).toBeInTheDocument();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not move a mounted tail answer into offscreen rendering on the next turn", () => {
|
it("does not move a mounted tail answer into offscreen rendering on the next turn", () => {
|
||||||
|
|||||||
Reference in new issue
Block a user