Skip to content

fix: keep Enter and Tab bound in page search while a page change restarts it - #6042

Merged
leaf-agent merged 2 commits into
mainfrom
fix/issue-3985-search-enter
Nov 15, 2026
Merged

leaf-agent merged 2 commits into
mainfrom
fix/issue-3985-search-enter

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

In page search, Enter and Tab could be lost when the page changed while a search was still running. This happened when a step opened a match's closed tab, or when a revision landed. The change restarts the search with no matches in until its next slice finds one (restart, from #5875). The two keys were bound only while matches held a match, so a key pressed in that window fell through to the field. Enter then selected nothing and left the search open. chooseMatch and moveMatch already finish a running search synchronously (settle), so both keys now stay bound while a search is still finding matches (searchStands).

This is why test_a_walk_through_search_matches_in_closed_tabs_reaches_each_in_turn[browser] timed out on main's push run 43692164348. Its failure picture shows the search still open at "3 of 4" after Enter. Locally, a probe shows Shift+Tab reading "3 of 4" and the restart ("…") following, sometimes after the test has already read the count. The test passed in the two earlier push runs and locally under --cpu-throttle 6 to 20 and 18 concurrent copies, so the window opens only on CI's timing.

Verification:

  • The new test test_enter_selects_the_match_while_a_change_to_the_page_searches_again holds the page's zero-delay timers, changes the page's words while the search runs, and presses Enter during the restart. Without the change it fails at the Enter assertion in Chromium and Firefox. With it, it passes 18 of 18 copies per engine under leaf-dev suite flake.
  • The 35 search tests in test_render_anchors.py, pnpm run test:runtime and pnpm run check pass.

Refs #3985 — automated triage

A page change while a search is still running (a step that opens a match's
tab, a revision) restarts the search with no matches in until its next
slice finds one (#5875). Enter and Tab in page search were bound only while
`matches` held a match, so a key in that window fell through to the field:
Enter selected nothing and left the search open. `chooseMatch` and
`moveMatch` already finish a running search synchronously (`settle`), so
both keys now stay bound while a search is still finding matches.

This is the cause of the Chromium timeout in
`test_a_walk_through_search_matches_in_closed_tabs_reaches_each_in_turn`
on main's push run 43692164348. The new test holds the page's zero-delay
timers, changes the page's words, and presses Enter during the restart; it
fails before the change in both engines and passes after.

Refs #3985

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

searchStands now decides the previous/next arrows' availability as well as the keys, but pending is a plain variable, so the arrows can go stale. An owned button reads its row's when inside a tracked effect and reads it again only when a signal that effect read changes (reflectButton in keyboard/scopes.js). The header for bindings.js says to "request a repaint when any fact used by a word or liveness predicate changes." Here is how they go stale: a search that runs past a frame shows the arrows enabled while it runs. It then ends with no matches, setting pending = null in take or findMore, and matches.value is never reassigned, so the arrows stay enabled beside "No matches". Before this change they were disabled. The comment above matches also says its signal is all the arrows read, which no longer holds. I'll push a fix that holds the running search in a signal.

…ailability follows it

searchStands made the previous/next arrows' availability read `pending`, a plain
variable, so an arrow's tracked effect reran only on `matches`. A search that ran
past a frame and ended with nothing found left the arrows enabled beside
"No matches". Holding the running search in a signal makes the predicate tracked.
@leaf-agent
leaf-agent merged commit 6b38b02 into main Nov 15, 2026
6 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-3985-search-enter branch November 15, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant