Skip to content

UI hints follow the keymap (pane labels + dialog shortcuts); drop quit from user keymap#231

Merged
Maxteabag merged 2 commits into
mainfrom
fix/textual-quit-binding-keymap-override
May 25, 2026
Merged

UI hints follow the keymap (pane labels + dialog shortcuts); drop quit from user keymap#231
Maxteabag merged 2 commits into
mainfrom
fix/textual-quit-binding-keymap-override

Conversation

@Maxteabag
Copy link
Copy Markdown
Owner

@Maxteabag Maxteabag commented May 25, 2026

Two related fixes so the keymap actually drives what the user sees in the UI.

1. UI hints showed stale keys. The pane border labels ([e] Explorer, [q] Query, [r] Results) in ui_status.py were hardcoded. Remapping focus_explorer to E left the border still showing [e]. Same problem in three dialog shortcut hints:

  • ValueViewScreenCopy: y, Toggle: t, Collapse: z
  • ErrorScreenCopy: y
  • ConnectionScreenTest: ^t, Save: ^s

All now read from the keymap.

2. Quit is no longer user-overridable. The earlier attempt to make ctrl+q keymap-driven (by overriding Textual's App.BINDINGS) is reverted — quit is the kind of key nobody benefits from rebinding, and giving it special treatment created a foot-gun where a typo in keymap.json could lock the user out of the exit key. Textual's hardcoded ctrl+q -> quit and ctrl+c -> help_quit stay as the only routes (plus the :q command).

To support screen-local actions (error_copy_message, connection_save, connection_test, connection_install_driver) cleanly, adds two new contexts (error_dialog, connection_editor) and teaches the action validator to skip them — their action methods live on the Screen, not the App.

Maxteabag added 2 commits May 25, 2026 12:20
Two related fixes for the "edit keymap.json, see the UI update"
promise.

1. **Textual's hardcoded `App.BINDINGS` slipped past the keymap.**
   Pressing `ctrl+q` quit sqlit even when a user remapped `quit` to
   `ctrl+c`, because the framework's default `Binding("ctrl+q",
   "quit", priority=True)` had no `id=` and so wasn't reachable by
   `App.set_keymap`. SSMSTUI now declares `inherit_bindings=False`
   and re-declares the quit binding with `id="quit"`, so the keymap
   actually controls it.

2. **UI hints (pane labels and dialog shortcuts) showed stale keys.**
   - Pane border labels (`[e] Explorer`, `[q] Query`, `[r] Results`)
     in `ui_status.py` were hardcoded; now they pull from the keymap
     so remapping `focus_explorer` to `E` updates the border to match.
   - `ValueViewScreen`, `ErrorScreen`, and `ConnectionScreen` dialog
     hints (`Copy: y`, `Test: ^t`, `Save: ^s`, …) also pulled from
     hardcoded strings; now derived from the keymap.

To make screen-local actions (`error_copy_message`,
`connection_save`, `connection_test`, `connection_install_driver`)
reachable from the keymap without polluting the action validator,
adds two new screen-local contexts (`error_dialog`,
`connection_editor`) and a skip-list in `validate_actions` for
contexts whose action methods live on a Screen instead of the App.
Drops the prior approach of shadowing Textual's App.BINDINGS to make
ctrl+q remappable. The friction wasn't worth it — quit is a key
nobody benefits from rebinding, and giving it the special treatment
opens a foot-gun where a typo in keymap.json could lock the user out
of the exit key.

- Reverts SSMSTUI back to default inherit_bindings behavior. Textual's
  built-in ctrl+q -> quit and ctrl+c -> help_quit stay as the only
  routes (plus the :q command-mode form).
- Removes `quit` from sqlit's user-overridable keymap defaults (both
  the action_keys entry and the <leader>q LeaderCommand).
- Regenerates config/keymap.template.json to match.
- Updates tests that previously used 'quit' as a sample action.
@Maxteabag Maxteabag changed the title Keymap-drive Textual app bindings + dialog hint keys UI hints follow the keymap (pane labels + dialog shortcuts); drop quit from user keymap May 25, 2026
@Maxteabag Maxteabag merged commit 91ece39 into main May 25, 2026
21 checks passed
@Maxteabag Maxteabag deleted the fix/textual-quit-binding-keymap-override branch May 25, 2026 10:49
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.

1 participant