Skip to content

fix: restore hoisted head listeners after transition rollback - #994

Merged
domgan-oai merged 4 commits into
octanejs:mainfrom
openai-oss-forks:fix/head-listener-rollback
Sep 8, 2026
Merged

domgan-oai merged 4 commits into
octanejs:mainfrom
openai-oss-forks:fix/head-listener-rollback

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

Why

  • Head elements live outside the delegated event root. Their native listeners currently change during speculative rendering, while the visible head node and text roll back. An old screen can therefore respond with the next handler or none at all.

Changes

  • Snapshot direct head listeners once before the first speculative change and restore native registrations plus the handler map on rollback, including aliased native events.
  • Keep teardown listener removals outside the rollback journal and avoid snapshots when handlers are unchanged.
  • Cover replacement, omission, explicit undefined, and alias collision in development and production; add an octane patch changeset.

Validation

  • Current-head CI passed pnpm format:check, typecheck, all four Node 24 test shards, React parity, integrations, examples, and required aggregate checks.
  • Pre-fix test shard 4/4 failed in development and production: the unchanged aliased handler fired once instead of twice while the old screen was held.
  • git diff --check; same esbuild 0.28.1 production minifier: 334,263 → 334,745 bytes of unbundled runtime.ts (+482 bytes, 0.14%).
  • Local pnpm sync passed lockfile supply-chain verification but dependency installation was blocked by the configured registry's 403 for @tsrx/[email protected]; CI validated the final head.

Risk / follow-ups

  • Runtime timing could not be measured locally because dependency installation is blocked; snapshots allocate only when a head listener changes inside an active rollback journal.

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 transition rollback and native event registration on document.head; incorrect journaling could leave wrong handlers or duplicate listeners, but scope is limited to hoisted head slots during suspended transitions.

Overview
Fixes suspended transitions mutating direct on* listeners on hoisted <head> nodes while the visible head (text/attrs) is held on the old screen — listeners now participate in the same transition journal/rollback as other head slot state.

The runtime adds journalHeadEventListeners, which snapshots the per-prop listener map once per head update pass and records undo steps that tear down and re-register native listeners. That avoids unsafe per-prop reversals when multiple props alias the same native event (addEventListener dedupes). removeHeadEventListeners and head on* patching now opt into journaling when TRANSITION_JOURNAL is active, with a single journal per pass.

Regression coverage adds a boundary + <title> fixture with direct click handlers (replace / omit / explicit clear) and a case for aliased handlers (onDoubleClick / onDblClick). Ships an octane patch changeset.

Reviewed by Cursor Bugbot for commit 8728683. 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 8, 2026 13:58
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Sep 8, 2026
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.

1 participant