* Type predicate: Check if a message is a tool result for collapsible tools. * Returns true if ALL tool results in the message are for tracked collapsible tools.
( msg: RenderableMessage, collapsibleToolUseIds: Set<string>, )
| 429 | * Returns true if ALL tool results in the message are for tracked collapsible tools. |
| 430 | */ |
| 431 | function isCollapsibleToolResult( |
| 432 | msg: RenderableMessage, |
| 433 | collapsibleToolUseIds: Set<string>, |
| 434 | ): msg is CollapsibleMessage { |
| 435 | if (msg.type === 'user') { |
| 436 | const toolResults = msg.message.content.filter( |
| 437 | (c): c is { type: 'tool_result'; tool_use_id: string } => |
| 438 | c.type === 'tool_result', |
| 439 | ) |
| 440 | // Only return true if there are tool results AND all of them are for collapsible tools |
| 441 | return ( |
| 442 | toolResults.length > 0 && |
| 443 | toolResults.every(r => collapsibleToolUseIds.has(r.tool_use_id)) |
| 444 | ) |
| 445 | } |
| 446 | return false |
| 447 | } |
| 448 | |
| 449 | /** |
| 450 | * Get all tool use IDs from a single message (handles grouped tool uses). |
no test coverage detected