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 ./...
|
go vet ./...
|
||||||
|
|
||||||
watch: build
|
watch: build
|
||||||
|
-./vmux stop 2>/dev/null
|
||||||
watch --color -n2 ./vmux list
|
watch --color -n2 ./vmux list
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -60,7 +62,7 @@ func (r *SessionRegistry) Update(info SessionInfo) {
|
|||||||
existing.PrevState = info.State
|
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 {
|
func (r *SessionRegistry) List() []SessionInfo {
|
||||||
r.mu.RLock()
|
r.mu.RLock()
|
||||||
defer r.mu.RUnlock()
|
defer r.mu.RUnlock()
|
||||||
@@ -69,6 +71,11 @@ func (r *SessionRegistry) List() []SessionInfo {
|
|||||||
for _, ts := range r.sessions {
|
for _, ts := range r.sessions {
|
||||||
result = append(result, ts.Info)
|
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
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user