detached f5a831c

refactor(daemon): ListSessions reads snapshotView

commit
f5a831c0c80232f984dbf6867f439bfbfd1f5ab1
author
brice · · 2026-07-29 19:36 UTC
parent
aa7c5e4
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +10 -8
M internal/usecase/daemon/control.go +10 -8
@@ -575,17 +575,19 @@ func (e controlExec) ListSessions(asJSON bool) (string, error) {
575575 sessions = append(sessions, sess)
576576 }
577577 e.d.mu.Unlock()
578- var active *session
578+ snaps := make([]sessionView, 0, len(sessions))
579579 for _, sess := range sessions {
580- if active == nil || sess.mruAt.Load() > active.mruAt.Load() {
581- active = sess
580+ snaps = append(snaps, sess.snapshotView(viewOptions{}))
581+ }
582+ activeIdx := -1
583+ for i, snap := range snaps {
584+ if activeIdx == -1 || snap.mruAt > snaps[activeIdx].mruAt {
585+ activeIdx = i
582586 }
583587 }
584- rows := make([]row, 0, len(sessions))
585- for _, sess := range sessions {
586- sess.mu.Lock()
587- rows = append(rows, row{Name: sess.name, Ephemeral: sess.ephemeral, Tabs: len(sess.tabs), Attached: sess.client != nil, Active: sess == active})
588- sess.mu.Unlock()
588+ rows := make([]row, 0, len(snaps))
589+ for i, snap := range snaps {
590+ rows = append(rows, row{Name: snap.name, Ephemeral: snap.ephemeral, Tabs: snap.tabCount, Attached: snap.attached, Active: i == activeIdx})
589591 }
590592 sort.Slice(rows, func(i, j int) bool { return rows[i].Name < rows[j].Name })
591593 if asJSON {
@@ -575,17 +575,19 @@ func (e controlExec) ListSessions(asJSON bool) (string, error) {
575 sessions = append(sessions, sess)575 sessions = append(sessions, sess)
576 }576 }
577 e.d.mu.Unlock()577 e.d.mu.Unlock()
578- var active *session578+ snaps := make([]sessionView, 0, len(sessions))
579 for _, sess := range sessions {579 for _, sess := range sessions {
580- if active == nil || sess.mruAt.Load() > active.mruAt.Load() {580+ snaps = append(snaps, sess.snapshotView(viewOptions{}))
581- active = sess581+ }
582+ activeIdx := -1
583+ for i, snap := range snaps {
584+ if activeIdx == -1 || snap.mruAt > snaps[activeIdx].mruAt {
585+ activeIdx = i
582 }586 }
583 }587 }
584- rows := make([]row, 0, len(sessions))588+ rows := make([]row, 0, len(snaps))
585- for _, sess := range sessions {589+ for i, snap := range snaps {
586- sess.mu.Lock()590+ rows = append(rows, row{Name: snap.name, Ephemeral: snap.ephemeral, Tabs: snap.tabCount, Attached: snap.attached, Active: i == activeIdx})
587- rows = append(rows, row{Name: sess.name, Ephemeral: sess.ephemeral, Tabs: len(sess.tabs), Attached: sess.client != nil, Active: sess == active})
588- sess.mu.Unlock()
589 }591 }
590 sort.Slice(rows, func(i, j int) bool { return rows[i].Name < rows[j].Name })592 sort.Slice(rows, func(i, j int) bool { return rows[i].Name < rows[j].Name })
591 if asJSON {593 if asJSON {

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