Skip to content

Let mass dashboard keys be rebound from a file - #290

Merged
coryodaniel merged 6 commits into
dashboardfrom
dashboard-keys
Nov 30, 2026
Merged

coryodaniel merged 6 commits into
dashboardfrom
dashboard-keys

Conversation

@coryodaniel

Copy link
Copy Markdown
Member

Stacked on #289.

mass dashboard keys can be rebound from a file.

keys:
  approve: [y]
  follow_logs: [f, L]
  quit: [q, ctrl+c]
  help: ["?"]
  deploy: []
  • Where the file lives. By default $XDG_CONFIG_HOME/massdriver/dashboard.yaml, else ~/.config/massdriver/dashboard.yaml. --keys <path> reads another file. A missing default file means the built-in keys. A missing --keys file, an unknown action or key, malformed YAML, or a key doing two things on one screen is an error at startup that names the problem. It's the dashboard's own file, apart from the SDK's credentials config.
  • One keymap. Every key handler looks up named actions per context: tabs, map, replay, runtimes, deployments, logs, approval and rejection boxes, search, config box, write-up and editor, tutorial. Rebinding an action replaces its keys everywhere it appears. The helpdoc has the full table of actions and defaults.
  • Text entry wins. The search box, rejection reason and write-up editor take typed characters before any binding. Binding one of their actions to a single printable key is rejected.
  • Displays follow. The footer key line and every box's footer, the ? legend and tab help, the tutorial's captions and keys step, and the toggle toast all show the bound keys.

?, [ and ] must be quoted in YAML lists, and the helpdoc says so. The default keys and their text are unchanged, and the existing tests pass untouched.

🤖 Generated with Claude Code

@coryodaniel

Copy link
Copy Markdown
Member Author

@claude please review.

@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Claude finished @coryodaniel's task in 2m 33s —— View job


Review of #290: rebindable dashboard keys

I read keys.go, keys_test.go, the cmd/dashboard.go and dashboard.go wiring, and the helpdoc. I did not read the views.go, model.go and tutorial.go call-site changes in full, and I did not run make check or make docs. go test ./internal/commands/dashboard/ passes.

Correction: my first version of this comment made two claims I hadn't checked. It said ctrl+x-style names would be rejected, but keyNames is built from bubbletea's key types and includes the ctrl+<letter> names. It also listed test cases as missing that keys_test.go already has. Both are removed below.

Verdict: the design is sound and I found no blocking bugs. The layering follows CLAUDE.md: cmd/ only reads flags, and the logic and tests sit in internal/commands/dashboard. The tutorial and --playback both go through Run, so --keys applies to them too.

Things to consider

  1. One action name covers several contexts, so an override applies to all of them. newKeymap replaces an action's keys in every context that uses it.

    • close: [x] also changes write-up and configuration.
    • select: [x] drops space from the replay picker, where the default is enter and space.
    • cancel: [esc] drops the picker's t.
    • The PR description says this is intended. I'd add a sentence to the helpdoc listing the actions that appear in more than one context.
  2. You can bind yourself out of quitting. quit: [] removes q and ctrl+c from the tabs, replay picker and tutorial contexts, and no other action takes ctrl+c there. Keeping ctrl+c bound to some quit or force-quit action in every context, or rejecting an empty quit, would stop a user from locking themselves in.

  3. keyNames depends on bubbletea's constant ordering. keys.go builds it by looping t := tea.KeyF20; t <= tea.KeyBackspace. That works today, but a bubbletea upgrade that reorders those constants would silently change which key names are accepted. A test that asserts a fixed set of names (esc, enter, tab, shift+tab, ctrl+c, pgup, shift+up, home, end) would catch it.

  4. Windows paths in openKeys. It builds an fs.FS rooted at VolumeName + separator and trims that prefix off the path. For a UNC path such as \\server\share\dashboard.yaml, VolumeName is \\server\share, so the result works only by accident. Opening the file directly with os.Open would be simpler and would drop the fs.FS indirection. I didn't test this on Windows.

  5. YAML shape errors are vague. A scalar instead of a list (approve: y) surfaces yaml.v3's raw "cannot unmarshal !!str into []string". The test only asserts the message contains yaml. Accepting a bare scalar as a one-item list, or wrapping the error with the action name, would be friendlier.

  6. Keys are read before the non-interactive check. Run calls openKeys before the IsInteractive branch, so a bad default file fails mass dashboard even when output is piped. That may be what you want, since it matches the startup-error behavior in the description. I'm only noting it.

  7. Test gaps. The existing cases cover the error paths and the main remaps well. The gaps I see:

    • keyNames has no test (point 3).
    • Nothing tests that quit: [] leaves a way out (point 2).
    • tabsLabel with rearranged tabs is covered only indirectly through the footer case.

Minor

  • DefaultKeymap panics on error. That is safe because the defaults are static, and a test that calls it would make that a guarantee.
  • Run make docs once more before merging. docs/generated/mass_dashboard.md and docs/helpdocs/dashboard.md both changed, and CI fails on any diff.

coryodaniel and others added 2 commits November 28, 2026 10:36
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	internal/commands/dashboard/tutorial.go
@coryodaniel

Copy link
Copy Markdown
Member Author

Fixed in 7022ae2, with #289 merged in:

  • ctrl+c always quits. quit: [] and force_quit: [] keep it, and binding ctrl+c to any other action fails at startup. In the rejection-reason box, the confirm box and the search box, ctrl+c keeps doing what it already did there. TestInterrupt covers this.
  • Key names come from an explicit list, and TestKeyNames asserts the set.
  • --keys opens with os.Open, and tests pass an opener backed by an in-memory filesystem.
  • YAML: a single key needs no list, and other wrong shapes name the action in the error.
  • Helpdoc: it lists the actions that work in more than one place, and TestDefaultKeymap covers the built-in keys.

@claude please review.

@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Claude finished @coryodaniel's task in 2m 23s —— View job


Review of #290 after 7022ae2: rebindable dashboard keys

Verdict: no blocking issues. Each point from my earlier review is addressed in the code, and I found only minor things in this pass.

What I checked: I read keys.go in full, plus the --keys and openKeys wiring and the TestInterrupt and TestKeyNames cases. go test ./internal/commands/dashboard/ passes. I did not read the views.go, model.go, postmortem.go and tutorial.go call-site changes line by line. I did not run make check or make docs, so CI is the check on lint and on the docs diff.

Earlier points, now resolved

  • ctrl+c: newKeymap appends ctrl+c back to every binding that had it by default. readKeyList rejects ctrl+c for actions that never had it. TestInterrupt covers quit: [], a rebound quit, the tutorial, and force_quit: [] in the write-up.
  • Key names: the set is now an explicit list, and TestKeyNames asserts it.
  • --keys: it opens with os.Open through an injected opener, so the Windows fs.FS problem is gone.
  • YAML shapes: a single key needs no list, ~ and an empty value mean no keys, and other wrong shapes name the action.

Remaining nits

  1. cancel: [ctrl+c] passes the per-action check and then fails with a confusing error.
    • readKeyList allows ctrl+c for cancel because cancel has it by default in the rejection box.
    • cancel also applies in the replay picker, where quit already owns ctrl+c. The user gets "ctrl+c is bound to both quit and cancel in replay picker".
    • That is still a startup error, so nothing breaks. The message doesn't point back at the action the user typed, and the check could be per context.
    • In the search context, where ctrl+c isn't bound by default, the same override would make ctrl+c cancel the search where it didn't before. That differs from "ctrl+c keeps doing what it already did there". A per-context check would cover this too.
  2. keys.go:38: type action = string gives up type safety. The comment says why, to keep exhaustive quiet. The cost is that k.action(ctx, key) and the readKeyList name parameter accept any string. A typo'd constant would not be caught at compile time. This is a trade-off, not a bug.
  3. LoadKeys returns a bare no such file for a missing required file. openKeys wraps it with the path, so users see key bindings in <path>: no such file. A caller of LoadKeys other than openKeys would lose the path.
  4. Typing contexts only reject single-rune keys. alt+x is allowed in the search box, rejection reason and editor. That seems right, since it isn't typed text, but the helpdoc could say so.

Layering and CLAUDE.md

  • cmd/ only reads the flag, and the logic and tests sit in internal/commands/dashboard.
  • The keys file is separate from the SDK config, as the description says.
  • make docs still needs a final run, because the flag help text changed in 7022ae2.

coryodaniel and others added 2 commits November 29, 2026 22:02
Listing it for cancel spread it to the replay picker and the search box,
where it either clashed with quit or changed what ctrl+c does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coryodaniel

Copy link
Copy Markdown
Member Author

c7c6e2e, with #289 merged in:

  • 1, cancel: [ctrl+c]: listing ctrl+c for an action that has it by default is now a no-op. newKeymap already puts it back only in the contexts where it's a default, so it can't spread to the replay picker or the search box. There's a test case for it.
  • 4: the helpdoc says a named key or an alt+ key works in the typing boxes.

No change:

  • 2, type action = string: kept for exhaustive, as the comment says.
  • 3, bare no such file from LoadKeys: the only caller wraps it with the path.

@claude please review.

@claude

claude Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Claude finished @coryodaniel's task in 2m 2s —— View job


Review of #290 after c7c6e2e: rebindable dashboard keys

Verdict: no issues. Both changes do what the description says.

What I checked: I read the c7c6e2e diff (keys.go, keys_test.go, the helpdoc and generated doc), plus readKeyList and newKeymap in full. go test ./internal/commands/dashboard/ passes. I did not run make check or make docs, so CI is the check on lint and the docs diff.

Your two changes

  • ctrl+c listed for an action that has it by default.
    • readKeyList now skips ctrl+c instead of keeping it, so listing it is a no-op.
    • newKeymap (keys.go:264) appends it back only for the bindings whose defaults include it. So cancel: [esc, ctrl+c] can't carry ctrl+c into the replay picker, where quit owns it. It also can't reach the search box, where it isn't a default.
    • This also fixes the confusing "bound to both quit and cancel" error I raised last time.
    • The case interrupt where it is a default covers it. approve: [ctrl+c] still fails with the named-action error.
  • Helpdoc. It now says a named key or an alt+ key works in the typing boxes. That matches validate, which only rejects single-rune keys there. docs/generated/mass_dashboard.md changed in step with it.

Your two "no change" calls

Both are fine.

  • type action = string is a documented trade-off for exhaustive.
  • LoadKeys has one caller, and openKeys wraps the error with the path.

One optional nit

  • cancel: [ctrl+c] leaves cancel with no keys in the contexts where ctrl+c isn't its default. This is the same as cancel: [], so I'd expect it, but a user who writes it may think they bound cancel to ctrl+c. Nothing breaks, and the helpdoc already says ctrl+c can't be bound to anything else. Ignore it if you like.

Base automatically changed from dashboard-light-refresh to dashboard November 30, 2026 06:12
@coryodaniel
coryodaniel merged commit c7c6e2e into dashboard Nov 30, 2026
7 checks passed
@coryodaniel
coryodaniel deleted the dashboard-keys branch November 30, 2026 06:12
@coryodaniel

Copy link
Copy Markdown
Member Author

Folded into #272.

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