Skip to content

ui-react: parallel-sessions runtime "selecting A cleared nothing" reads cleared under heavy load on 390 phone #3406

Closed

Description

@schlessera

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 (openTracker in packages/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

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, through startAssistantMessage and stampTurn). 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 stamped turnId with streamTurnId.
  • observeTrackerSeen (packages/ui-react/src/hooks/use-tracker-seen.ts:18-44) compares the last message's turnId with 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 records seen: { basis: "proof" } for a turn that is still running. 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

  1. added
    type: test
    area: ui-react
    priority: p2
    on Nov 3, 2026
  2. self-assigned this
    on Nov 3, 2026
  3. schlessera commented on Nov 3, 2026

    @schlessera
    OwnerAuthor

    Claiming (token w3406-aca9). Branch fix/3406-parallel-sessions-select-cleared, stacked on #3409's branch because both change the same test file. Collision: #3409 (draft) edits packages/ui-react/tests/parallel-sessions-runtime.test.ts.

  4. added
    type: fix
    agent-ready
    and removed
    type: test
    on Nov 3, 2026
  5. added this to the 0.45.0 milestone on Nov 3, 2026
  6. schlessera commented on Nov 3, 2026

    @schlessera
    OwnerAuthor

    Outcome: #3416 (stacked on #3409, head b06d617bf), milestone 0.45.0.

    • Cause: a product race in the seen observer. Selecting a running session before its history replay arrives let observeTrackerSeen match the turn that the live frames had stamped on the still-streaming answer. It recorded proof for a turn that was still running.
    • Fix: the observer refuses an answer that is still being written. Every assertion and deadline is unchanged.
    • Receipts in the PR: failing first with an injected 1.5 s history delay (fails at "selecting A cleared nothing"), fixed 3/3, unit mutation, and 30/30 loaded runs of the case at a load median of 29.4.
    • Found here and filed: ui-react: parallel-sessions runtime announces B's failure twice under load on 390 phone #3414 (B's failure announced twice under load).

    Remaining: hosted proof and merge of the stack (#3409, then #3416). Closes #3406 does not fire while #3416 targets #3409's branch, so whoever merges the stack closes this issue after checking the delivered tree.

  7. removed their assignment
    on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-reactpriority: p2type: fix

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions