Repository navigation
fix(ui-kit): end the ghost handoff on its fades' own end (#3425) - #4065
Conversation
The arrival handoff ended on a 600ms timer started at the commit, while the fades start on the first frame rendered after it. A late first frame (a loaded runner, a long task right after the commit) let the timer remove the ghost part-way through its fade; even unloaded it cut the fade a frame short. useArrival now takes the item's frame and waits for that frame's running ghost-in/ghost-out animations to finish. Where no fade runs (reduced motion's 0s, animation: none, no Web Animations) it keeps the HANDOFF_MS timer, and a fade that has not started FIRST_FRAME_MS after the commit (a document that renders no frames) ends the handoff then. The handoff clock now records whether the fade ended before removal, and the stories assert it. New Chromium controls stall the main thread right after the arrival commit; the 200ms-hold controls hold the incoming fade instead of the retired timer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ntrols (#3425) A CPU-starved browser renders a 200ms hold in as few as three frames, inside the three-frame allowance, so the negative controls stopped rejecting under load once the hold moved from the retired timer onto the incoming fade. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No uploads on this PR yet This PR changes UI files (
Tips for agentsLabel each shot so reviewers know what they're seeing. Labels apply to every file in a call, so run one uploads put after.png --pr 4065 --meta path=/settings --state after --caption "Saved settings toast"
uploads put chat.png --pr 4065 --app ios --screen "Chat" --state afterNo CLI? With the Uploads MCP, call This comment updates with each upload, so you don't need to post the images yourself. A shot or two in the PR description is still welcome. Check what's attached with Workspace admins can turn this comment off in Settings → GitHub · docs |
…or hygiene check (#3425) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This PR's squash |
Closes #3425
What changed
The loading ghost's handoff now ends when the item's own fades end, not on a 600 ms timer started at the arrival commit.
useArrival(loading, frame)takes the item's root element. After the commit it collects that frame's runningghost-in/ghost-outCSS animations and ends the handoff when they have all finished (a cancelled fade counts as finished). Where no fade runs, it keeps theHANDOFF_MStimer: reduced motion's 0s fades,animation: none, or a DOM without Web Animations (happy-dom). If no fade has startedFIRST_FRAME_MS(3 s) after the commit, the document is rendering no frames and the handoff ends then. All six consumers pass their root as the frame: ActionCard, FileRow, QueueItemRow, SearchResultCard, Placeholder and StreamingAnswer. Together they cover everybk-ghost-outsite, includingGhostedandGhostBand. The 600 ms fade, its easing and its keyframes are unchanged.Why this shape
useArrivalreturned a boolean and owned no element, so it could not see a fade. I passed the frame as a ref rather than threading anonAnimationEndcallback through everyGhosted/GhostBandslot. That is one ref per consumer instead of a prop at roughly twenty call sites, and it keepsarrivinga plain boolean. Waiting onAnimation.finishedrather than listening foranimationendhandles several slots and a cancelled layer in one place. The fade-or-timer decision comes fromgetAnimations()at commit, which already forces the style flush that creates the animations.The hook waits on
ghost-inas well asghost-out. Both start in the same frame with the same 600 ms length, so in production this changes nothing. It does mean the incoming text is never cut mid-fade either. It also gives the negative controls a way to hold the ghost past its fade without touching the component, now that the timer they used to stretch is gone.The fix is also a small change in the unloaded case. On main the ghost was always removed a frame or more before its fade ended, because the timer starts at the commit and the fade on the next frame. The existing harness comment said as much ("normally the ghost is removed before its fade ends at all").
Docs: a D53 addendum in
docs/decisions/design-kit/loading.md, the ghost-handoff section ofdocs/process/test-waits.md(itsuseArrivalcitation is updated), andtests/visual/README.md.Proof
Harness.
watchHandoff(stories/_handoff-clock.ts) now recordsfadeEnded: aghost-outanimationendarrived before removal.playHandoffandplayStreamingHandoffassert it for every frame, so every LoadingToReady story checks that the ghost reached opacity 0 before it went. The #3777 frame-clock mid-fade sample, the geometry checks and the #3417 three-frame allowance are unchanged.New control (
ghost-handoff.visual.tsxandstreaming-handoff.visual.tsx, both themes): a 300 ms synchronous long task right after the arrival commit, so the fades start late.Failing first. This branch's tests were run with only
packages/ui-kit/srcreverted toorigin/main. 13 of 15 handoff tests failed. The new controls failed at320px: the outgoing ghost's fade ended before its removal: expected false to be true, and the streaming control atthe outgoing ghost's fade ended before its removal. The unloaded input-orchestration and stall cases failed on the same assertion, because main cuts every fade short.Mutations (each restored, then the file re-run green):
setTimeout(end, HANDOFF_MS). All four long-task controls fail at…fade ended before its removal: expected false to be true.duration > 0filter, so the 0s fade under reduced motion is waited on.reduced motion: the handoff is instant, and ends after HANDOFF_MSfails atthe outgoing ghost is laid over the arriving content: expected null not to be null: the ghost is gone before HANDOFF_MS. An earlierplayState !== "finished"clause was redundant (Chrome reports a pending 0s animation as finished) and was removed, so this filter alone carries the claim.animation: nonetests fail: the ghost is never removed.a fade that never starts — no rendered frames — ends the handoff after FIRST_FRAME_MSfails atFRAMELESS_DOCUMENT_ENDS.Reduced motion and
animation: none(ghost-media.visual.tsx, emulated media in Chromium): each test arrives once more, asserts the ghost is still present, waits for its removal, and asserts that a 600 ms timer was registered and no 3 s first-frame wait was. Unit tests with stand-in fades cover the timing logic: no 600 ms timer while a fade runs, a fade that started late still runs, removal on the fade's end, the no-frame fallback, and a 0s fade taking the timer.Under CPU starvation (20 busy loops on 16 cores, load average about 30): five runs of the three visual files passed 23/23 four times. In run 3, the
720px held 200ms past its fadenegative control did not reject: under that load a 200 ms hold renders as few as three frames, inside the allowance. A focused comparison of that control alone gave 5 of 8 non-rejections on this branch at 200 ms and 1 of 8 onorigin/main. Both controls now hold the ghost 400 ms past its fade, and they rejected in 12 of 12 runs under the same load. The positive tests, including the new long-task controls, passed in every loaded run.Descriptor hygiene pin.
tests/dom-global-restoration.test.tsruns the ordered ghost suite under native, absent and readonly global descriptors, and pins its pass count. The three new arrival tests raise that count from 63 to 66. Candidate confirmation failed on the old pin (expected 63 pass, received66 pass) inunit (3). The stand-in fades overridegetAnimationson one DOM node only, never a global, and the descriptor receipts stayed equal. After the pin change, that test andghost-text.test.tsxpass (57), andtsc --noEmitis clean at441d940e6(merged with maine19300f12).Environment-only failures. The first
check:prrun, under that load, failed 11 tests intests/ci-runner.test.ts,tests/ci-workflows.test.ts,tests/contract-gate.test.tsandtests/diagram-export-source.test.ts. All four files pass on an unmodifiedorigin/mainworktree and on this branch run directly (124 pass), and the rerun below passed.Collisions (
bun scripts/collisions.ts --json --pr 4065at head05a1252f2): nopathorunknownreports. Onlyclosureoverlaps through shared test closures, with #3054, #3056, #3059, #3069, #3581, #3622, #3806, #4002, #4018, #4028, #4034–#4038, #4040–#4042, #4046, #4050–#4053, #4055–#4058, #4060, #4062 and #4064.{"version":1,"kind":"brain-check-pr-receipt","head":"441d940e69347f03d0cd444047dfdb5f8321d1c7","base":"origin/main","mode":"focused","startedAt":"2026-11-16T11:05:39.037Z","finishedAt":"2026-11-16T11:06:50.271Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":13007.189888},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":114.0744709999999},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":84.52383499999996},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":18.975501000000804},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":57992.678231000005}]}Checklist
docs/reflect the change, or nothing documented moved.docs/decisions/provider-history.md): the provider-history guard passes, or nothing on a turn's path changed.Anything left open
The native runs above used the host's Playwright Chromium (chromium-1243), not the pinned
mcr.microsoft.com/playwright:v1.63.0-nobleimage. The pinned-image browser and story proof runs on the squash's main run under the hybrid ruling. Nothing else.🤖 Generated with Claude Code