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