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) <noreply@anthropic.com>
This commit is contained in:
Pierre Martin
2026-03-23 20:42:10 +01:00
parent afa238e29a
commit c921124bcc
2 changed files with 9 additions and 1 deletions

View File

@@ -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
}