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:
1
Makefile
1
Makefile
@@ -12,6 +12,7 @@ vet:
|
||||
go vet ./...
|
||||
|
||||
watch: build
|
||||
-./vmux stop 2>/dev/null
|
||||
watch --color -n2 ./vmux list
|
||||
|
||||
clean:
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user