detached e6c3832

feat(input): add hot reload for keyboard shortcuts

commit
e6c3832537e73ab84f76a1991ef1e09d8aadeff8
author
bnema · · 2026-01-11 14:21 UTC
committer
brice · · 2026-01-24 06:22 UTC
parent
7e934a8
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +18 -1
M internal/ui/app.go +5 -1
@@ -1946,11 +1946,15 @@ func (a *App) initConfigWatcher(ctx context.Context) {
19461946 return
19471947 }
19481948
1949- // Only appearance is hot-reloaded for now.
1949+ // Hot-reload appearance and keybindings on config change.
19501950 a.configManager.OnConfigChange(func(newCfg *config.Config) {
19511951 cfgCopy := newCfg
19521952 cb := glib.SourceFunc(func(_ uintptr) bool {
19531953 a.applyAppearanceConfig(ctx, cfgCopy)
1954+ // Reload keyboard shortcuts
1955+ if a.keyboardHandler != nil {
1956+ a.keyboardHandler.ReloadShortcuts(ctx, cfgCopy)
1957+ }
19541958 return false
19551959 })
19561960 glib.IdleAdd(&cb, 0)
@@ -1946,11 +1946,15 @@ func (a *App) initConfigWatcher(ctx context.Context) {
1946 return1946 return
1947 }1947 }
1948 1948
1949- // Only appearance is hot-reloaded for now.1949+ // Hot-reload appearance and keybindings on config change.
1950 a.configManager.OnConfigChange(func(newCfg *config.Config) {1950 a.configManager.OnConfigChange(func(newCfg *config.Config) {
1951 cfgCopy := newCfg1951 cfgCopy := newCfg
1952 cb := glib.SourceFunc(func(_ uintptr) bool {1952 cb := glib.SourceFunc(func(_ uintptr) bool {
1953 a.applyAppearanceConfig(ctx, cfgCopy)1953 a.applyAppearanceConfig(ctx, cfgCopy)
1954+ // Reload keyboard shortcuts
1955+ if a.keyboardHandler != nil {
1956+ a.keyboardHandler.ReloadShortcuts(ctx, cfgCopy)
1957+ }
1954 return false1958 return false
1955 })1959 })
1956 glib.IdleAdd(&cb, 0)1960 glib.IdleAdd(&cb, 0)
M internal/ui/input/keyboard.go +13 -0
@@ -79,6 +79,19 @@ func (h *KeyboardHandler) SetOnAction(fn ActionHandler) {
7979 h.onAction = fn
8080 }
8181
82+// ReloadShortcuts rebuilds the shortcut set from the new config.
83+// This enables hot-reloading of keybindings without restarting.
84+func (h *KeyboardHandler) ReloadShortcuts(ctx context.Context, cfg *config.Config) {
85+ h.mu.Lock()
86+ defer h.mu.Unlock()
87+
88+ log := logging.FromContext(ctx)
89+ log.Debug().Msg("reloading shortcuts from config")
90+
91+ h.shortcuts = NewShortcutSet(ctx, cfg)
92+ h.cfg = cfg
93+}
94+
8295 // SetOnModeChange sets the callback for mode changes (for UI updates).
8396 func (h *KeyboardHandler) SetOnModeChange(fn func(from, to Mode)) {
8497 h.modal.SetOnModeChange(fn)
@@ -79,6 +79,19 @@ func (h *KeyboardHandler) SetOnAction(fn ActionHandler) {
79 h.onAction = fn79 h.onAction = fn
80 }80 }
81 81
82+// ReloadShortcuts rebuilds the shortcut set from the new config.
83+// This enables hot-reloading of keybindings without restarting.
84+func (h *KeyboardHandler) ReloadShortcuts(ctx context.Context, cfg *config.Config) {
85+ h.mu.Lock()
86+ defer h.mu.Unlock()
87+
88+ log := logging.FromContext(ctx)
89+ log.Debug().Msg("reloading shortcuts from config")
90+
91+ h.shortcuts = NewShortcutSet(ctx, cfg)
92+ h.cfg = cfg
93+}
94+
82 // SetOnModeChange sets the callback for mode changes (for UI updates).95 // SetOnModeChange sets the callback for mode changes (for UI updates).
83 func (h *KeyboardHandler) SetOnModeChange(fn func(from, to Mode)) {96 func (h *KeyboardHandler) SetOnModeChange(fn func(from, to Mode)) {
84 h.modal.SetOnModeChange(fn)97 h.modal.SetOnModeChange(fn)

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close