wip: refactoring tui

This commit is contained in:
adamdottv 2025-06-02 12:00:21 -05:00
commit 8b5394e031
No known key found for this signature in database
GPG key ID: 9CB48779AF150E75
2 changed files with 8 additions and 2 deletions

View file

@ -3,6 +3,7 @@ package app
import (
"context"
"fmt"
"sort"
"log/slog"
@ -137,8 +138,13 @@ func (a *App) ListSessions(ctx context.Context) ([]client.SessionInfo, error) {
if resp.JSON200 == nil {
return []client.SessionInfo{}, nil
}
sessions := *resp.JSON200
// sort sessions by last message time
sort.Slice(sessions, func(i, j int) bool {
return sessions[i].Time.Created-sessions[j].Time.Created > 0
})
return sessions, nil
}