Skip to content

fix(octane): tolerate translated boundary whitespace in DOM bindings - #1978

Merged
trueadm merged 2 commits into
octanejs:mainfrom
openai-oss-forks:codex/fix-translated-binding-adoption-318
Oct 10, 2026
Merged

trueadm merged 2 commits into
octanejs:mainfrom
openai-oss-forks:codex/fix-translated-binding-adoption-318

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Firefox page translation can move boundary spaces out of translated text hosts. A fixed div > span(text), button(text) view then has whitespace Text siblings before, between, or after its expected elements. DOM binding adoption currently throws #318 even though the element topology is intact.

Skip ASCII-whitespace Text siblings while resolving fixed and closed addressed children. Preserve those nodes and retain all checks for unexpected elements, comments, meaningful text, namespaces, ordering, and text-leaf shape. Add regression coverage, a short contract note, and an Octane patch changeset.

Validation

  • pnpm format:check (repository-wide check not run; changed files checked)

  • pnpm typecheck (repository-wide check not run; owning source/test files checked)

  • pnpm test (repository-wide suite left to CI)

  • Targeted regression: 10 new cases failed before the repair; 76 scalar DOM-binding tests pass after it, in development/production and scalar/general/addressed modes. Assertions cover exact node identity, text values, updates, cleanup, and rejected invalid topology.

  • Focused binding/handoff suites: 220 tests pass. Scoped typecheck, changed-file formatting, and changeset policy pass.

  • Native Firefox 157, French-to-English translation, Octane 0.12.1 compiler/SSR: before, 6 of 40 view cases throw feat(base-ui): port the Menu item family (Phase 3f stage 2) #318; after, 40 of 40 pass 600 assertions. The same six failing cases contain browser-relocated whitespace and pass after the repair. A translation-mutation observer also captured seven candidate views with relocated whitespace, with no adoption errors. Updates and disposal pass; no page errors were captured.

  • All 14 pnpm sync script subcommands completed in declared order using existing local executables. Direct invocation avoided an unnecessary automatic dependency reinstall; no configuration/security policy changes. No generated tracked changes.

  • Independent read-only correctness/complexity review: no remaining findings. Validation and sync were repeated successfully on signed merged head 134387fd9 after incorporating the current base; worktree clean.

  • Current-head CI on 134387fd9: all required and relevant checks passed, including all runtime/parity shards, browser/integration suites, lint, typecheck, package validation, bundle checks, and benchmark gates. Bugbot completed without findings. CI run.

Perf review

Final scan against 2075c0e7: 0 candidates. resolveFixedNodes and resolveAddressedNodes run per descriptor node during adoption; the added sibling walk visits each skipped Text node once. No record shape changes, per-node allocations, DOM writes, geometry reads, scheduling changes, or new runtime imports. The regular signal-update path is unchanged. No must-fix findings. Current-head PR benchmark passed: all 64 production-call/DOM-mutation counters are unchanged; application bundle sizes (60 measured values) and public-import reachability bundle sizes (111 values) are unchanged. The advisory octane-tsrx select_lots timing result is +7.0% (approximately 0.005 to 0.006 ms, 95% interval +6.6% to +8.2%); the other 19 timed operations have no verdict. This is recorded without claiming a cause or a speed improvement. Benchmark report.

Concise-code

Runtime source +21/-7; one private helper shared by the existing resolvers, no new exports, options, modules, or hot-record fields. The only new file is the required patch changeset. nextElementSibling would also hide comments and meaningful text; trim/\s would accept extra Unicode whitespace. DOM normalization or fallback rendering would mutate/rebuild nodes unnecessarily. A matched fixture-adopter bundle grows by 125 raw bytes / 55 gzip bytes; this is a micro-bundle measurement, not a whole-application size claim.

Risk / follow-ups

The accepted exception is ASCII HTML whitespace only, including empty Text nodes. Non-whitespace text, NBSP, comments, extra/missing/reordered elements, and invalid text leaves remain errors. Open/opaque descendants retain their previous behavior. Browser translation can make other DOM changes; this repair does not claim to cover every #318 cause.

Provenance

  • An agent produced this diff (agent-authored)

Codex task · Host: com-79386.


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


Note

Low Risk
Adoption-only sibling walking change with a strict ASCII-whitespace exception; binding updates and channel writes are unchanged, with broad regression coverage.

Overview
DOM binding adoption no longer fails when closed child lists include extra ASCII-whitespace Text nodes (including empty nodes), which browser page translation can insert between expected elements.

resolveFixedNodes and resolveAddressedNodes in dom-bindings.ts now advance cursors with skipBindingWhitespace instead of treating those siblings as topology errors (#318/#321). The whitespace nodes are left untouched; meaningful text, comments, NBSP, extra elements, and invalid text leaves still reject adoption.

Docs in deferred-hydration.md document the contract; scalar DOM-binding tests add adoption/update/disposal coverage and tighten invalid-topology cases. Octane patch changeset included.

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

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Oct 10, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review October 10, 2026 12:23
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🟡 js-framework: 1 timed operation(s) slower beyond ±3%

Compares 2075c0e72, the merge commit's first parent with d71828e6c on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. 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

target operation base ms head ms head/base 95% CI
octane-tsrx select_lots 0.005 0.006 +7.0% +6.6% … +8.2% 🟡 slower
All 20 timed operations (19 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 2.625 2.575 ±0.0% −0.0% … +3.3% ⚪ within noise
octane-tsrx replace 6.317 6.575 +1.5% −1.4% … +4.4% ⚪ within noise
octane-tsrx add 2.458 2.450 −0.0% −4.0% … ±0.0% ⚪ within noise
octane-tsrx update 0.116 0.118 +1.3% −0.0% … +2.2% ⚪ within noise
octane-tsrx select 0.005 0.005 ±0.0% −0.5% … +0.5% ⚪ within noise
octane-tsrx swap 0.017 0.018 +2.5% +1.7% … +3.6% ⚪ within noise
octane-tsrx remove 0.014 0.014 −1.4% −3.6% … +0.4% ⚪ within noise
octane-tsrx runlots 24.833 23.883 −0.6% −2.9% … +0.4% ⚪ within noise
octane-tsrx select_lots 0.005 0.006 +7.0% +6.6% … +8.2% 🟡 slower
octane-tsrx clear 45.708 46.550 +1.3% −1.1% … +3.9% ⚪ within noise
octane-jsx run 3.267 3.325 ±0.0% −2.9% … ±0.0% ⚪ within noise
octane-jsx replace 6.658 6.575 +1.5% −3.1% … +3.3% ⚪ within noise
octane-jsx add 3.383 3.292 ±0.0% −1.4% … +1.6% ⚪ within noise
octane-jsx update 0.249 0.250 +0.0% −1.3% … +1.0% ⚪ within noise
octane-jsx select 0.126 0.125 +0.5% −0.3% … +1.1% ⚪ within noise
octane-jsx swap 0.164 0.166 +0.6% +0.3% … +1.1% ⚪ within noise
octane-jsx remove 0.167 0.170 ±0.0% −1.2% … +0.6% ⚪ within noise
octane-jsx runlots 28.692 28.408 −0.7% −3.8% … +2.0% ⚪ within noise
octane-jsx select_lots 1.419 1.460 +1.8% +0.6% … +3.5% ⚪ within noise
octane-jsx clear 48.517 49.783 +1.6% +0.6% … +2.6% ⚪ 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 111 measured values.

@trueadm

trueadm commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

Good to go, with two optional nits and one follow-up question. The fix is in the owning resolvers (skipBindingWhitespace). The compiler forbids non-layout text siblings in fixed and addressed views, so skipping ASCII-whitespace Text nodes adopts nothing the template didn't prove, and server output never contains these nodes.

  • Question (follow-up, predates this PR): if Firefox writes translated text into the leaf's existing Text node rather than wrapping it in <font>, the first adoption write at L425 restores the source language. The new tests keep the leaf text untranslated. Does the Firefox run check that the translation survives? Structural programs also still reject both shapes (dom-binding-program.ts#L872). Both may warrant a follow-up issue.
  • Nit: the docs paragraph could say why the tolerance exists (translation, Firefox) and be folded into the next paragraph, which still calls <font> "the one text rewrite adoption accepts". The feat(base-ui): port the Menu item family (Phase 3f stage 2) #318 and feat(octane): cross-module hook fact extraction (opt-in) #321 note text in codes.json says the same.
  • Nit: whitespace inside a childless closed element (<hr>, <use>) is now accepted too (L286). One table row would pin that either way.

Verified:

@trueadm
trueadm merged commit 64c33de into octanejs:main Oct 10, 2026
53 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.

2 participants