Repository navigation
Description
Context
Under heavy local CPU load, packages/ui-react/tests/parallel-sessions-runtime.test.ts failed twice in 30 sequential runs of the case "mounted parallel sessions > 390 phone, light, coarse pointer, reduced motion: A and B stream side by side; trackers follow success, failure and a queued follow-up, and clear only once seen". The runs used real Chromium, --rerun-each 30, and eight busy-loop processes on a 16-core host with a sampled one-minute load median of 28.4 (16.8–47.9). Both failures hit the same assertion:
expect(await probe(a.page, (p) => p.views().find((v) => v.sessionId === p.activeSessionId())?.cleared), "selecting A cleared nothing").toBe(false);
Expected: false
Received: true
That is line 678 at the head of the #3377 fix. The test has just opened A again through its tracker while A is still running (openTracker, lines 672-678), waited 300 ms, and expects the selection not to count A's running turn as seen. Under load, A already reads as cleared.
This is a separate failure from #3377, which was the later "Scroll to latest" step for session C. The #3377 change touches only scrollUp, and the first scrollUp call comes after line 678.
Scope
- Find out whether the seen observer (
observeTrackerSeen,packages/ui-react/src/hooks/use-tracker-seen.ts:18-44) can record proof for a session that was only selected while its turn is still running. That would be a product race on the opening path (openTrackerinpackages/ui-react/src/components/chat/chat-page.tsx). The other possibility is that the test reads the state at a moment it does not control. - Fix the real cause.
Out of scope
- Lengthening deadlines, retrying the case, or weakening or removing the assertion.
- The "Scroll to latest" step (ui-react: parallel-sessions runtime "scrolled-up session clears after Scroll to latest" times out intermittently on 390 phone #3377) and the other cases in this file.
Acceptance criteria
- The cause is shown with evidence: a trace, or a failing-first reproduction under load or with an injected delay.
- The fix keeps every assertion and deadline. The case fails with the fix reverted under the same condition, and passes with it in place.
- 30 sequential passes of the 390-phone case under load, recorded in the PR.
Verification
bun run test packages/ui-react/tests/parallel-sessions-runtime.test.ts -t '390 phone.*A and B stream' --rerun-each 30 under CPU load, plus the hosted unit shard that carries the file.
Contract impact
None.
Found while working #3377.
Readiness review: cause (2026-11-03)
This is a product race in the seen observer, not a test race. Selecting a session whose turn is still running can record proof for that turn.
- While A streams in view, its live frames stamp the turn they name onto the answer (
turnId, throughstartAssistantMessageandstampTurn). That id is meant for correlation only. History links a turn only once it has ended (ui-server: establish authorized latest-turn and pending-approval recovery for trackers #964), so when A is reopened, the replay replaces the stampedturnIdwithstreamTurnId. observeTrackerSeen(packages/ui-react/src/hooks/use-tracker-seen.ts:18-44) compares the last message'sturnIdwith the latest turn. It does not check whether that message is still being written. It runs on the first committed render after A is selected. If the replay has not arrived by then, the stale frame turn matches. A's transcript is already at the bottom, so the observer recordsseen: { basis: "proof" }for a turn that is stillrunning. The record stays cleared after the replay.
Evidence (real Chromium 1243): a trace of every seen write shows the observer writing proof from observeTrackerSeen while latest.state === "running", with the last message { isStreaming: true, turnId: <latest> } and reading: false. On a passing run, the same probe at line 678 shows the message after the replay as { isStreaming: true, streamTurnId: <latest> } with no turnId. Delaying the host's getHistory by 1.5 s while A is reopened makes the unmodified case fail at "selecting A cleared nothing" every time.
Approach: the observer refuses a last message that is still being written. That matches what the observer already sees once the replay has arrived, so only the race window closes. A turn that ends while the reader is at its end is still seen, from the ended message.
2026-11-03: added this readiness section with the cause and evidence, replaced "the cause is not known yet" with it, and changed the type to type: fix, since the fix is in product code. Scope, out-of-scope and acceptance criteria are unchanged.
Activity
schlessera commentedon Nov 3, 2026
Claiming (token
w3406-aca9). Branchfix/3406-parallel-sessions-select-cleared, stacked on #3409's branch because both change the same test file. Collision: #3409 (draft) editspackages/ui-react/tests/parallel-sessions-runtime.test.ts.schlessera commentedon Nov 3, 2026
Outcome: #3416 (stacked on #3409, head
b06d617bf), milestone 0.45.0.observeTrackerSeenmatch the turn that the live frames had stamped on the still-streaming answer. It recordedprooffor a turn that was still running.Remaining: hosted proof and merge of the stack (#3409, then #3416).
Closes #3406does not fire while #3416 targets #3409's branch, so whoever merges the stack closes this issue after checking the delivered tree.