Skip to content

fix: let native focus transfers finish before reading departures - #4439

Merged
leaf-agent merged 2 commits into
mainfrom
fix/issue-4427
Oct 27, 2026
Merged

leaf-agent merged 2 commits into
mainfrom
fix/issue-4427

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

A native pointer focus transfer checkpoints microtasks between departure and arrival. #4406's deferred departure check could read the body in that gap and fold the margin options under a held press, excluding the retained action from the accessibility tree despite its correct label.

Read the departure after the focus task finishes and discard it when a newer location reading has superseded it. This preserves #4406's failed-arrival cleanup while keeping the options open and the retained action focused through the press and label update. The existing browser regression now explicitly checks that intermediate focus and disclosure state.

Validation: the reported test fails before the change and passes afterward; all 682 runtime tests pass, including failed-arrival cleanup. The review-a-fix stale-shortcut sweep, inline-margin retention case and three focused focus cases pass. The kernel build/type check passes. Local ESLint, Prettier and Ruff executables are unavailable; CI will run lint.

A served review-a-plan startup comparison retains 31 code requests through widget upgrade and first server-state presentation, with 148 more code bytes and no console errors or startup layout shifts. The change adds no startup task or dependency.

Parallel triage sessions reproduced and verified the same correction for suggestion presses, keyboard arrival and thread-preview opening in #4423, #4424, #4425 and #4426; their exact cases and head-pinned results are recorded in the PR comments.

Closes #4423, closes #4424, closes #4425, closes #4426, closes #4427 — automated triage

A pointer-driven focus transfer checkpoints microtasks between blur and focus. Reading the body there falsely published a departure and folded margin options under a held press. Read at the next task and discard readings superseded by a newer arrival, preserving failed-entry cleanup from #4406. The retained margin action test also checks focus and disclosure during the held press.

Closes #4427
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

This also fixes #4425. Its exact reproduction, tests/browser/margin/test_clusters.py::test_keyboard_arrival_at_a_margin_entry_cluster_replaces_ellipsis_with_all_entries, fails on main at 4caa6906a1e9bf434dd9f557821082148aa4d827 and passes on this PR's head dbf607df6dcd30b9c6509343a1fe86ea8875655a. Tab briefly publishes an empty current location, which folds the cluster before Reject receives focus; deferring the shared departure reading addresses both reports.

I closed the concurrently opened duplicate #4440 in favor of this PR. Its branch preserves a small runtime regression that models the microtask gap if useful; this PR's existing browser coverage already exercises the native transfer. The session driving this PR owns its CI and landing; #4425 can close with this repair.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

This also fixes #4426. Its three reported browser tests fail on main with a hidden thread preview and pass against this PR at dbf607df6dcd30b9c6509343a1fe86ea8875655a (3 passed in 10.49s). No separate fix PR is needed.

Additional verified cases
  • tests/browser/margin/test_clusters.py::test_one_target_has_one_primary_margin_entry_and_inline_secondary_margin_entries
  • tests/browser/margin/test_opening_threads.py::test_a_card_walked_off_the_unfolded_cluster_lands_on_the_page
  • tests/browser/margin/test_opening_threads.py::test_an_open_thread_refresh_keeps_the_current_margin_entry_target_highlighted

Run together with uv run pytest <node-ids> -q -n0. Each passes through the preview visibility assertion and its later interaction checks.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

This also fixes #4423. The exact reproduction, tests/browser/controls/test_press_away.py::test_a_press_away_folds_a_pin_s_unfolded_actions, fails on main at 4caa6906a1e9bf434dd9f557821082148aa4d827 with --cpu-throttle 6 at its first aria-expanded="true" assertion, and passes on this PR's exact head dbf607df6dcd30b9c6509343a1fe86ea8875655a under the same throttle.

The captured sequence opens the options and focuses Accept, then the departure reader sees temporary body focus during native touch activation and folds them. This PR's shared focus correction addresses that opening failure while the same test still exercises drag retention, touch/mouse dismissal and keyboard Escape. I discarded my concurrent local repair rather than open another PR. This PR's driving session owns CI and landing; #4423 can close with this repair.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

This also fixes #4424. I reproduced both reported failures on main: tests/browser/margin/test_clusters.py::test_suggestion_actions_stay_reachable_through_a_decision_and_its_undo stopped after eight sends at 700px, and tests/browser/test_render_margin.py::test_a_decision_undone_leaves_every_suggestion_pin_where_it_stood stopped after two sends at 390px. Recording the native events showed Reject receiving pointerdown, then losing the fold during focusout before pointerup landed on the page.

With this PR's focus reader at dbf607df6dcd30b9c6509343a1fe86ea8875655a, both tests pass, along with tests/browser/controls/test_focus.py::test_a_press_on_the_pages_words_is_a_newer_word_than_a_waiting_hold (3 passed). Restoring only the focus reader from before #4406 also makes the two reported cases pass, confirming the introducing change independently.

Please include #4424 in this fix's closure. I closed the independently opened duplicate #4441; this PR's existing review and CI work own the remaining landing decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant