Repository navigation
Hold keys pressed while a page loads until the page can run them - #5386
Merged
Merged
Conversation
…ocus, and find reference rows as options Three browser tests failed on main. Two were stale; the third caught a product defect. - Held keys under load. Bootstrap dropped the keys it held on a page not yet upgraded ten seconds after it started, a decision from #1213 that read such a page as faulted. On a loaded Mac a healthy page upgrades later than that. `test_held_keys_after_one_that_opens_a_box_are_typed_into_it` failed when a page-side trace showed the hold ending at 15.4 s and the page upgrading at 15.6 s with nothing left to take, and the phone's `test_a_key_pressed_before_presentation_runs_once_the_page_presents[True-module]` failed the same way. 8x CPU throttle reproduces both. The notice had told the user those keys "run when it's ready". This reverses #1213's deadline. The hold now ends when the runtime takes it, when the page reports it cannot start, or when the user lets go with another key or a pointer press, never on a clock. A page that hangs without a report keeps saying it is still loading, which is then true. Two modes never upgrade, so they end the hold at their own signal: a document the runtime gives up on as it starts (`prepareDocument` finds the registry on another layer) lets go through `letHeldKeysGo`, and a sample opened as a window of its own, which no containing page will connect, holds nothing. Behavior change: a key held while a page loads now runs however long the load takes. `test_upgrade_relinquishes_the_bootstrap_timeout_for_held_keys` becomes `test_held_keys_outlast_any_wait_for_the_runtime`, which advances the page's clock 30 s past a held key. The journey `test_a_page_that_never_presents_lets_its_held_keys_go` waited out the deadline. It becomes `test_a_page_that_cannot_start_lets_its_held_keys_go` in `startup/test_keys.py`, where a failed runtime module ends the hold, and `test_a_document_the_runtime_gives_up_on_lets_its_held_keys_go` covers the other path. The tests that hold the runtime module now press their keys once the body is parsed. Holding the module's request doesn't prove bootstrap is listening, and one run lost its first key that way. - A held `t` on a phone. Since #5039 a phone opens the thread in the floating panel, whose head and thread view both carry `data-lf-thread`, with the head first in the document. Focus lands on the view, but the test took the first match. `startup/test_keys.py` now reads the held thread as the element carrying its id that holds focus (`ON_HELD_THREAD`): the card on a desktop, the panel's view on a phone. - The command reference's rows. Since #5118 each row is a `button role="option"`, so `test_a_heading_copies_the_link_to_the_section_it_opens` found no button "Copy link to section". The row is still offered from a focused section and still copies the link. The same stale lookup failed `test_code_wrapping_keeps_source_copy_and_reader_choice` and `test_a_reference_command_finishes_its_gesture_before_a_newer_control` in CI, and both now ask for options too. Closes #5137
Main's #5313 made the same fix for the command reference's rows, asking for `option` rather than `button`, in test_render_heading_links, test_render_code_reading and test_focus. Those files now match main, so this branch's net change fixes two failures: held keys dropped while a slow page loads, which removes bootstrap's ten-second deadline, and the phone's held `t`, which reads the held thread by focus.
…h's reading of it
leaf-agent
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Leaf holds printed keys pressed before its runtime loads and shows "Page still loading —
truns when it's ready". Since #1213 it also dropped them if the page hadn't upgraded ten seconds after it started, reading such a page as faulted. On a loaded Mac a healthy page takes longer than that, so keys the notice promised to run were dropped:test_held_keys_after_one_that_opens_a_box_are_typed_into_itfailed at load ~107. A page-side trace showed the keys held at 2.6 s, the notice gone at 15.4 s, and the page upgrading at 15.6 s with nothing left to take.test_a_key_pressed_before_presentation_runs_once_the_page_presents[True-module]failed the same way at load ~90.dynamic-widgetstook 18.8 s to upgrade underleaf-dev probe.This reverses #1213's deadline. The hold now ends when the runtime takes it, when the page reports it cannot start, or when the user lets go, and never on a clock. On a page that truly hangs the hold costs little: only printed page keys are held, any other key or a pointer press already ends the run and acts natively, and "Page still loading" is then true.
Every mode that runs the hold now ends it:
boot()rejecting all reachrecover, which ends the hold, as before.prepareDocumentreturns false when the registry names another layer, andbootreturns without upgrading. Only the deadline ended the hold here. It now ends at that return, throughletHeldKeysGoinkeyboard/controller.js.bootwaits onlfSample.readyforever. It now holds nothing. This one is confirmed by reading the code rather than running it.bootstrap.js.The tests follow:
test_upgrade_relinquishes_the_bootstrap_timeout_for_held_keysbecomestest_held_keys_outlast_any_wait_for_the_runtime, which advances the page's clock 30 s past a heldtand checks thetstill walks to the thread.test_a_page_that_never_presents_lets_its_held_keys_gowaited ten real seconds for the deadline. It becomestest_a_page_that_cannot_start_lets_its_held_keys_goinbrowser/startup/test_keys.py, where a failed runtime module ends the hold and later presses reach the page.test_a_document_the_runtime_gives_up_on_lets_its_held_keys_gocovers the give-up path. WithletHeldKeysGotaken out it fails with the notice still standing.Testing
After merging
main: the six held-key tests above andtest_a_key_that_is_not_printed_ends_the_held_run(10 items), serially undertaskpolicy -b, pass;pnpm run test:runtime(813) andpnpm run check:browserpass. Before the merge, B and the phone's[True-module]also passed at--cpu-throttle 8, where both failed with the deadline.mainhas since fixed the phone variant's stale locator itself (#5350), so this branch keeps main's reading of it.