Skip to content

ui-kit: the arrival timer cuts the ghost's fade short when its first frame is late #3425

Closed

Description

@schlessera

Context

Found while fixing #3417. The ghost handoff ends on a wall-clock timer, setTimeout(() => setArriving(false), HANDOFF_MS) (useArrival, packages/ui-kit/src/internal/GhostText.tsx:181-194; the timer at :190, HANDOFF_MS = 600 at :38). The outgoing fade runs on the animation clock: .bk-ghost-out { animation: ghost-out 600ms ease both; } (packages/ui-kit/src/tokens.css:1399-1401, with the GhostBand combination at :1403). The timer starts at the arrival commit. The fade starts on the first frame the browser renders after the commit.

The outgoing class is applied at four call sites, all driven by useArrival:

  • packages/ui-kit/src/internal/GhostText.tsx:222 (Ghosted)
  • packages/ui-kit/src/states/Placeholder.tsx:215
  • packages/ui-kit/src/internal/GhostBand.tsx:60
  • packages/ui-kit/src/conversation/StreamingAnswer.tsx:139

When that first frame is late (a loaded runner, a long task right after the commit), the timer still removes the ghost 600 ms after the commit, part-way through its fade. In the pinned Chromium image, at one CPU shared with six busy loops, a traced ActionCard handoff started its ghost-out fade 209 ms after the commit. Its last frame was at 283 ms of fade time, and the timer cancelled it at about 390 ms. The ghost disappears from partial opacity instead of fading out, which D53 (docs/decisions/design-kit/loading.md) says it should do.

This was the likely mechanism behind the intermediate-opacity and mid-sample signatures recorded under #1946 (closed not planned). Under heavy load the old playHandoff mid-handoff sample (a 300 ms wall-clock sleep, then an outgoing-opacity read) failed with expected NaN to be greater than 0 in 3 of 4 runs: the ghost was already gone. Sampling at the fade's own 300 ms midpoint instead, frame by frame, still failed 3 times in 4 runs, because the timer cancels the fade before it reaches its midpoint.

Measurement evidence from #3777 (merged 2026-11-09, harness only, folded in from #3804). #3777 moved the story's mid-fade sample onto the page's own rendered frames (watchHandoff, packages/ui-kit/stories/_handoff-clock.ts, used by playHandoff in packages/ui-kit/stories/_ghost.tsx:46): it records both layers' opacity in the first frame whose ghost-out fade is running and at least a tenth through. On a CPU-loaded host (16 busy loops on 16 cores, load average 26–38) it recorded:

  • waiting until 300 ms after arrival on the wall clock read out = 1 and in = 0, because the browser had not started the CSS animation yet;
  • waiting until the fade's own currentTime reached 300 ms failed 6 of 10 runs, because the component removes the ghost on the 600 ms commit timer, not on animationend, so a late-starting fade is cut off before its midpoint;
  • its PR left exactly this product defect open ("Anything left open"). The frame-count budget from test(ui-kit): StreamingAnswer 'Loading To Ready' fails on a 700 ms wall-clock handoff bound under runner load #3417 still guards removal past the fade, not before it ends.

Out of scope

Scope

End the arrival handoff on the outgoing fade's own end (its animationend), with the timer kept as a fallback only where no fade runs: reduced motion, animation: none, or a document that does not render frames. Every useArrival consumer is affected: StreamingAnswer, Placeholder, and the Ghosted and GhostBand callers (ActionCard, FileRow, QueueItemRow, SearchResultCard), across the four bk-ghost-out call sites above.

Acceptance criteria

Verification

Pinned mcr.microsoft.com/playwright:v1.63.0-noble, network disabled, real Chromium. Run the LoadingToReady stories (the stories/decisions and stories/rows projects) in storybook and storybook-light, plus tests/visual/ghost-handoff.visual.tsx and tests/visual/streaming-handoff.visual.tsx, under a CPU-starved container. No API key, no network.

Contract impact

None. Internal hook timing only; no public prop or --json shape changes.

Refs #3417, #1946, #3777

Triage 2026-11-03: added blocked with Blocked by #3417; re-verified citations; kept priority: p3. Second pass: raised to p2 (product defect against D53 with a recorded failure); milestone 0.45.0; no epic parent.

Triage 2026-11-10 at main 3aadc8df5: Decision (maintainer, 2026-11-10): #3804 is folded into this issue and closed as its duplicate. Moved in #3804's four bk-ghost-out call sites and #3777's measurement evidence, and its animation: none fallback criterion. Blocker #3417 closed completed and #3426 merged on 2026-11-03, so Blocked by #3417 became a reference and blocked was removed. #3777 already removed the wall-clock sleep from playHandoff, so that part left the scope. Corrected tokens.css to :1399-1401. Still agent-ready, p2, 0.45.0.

Activity

  1. added
    type: fix
    area: ui-kit
    priority: p3
    blocked
    agent-ready
    on Nov 3, 2026
  2. schlessera commented on Nov 3, 2026

    @schlessera
    OwnerAuthor

    Triage 2026-11-03: added blocked with Blocked by #3417. The acceptance criteria keep #3417's frame-clock assertions passing, and those exist only in draft PR #3426. Also corrected the _ghost.tsx citation to main (:95 sleep, :98 read).

  3. added
    priority: p2
    and removed
    priority: p3
    on Nov 3, 2026
  4. added this to the 0.45.0 milestone on Nov 3, 2026
  5. schlessera commented on Nov 3, 2026

    @schlessera
    OwnerAuthor

    Triage 2026-11-03 (second pass): every citation re-verified at main d990c0ab3, unchanged. Raised priority: p3 to p2: this is a product defect against D53 with a recorded failure, and the mechanism behind #1946's mid-handoff signature. Its blocker #3417 is p2, so the blocker rule holds. Milestone 0.45.0, as a direct, small follow-up of #3417. No epic parent: like #3417 this is a product fix that lands on main, outside #1849's test-cost outcome. Still agent-ready and blocked.

  6. removed
    blocked
    on Nov 10, 2026
  7. schlessera commented on Nov 10, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-10): fold #3804 into this issue and close #3804 as a duplicate of it. One implementation of the useArrival fix lands here.

    2026-11-10 triage at main 3aadc8df5: the body now carries #3804's four bk-ghost-out call sites (GhostText.tsx:222, Placeholder.tsx:215, GhostBand.tsx:60, StreamingAnswer.tsx:139), #3777's measurement evidence (the fade-currentTime 300 ms anchor failed 6 of 10 under load because of the commit timer), and #3804's animation: none fallback criterion. #3417 closed completed and #3426 merged on 2026-11-03, so blocked is removed and Blocked by #3417 is now a reference. #3777 already took the wall-clock sleep out of playHandoff, so that part left the scope. Corrected the tokens.css citation to :1399-1401. Still agent-ready, p2, milestone 0.45.0.

  8. self-assigned this
    on Nov 15, 2026
  9. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-657baba6. Branch: fix/3425-ghost-fade-animationend.

    collisions: closure-only overlaps with open PRs via shared test closures; no path collisions

  10. schlessera commented on Nov 16, 2026

    @schlessera
    OwnerAuthor

    Merged in #4065 as e66cf4c8f through the integration lease (orchestrator merge queue for 0.45.0). Candidate confirmation passed on the exact head; the squash's own main run carries the post-merge heavy categories.

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

Metadata

Metadata

Assignees

Labels

agent-readyarea: ui-kitpriority: p2type: fix

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions