(messages: RenderableMessage[], index: number, tools: Tools, streamingToolUseIDs: Set<string>)
| 48 | * accumulating every historical version of the array ≈ 1-2MB over a 7-turn session). |
| 49 | */ |
| 50 | export function hasContentAfterIndex(messages: RenderableMessage[], index: number, tools: Tools, streamingToolUseIDs: Set<string>): boolean { |
| 51 | for (let i = index + 1; i < messages.length; i++) { |
| 52 | const msg = messages[i]; |
| 53 | if (msg?.type === 'assistant') { |
| 54 | const content = msg.message.content[0]; |
| 55 | if (content?.type === 'thinking' || content?.type === 'redacted_thinking') { |
| 56 | continue; |
| 57 | } |
| 58 | if (content?.type === 'tool_use') { |
| 59 | if (getToolSearchOrReadInfo(content.name, content.input, tools).isCollapsible) { |
| 60 | continue; |
| 61 | } |
| 62 | // Non-collapsible tool uses appear in syntheticStreamingToolUseMessages |
| 63 | // before their ID is added to inProgressToolUseIDs. Skip while streaming |
| 64 | // to avoid briefly finalizing the read group. |
| 65 | if (streamingToolUseIDs.has(content.id)) { |
| 66 | continue; |
| 67 | } |
| 68 | } |
| 69 | return true; |
| 70 | } |
| 71 | if (msg?.type === 'system' || msg?.type === 'attachment') { |
| 72 | continue; |
| 73 | } |
| 74 | // Tool results arrive while the collapsed group is still being built |
| 75 | if (msg?.type === 'user') { |
| 76 | const content = msg.message.content[0]; |
| 77 | if (content?.type === 'tool_result') { |
| 78 | continue; |
| 79 | } |
| 80 | } |
| 81 | // Collapsible grouped_tool_use messages arrive transiently before being |
| 82 | // merged into the current collapsed group on the next render cycle |
| 83 | if (msg?.type === 'grouped_tool_use') { |
| 84 | const firstInput = msg.messages[0]?.message.content[0]?.input; |
| 85 | if (getToolSearchOrReadInfo(msg.toolName, firstInput, tools).isCollapsible) { |
| 86 | continue; |
| 87 | } |
| 88 | } |
| 89 | return true; |
| 90 | } |
| 91 | return false; |
| 92 | } |
| 93 | function MessageRowImpl(t0) { |
| 94 | const $ = _c(64); |
| 95 | const { |
no test coverage detected