feat: sort sessions by latest message time instead of creation time

Use `last_active` from SQLite (max message timestamp) for accurate
sorting, with fallback chain: last_active → ended_at → started_at.
CLI mode lacks last_active so falls back to ended_at.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ekko
2026-04-19 23:32:01 +08:00
parent 969e56b45e
commit d3817556ac
3 changed files with 3 additions and 3 deletions
@@ -85,8 +85,7 @@ function sortSessionsWithActiveFirst(items: Session[]): Session[] {
const aLive = chatStore.isSessionLive(a.id)
const bLive = chatStore.isSessionLive(b.id)
if (aLive !== bLive) return aLive ? -1 : 1
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt
return b.updatedAt - a.updatedAt
return (b.updatedAt || 0) - (a.updatedAt || 0)
})
}