From d3817556ac2f3412a4f065b807efb0bd2e1ffab7 Mon Sep 17 00:00:00 2001 From: ekko Date: Sun, 19 Apr 2026 23:32:01 +0800 Subject: [PATCH] feat: sort sessions by latest message time instead of creation time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- packages/client/src/api/hermes/sessions.ts | 1 + packages/client/src/components/hermes/chat/ChatPanel.vue | 3 +-- packages/client/src/stores/hermes/chat.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/client/src/api/hermes/sessions.ts b/packages/client/src/api/hermes/sessions.ts index ae27523..1201ac1 100644 --- a/packages/client/src/api/hermes/sessions.ts +++ b/packages/client/src/api/hermes/sessions.ts @@ -7,6 +7,7 @@ export interface SessionSummary { title: string | null started_at: number ended_at: number | null + last_active?: number message_count: number tool_call_count: number input_tokens: number diff --git a/packages/client/src/components/hermes/chat/ChatPanel.vue b/packages/client/src/components/hermes/chat/ChatPanel.vue index 369895f..26b69de 100644 --- a/packages/client/src/components/hermes/chat/ChatPanel.vue +++ b/packages/client/src/components/hermes/chat/ChatPanel.vue @@ -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) }) } diff --git a/packages/client/src/stores/hermes/chat.ts b/packages/client/src/stores/hermes/chat.ts index e27f474..92c8882 100644 --- a/packages/client/src/stores/hermes/chat.ts +++ b/packages/client/src/stores/hermes/chat.ts @@ -151,7 +151,7 @@ function mapHermesSession(s: SessionSummary): Session { source: s.source || undefined, messages: [], createdAt: Math.round(s.started_at * 1000), - updatedAt: Math.round((s.ended_at || s.started_at) * 1000), + updatedAt: Math.round((s.last_active || s.ended_at || s.started_at) * 1000), model: s.model, provider: (s as any).billing_provider || '', messageCount: s.message_count,