chat: read the /chat session list from Claude's own transcript store

First slice of making Claude's session store the source of truth. Adds a reader
(api/chat/claude-sessions.ts) that lists sessions straight from Claude's JSONL
transcripts under $HOME/.claude/projects/<cwd-slug>/, plus GET /chat/sessions
over a dedicated per-user claude_sessions working directory. No bookkeeping
layer — Claude's files are authoritative. Verified against real transcripts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-24 09:40:58 +00:00
co-authored by Claude Opus 4.8
parent 63819fc25e
commit 319cf39e84
3 changed files with 124 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
import { createRouter } from '../../create-router';
import { getClaudeSessionsCwd, listClaudeSessions } from './claude-sessions';
export const chatRouter = createRouter();
// GET /chat/sessions — the /chat route's conversations, read straight from Claude's own transcript
// store for the dedicated claude_sessions working directory (Claude is the source of truth).
chatRouter.get('/sessions', (ctx) => {
const email = ctx.get('user').email;
const sessions = listClaudeSessions(email, getClaudeSessionsCwd(email));
return ctx.json({ sessions });
});