detached 8755162

docs(daemon): fix misleading comments in bar script env handling

- Record why collectBarScriptContext can capture sess.env without
  copying it, unlike every other reader in the package.
- Correct the TestRefreshBarScriptsAllSessionsForcesRun comment: the
  60s interval is not actually exercised since lastRefresh is zero on
  a fresh session, so the interval check is skipped regardless of
  force.
commit
87551626c75d9920b729fa1a68f624d1d3c6300a
author
brice · · 2026-07-20 08:45 UTC
parent
56f6958
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +8 -2
M internal/usecase/daemon/bar_refresh.go +3 -0
@@ -107,6 +107,9 @@ func (d *Daemon) collectBarScriptContext(sess *session, anchor string) (barScrip
107107 }
108108 sess.mu.Lock()
109109 ctx.Session = sess.name
110+ // No copy needed: writers always replace sess.env with a whole fresh
111+ // slice under sess.mu (daemon.go, resume.go), and nothing mutates the
112+ // backing array in place, so capturing the header here is safe.
110113 env := sess.env
111114 active := sess.active
112115 var tb *tab
@@ -107,6 +107,9 @@ func (d *Daemon) collectBarScriptContext(sess *session, anchor string) (barScrip
107 }107 }
108 sess.mu.Lock()108 sess.mu.Lock()
109 ctx.Session = sess.name109 ctx.Session = sess.name
110+ // No copy needed: writers always replace sess.env with a whole fresh
111+ // slice under sess.mu (daemon.go, resume.go), and nothing mutates the
112+ // backing array in place, so capturing the header here is safe.
110 env := sess.env113 env := sess.env
111 active := sess.active114 active := sess.active
112 var tb *tab115 var tb *tab
M internal/usecase/daemon/bar_refresh_test.go +5 -2
@@ -222,8 +222,11 @@ func TestRefreshBarScriptsAllSessionsForcesRun(t *testing.T) {
222222 sess.client = &attachedClient{size: domain.Size{Cols: 80, Rows: 24}}
223223 d.sessions = map[domain.SessionID]*session{sess.id: sess}
224224
225- // Nothing has run yet, and the 60s interval means a non-forced tick would
226- // not be due for a long time.
225+ // Verifies refreshBarScriptsAllSessions iterates every live session and
226+ // dispatches a run for each. This does not exercise force specifically:
227+ // lastRefresh is zero on a fresh session, so refreshBarScriptsIfDue skips
228+ // the interval check regardless of force, and a non-forcing call would
229+ // pass this test too.
227230 d.refreshBarScriptsAllSessions()
228231 waitBarRefreshIdle(t, d)
229232
@@ -222,8 +222,11 @@ func TestRefreshBarScriptsAllSessionsForcesRun(t *testing.T) {
222 sess.client = &attachedClient{size: domain.Size{Cols: 80, Rows: 24}}222 sess.client = &attachedClient{size: domain.Size{Cols: 80, Rows: 24}}
223 d.sessions = map[domain.SessionID]*session{sess.id: sess}223 d.sessions = map[domain.SessionID]*session{sess.id: sess}
224 224
225- // Nothing has run yet, and the 60s interval means a non-forced tick would225+ // Verifies refreshBarScriptsAllSessions iterates every live session and
226- // not be due for a long time.226+ // dispatches a run for each. This does not exercise force specifically:
227+ // lastRefresh is zero on a fresh session, so refreshBarScriptsIfDue skips
228+ // the interval check regardless of force, and a non-forcing call would
229+ // pass this test too.
227 d.refreshBarScriptsAllSessions()230 d.refreshBarScriptsAllSessions()
228 waitBarRefreshIdle(t, d)231 waitBarRefreshIdle(t, d)
229 232

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