Repository navigation
fix: keep Enter and Tab bound in page search while a page change restarts it - #6042
Conversation
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
left a comment
There was a problem hiding this comment.
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.
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 whilematchesheld a match, so a key pressed in that window fell through to the field. Enter then selected nothing and left the search open.chooseMatchandmoveMatchalready 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-throttle6 to 20 and 18 concurrent copies, so the window opens only on CI's timing.Verification:
test_enter_selects_the_match_while_a_change_to_the_page_searches_againholds 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 underleaf-dev suite flake.test_render_anchors.py,pnpm run test:runtimeandpnpm run checkpass.Refs #3985 — automated triage