Repository navigation
Declare each command's availability in its when, and drop run getters - #5313
Merged
Merged
Conversation
#4873 let a command row declare `run` as a getter that returns nothing while the command can't act. Dispatch then fell through, but every other reader of availability (the command reference, key hints, `aria-keyshortcuts`) reads `when` and took such a row as live. #5250 put four thread rows back on `when` with a plain `run`, as `bindings.js` asks ("Do not repeat a guard inside `run` if the guard changes whether the key should be shown"). This does the same for the six rows that were left: - `navigation.back` (`register.js`), `selection.restore` (`composing/capture.js`) and the three `margin.card.*` rows (`annotation-overlay/thread-preview.js`) already had a `when` that matched their getter's guard, so their behavior is unchanged. - `code.copy` (`code-copy.js`) had no `when`. Before its Copy button upgraded, a code block advertised Enter as "copy code" and the press fell through to the page. It now waits in its `when` for the button. The detail dial's arrows (`packages/detail/widgets/lf-dial.js`) had the same fault without a getter: `dial.less` and `dial.more` had no `when`, and their `run` returned at the dial's ends. At Skim the dial advertised ← for Less detail, which does nothing. Each row now needs a depth beside the current one in its `when`, and drawing a depth calls `commandsChanged` so Leaf reads them again. A probe of `detail` reads the dial's `aria-keyshortcuts` as `ArrowRight` at Skim, both arrows at Read and `ArrowLeft` at Everything; on `main` it reads both arrows at every depth. With no getter left, a row's `run` and `runKey` are plain values again: - `declaresCommandHandler` is deleted. Registration, the register's touch check, button wiring and the command reference read `row.run` and `row.runKey` directly. - Go-to registers its direct destinations by spreading them, without copying property descriptors. - The three runtime tests that pinned the getter contract are deleted. Three browser tests still looked up command reference rows as buttons, which #4895 made listbox options. They now ask for options: - `controls/test_focus.py::test_a_reference_command_finishes_its_gesture_before_a_newer_control`, which failed on `main` with no Tend cause issue. - `test_render_code_reading.py::test_code_wrapping_keeps_source_copy_and_reader_choice`, which presses Unwrap lines and Copy code in the reference, then Enter on the block. - `test_render_heading_links.py::test_a_heading_copies_the_link_to_the_section_it_opens`. Checked by node id: those tests; `test_reading_place`'s Restore selection; `test_render_code_reading`'s copy over plain HTTP; `test_summaries`' margin paging, which Tabs into and out of a card; `test_clusters`' reference row for Escape; four of `test_key_scopes`' Escape and back-gesture tests; and `test_dial`. `pnpm run test:runtime`, `pnpm run check:browser` and pre-commit pass. Locally, three of `check:worker`'s bundle and storage tests hit their 5 s and 60 s timeouts at a load average of 50 to 85, so the pull request's run is their check. > _This was written by Claude Code on behalf of max-sixty_
# Conflicts: # browser/runtime/annotation-overlay/thread-preview.js
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.
#4873 let a command row declare
runas a getter that returns nothing while the command can't act. Dispatch then fell through, but every other reader of availability (the command reference, key hints,aria-keyshortcuts) readswhenand took such a row as live. #5250 put four thread rows back onwhenwith a plainrun, asbindings.jsasks ("Do not repeat a guard insiderunif the guard changes whether the key should be shown"). This does the same for the six rows that were left:navigation.back(register.js),selection.restore(composing/capture.js) and the threemargin.card.*rows (annotation-overlay/thread-preview.js) already had awhenthat matched their getter's guard, so their behavior is unchanged.code.copy(code-copy.js) had nowhen. Before its Copy button upgraded, a code block advertised Enter as "copy code" and the press fell through to the page. It now waits in itswhenfor the button.The detail dial's arrows (
packages/detail/widgets/lf-dial.js) had the same fault without a getter:dial.lessanddial.morehad nowhen, and theirrunreturned at the dial's ends. At Skim the dial advertised ← for Less detail, which does nothing. Each row now needs a depth beside the current one in itswhen, and drawing a depth callscommandsChangedso Leaf reads them again. A probe ofdetailreads the dial'saria-keyshortcutsasArrowRightat Skim, both arrows at Read andArrowLeftat Everything; onmainit reads both arrows at every depth.With no getter left, a row's
runandrunKeyare plain values again:declaresCommandHandleris deleted. Registration, the register's touch check, button wiring and the command reference readrow.runandrow.runKeydirectly.Three browser tests still looked up command reference rows as buttons, which #4895 made listbox options. They now ask for options:
controls/test_focus.py::test_a_reference_command_finishes_its_gesture_before_a_newer_control, which failed onmainwith no Tend cause issue.test_render_code_reading.py::test_code_wrapping_keeps_source_copy_and_reader_choice, which presses Unwrap lines and Copy code in the reference, then Enter on the block.test_render_heading_links.py::test_a_heading_copies_the_link_to_the_section_it_opens.Checked by node id: those tests;
test_reading_place's Restore selection;test_render_code_reading's copy over plain HTTP;test_summaries' margin paging, which Tabs into and out of a card;test_clusters' reference row for Escape; four oftest_key_scopes' Escape and back-gesture tests; andtest_dial.pnpm run test:runtime,pnpm run check:browserand pre-commit pass. Locally, three ofcheck:worker's bundle and storage tests hit their 5 s and 60 s timeouts at a load average of 50 to 85, so the pull request's run is their check.