Skip to content

fix(octane): tolerate retired focused links during keyed moves - #2088

Merged
trueadm merged 1 commit into
octanejs:nextfrom
openai-oss-forks:codex/next-retired-focus-anchor
Oct 15, 2026
Merged

trueadm merged 1 commit into
octanejs:nextfrom
openai-oss-forks:codex/next-retired-focus-anchor

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

When a commit retires a focused link before reordering later keyed rows, the detached link becomes its own root. Its host is a URL string, so treating every getRootNode() result as a ShadowRoot sends a string to contains() and throws midway through the commit.

Only follow host through a document fragment, the cross-realm node type of a shadow root. This keeps shadow-tree focus preservation while allowing the later reorder to finish after the previously focused link is gone. No work is added to unfocused moves.

Validation

  • Reproduced the focused-link retirement and keyed-row reorder failure on the exact next base with only the new regression applied.
  • 124 tests pass in development and production (focus restoration, text moves, keyed child aliasing).
  • 41 real Chromium mobile-input tests pass, including native/fallback movement, shadow roots and composition.
  • Prettier on the 3 changed files; perf-review scan has no candidates.
  • pnpm sync
  • pnpm test (full suite: CI)
  • pnpm typecheck (full suite: CI)

Risk / follow-up

A tiny change in the focus-containment walk, shared by both general keyed commits and renderer-free keyed views. It uses the existing cross-realm node-type convention rather than instanceof ShadowRoot. Hydration and prepare/commit are unchanged. This is a correctness fix, not a claimed bundle reduction. Independent extraction from #2036; it targets next.

Provenance

  • An agent produced this diff (agent-authored)

Implementation: 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.


Note

Low Risk
Small guard in shared focus-containment logic for keyed commits; behavior unchanged for normal shadow-root and unfocused moves.

Overview
Fixes a crash during keyed DOM moves when the same update removes a focused link before reordering sibling rows.

moveNativeNodeBefore no longer treats every getRootNode() result as a shadow root when walking from the focused element. Detached anchors can be their own root, where .host is a URL string—passing that into Element.contains() threw mid-commit. The walk now only follows .host when the root is a document fragment (node type 11), preserving focus detection across nested shadow trees without touching unfocused move paths.

Adds a regression test: focus a nav link, then in one update hide the link and reverse keyed list inputs; reorder completes and inputs keep their values.

Reviewed by Cursor Bugbot for commit 4c03238. 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 15, 2026
@github-actions
github-actions Bot marked this pull request as draft October 15, 2026 12:47
@trueadm
trueadm marked this pull request as ready for review October 15, 2026 12:52
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 65 value(s) increased
  • 🔴 bundle-reachability: 73 value(s) increased

Compares 98ce9c362, the merge commit's first parent with e4915e1db 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

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 2.492 2.508 −0.0% −3.8% … +1.9% ⚪ within noise
octane-tsrx replace 5.067 4.875 −2.1% −7.8% … +1.1% ⚪ within noise
octane-tsrx add 2.275 2.350 ±0.0% −4.2% … +4.4% ⚪ within noise
octane-tsrx update 0.085 0.084 −1.4% −3.5% … +1.7% ⚪ within noise
octane-tsrx select 0.006 0.006 +0.0% −4.6% … +3.1% ⚪ within noise
octane-tsrx swap 0.024 0.025 +4.5% +0.3% … +8.5% ⚪ within noise
octane-tsrx remove 0.026 0.025 +1.7% −6.5% … +8.4% ⚪ within noise
octane-tsrx runlots 34.183 34.775 +4.1% −4.5% … +20.1% ⚪ within noise
octane-tsrx select_lots 0.008 0.008 +2.9% +0.5% … +6.8% ⚪ within noise
octane-tsrx clear 52.408 52.058 +1.4% −2.8% … +5.7% ⚪ within noise
octane-jsx run 3.808 3.675 ±0.0% −2.7% … +2.9% ⚪ within noise
octane-jsx replace 6.575 6.700 −1.6% −9.3% … +2.9% ⚪ within noise
octane-jsx add 3.192 3.167 +3.3% −1.5% … +7.4% ⚪ within noise
octane-jsx update 0.192 0.195 +0.7% −0.7% … +3.6% ⚪ within noise
octane-jsx select 0.104 0.100 −1.5% −3.7% … −0.5% ⚪ within noise
octane-jsx swap 0.147 0.148 −0.3% −2.4% … +2.2% ⚪ within noise
octane-jsx remove 0.126 0.125 −0.3% −1.7% … +1.7% ⚪ within noise
octane-jsx runlots 29.175 30.633 −1.1% −3.4% … +2.9% ⚪ within noise
octane-jsx select_lots 1.091 1.125 −0.0% −6.4% … +6.7% ⚪ within noise
octane-jsx clear 53.775 57.208 +0.4% −4.0% … +9.1% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx js_raw 93,640 93,671 +31 (+0.0%) 🔴
octane-tsrx js_gzip 31,542 31,551 +9 (+0.0%) 🔴
octane-tsrx js_brotli 28,287 28,275 −12 (−0.0%) 🟢
octane-tsrx app_gzip 2,621 2,619 −2 (−0.1%) 🟢
octane-tsrx app_brotli 2,274 2,272 −2 (−0.1%) 🟢
octane-tsrx fw_raw 86,084 86,115 +31 (+0.0%) 🔴
octane-tsrx fw_gzip 28,921 28,932 +11 (+0.0%) 🔴
octane-tsrx fw_brotli 26,013 26,003 −10 (−0.0%) 🟢
octane-tsrx todo_js_raw 106,478 106,509 +31 (+0.0%) 🔴
octane-tsrx todo_js_gzip 36,163 36,173 +10 (+0.0%) 🔴
octane-tsrx todo_js_brotli 32,259 32,223 −36 (−0.1%) 🟢
octane-tsrx todo_app_gzip 2,781 2,779 −2 (−0.1%) 🟢
octane-tsrx todo_app_brotli 2,333 2,332 −1 (−0.0%) 🟢
octane-tsrx todo_fw_raw 100,237 100,268 +31 (+0.0%) 🔴
octane-tsrx todo_fw_gzip 33,382 33,394 +12 (+0.0%) 🔴
octane-tsrx todo_fw_brotli 29,926 29,891 −35 (−0.1%) 🟢
octane-tsrx chat_js_raw 105,328 105,359 +31 (+0.0%) 🔴
octane-tsrx chat_js_gzip 35,960 35,973 +13 (+0.0%) 🔴
octane-tsrx chat_js_brotli 32,108 32,129 +21 (+0.1%) 🔴
octane-tsrx chat_app_gzip 3,224 3,225 +1 (+0.0%) 🔴
octane-tsrx chat_app_brotli 2,810 2,807 −3 (−0.1%) 🟢
octane-tsrx chat_fw_raw 98,187 98,218 +31 (+0.0%) 🔴
octane-tsrx chat_fw_gzip 32,736 32,748 +12 (+0.0%) 🔴
octane-tsrx chat_fw_brotli 29,298 29,322 +24 (+0.1%) 🔴
octane-tsrx weather_js_raw 142,984 143,015 +31 (+0.0%) 🔴
octane-tsrx weather_js_gzip 47,540 47,548 +8 (+0.0%) 🔴
octane-tsrx weather_js_brotli 42,006 42,068 +62 (+0.1%) 🔴
octane-tsrx weather_app_brotli 7,323 7,324 +1 (+0.0%) 🔴
octane-tsrx weather_fw_raw 117,902 117,933 +31 (+0.0%) 🔴
octane-tsrx weather_fw_gzip 38,890 38,898 +8 (+0.0%) 🔴
octane-tsrx weather_fw_brotli 34,683 34,744 +61 (+0.2%) 🔴
octane-tsrx bindings_js_raw 685,160 685,191 +31 (+0.0%) 🔴
octane-tsrx bindings_js_gzip 226,480 226,487 +7 (+0.0%) 🔴
octane-tsrx bindings_js_brotli 192,720 192,774 +54 (+0.0%) 🔴
octane-tsrx bindings_app_gzip 117,001 117,000 −1 (−0.0%) 🟢
octane-tsrx bindings_app_brotli 97,038 97,042 +4 (+0.0%) 🔴
octane-tsrx bindings_fw_raw 330,845 330,876 +31 (+0.0%) 🔴
octane-tsrx bindings_fw_gzip 109,479 109,487 +8 (+0.0%) 🔴
octane-tsrx bindings_fw_brotli 95,682 95,732 +50 (+0.1%) 🔴
octane-tsrx wayfinder_js_raw 438,520 438,551 +31 (+0.0%) 🔴
octane-tsrx wayfinder_js_gzip 145,014 145,022 +8 (+0.0%) 🔴
octane-tsrx wayfinder_js_brotli 125,980 125,982 +2 (+0.0%) 🔴
octane-tsrx threadline_oxc_js_raw 160,675 160,706 +31 (+0.0%) 🔴
octane-tsrx threadline_oxc_js_gzip 53,211 53,221 +10 (+0.0%) 🔴
octane-tsrx threadline_oxc_js_brotli 46,589 46,542 −47 (−0.1%) 🟢
octane-tsrx threadline_esbuild_js_raw 178,568 178,601 +33 (+0.0%) 🔴
octane-tsrx threadline_esbuild_js_gzip 60,309 60,319 +10 (+0.0%) 🔴
octane-tsrx threadline_esbuild_js_brotli 52,732 52,744 +12 (+0.0%) 🔴
octane-tsrx pagecraft_oxc_js_raw 544,306 544,337 +31 (+0.0%) 🔴
octane-tsrx pagecraft_oxc_js_gzip 171,545 171,557 +12 (+0.0%) 🔴
octane-tsrx pagecraft_oxc_js_brotli 145,448 145,368 −80 (−0.1%) 🟢
octane-tsrx pagecraft_esbuild_js_raw 576,763 576,796 +33 (+0.0%) 🔴
octane-tsrx pagecraft_esbuild_js_gzip 186,893 186,902 +9 (+0.0%) 🔴
octane-tsrx pagecraft_esbuild_js_brotli 158,634 158,683 +49 (+0.0%) 🔴
octane-tsrx full_fw_raw 522,644 522,675 +31 (+0.0%) 🔴
octane-tsrx full_fw_gzip 163,487 163,496 +9 (+0.0%) 🔴
octane-tsrx full_fw_brotli 138,759 138,678 −81 (−0.1%) 🟢
octane-jsx js_raw 169,065 169,096 +31 (+0.0%) 🔴
octane-jsx js_gzip 55,422 55,431 +9 (+0.0%) 🔴
octane-jsx js_brotli 48,643 48,661 +18 (+0.0%) 🔴
octane-jsx app_brotli 2,930 2,925 −5 (−0.2%) 🟢
octane-jsx fw_raw 158,006 158,037 +31 (+0.0%) 🔴
octane-jsx fw_gzip 51,838 51,847 +9 (+0.0%) 🔴
octane-jsx fw_brotli 45,713 45,736 +23 (+0.1%) 🔴
octane-jsx shell_js_raw 327,649 327,680 +31 (+0.0%) 🔴
octane-jsx shell_js_gzip 107,202 107,221 +19 (+0.0%) 🔴
octane-jsx shell_app_gzip 762 770 +8 (+1.0%) 🔴
octane-jsx shell_app_brotli 669 672 +3 (+0.4%) 🔴
octane-jsx shell_fw_raw 326,556 326,587 +31 (+0.0%) 🔴
octane-jsx shell_fw_gzip 106,440 106,451 +11 (+0.0%) 🔴
octane-jsx shell_fw_brotli 92,022 92,019 −3 (−0.0%) 🟢
octane-jsx shell_client_js_raw 278,563 278,594 +31 (+0.0%) 🔴
octane-jsx shell_client_js_gzip 90,681 90,691 +10 (+0.0%) 🔴
octane-jsx shell_client_js_brotli 79,044 79,058 +14 (+0.0%) 🔴
octane-jsx shell_client_app_gzip 765 764 −1 (−0.1%) 🟢
octane-jsx shell_client_app_brotli 665 667 +2 (+0.3%) 🔴
octane-jsx shell_client_fw_raw 277,462 277,493 +31 (+0.0%) 🔴
octane-jsx shell_client_fw_gzip 89,916 89,927 +11 (+0.0%) 🔴
octane-jsx shell_client_fw_brotli 78,379 78,391 +12 (+0.0%) 🔴
octane-jsx full_fw_raw 522,644 522,675 +31 (+0.0%) 🔴
octane-jsx full_fw_gzip 163,487 163,496 +9 (+0.0%) 🔴
octane-jsx full_fw_brotli 138,759 138,678 −81 (−0.1%) 🟢

11 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
cli-spa-starter raw 85,921 85,952 +31 (+0.0%) 🔴
cli-spa-starter gzip 29,744 29,756 +12 (+0.0%) 🔴
cli-spa-starter brotli 26,481 26,512 +31 (+0.1%) 🔴
root-static-specialized raw 57,198 57,229 +31 (+0.1%) 🔴
root-static-specialized gzip 19,560 19,570 +10 (+0.1%) 🔴
root-static-specialized brotli 17,725 17,724 −1 (−0.0%) 🟢
root-chained-jsx raw 59,340 59,371 +31 (+0.1%) 🔴
root-chained-jsx gzip 20,272 20,284 +12 (+0.1%) 🔴
root-chained-jsx brotli 18,355 18,366 +11 (+0.1%) 🔴
root-static raw 144,648 144,679 +31 (+0.0%) 🔴
root-static gzip 47,608 47,618 +10 (+0.0%) 🔴
root-static brotli 42,125 42,178 +53 (+0.1%) 🔴
root-static-local raw 57,100 57,131 +31 (+0.1%) 🔴
root-static-local gzip 19,495 19,504 +9 (+0.0%) 🔴
root-static-local brotli 17,682 17,691 +9 (+0.1%) 🔴
root-callback-local raw 59,757 59,788 +31 (+0.1%) 🔴
root-callback-local gzip 20,375 20,386 +11 (+0.1%) 🔴
root-callback-local brotli 18,451 18,461 +10 (+0.1%) 🔴
hooks-state raw 68,097 68,128 +31 (+0.0%) 🔴
hooks-state gzip 23,200 23,211 +11 (+0.0%) 🔴
hooks-state brotli 21,010 20,973 −37 (−0.2%) 🟢
prop-attributes raw 65,211 65,242 +31 (+0.0%) 🔴
prop-attributes gzip 22,353 22,363 +10 (+0.0%) 🔴
prop-attributes brotli 20,197 20,203 +6 (+0.0%) 🔴
context raw 75,215 75,246 +31 (+0.0%) 🔴
context gzip 25,370 25,380 +10 (+0.0%) 🔴
context brotli 22,910 22,865 −45 (−0.2%) 🟢
hydrate-root raw 96,720 96,751 +31 (+0.0%) 🔴
hydrate-root gzip 32,473 32,486 +13 (+0.0%) 🔴
hydrate-root brotli 28,956 29,015 +59 (+0.2%) 🔴
deferred-hydration raw 180,701 180,732 +31 (+0.0%) 🔴
deferred-hydration gzip 58,902 58,910 +8 (+0.0%) 🔴
deferred-hydration brotli 51,418 51,404 −14 (−0.0%) 🟢
hydrate-frame raw 340,877 340,908 +31 (+0.0%) 🔴
hydrate-frame gzip 110,091 110,103 +12 (+0.0%) 🔴
hydrate-frame brotli 95,149 95,188 +39 (+0.0%) 🔴
suspense-transition raw 119,904 119,935 +31 (+0.0%) 🔴
suspense-transition gzip 39,202 39,211 +9 (+0.0%) 🔴
suspense-transition brotli 34,870 34,909 +39 (+0.1%) 🔴
component-owned-effects raw 61,285 61,316 +31 (+0.1%) 🔴
component-owned-effects gzip 20,929 20,938 +9 (+0.0%) 🔴
component-owned-effects brotli 18,947 19,022 +75 (+0.4%) 🔴
descriptor-children raw 166,310 166,341 +31 (+0.0%) 🔴
descriptor-children gzip 54,406 54,416 +10 (+0.0%) 🔴
descriptor-children brotli 47,972 47,930 −42 (−0.1%) 🟢
binding-hooks raw 70,497 70,528 +31 (+0.0%) 🔴
binding-hooks gzip 24,166 24,178 +12 (+0.0%) 🔴
binding-hooks brotli 21,842 21,884 +42 (+0.2%) 🔴
split-shell raw 391,752 391,783 +31 (+0.0%) 🔴
split-shell gzip 128,364 128,372 +8 (+0.0%) 🔴
split-shell brotli 111,248 111,155 −93 (−0.1%) 🟢
split-shell-runtime raw 316,369 316,400 +31 (+0.0%) 🔴
split-shell-runtime gzip 102,498 102,508 +10 (+0.0%) 🔴
split-shell-runtime brotli 87,977 87,888 −89 (−0.1%) 🟢
binding-base-ui-vite raw 176,828 176,859 +31 (+0.0%) 🔴
binding-base-ui-vite gzip 58,034 58,045 +11 (+0.0%) 🔴
binding-base-ui-vite brotli 51,117 51,142 +25 (+0.0%) 🔴
binding-base-ui-esbuild raw 198,236 198,267 +31 (+0.0%) 🔴
binding-base-ui-esbuild gzip 66,886 66,897 +11 (+0.0%) 🔴
binding-base-ui-esbuild brotli 58,754 58,689 −65 (−0.1%) 🟢
binding-radix-vite raw 176,261 176,292 +31 (+0.0%) 🔴
binding-radix-vite gzip 57,603 57,611 +8 (+0.0%) 🔴
binding-radix-vite brotli 50,734 50,770 +36 (+0.1%) 🔴
binding-radix-esbuild raw 197,719 197,750 +31 (+0.0%) 🔴
binding-radix-esbuild gzip 66,552 66,564 +12 (+0.0%) 🔴
binding-radix-esbuild brotli 58,410 58,377 −33 (−0.1%) 🟢
binding-mantine-hooks-vite raw 68,701 68,732 +31 (+0.0%) 🔴
binding-mantine-hooks-vite gzip 23,613 23,623 +10 (+0.0%) 🔴
binding-mantine-hooks-vite brotli 21,347 21,402 +55 (+0.3%) 🔴
binding-mantine-hooks-esbuild raw 77,606 77,637 +31 (+0.0%) 🔴
binding-mantine-hooks-esbuild gzip 27,500 27,511 +11 (+0.0%) 🔴
binding-mantine-hooks-esbuild brotli 24,849 24,861 +12 (+0.0%) 🔴
binding-apollo-client-vite raw 321,342 321,373 +31 (+0.0%) 🔴
binding-apollo-client-vite gzip 101,006 101,016 +10 (+0.0%) 🔴
binding-apollo-client-vite brotli 89,025 88,861 −164 (−0.2%) 🟢
binding-apollo-client-esbuild raw 350,072 350,103 +31 (+0.0%) 🔴
binding-apollo-client-esbuild gzip 113,912 113,922 +10 (+0.0%) 🔴
binding-apollo-client-esbuild brotli 100,101 100,202 +101 (+0.1%) 🔴
binding-usehooks-ts-vite raw 69,483 69,514 +31 (+0.0%) 🔴
binding-usehooks-ts-vite gzip 23,829 23,840 +11 (+0.0%) 🔴
binding-usehooks-ts-vite brotli 21,537 21,592 +55 (+0.3%) 🔴
binding-usehooks-ts-esbuild raw 78,376 78,407 +31 (+0.0%) 🔴
binding-usehooks-ts-esbuild gzip 27,715 27,725 +10 (+0.0%) 🔴
binding-usehooks-ts-esbuild brotli 25,059 25,055 −4 (−0.0%) 🟢

39 other measured values are unchanged.

@trueadm
trueadm merged commit 4ae77f2 into octanejs:next Oct 15, 2026
41 of 59 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