cc-haha/desktop/src/api/traces.ts
程序员阿江(Relakkes) 46f612abd5 feat: allow deleting trace sessions
Adds an idempotent DELETE /api/traces/:sessionId path that removes only the local trace JSONL file and invalidates trace read cache. The Trace list now exposes a trash action behind a confirmation dialog that states chat history is not deleted.

Tested: bun test src/server/__tests__/trace-capture.test.ts

Tested: cd desktop && bun run test -- src/pages/TraceList.test.tsx --run

Tested: bun run check:server

Tested: bun run check:desktop

Tested: Browser smoke with temporary CLAUDE_CONFIG_DIR verified the Trace list delete button and confirmation dialog on ?traceWindow=1.

Constraint: GitHub issue #868 remains open until a release ships and post-release retest passes.

Confidence: high

Scope-risk: moderate
2026-06-23 16:20:11 +08:00

26 lines
1006 B
TypeScript

import { api } from './client'
import type { TraceCaptureSettings, TraceSessionDeleteResult, TraceSessionList } from '../types/trace'
export const tracesApi = {
list(options?: { limit?: number; offset?: number; query?: string }) {
const params = new URLSearchParams()
if (options?.limit !== undefined) params.set('limit', String(options.limit))
if (options?.offset !== undefined) params.set('offset', String(options.offset))
if (options?.query) params.set('q', options.query)
const suffix = params.toString() ? `?${params}` : ''
return api.get<TraceSessionList>(`/api/traces${suffix}`)
},
getSettings() {
return api.get<TraceCaptureSettings>('/api/traces/settings')
},
updateSettings(settings: Partial<Pick<TraceCaptureSettings, 'enabled'>>) {
return api.put<TraceCaptureSettings>('/api/traces/settings', settings)
},
deleteSession(sessionId: string) {
return api.delete<TraceSessionDeleteResult>(`/api/traces/${encodeURIComponent(sessionId)}`)
},
}