Skip to content

Declare each command's availability in its when, and drop run getters - #5313

Merged
max-sixty merged 2 commits into
mainfrom
command-when-only
Nov 4, 2026
Merged

max-sixty merged 2 commits into
mainfrom
command-when-only

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

#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

#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
@max-sixty
max-sixty merged commit 97ecff3 into main Nov 4, 2026
4 checks passed
@max-sixty
max-sixty deleted the command-when-only branch November 4, 2026 07:58
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.

2 participants