Skip to content

fix(octane): re-evaluate a ready derived invalidated before a held transition is accepted - #1816

Merged
trueadm merged 1 commit into
mainfrom
fix/staged-view-invalidation-1767
Oct 6, 2026
Merged

trueadm merged 1 commit into
mainfrom
fix/staged-view-invalidation-1767

Conversation

@trueadm

@trueadm trueadm commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1767. When a held View Transition is staging a render that redeclared a derived$, and the new definition's dependency changes before the browser accepts the update, the accepted cell now re-evaluates. Previously it committed the stale value, which rendering and event-handler reads then kept showing.

Why

promoteDeclarationView (packages/octane/src/signals/graph.ts) copies the private declaration view's state onto the canonical cell at acceptance. #1775 taught it to keep the view's pre-acceptance Dirty/Pending flags and retry moved consumers, but only for a pending view. A ready view invalidated by its new dependency during the hold was promoted with its flags cleared. The cell held the old ready value with clean flags, so nothing re-read it:

  • The comment's reproduction (ready old → dependency set while held → accept) rendered old and get() returned old.
  • The issue body's pending reproduction already passes on main since fix(octane): keep pending readers attached to accepted work #1775. It is kept here as coverage of the report as filed: its waiter never settles, so invalidation alone has to drive the retry.

Changes

  • promoteDeclarationView: preserve the view's Dirty/Pending invalidation for any evaluated view, not only a pending one. Then use the existing retry path: bump the revision, invalidate render witnesses, and propagate to the moved consumers. An unevaluated view is unchanged, because it already installs Dirty through its own path.
  • The invalidatedPending/retryPending locals are renamed to invalidated/retry, since they are no longer pending-only.
  • New behavioral test signals-staged-invalidation.test.ts with fixture. It runs in the dev, prod and Strong signal projects and covers:
    • a pending view and a ready view, each with the dependency changing before and after acceptance;
    • a dependency that changes and changes back while held, which keeps old without looping.

Validation

  • Pre-fix: the ready/before-acceptance case fails in all three modes (expected 'old' to be 'new'). The fix was also reverted locally to confirm the test goes red again.
  • Post-fix: signals-staged-invalidation.test.ts passes 15/15 across octane-signals, octane-signals-prod and octane-signals-strong.
  • fix(octane): keep pending readers attached to accepted work #1775's promotion suites (signals-pending-promotion, signals-pending-promotion-graph, signals-waiter-equivalent) and the redeclaration suites (signals-local, signals-local-chains, signals-update-depth) pass in octane-signals, 38/38.
  • pnpm typecheck:files and pnpm format:files:check pass on the changed files. pnpm sync produced no changes.
  • pnpm test, pnpm typecheck and pnpm format:check were not run locally, per the shared-machine load rule; CI covers them.

Risk / follow-ups

  • Cold path: this runs only when a redeclared computation is accepted. The change replaces a status comparison and adds no work.
  • A ready view carrying only Pending, where a dependency may have changed but evaluates equal, now notifies its moved consumers once. They re-read and get an unchanged value. That costs at most one extra render, only when a dependency moved between render and commit.
  • Async/query views re-evaluate themselves when notified before acceptance, so the carried flag mainly matters for sync derived$ and scalar views.

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Touches signal graph promotion on view-transition acceptance only; may trigger one extra re-read/render when a ready view was invalidated but the value is unchanged.

Overview
Fixes stale UI and reads when a held View Transition accepts a render that redeclared a derived$ whose new dependency changed while the update was staged.

promoteDeclarationView previously kept Dirty/Pending invalidation only for pending declaration views (#1775). A ready view that was invalidated before acceptance was promoted with clean flags, so the canonical cell kept the old value. The change treats any evaluated view the same: copy invalidation flags onto the cell, bump revision when needed, and propagate to moved subscribers so they re-read the current definition.

Adds signals-staged-invalidation tests (pending and ready cases, dependency changes before/after acceptance, and flip-back-while-held) under mocked view transitions.

Reviewed by Cursor Bugbot for commit b2dff75. Bugbot is set up for automated code reviews on this repo. Configure here.

…ansition is accepted

Promoting a redeclared derived view carried its pre-acceptance Dirty/Pending
flags onto the canonical cell only when the view was pending. A ready view whose
new dependency changed while a held View Transition staged the render was
promoted clean, so the committed cell and its moved consumers kept the stale
value. Preserve the invalidation for any evaluated view and retry its consumers.

Fixes #1767

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Oct 6, 2026
@trueadm
trueadm marked this pull request as ready for review October 6, 2026 12:42
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No budget breaches, no added work, and no timing changes beyond ±3%.

Compares ed57b1ea5, the merge commit's first parent with 2d9ced313 on the same runner. A byte value over its committed budget or any increase in a js-framework work counter fails this check. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 4.008 3.075 −3.4% −36.5% … +3.0% ⚪ within noise
octane-tsrx replace 8.058 8.742 +4.3% −1.4% … +13.2% ⚪ within noise
octane-tsrx add 3.108 2.717 −3.6% −6.6% … ±0.0% ⚪ within noise
octane-tsrx update 0.150 0.149 +1.0% −5.8% … +4.3% ⚪ within noise
octane-tsrx select 0.008 0.007 −7.2% −38.5% … −2.5% ⚪ within noise
octane-tsrx swap 0.044 0.049 +3.1% −2.1% … +13.8% ⚪ within noise
octane-tsrx remove 0.022 0.022 +2.0% −14.6% … +7.6% ⚪ within noise
octane-tsrx runlots 34.500 31.033 ±0.0% −4.4% … +1.9% ⚪ within noise
octane-tsrx select_lots 0.007 0.007 +0.8% −1.5% … +2.3% ⚪ within noise
octane-tsrx clear 38.408 41.500 +8.4% +2.6% … +12.9% ⚪ within noise
octane-jsx run 3.450 3.758 ±0.0% −2.7% … +2.9% ⚪ within noise
octane-jsx replace 6.033 5.992 +0.7% −1.6% … +1.7% ⚪ within noise
octane-jsx add 3.217 3.175 +0.0% −0.0% … +3.1% ⚪ within noise
octane-jsx update 0.268 0.269 −1.6% −3.8% … +0.3% ⚪ within noise
octane-jsx select 0.140 0.137 +2.1% −1.1% … +4.8% ⚪ within noise
octane-jsx swap 0.243 0.241 −1.0% −4.5% … +2.2% ⚪ within noise
octane-jsx remove 0.175 0.172 −1.6% −2.4% … +2.1% ⚪ within noise
octane-jsx runlots 34.967 34.517 +2.6% −0.4% … +4.8% ⚪ within noise
octane-jsx select_lots 2.161 2.100 −1.7% −12.2% … +2.4% ⚪ within noise
octane-jsx clear 43.358 44.308 +0.8% −2.2% … +4.8% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

No changes across 60 measured values.

Public-import reachability bundles (bytes)

No changes across 105 measured values.

@trueadm
trueadm merged commit ab9a043 into main Oct 6, 2026
53 checks passed
@trueadm
trueadm deleted the fix/staged-view-invalidation-1767 branch October 6, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A held ViewTransition accepts a stale pending derived after its dependency changes

1 participant