detached e9f98b3

fix(approve): clearer panel focus indicator and unhandled key feedback (#19)

- Footer now shows '● this panel has focus' so users know keypresses
  are going to the panel, not the editor
- Prompt line uses '› approve this action? [y/n]' cursor glyph
- Unhandled keys re-render with '› unrecognised key — press y or n'
  instead of silently swallowing the input
commit
e9f98b35780adc1e8ebf3db2079e1d9961a285ee
author
Raymond Gasper · · 2026-06-08 16:35 UTC
parent
5ffdafa
signature
unsigned
1 file · +22 -9
M examples/extensions/approve/main.go +22 -9
@@ -83,6 +83,22 @@ func main() {
8383 pid := nextPID()
8484 decision := make(chan bool, 1)
8585
86+ buildLines := func(hint string) []string {
87+ lines := []string{
88+ " Action: " + in.Action,
89+ }
90+ if strings.TrimSpace(in.Reason) != "" {
91+ lines = append(lines, " Reason: "+in.Reason)
92+ }
93+ lines = append(lines, "")
94+ lines = append(lines, " "+hint)
95+ return lines
96+ }
97+
98+ const footer = "● this panel has focus — y approve n deny esc cancel"
99+ const prompt = "› approve this action? [y/n]"
100+ const badKey = "› unrecognised key — press y to approve or n to deny"
101+
86102 // Register key handler before opening the panel so there
87103 // is no window where a key could arrive unhandled.
88104 e.OnPanelKey(pid, func(key, text string) {
@@ -94,6 +110,11 @@ func main() {
94110 key == "esc":
95111 e.ClosePanel(pid)
96112 decision <- false
113+ default:
114+ // Unknown key: re-render with a nudge so the user
115+ // knows the panel is alive and what to press.
116+ e.RenderPanel(pid, "Approval required",
117+ buildLines(badKey), footer)
97118 }
98119 }, func() {
99120 // Host closed the panel (e.g. user navigated away).
@@ -103,16 +124,8 @@ func main() {
103124 }
104125 })
105126
106- lines := []string{
107- " Action: " + in.Action,
108- }
109- if strings.TrimSpace(in.Reason) != "" {
110- lines = append(lines, " Reason: "+in.Reason)
111- }
112- lines = append(lines, "", " y approve n / esc deny")
113-
114127 // Open the panel spontaneously from inside the tool handler.
115- e.OpenPanel(pid, "Approval required", lines, "y approve n deny esc cancel")
128+ e.OpenPanel(pid, "Approval required", buildLines(prompt), footer)
116129
117130 // Block until the user responds.
118131 if <-decision {
@@ -83,6 +83,22 @@ func main() {
83 pid := nextPID()83 pid := nextPID()
84 decision := make(chan bool, 1)84 decision := make(chan bool, 1)
85 85
86+ buildLines := func(hint string) []string {
87+ lines := []string{
88+ " Action: " + in.Action,
89+ }
90+ if strings.TrimSpace(in.Reason) != "" {
91+ lines = append(lines, " Reason: "+in.Reason)
92+ }
93+ lines = append(lines, "")
94+ lines = append(lines, " "+hint)
95+ return lines
96+ }
97+
98+ const footer = "● this panel has focus — y approve n deny esc cancel"
99+ const prompt = "› approve this action? [y/n]"
100+ const badKey = "› unrecognised key — press y to approve or n to deny"
101+
86 // Register key handler before opening the panel so there102 // Register key handler before opening the panel so there
87 // is no window where a key could arrive unhandled.103 // is no window where a key could arrive unhandled.
88 e.OnPanelKey(pid, func(key, text string) {104 e.OnPanelKey(pid, func(key, text string) {
@@ -94,6 +110,11 @@ func main() {
94 key == "esc":110 key == "esc":
95 e.ClosePanel(pid)111 e.ClosePanel(pid)
96 decision <- false112 decision <- false
113+ default:
114+ // Unknown key: re-render with a nudge so the user
115+ // knows the panel is alive and what to press.
116+ e.RenderPanel(pid, "Approval required",
117+ buildLines(badKey), footer)
97 }118 }
98 }, func() {119 }, func() {
99 // Host closed the panel (e.g. user navigated away).120 // Host closed the panel (e.g. user navigated away).
@@ -103,16 +124,8 @@ func main() {
103 }124 }
104 })125 })
105 126
106- lines := []string{
107- " Action: " + in.Action,
108- }
109- if strings.TrimSpace(in.Reason) != "" {
110- lines = append(lines, " Reason: "+in.Reason)
111- }
112- lines = append(lines, "", " y approve n / esc deny")
113-
114 // Open the panel spontaneously from inside the tool handler.127 // Open the panel spontaneously from inside the tool handler.
115- e.OpenPanel(pid, "Approval required", lines, "y approve n deny esc cancel")128+ e.OpenPanel(pid, "Approval required", buildLines(prompt), footer)
116 129
117 // Block until the user responds.130 // Block until the user responds.
118 if <-decision {131 if <-decision {

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 1

Tags 476

↑↓ moveenter openesc close