Skip to content

fix: preserve keyed rows across @empty root rollback - #986

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/fix-empty-rollback-984
Sep 7, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/fix-empty-rollback-984

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Keep committed keyed rows visible and connected when a root render clears a list, mounts @empty, refills it, and then suspends in the same drain.
  • Preserve connected row cleanup when an inner Suspense boundary rolls back its refill and the outer clear commits.

Why

The @empty arm borrows the list's markers. Its parked DOM range could include rows that an earlier render window had already parked. A root rollback then restored those rows and removed them a second time while disposing the empty arm. Filtering that overlap also requires the inner rollback to leave earlier retired rows connected until the outer attempt settles.

Changes

  • Attribute parked DOM to the earlier rows or empty arms that own it, including inert rows from the owned-list bulk clear path.
  • Preserve those earlier rows across nested list restoration without moving them into the inner snapshot's row order.
  • Add public .tsrx regressions for multi-node rows, 1,000 inert owned rows, subsequent keyed insertion, effects, and connected cleanup on a nested fallback commit.
  • Add an octane patch changeset.

Validation

  • Regression observed on merged main: both row lists vanish during the root hold; subsequent insertion raises NotFoundError.
  • Source-only compile and jsdom execution of the public .tsrx fixtures against the candidate: row identity, ordering, cleanup, nested fallback commit, and hydrated adoption pass.
  • Prettier check of changed files with a cached formatter; git diff --check; esbuild TypeScript parse.
  • Baseline/candidate minified full-runtime bundle smoke (mount, update, input identity, unmount); candidate adds 621 raw / 210 gzip / 66 Brotli bytes with the same esbuild options. This is a bundle size observation, not a timing claim.
  • Current-head CI passed on 71b8e29f: all four Node test shards, four React parity shards, Chromium integration, lint, typecheck, package validation, examples, and provenance.
  • Local pnpm sync and pinned Vitest/typecheck could not start: frozen install returned 403 for @tsrx/[email protected]. The pinned-toolchain CI above passed.

Risk / follow-ups

The rare @empty swap and rollback paths scan previously parked rows and certified retired hosts. Ordinary row parking retains its unfiltered node loop. The browser benchmark suite does not isolate this same-drain rollback, so no timing claim is made.

Fixes #984.

Provenance

  • An agent produced this diff (agent-authored)

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 root-transaction parking and keyed @for/@empty rollback in the runtime DOM reconciler; scope is a rare suspense/hold path but incorrect behavior could corrupt list DOM or lifecycle timing.

Overview
Fixes a root-render hold where clearing a keyed @for, mounting @empty, refilling the list, and suspending in the same drain could drop or double-remove row DOM on rollback.

parkItemForHold now accepts the owning list and, for @empty, parks only nodes that belong to the empty arm—not rows already retired or parked for that slot (because @empty shares the list’s marker range). retainedForSlotNodes collects those earlier parked nodes and inert hosts from bulk owned-list clears. List snapshot restore reuses inert single-marker rows without requiring a parked range, and treats those retained nodes as “keep connected” during orphan sweeps so nested rollbacks don’t reorder or detach rows owned by an outer attempt.

Adds Vitest coverage for same-drain empty→refill→suspend (multi-node rows, 1k-item lists, keyed insert reuse) and nested Suspense commit with connected layout cleanups. Patch changeset for octane.

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

@domgan-oai
domgan-oai marked this pull request as ready for review September 7, 2026 22:29
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Sep 7, 2026
@domgan-oai
domgan-oai merged commit d5de04f into octanejs:main Sep 7, 2026
51 checks passed
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.

Root rollback loses keyed rows after an @empty refill in one drain

1 participant