Commit 0929fa0
authored
refactor(tui): keybinding precedence - promote hardcoded keys to actions (#333)
## Summary
- Refactors TUI key dispatch so the configurable `KeybindingResolver` is
the single source of truth for overridable keys, eliminating the
silent-shadow bug where hardcoded `switch keyStr` blocks short-circuited
user-configured bindings.
- Promotes every previously-hardcoded overridable key (`q`, `?`, `g`,
`v`, up/k, down/j, `/`, `:`, `G`) into a proper `action.Type` registered
as a default `UserCommand` and bound via `defaultViewsConfig`. Layer-1
system keys (`ctrl+c`, `esc`, `tab`, `shift+tab`) and modal-dismissal
keys remain hardcoded by design.
- Adds a model-level global-scope-only fallback so a view-scoped binding
for `q`/`?` cannot leak into the global `Quit`/`ShowHelp` handler.
## Phases
1. `0393dfd` Phase 1 — Action enums (`Sessions*`,
`GoToTop`/`GoToBottom`, `Quit`, `ShowHelp`), default `UserCommand`
registrations, `handleGlobalAction` extension.
2. `44fb686` Phase 2 — Sessions view: register defaults, delete
hardcoded blocks, wire view-internal `IsAction` dispatch.
3. `e6d082e` Phase 3 — Global `q`/`?` migration with `commandFor` helper
and global-scope-only model fallback.
4. `9df2818` Phase 4 — Tasks tree-pane + review view `g`/`G` migration
(detail-pane viewport navigation left hardcoded).
5. `4c7377c` Phase 5 — Precedence regression tests including
`TestPromotedKeysAreOverridable` driving `Model.Update` end-to-end
(resolver-only tests would have been GREEN on the original bug).
6. `2cd968f` Phase 6 — `AGENTS.md` precedence rule + help-text
regression test.
7. `9b8670f` Post-review polish — godocs, why-comments, additional
coverage (review-focus `?` carve-out, default-binding e2e, modal
`q`-under-override, out-of-scope-binding case).
## Test plan
- [ ] `mise run test` — full suite passes
- [ ] `env GOTOOLCHAIN=go1.26.2 golangci-lint run ./internal/core/config
./internal/tui ./internal/tui/views/tasks ./internal/tui/views/review` —
scoped lint clean
- [ ] Manually verify default keybindings still behave: in TUI, `q`
quits, `?` opens help, `g`/`v` work in sessions, `g`/`G` jump in
tasks/review, `/` enters filter mode, `:` opens command palette.
- [ ] Manually verify user override: configure a custom `g` binding in
sessions scope and confirm it takes precedence over
`SessionsRefreshGitStatuses`.
- [ ] Manually verify modal dismissal: open help modal, press `q` (or
`esc`) — closes regardless of user binding.1 parent 1dd9acd commit 0929fa0
14 files changed
Lines changed: 948 additions & 146 deletions
File tree
- internal
- core
- action
- config
- tui
- views
- review
- sessions
- tasks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
201 | 211 | | |
202 | 212 | | |
203 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
50 | 60 | | |
51 | 61 | | |
52 | 62 | | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
306 | 364 | | |
307 | 365 | | |
308 | 366 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
94 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
95 | 106 | | |
96 | 107 | | |
97 | 108 | | |
| |||
108 | 119 | | |
109 | 120 | | |
110 | 121 | | |
| 122 | + | |
| 123 | + | |
111 | 124 | | |
112 | 125 | | |
113 | 126 | | |
| |||
127 | 140 | | |
128 | 141 | | |
129 | 142 | | |
| 143 | + | |
| 144 | + | |
130 | 145 | | |
131 | 146 | | |
132 | 147 | | |
| |||
0 commit comments