| ... | @@ -267,7 +267,6 @@ interface ClaudeTurnState { | ... | @@ -267,7 +267,6 @@ interface ClaudeTurnState { |
| 267 | * steered instead (the queued message continues the same turn). | 267 | * steered instead (the queued message continues the same turn). |
| 268 | */ | 268 | */ |
| 269 | readonly synthetic?: boolean; | 269 | readonly synthetic?: boolean; |
| 270 | readonly items: Array<unknown>; | | |
| 271 | readonly assistantTextBlocks: Map<number, AssistantTextBlockState>; | 270 | readonly assistantTextBlocks: Map<number, AssistantTextBlockState>; |
| 272 | readonly assistantTextBlockOrder: Array<AssistantTextBlockState>; | 271 | readonly assistantTextBlockOrder: Array<AssistantTextBlockState>; |
| 273 | readonly capturedProposedPlanKeys: Set<string>; | 272 | readonly capturedProposedPlanKeys: Set<string>; |
| ... | @@ -422,10 +421,11 @@ interface ClaudeSessionContext { | ... | @@ -422,10 +421,11 @@ interface ClaudeSessionContext { |
| 422 | resumeSessionId: string | undefined; | 421 | resumeSessionId: string | undefined; |
| 423 | readonly pendingApprovals: Map<ApprovalRequestId, PendingApproval>; | 422 | readonly pendingApprovals: Map<ApprovalRequestId, PendingApproval>; |
| 424 | readonly pendingUserInputs: Map<ApprovalRequestId, PendingUserInput>; | 423 | readonly pendingUserInputs: Map<ApprovalRequestId, PendingUserInput>; |
| 425 | readonly turns: Array<{ | 424 | /** Completed turn ids, reported by readThread and trimmed on rollback. |
| 426 | id: TurnId; | 425 | * SDK messages are not kept: rollback reads Claude's own history through |
| 427 | items: Array<unknown>; | 426 | * turnStartMessageIds, and a long-lived session would otherwise hold every |
| 428 | }>; | 427 | * message it ever produced. */ |
| | 428 | readonly turns: Array<{ readonly id: TurnId }>; |
| 429 | readonly inFlightTools: Map<number, ToolInFlight>; | 429 | readonly inFlightTools: Map<number, ToolInFlight>; |
| 430 | readonly claudeTasks: Map<string, ClaudeTaskState>; | 430 | readonly claudeTasks: Map<string, ClaudeTaskState>; |
| 431 | readonly taskAgents: Map<string, ClaudeTaskAgentState>; | 431 | readonly taskAgents: Map<string, ClaudeTaskAgentState>; |
| ... | @@ -2176,10 +2176,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( | ... | @@ -2176,10 +2176,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( |
| 2176 | } | 2176 | } |
| 2177 | return { | 2177 | return { |
| 2178 | threadId, | 2178 | threadId, |
| 2179 | turns: context.turns.map((turn) => ({ | 2179 | turns: context.turns.map((turn) => ({ id: turn.id, items: [] })), |
| 2180 | id: turn.id, | | |
| 2181 | items: [...turn.items], | | |
| 2182 | })), | | |
| 2183 | }; | 2180 | }; |
| 2184 | }); | 2181 | }); |
| 2185 | | 2182 | |
| ... | @@ -2808,10 +2805,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( | ... | @@ -2808,10 +2805,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( |
| 2808 | }); | 2805 | }); |
| 2809 | } | 2806 | } |
| 2810 | | 2807 | |
| 2811 | context.turns.push({ | 2808 | context.turns.push({ id: turnState.turnId }); |
| 2812 | id: turnState.turnId, | | |
| 2813 | items: [...turnState.items], | | |
| 2814 | }); | | |
| 2815 | | 2809 | |
| 2816 | yield* emitThreadTokenUsage(context, usageSnapshot, { | 2810 | yield* emitThreadTokenUsage(context, usageSnapshot, { |
| 2817 | rawMethod: "claude/result", | 2811 | rawMethod: "claude/result", |
| ... | @@ -3175,10 +3169,6 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( | ... | @@ -3175,10 +3169,6 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( |
| 3175 | return; | 3169 | return; |
| 3176 | } | 3170 | } |
| 3177 | | 3171 | |
| 3178 | if (context.turnState) { | | |
| 3179 | context.turnState.items.push(message.message); | | |
| 3180 | } | | |
| 3181 | | | |
| 3182 | for (const toolResult of toolResultBlocksFromUserMessage(message)) { | 3172 | for (const toolResult of toolResultBlocksFromUserMessage(message)) { |
| 3183 | const toolEntry = Array.from(context.inFlightTools.entries()).find( | 3173 | const toolEntry = Array.from(context.inFlightTools.entries()).find( |
| 3184 | ([, tool]) => tool.itemId === toolResult.toolUseId, | 3174 | ([, tool]) => tool.itemId === toolResult.toolUseId, |
| ... | @@ -3378,7 +3368,6 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( | ... | @@ -3378,7 +3368,6 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( |
| 3378 | turnId, | 3368 | turnId, |
| 3379 | startedAt, | 3369 | startedAt, |
| 3380 | synthetic: true, | 3370 | synthetic: true, |
| 3381 | items: [], | | |
| 3382 | assistantTextBlocks: new Map(), | 3371 | assistantTextBlocks: new Map(), |
| 3383 | assistantTextBlockOrder: [], | 3372 | assistantTextBlockOrder: [], |
| 3384 | capturedProposedPlanKeys: new Set(), | 3373 | capturedProposedPlanKeys: new Set(), |
| ... | @@ -3461,7 +3450,6 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( | ... | @@ -3461,7 +3450,6 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( |
| 3461 | cwd: path.resolve(context.session.cwd ?? "."), | 3450 | cwd: path.resolve(context.session.cwd ?? "."), |
| 3462 | }); | 3451 | }); |
| 3463 | } | 3452 | } |
| 3464 | context.turnState.items.push(message.message); | | |
| 3465 | if ( | 3453 | if ( |
| 3466 | normalizeClaudeActiveTokenUsage( | 3454 | normalizeClaudeActiveTokenUsage( |
| 3467 | message.message.usage, | 3455 | message.message.usage, |
| ... | @@ -5205,7 +5193,6 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( | ... | @@ -5205,7 +5193,6 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( |
| 5205 | const turnState: ClaudeTurnState = { | 5193 | const turnState: ClaudeTurnState = { |
| 5206 | turnId, | 5194 | turnId, |
| 5207 | startedAt: yield* nowIso, | 5195 | startedAt: yield* nowIso, |
| 5208 | items: [], | | |
| 5209 | assistantTextBlocks: new Map(), | 5196 | assistantTextBlocks: new Map(), |
| 5210 | assistantTextBlockOrder: [], | 5197 | assistantTextBlockOrder: [], |
| 5211 | capturedProposedPlanKeys: new Set(), | 5198 | capturedProposedPlanKeys: new Set(), |