diff --git a/src/server/services/session-parser.ts b/src/server/services/session-parser.ts index 3a1dccd..a6e28ef 100644 --- a/src/server/services/session-parser.ts +++ b/src/server/services/session-parser.ts @@ -1,5 +1,5 @@ import fs from "fs/promises"; -import type { ParsedMessage } from "../../shared/types.js"; +import type { ParsedMessage, ProgressSubtype } from "../../shared/types.js"; /** * Real Claude Code JSONL format (verified from actual session files): @@ -19,6 +19,7 @@ import type { ParsedMessage } from "../../shared/types.js"; interface ContentBlock { type: string; + id?: string; text?: string; thinking?: string; name?: string; @@ -31,6 +32,7 @@ interface RawLine { type?: string; uuid?: string; timestamp?: string; + parentToolUseID?: string; message?: { role?: string; content?: string | ContentBlock[]; @@ -85,12 +87,16 @@ function extractMessages(raw: RawLine, rawIndex: number): ParsedMessage[] { const progressText = data ? formatProgressData(data) : "Progress event"; + const dataType = typeof data?.type === "string" ? data.type : ""; + const progressSubtype = deriveProgressSubtype(dataType); messages.push({ uuid, category: "hook_progress", content: progressText, timestamp, rawIndex, + parentToolUseId: raw.parentToolUseID, + progressSubtype, }); return messages; } @@ -155,7 +161,7 @@ function extractMessages(raw: RawLine, rawIndex: number): ParsedMessage[] { uuid: `${uuid}-tr-${block.tool_use_id || rawIndex}`, category: "tool_result", content: resultText, - toolName: block.tool_use_id, + toolUseId: block.tool_use_id, timestamp, rawIndex, }); @@ -215,6 +221,7 @@ function extractMessages(raw: RawLine, rawIndex: number): ParsedMessage[] { toolInput: JSON.stringify(block.input, null, 2), timestamp, rawIndex, + toolUseId: block.id, }); } } @@ -239,3 +246,10 @@ function formatProgressData(data: Record): string { function detectSystemReminder(text: string): boolean { return text.includes("") || text.includes(""); } + +function deriveProgressSubtype(dataType: string): ProgressSubtype { + if (dataType === "bash_progress") return "bash"; + if (dataType === "mcp_progress") return "mcp"; + if (dataType === "agent_progress") return "agent"; + return "hook"; +} diff --git a/src/shared/types.ts b/src/shared/types.ts index b639890..ab0432d 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -9,6 +9,8 @@ export type MessageCategory = | "file_snapshot" | "summary"; +export type ProgressSubtype = "hook" | "bash" | "mcp" | "agent"; + export interface ParsedMessage { uuid: string; category: MessageCategory; @@ -17,6 +19,9 @@ export interface ParsedMessage { toolInput?: string; timestamp?: string; rawIndex: number; + toolUseId?: string; + parentToolUseId?: string; + progressSubtype?: ProgressSubtype; } export interface SessionEntry { @@ -39,6 +44,7 @@ export interface SessionDetailResponse { id: string; project: string; messages: ParsedMessage[]; + toolProgress?: Record; } export interface ExportRequest {