From c921124bcc1c696c802e0dd6bfddc1c97b696e0b Mon Sep 17 00:00:00 2001 From: Pierre Martin Date: Mon, 23 Mar 2026 20:42:10 +0100 Subject: [PATCH] feat: sort sessions by workspace number in list output Also restart daemon on make watch so new binary is used. Co-Authored-By: Claude Opus 4.6 (1M context) --- Makefile | 1 + daemon.go | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1bc30e9..2b86940 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ vet: go vet ./... watch: build + -./vmux stop 2>/dev/null watch --color -n2 ./vmux list clean: diff --git a/daemon.go b/daemon.go index c799b25..4dc8415 100644 --- a/daemon.go +++ b/daemon.go @@ -8,6 +8,8 @@ import ( "net/http" "os" "path/filepath" + "sort" + "strconv" "sync" "time" ) @@ -60,7 +62,7 @@ func (r *SessionRegistry) Update(info SessionInfo) { existing.PrevState = info.State } -// List returns a snapshot of all tracked sessions. +// List returns a snapshot of all tracked sessions, sorted by workspace number. func (r *SessionRegistry) List() []SessionInfo { r.mu.RLock() defer r.mu.RUnlock() @@ -69,6 +71,11 @@ func (r *SessionRegistry) List() []SessionInfo { for _, ts := range r.sessions { result = append(result, ts.Info) } + sort.Slice(result, func(i, j int) bool { + wi, _ := strconv.Atoi(result[i].Workspace) + wj, _ := strconv.Atoi(result[j].Workspace) + return wi < wj + }) return result }