Skip to content

fix(tui): let Tab indent a multi-line Playbook selection; C-o focuses the menu - #1240

Merged
edwin-zvs merged 1 commit into
mainfrom
playbook-tab-indent
Aug 11, 2026
Merged

fix(tui): let Tab indent a multi-line Playbook selection; C-o focuses the menu#1240
edwin-zvs merged 1 commit into
mainfrom
playbook-tab-indent

Conversation

@edwin-zvs

Copy link
Copy Markdown
Contributor

Closes #1106.

Spec 0094 gives Tab / S-Tab list nesting that operates on every list line the selection spans — but the selection action menu claimed bare Tab first, to focus itself, so the multi-line half was unreachable. S-Tab wasn't claimed, leaving the pair asymmetric: a selected block could be un-nested but never nested.

What changed

crates/cli/src/app/editor.rs — the unfocused menu now claims C-o instead of Tab. While the menu is merely shown, every editing key — including Tab/S-Tab indent over the selection — keeps reaching the editor. Once focused, menu behavior is unchanged (Up/Down/Tab/BackTab cycle rows, Esc unfocuses, Enter runs).

Why C-o: reliable in every terminal (unlike M-Enter, which dies on macOS terminals not configured to send Option as Meta), free in the playbook keymap, and consistent with the editor's emacs-flavored chord family. Only C-x chords are claimed globally, so there's no collision.

crates/cli/src/ui.rs — the passive menu advertises the chord: a dim C-o menu bottom-border title, shown only while unfocused. This also closes the discoverability half of #1092 (nothing on the menu ever said how to reach it); #1092's remaining half (what Enter should do while the menu is passive) is deliberately left to that issue.

specs/0196-playbook-selection-menu-focus-model.md — records the rule: a passive popup may not steal keys the surface underneath documents, and the focus chord must be advertised on the menu frame.

Acceptance criteria from the issue

  • Tab with a multi-line selection indents every list line the selection spans (repro test: - one\n- two\n- three with lines 1–2 selected → both nest)
  • S-Tab keeps outdenting the same lines (asserted on the remapped selection right after the indent)
  • ✅ The menu is still keyboard-reachable, by an advertised key (C-o, rendered on the menu; render test asserts the hint)

Testing

  • Replaced the old playbook_tab_focuses_selection_menu_for_multi_line_selection test (which enshrined the bug) with the issue's repro + a C-o-focuses test.
  • Updated the four menu tests that used Tab as the focus vehicle (comment editing, emacs keys, verb navigation, render highlight) to C-o.
  • cargo test -p construct-cli --bin construct playbook: 333 passed. Full workspace suite running before merge.

🤖 Generated with Claude Code

… the menu

The selection action menu claimed bare Tab to focus itself, shadowing
the editor's 'Tab nests every list line the selection spans' (spec 0094)
exactly when a selection exists — which is the only time multi-line
nesting is possible. S-Tab was not claimed, so the pair was asymmetric:
a selected block could be un-nested but not nested (issue #1106).

- The unfocused menu now claims C-o instead of Tab; Tab and S-Tab both
  reach the editor's indent commands while the menu is merely shown.
  Menu-internal navigation (Up/Down/Tab/BackTab once focused, Esc to
  unfocus) is unchanged.
- The passive menu advertises the chord with a dim ' C-o menu ' bottom
  border title, so the focus model is discoverable (also the
  discoverability half of issue #1092).
- New spec 0196 records the focus model: a passive popup may not steal
  keys the surface underneath documents; the focus chord must be
  advertised on the menu frame.
- Tests: the old test asserting Tab-focuses-the-menu is replaced by the
  issue's repro (Tab indents the selected lines, S-Tab un-nests them,
  the menu never steals focus), a C-o-focuses test, a hint-render
  assertion, and the remaining menu tests drive focus via C-o.

Closes #1106
@edwin-zvs
edwin-zvs merged commit 1effebc into main Aug 11, 2026
1 check passed
@edwin-zvs
edwin-zvs deleted the playbook-tab-indent branch August 11, 2026 02:25
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.

tui: Tab cannot indent a multi-line Playbook selection — the selection menu claims the key

1 participant