Skip to content

feat(tui): rebindable keys — CLI flag, validator, YAML settings, and runtime dispatch - #222

Merged
jhrozek merged 4 commits into
mainfrom
rebindable-keys
Jul 1, 2026
Merged

jhrozek merged 4 commits into
mainfrom
rebindable-keys

Conversation

@jhrozek

@jhrozek jhrozek commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Wire the full rebindable-keys pipeline for mecatui:

  • cmd/mecatui/config.go: --keymap CLI flag (repeatable, Action=chord[,chord2])
  • cmd/mecatui/main.go: keyOverridesFromConfig() parses flag values into the map[string][]string the ui layer expects; applyKeyOverridesToDeps() plumbs them through Deps.KeyOverrides.
  • cmd/mecatui/ui/keys.go: keyMap struct with all ~30 named bindings, defaultKeys() establishing defaults, and applyKeyOverrides() returning a copy of the keyMap with overridden chords + rebuilt help short keys.
  • cmd/mecatui/ui/model.go: Deps.KeyOverrides field (nil = no overrides); New() calls applyKeyOverrides(defaultKeys(), deps.KeyOverrides) so the live keys reflect CLI overrides from turn zero.
  • cmd/mecatui/keymap/validator.go + _test.go: ValidateActions() rejects unknown action names at load time so a typo --keymap Foo=bar fails early rather than silently ignoring.
  • cmd/mecatui/keymap_wiring_yaml.go: operator-settings.yaml reader (future use; inert until wired into the flag-resolution chain — reads keymap: block from settings.yaml alongside the CLI).
  • .gitignore: fix bare 'mecatui' pattern to '/mecatui' so it doesn't shadow the cmd/mecatui/ directory tree.

The welcome splash + help overlay still hardcode some keys; that follow-up landed as 666ec22.

feat(tui): show live key bindings on welcome splash and help overlay

The rebindable-keys system (--keymap) was wired through the CLI/config/keymap pipeline and applied to runtime dispatch, but the welcome screen (doggo mascot + wordmark + affordances) and the '?' help overlay still hardcoded 'ctrl+a' for the agents overlay key and 'home/end' for scroll-jump key markings.

Changes:

  • zeroStateRows() now takes an agentsKey parameter so the welcome splash shows the live binding instead of the literal 'ctrl+a'.
  • renderHelpOverlay() and helpBody() accept agentsKey + jumpKey strings consumed from the model's keyMap via agentsKeyMarking() and the new jumpKeyMarking() methods.
  • Removed the dead currentJumpMarking() placeholder.
  • Both legacyZeroStateBody() and zeroStateAffordanceRows() call m.agentsKeyMarking().
  • Test helper m_helpBody() updated to pass the default key values.

With default key bindings the output is byte-identical (all golden tests pass). With --keymap Agents=ctrl+k the splash and overlay now show ctrl+k.

…runtime dispatch

Wire the full rebindable-keys pipeline for mecatui:

- cmd/mecatui/config.go: --keymap CLI flag (repeatable, Action=chord[,chord2])
- cmd/mecatui/main.go: keyOverridesFromConfig() parses flag values into the
  map[string][]string the ui layer expects; applyKeyOverridesToDeps() plumbs
  them through Deps.KeyOverrides.
- cmd/mecatui/ui/keys.go: keyMap struct with all ~30 named bindings,
  defaultKeys() establishing defaults, and applyKeyOverrides() returning a copy
  of the keyMap with overridden chords + rebuilt help short keys.
- cmd/mecatui/ui/model.go: Deps.KeyOverrides field (nil = no overrides);
  New() calls applyKeyOverrides(defaultKeys(), deps.KeyOverrides) so the live
  keys reflect CLI overrides from turn zero.
- cmd/mecatui/keymap/validator.go + _test.go: ValidateActions() rejects unknown
  action names at load time so a typo --keymap Foo=bar fails early rather than
  silently ignoring.
- cmd/mecatui/keymap_wiring_yaml.go: operator-settings.yaml reader (future
  use; inert until wired into the flag-resolution chain — reads keymap: block
  from settings.yaml alongside the CLI).
- .gitignore: fix bare 'mecatui' pattern to '/mecatui' so it doesn't shadow
  the cmd/mecatui/ directory tree.

The welcome splash + help overlay still hardcode some keys; that follow-up
landed as 666ec22.

Co-Authored-By: mecatl <[email protected]>

feat(tui): show live key bindings on welcome splash and help overlay

The rebindable-keys system (--keymap) was wired through the CLI/config/keymap
pipeline and applied to runtime dispatch, but the welcome screen (doggo mascot +
wordmark + affordances) and the '?' help overlay still hardcoded 'ctrl+a' for
the agents overlay key and 'home/end' for scroll-jump key markings.

Changes:
- zeroStateRows() now takes an agentsKey parameter so the welcome splash shows
  the live binding instead of the literal 'ctrl+a'.
- renderHelpOverlay() and helpBody() accept agentsKey + jumpKey strings
  consumed from the model's keyMap via agentsKeyMarking() and the new
  jumpKeyMarking() methods.
- Removed the dead currentJumpMarking() placeholder.
- Both legacyZeroStateBody() and zeroStateAffordanceRows() call
  m.agentsKeyMarking().
- Test helper m_helpBody() updated to pass the default key values.

With default key bindings the output is byte-identical (all golden tests pass).
With --keymap Agents=ctrl+k the splash and overlay now show ctrl+k.

Co-Authored-By: mecatl <[email protected]>
jhrozek and others added 3 commits July 1, 2026 11:06
- gci import ordering in keys.go, model.go, validator.go, validator_test.go
- gocyclo: refactor applyKeyOverrides from 30+ if-blocks into a
  data-driven setter map loop (complexity 35 → ~6)
- revive: add package comment to keymap/validator.go; simplify
  if-return at the end of Validate() to a single return
- staticcheck S1009: drop nil check on ov (len(nil map) is 0)
- unused: remove dead approval var
- Regenerate llms.txt via matlatl (stale from doc changes in this branch)

Co-Authored-By: mecatl <[email protected]>
- gci import ordering in keys.go, model.go, validator.go, validator_test.go
- gocyclo: refactor applyKeyOverrides from 30+ if-blocks into a
  data-driven setter map loop (complexity 35 → ~6)
- revive: add package comment to keymap/validator.go; simplify
  if-return at the end of Validate() to a single return
- staticcheck S1009: drop nil check on ov (len(nil map) is 0)
- unused: remove dead approval var
- Regenerate llms.txt via matlatl (previous commit had stale content
  from a failed go run — the CI's matlatl binary produced a clean file)

Co-Authored-By: mecatl <[email protected]>
staticcheck SA5011 does not see t.Fatal/t.Fatalf as terminal and warns
on subsequent nil dereference across the whole codebase. Adding 'return'
after each nil-check guard resolves the CI Lint failure.

Files fixed (11 files, 16 sites):
- internal/adapter/anthropic/multimodal_test.go
- internal/adapter/anthropic/stream_test.go
- internal/adapter/mcpperf/mcpperf_test.go
- internal/adapter/memory/loop_search_integration_test.go
- internal/adapter/permconfig/claudeimport_test.go
- internal/adapter/permconfig/guardrails_test.go
- internal/adapter/permconfig/models_project_test.go
- internal/adapter/permconfig/models_test.go
- internal/adapter/permconfig/subagent_test.go
- internal/adapter/providercatalog/catalog_test.go
- internal/cliconfig/cliconfig_test.go

Co-Authored-By: mecatl <[email protected]>
@jhrozek
jhrozek merged commit 5286a83 into main Jul 1, 2026
13 checks passed
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