detached 67b1767

refactor(daemon): share bar anchor names between run and cleanup

Introduce barAnchorTopRight/barAnchorBottomRight constants and a
barAnchors slice so clearBarScriptsForSession's lastFailure cleanup
loops over the same anchor set that runBarScripts executes, instead
of duplicating "top-right"/"bottom-right" literals in both places.
commit
67b1767f36b1b65436516f8cea8e948b76a990c6
author
brice · · 2026-07-20 09:53 UTC
parent
8755162
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +16 -4
M internal/usecase/daemon/bar_refresh.go +16 -4
@@ -13,6 +13,17 @@ type barScriptExecutor interface {
1313 run(ctx context.Context, command string, env []string, scriptCtx barScriptContext) (string, error)
1414 }
1515
16+// Anchor names, exported to bar scripts as VEV_ANCHOR and documented in
17+// docs/configuration.md. barAnchors must list every anchor so cleanup in
18+// clearBarScriptsForSession stays in sync with the anchors run in
19+// runBarScripts.
20+const (
21+ barAnchorTopRight = "top-right"
22+ barAnchorBottomRight = "bottom-right"
23+)
24+
25+var barAnchors = []string{barAnchorTopRight, barAnchorBottomRight}
26+
1627 type barScriptConfig struct {
1728 topRight string
1829 bottomRight string
@@ -207,8 +218,9 @@ func (d *Daemon) clearBarScriptsForSession(id domain.SessionID) {
207218 delete(d.barScripts.lastContext, id)
208219 delete(d.barScripts.running, id)
209220 delete(d.barScripts.pending, id)
210- delete(d.barScripts.lastFailure, barScriptFailureKey{id: id, anchor: "top-right"})
211- delete(d.barScripts.lastFailure, barScriptFailureKey{id: id, anchor: "bottom-right"})
221+ for _, anchor := range barAnchors {
222+ delete(d.barScripts.lastFailure, barScriptFailureKey{id: id, anchor: anchor})
223+ }
212224 }
213225
214226 // shouldLogBarFailure reports whether this failure differs from the last one
@@ -329,8 +341,8 @@ func (d *Daemon) runBarScripts(sess *session, runner barScriptExecutor, cfg barS
329341 if ctx == nil {
330342 ctx = context.Background()
331343 }
332- top, topOK := d.runOneBarScript(ctx, runner, cfg.topRight, env, base, "top-right", sess)
333- bottom, bottomOK := d.runOneBarScript(ctx, runner, cfg.bottomRight, env, base, "bottom-right", sess)
344+ top, topOK := d.runOneBarScript(ctx, runner, cfg.topRight, env, base, barAnchorTopRight, sess)
345+ bottom, bottomOK := d.runOneBarScript(ctx, runner, cfg.bottomRight, env, base, barAnchorBottomRight, sess)
334346 d.barScripts.mu.Lock()
335347 d.barScripts.initLocked()
336348 if !d.barScripts.running[sess.id] || d.barScripts.version != version {
@@ -13,6 +13,17 @@ type barScriptExecutor interface {
13 run(ctx context.Context, command string, env []string, scriptCtx barScriptContext) (string, error)13 run(ctx context.Context, command string, env []string, scriptCtx barScriptContext) (string, error)
14 }14 }
15 15
16+// Anchor names, exported to bar scripts as VEV_ANCHOR and documented in
17+// docs/configuration.md. barAnchors must list every anchor so cleanup in
18+// clearBarScriptsForSession stays in sync with the anchors run in
19+// runBarScripts.
20+const (
21+ barAnchorTopRight = "top-right"
22+ barAnchorBottomRight = "bottom-right"
23+)
24+
25+var barAnchors = []string{barAnchorTopRight, barAnchorBottomRight}
26+
16 type barScriptConfig struct {27 type barScriptConfig struct {
17 topRight string28 topRight string
18 bottomRight string29 bottomRight string
@@ -207,8 +218,9 @@ func (d *Daemon) clearBarScriptsForSession(id domain.SessionID) {
207 delete(d.barScripts.lastContext, id)218 delete(d.barScripts.lastContext, id)
208 delete(d.barScripts.running, id)219 delete(d.barScripts.running, id)
209 delete(d.barScripts.pending, id)220 delete(d.barScripts.pending, id)
210- delete(d.barScripts.lastFailure, barScriptFailureKey{id: id, anchor: "top-right"})221+ for _, anchor := range barAnchors {
211- delete(d.barScripts.lastFailure, barScriptFailureKey{id: id, anchor: "bottom-right"})222+ delete(d.barScripts.lastFailure, barScriptFailureKey{id: id, anchor: anchor})
223+ }
212 }224 }
213 225
214 // shouldLogBarFailure reports whether this failure differs from the last one226 // shouldLogBarFailure reports whether this failure differs from the last one
@@ -329,8 +341,8 @@ func (d *Daemon) runBarScripts(sess *session, runner barScriptExecutor, cfg barS
329 if ctx == nil {341 if ctx == nil {
330 ctx = context.Background()342 ctx = context.Background()
331 }343 }
332- top, topOK := d.runOneBarScript(ctx, runner, cfg.topRight, env, base, "top-right", sess)344+ top, topOK := d.runOneBarScript(ctx, runner, cfg.topRight, env, base, barAnchorTopRight, sess)
333- bottom, bottomOK := d.runOneBarScript(ctx, runner, cfg.bottomRight, env, base, "bottom-right", sess)345+ bottom, bottomOK := d.runOneBarScript(ctx, runner, cfg.bottomRight, env, base, barAnchorBottomRight, sess)
334 d.barScripts.mu.Lock()346 d.barScripts.mu.Lock()
335 d.barScripts.initLocked()347 d.barScripts.initLocked()
336 if !d.barScripts.running[sess.id] || d.barScripts.version != version {348 if !d.barScripts.running[sess.id] || d.barScripts.version != version {

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 12

Tags 11

↑↓ moveenter openesc close