chat: delete sessions + auto-refresh the /chat list after each turn
DELETE /chat/sessions/:id removes Claude's transcript file; the list gets a per-row delete button. The list also invalidates on turn-complete so new and continued sessions surface without a manual refresh. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { readdirSync, readFileSync, existsSync, statSync, mkdirSync } from 'node:fs';
|
||||
import { readdirSync, readFileSync, existsSync, statSync, mkdirSync, rmSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { DATA_PATH } from '../../data-path';
|
||||
|
||||
@@ -187,6 +187,14 @@ export function loadClaudeSession(email: string, cwd: string, sessionId: string)
|
||||
return { id: sessionId, model, cwd: sessionCwd, messages };
|
||||
}
|
||||
|
||||
/** Delete a session by removing its transcript file. Returns false if it didn't exist. */
|
||||
export function deleteClaudeSession(email: string, cwd: string, sessionId: string): boolean {
|
||||
const filePath = join(claudeProjectsDir(email), projectSlug(cwd), `${sessionId}.jsonl`);
|
||||
if (!existsSync(filePath)) return false;
|
||||
rmSync(filePath);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** List sessions Claude has stored for a given working directory, newest first. */
|
||||
export function listClaudeSessions(email: string, cwd: string): ClaudeSessionSummary[] {
|
||||
const dir = join(claudeProjectsDir(email), projectSlug(cwd));
|
||||
|
||||
Reference in New Issue
Block a user