feat: add session grouping by source with collapsible accordion

- Group sessions by source in sidebar (api_server first, cron last)
- Accordion behavior: only one group expanded at a time
- Auto-select first session when expanding a group
- Backfill session titles from first user message in listSessions
- Remove chat header model badge
- Fix toolPreview type error for non-string values
- New chats default to api_server source

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ekko
2026-04-13 00:52:34 +08:00
parent 8663704133
commit 081c60a15f
3 changed files with 144 additions and 86 deletions
+9 -1
View File
@@ -53,12 +53,20 @@ export async function listSessions(source?: string, limit?: number): Promise<Her
for (const line of lines) {
try {
const raw: HermesSessionFull = JSON.parse(line)
let title = raw.title
if (!title && raw.messages) {
const firstUser = raw.messages.find((m: any) => m.role === 'user')
if (firstUser?.content) {
const t = String(firstUser.content).slice(0, 40)
title = t + (String(firstUser.content).length > 40 ? '...' : '')
}
}
sessions.push({
id: raw.id,
source: raw.source,
user_id: raw.user_id,
model: raw.model,
title: raw.title,
title,
started_at: raw.started_at,
ended_at: raw.ended_at,
end_reason: raw.end_reason,