From 224d3d7e17b53c605de40190d9f7ce4d5a5eb4ae Mon Sep 17 00:00:00 2001 From: paseo-bot Date: Wed, 23 Sep 2026 13:06:32 +0200 Subject: [PATCH] test(server): synchronize the steer regression test on timeline state Replace the fixed sleeps with polling assertions, and run the coalescer with a zero window so every chunk flushes on its leading edge. --- .../src/server/agent/agent-manager.test.ts | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/packages/server/src/server/agent/agent-manager.test.ts b/packages/server/src/server/agent/agent-manager.test.ts index 89ae20a769..09698dc5f3 100644 --- a/packages/server/src/server/agent/agent-manager.test.ts +++ b/packages/server/src/server/agent/agent-manager.test.ts @@ -908,7 +908,9 @@ test("keeps one assistant message whole when a steer lands between its chunks", } })(), }, - agentStreamCoalesceWindowMs: 1, + // Zero window: every streamed chunk flushes on the coalescer's leading edge, + // so the timeline reaches its next state without waiting on a timer. + agentStreamCoalesceWindowMs: 0, logger, }); let agentId: string | null = null; @@ -924,13 +926,25 @@ test("keeps one assistant message whole when a steer lands between its chunks", })(); await manager.waitForAgentRunStart(agent.id); + const conversation = () => + manager + .fetchTimeline(agent.id, { limit: 0 }) + .rows.filter( + (row) => row.item.type === "assistant_message" || row.item.type === "user_message", + ) + .map((row) => row.item); + session.pushEvent({ type: "timeline", provider: "codex", turnId: "active-turn-1", item: { type: "assistant_message", text: "with the uncommit", messageId: "msg-1" }, }); - await new Promise((resolve) => setTimeout(resolve, 20)); + await expect + .poll(conversation) + .toMatchObject([ + { type: "assistant_message", text: "with the uncommit", messageId: "msg-1" }, + ]); await expect( manager.steerAgentRun(agent.id, "keep going", { clientMessageId: "keep-going-client" }), ).resolves.toEqual({ status: "accepted" }); @@ -940,15 +954,8 @@ test("keeps one assistant message whole when a steer lands between its chunks", turnId: "active-turn-1", item: { type: "assistant_message", text: "ted changes.", messageId: "msg-1" }, }); - await new Promise((resolve) => setTimeout(resolve, 20)); - const rows = manager - .fetchTimeline(agent.id, { limit: 0 }) - .rows.filter( - (row) => row.item.type === "assistant_message" || row.item.type === "user_message", - ) - .map((row) => row.item); - expect(rows).toMatchObject([ + await expect.poll(conversation).toMatchObject([ { type: "assistant_message", text: "with the uncommitted changes.", messageId: "msg-1" }, { type: "user_message", text: "keep going" }, ]);