Repository navigation
fix(octane): render a pending cue at urgent priority (#1864) - #1899
Conversation
A useTransition or useActionState raising isPending, or a useOptimistic value, rendered at transition priority in the click's microtask flush. When that render reached a descendant whose state the transition sets, the descendant rendered its new state there too, so the browser could not paint the cue until the whole transition render finished. React renders the cue in an urgent lane, where that descendant shows its committed state, and renders the transition in a later Scheduler task. The microtask flush now renders a pure cue (one with no transition work of its own) at urgent priority. renderBlockInner's existing urgent-ancestor exposure keeps descendants with waiting transition work on their committed cells, and they keep that work for the transition task. The cue marks live in the transition driver (TRANSITION_CUES) and are scoped to the queue epoch, so apps that never start a transition carry no new bytes. View Transition routing extends #1872's Action-cue rule to every pure cue: a drain of cues alone starts no capture, and transition work that rides with them (a root render, native signal work, staged state) keeps it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Benchmark report
Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)❌ 2 value(s) exceed their committed budget. Reduce the growth, or raise the budget in a separate pull request that names the bytes and the reason (CONTRIBUTING.md, "Size budgets").
47 other measured values are unchanged. Public-import reachability bundles (bytes)❌ 9 value(s) exceed their committed budget. Reduce the growth, or raise the budget in a separate pull request that names the bytes and the reason (CONTRIBUTING.md, "Size budgets").
90 other measured values are unchanged. |
Resolve with #1875: splitCue/splitsCue moved to TRANSITION_ROOT_DRIVER, and the task queue now also takes native producer refreshes. The cue marks move out of queueTransitionBlock into the three hooks that raise a cue (markTransitionCue), so native-reader apps that reach the shared task queue carry none of them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Closes the remaining same-class gap after #1888: a pending cue in an ancestor of the component that holds the transition's state. The microtask flush now renders a pending cue at urgent priority, as React renders
isPendingand optimistic values in an urgent lane. A descendant whose transition is waiting shows its committed state in the cue's commit and renders the transition in the posted task.Refs #1864 (does not close it).
Why
Appownsconst [isPending, start] = useTransition()and renders<List isPending={isPending} start={start} />.Listowns the state thatstart(() => setFilter('b'))sets. The cue renderedAppat transition priority in the click's microtask flush.renderBlockInnerkeeps a child with queued transition work on its committed cells only under an urgent parent, so the cue's render reachedListand rendered its new state there. The browser could not paint the cue until the whole transition render had finished. #1888 fixed this only when the cue and the state share one component.jsdom frames at the next two host-task boundaries, clicking with a
MessageChannelmarker posted first:main(#1888)b pending,b idlea pending,b idlea pending,b idleChanges
runtime.ts, all inside the optional transition driver:markTransitionCue, called by the three hooks that raise a cue (useTransition,useActionState,useOptimistic), records a cue scheduled outside a render, flush,flushSyncor the transition task inTRANSITION_CUES. The marks are stamped withQUEUE_REINDEX_EPOCHand expire when a drain empties or reindexesQUEUE, so a stale mark can never reclassify later work.scheduleRender,drainQueueandqueueTransitionBlockgain no code; since fix: coalesce and pace ready signal producers #1875, native readers share the task queue and so carry none of it.splitsTransitionCue/splitTransitionCue: a pure cue renders at urgent priority. A pure cue is a marked block with no transition work of its own: not waiting in the task queue, no staged cells, no pending root request, and no Suspense/Activity owner at urgent priority. The existing urgent-ancestor exposure then keeps waiting descendants on their committed cells, and they keep their queue entries for the task. fix(octane): commit the pending cue apart from its component's transition (#1864) #1888's split path for a cue whose own block has waiting work is unchanged.queuedTransitionCueno longer needs transition work to be waiting.SyncLaneoptimistic updates):useTransitionasync Action before its first update, starts no View Transition. fix: publish Action cues before native transition capture #1872 already did this foruseActionState.docs/differences-from-react.md§Scheduler: the cue paragraph now states that cues render at urgent priority, covers descendants, the Suspense and View Transition consequences, and when a cue keeps transition priority.octanepatch.Validation
packages/octane/tests/transition-flush-task.test.ts(--project octane): 40/40. 6 of the 7 new tests fail onmain:useTransition,useOptimisticanduseActionState(b pending/b saving/b 0 pendinginstead ofa …);ViewTransitionaround the child's state (the cue renderedbbbb);queuedTransitionCuechange reverted);mainheld it:goidle).--project octane: 36 files, 711 tests, including everytransition-*(fix: publish Action cues before native transition capture #1872's Action-cue capture cases intransition-task),view-transition*,actions,transitions,form-reset,conformance/async-actions,conformance/transitions-extra,differential/action-state,universal-scheduling. fix: publish Action cues before native transition capture #1872's "preserves a native signal capture alongside an Action cue" is what required keeping its cue-only rule instead of treating every pure cue as urgent work in routing.packages/octane/tests/browser/transition-cue(--project octane-events-browser): the Sort fixture gains an ancestor variant (TransitionSortShell), compiled from the same.tsrxfor Octane and React 19.2.7 (@tsrx/react). 4/4 pass; the Octane ancestor case fails onmain(Sorting…commits withsorted: true).pnpm typecheck:fileson the changed files;pnpm format:files:check;pnpm syncclean.pnpm test, fullpnpm typecheck,pnpm format:check: left to CI (repo rule: no wide local runs while parallel sessions share the machine).Chromium Event Timing (cue in the ancestor, memoized 40 ms list, 5 clicks, Event Timing ≥ 16 ms)
mainThe same-component variant (#1888) measures the same before and after: 1/5 at 24 ms (1×) and 32–40 ms (4×), as React does.
Perf review:
fix/transition-cue-ancestor(main..HEAD)Scan:
node scripts/perf-review-scan.mjs→ 0 candidates.Hot paths touched:
markTransitionCue(once per cue publish, from the three cue hooks),splitTransitionCue(per drained block once the transition root driver is installed),splitsTransitionCue/queuedTransitionCue(per transition-priority queued block during drain and View Transition routing).scheduleRender,queueTransitionBlock,renderBlockInner,drainQueueand the Block shape are unchanged. CI's js-framework report: all 64 work counters unchanged.runtime.tssplitTransitionCuesplitTransitionCueTRANSITION_CUESgrows once and is reused. The exposure record for a waiting descendant is the existingUrgentTransitionRenderpath.splitTransitionCuebenchmarks/transition-hooks(OCTANE_TRANSITION_TIMING=0): all 42 work-model rows and every render, runtime function/array/object/constructor andMap.getcounter are identical. Onlybundle_minified+146 andbundle_gzip+52 move.Bundle rows (local, against
main)suspense-transition,binding-base-ui-*,binding-radix-*,binding-apollo-client-*bindings/octane-tsrxfw /octane-*ceilingThese exceed the 32-byte headroom on 11 rows (+100 raw on each transition row, plus
binding-base-ui-*gzip). The raise lands in the budget-only companion PR #1905, which merges immediately before this one; thebundle sizecheck stays red here until then. #1905 is raise-only againstmain's current caps, after #1888's own raise landed onmain(87d9f95b4c, which supersedes #1887).Risk / follow-ups
VT_ACTION_CUEflag stays. It still covers an Action cue that keeps transition priority (one started during a render or a commit). A follow-up could fold it into the pure-cue marks.mainit rendered once. This needs both hooks in one transition batch, so it is rare. It is not deduplicated here, to keep the bytes down.flushSyncor the transition's task, and while hydration reindexes the queue.isPending's falling edge is still a separate commit right after the transition render, in the same task (fix(octane): commit the pending cue apart from its component's transition (#1864) #1888's residual).Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes core transition scheduling and View Transition eligibility in
runtime.ts; behavior shifts for ancestor cues, cue-only commits, and suspending cues, though heavily regression-tested against React parity.Overview
Fixes #1864 for pending transition cues owned by an ancestor of the component whose state the transition updates.
useTransition/useActionStateisPendinganduseOptimisticnow callmarkTransitionCueso the microtask flush treats them as urgent (like React’s urgent lane): descendants with queued transition work keep committed state in that commit and finish the transition in the posted host task.View Transition routing is tightened so a cue-only drain (e.g. async Action before its first update) does not start native capture; real transition work that commits with the cue still captures. A cue that suspends now shows the boundary fallback instead of being held.
Docs §Scheduler and new jsdom + Chromium tests cover ancestor shells, optimistic/action cues, ViewTransition around child state, and suspending cue content; the Sort browser fixture adds an ancestor variant.
Reviewed by Cursor Bugbot for commit 8a2cd8c. Bugbot is set up for automated code reviews on this repo. Configure here.