From 5daf2adc60216831e0db569df799daff59a93789 Mon Sep 17 00:00:00 2001 From: qwen-code-dev-bot Date: Wed, 26 Aug 2026 20:54:49 +0000 Subject: [PATCH] fix(webui): make the delta-resume reconnect test deterministic (#10200) The 'preserves session and uses delta resume after a retriable SSE error' test asserted the resumed transcript after a fixed 20 ms wait counted from render, racing two asynchronous hops: the 1 ms reconnect and the 16 ms batched transcript dispatch. On loaded runners the reconnect plus dispatch flush lands after the wait ends, so the assertion saw only the pre-error chunk and the nightly macOS/Windows lanes failed (run 33007778391, Windows annotation at DaemonSessionProvider.test.tsx). Wait on a deferred the mock generator resolves once the resumed chunk is pulled by the consumer, then drain the batched dispatch with the same flushTranscriptDispatch() idiom the sibling reattach test uses. Assertions are unchanged. --- .../webui/src/daemon/session/DaemonSessionProvider.test.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/webui/src/daemon/session/DaemonSessionProvider.test.tsx b/packages/webui/src/daemon/session/DaemonSessionProvider.test.tsx index e0cd89f6b21..572c9b4e536 100644 --- a/packages/webui/src/daemon/session/DaemonSessionProvider.test.tsx +++ b/packages/webui/src/daemon/session/DaemonSessionProvider.test.tsx @@ -12140,6 +12140,7 @@ describe('DaemonSessionProvider', () => { }); it('preserves session and uses delta resume after a retriable SSE error', async () => { + const resumeDelivered = createDeferred(); let callCount = 0; const events = vi.fn(async function* retriableEvents( opts: { signal?: AbortSignal } = {}, @@ -12171,6 +12172,7 @@ describe('DaemonSessionProvider', () => { }, }, } satisfies DaemonEvent; + resumeDelivered.resolve(); await new Promise((resolve) => { if (opts.signal?.aborted) { resolve(); @@ -12196,8 +12198,9 @@ describe('DaemonSessionProvider', () => { maxReconnectDelayMs: 1, }); await act(async () => { - await wait(20); + await resumeDelivered.promise; await flushPromises(); + await flushTranscriptDispatch(); }); expect(sdkMocks.MockDaemonSessionClient.load).toHaveBeenCalledTimes(1);