Skip to content

ui-react: audit frame-scheduled focus and held-request teardown for the #3657 hang class #3665

Closed

Description

@schlessera

Context

#3657 (fixed by #3659, 501e93e21) was one instance of a bug class. The media card focused an element in a requestAnimationFrame callback scheduled before React committed that element. Under load the frame ran first, the ref was null, and focus stayed put. Separately, the layout test's teardown (stop) drained held fixture requests before releasing holdPlans, so a failing assertion turned into a 30 s timeout with no failure detail.

#3659 fixed both only in hygiene-media.tsx's stale-apply path and in hygiene-media.layout.tsx's teardown.

Other frame-scheduled focus calls on main 1619741f2:

  • packages/ui-react/src/components/activity/hygiene-media.tsx:197, :421-422 and :730
  • packages/ui-react/src/components/activity/activity-page.tsx:495
  • packages/ui-react/src/components/files/file-panel.tsx:193
  • packages/ui-react/src/components/files/untrusted-marks.tsx:411
  • packages/ui-react/src/components/settings/modules-tab.tsx:149 and :157
  • packages/ui-react/src/lib/local-work.ts:611

Other browser fixtures may also hold requests across teardown (packages/ui-react/tests/fixtures/hygiene-browser-server.ts owns holdPlans).

Scope

  • Classify each site above. Does its focus target mount in the same commit that schedules the frame? A site is only at risk when the target is rendered conditionally by a state change made in the same handler or effect.
  • Fix each at-risk site so focus happens after the commit that mounts the target, the way fix(ui-react): focus the stale-apply banner after it renders #3659 did.
  • Make teardown release held fixture requests before draining, for every browser fixture that can hold one. A failing assertion must report its own failure, not a timeout.

Out of scope

  • Raising test timeouts, retries, or skipping variants.
  • Sites where the target is always mounted before the frame is scheduled; record those as not at risk.

Acceptance criteria

  • Every site above is recorded in the PR as at risk or not at risk, with the reason.
  • Each at-risk site has a failing-first receipt under a forced frame-before-commit order, using the fix(ui-react): focus the stale-apply banner after it renders #3659 technique, and passes after the fix.
  • A deliberately failing held-plan assertion in a hygiene layout test reports its assertion within the test timeout, instead of hanging until HeadersTimeoutError. The mutation is recorded and restored.
  • The affected layout files pass in hosted layout jobs on the ready candidate.

Verification

bun run build && bun run test:layout
bun run check:pr --base origin/main

The pinned browser runs are offline and keyless.

Contract impact

None.

Activity

  1. added this to the 0.45.0 milestone on Nov 8, 2026
  2. added
    type: testCoverage, harness or proof work with no behaviour change.
    area: ui-reactReact chat/files/voice components, stores, WebSocket transport.
    priority: p2Wanted, not scheduled. Pulled in when a milestone has room.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 8, 2026
  3. self-assigned this
    on Nov 8, 2026
  4. schlessera commented on Nov 8, 2026

    @schlessera
    OwnerAuthor

    Claiming (token claim-3665-cc9d) on branch test/3665-focus-teardown-audit. Collision check on the cited files: closure-only overlaps with long-running draft PRs (#3054, #3056, #3059, #3069 …), no direct path collision with a live ready PR.

  5. schlessera commented on Nov 8, 2026

    @schlessera
    OwnerAuthor

    Delivered in #3671, squash a63e564 on main. Candidate proof: run 42469832210 at head 85fa6b6, base 1619741, all 17 selected jobs green, including layout (1) and layout (2).

    • One site was at risk: untrusted-marks.tsx:411, the clear's async onDone path. It now focuses after the commit, with a failing-first receipt under a forced late Scheduler task.
    • The other nine listed sites were not at risk. Reasons are in the PR's table: discrete or useSyncExternalStore updates commit in a microtask, targets are already mounted, or the site polls.
    • Teardown: every hygiene layout teardown now releases all fixture holds before stop. A held-plan failure reports its assertion in 627 ms, against a 30 s hook timeout before.

    Claim claim-3665-cc9d is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ui-reactReact chat/files/voice components, stores, WebSocket transport.priority: p2Wanted, not scheduled. Pulled in when a milestone has room.type: testCoverage, harness or proof work with no behaviour change.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions