* Counts visible messages that would appear as conversation turns in the UI. * Excludes: * - System, attachment, and progress messages * - User messages with isMeta flag (hidden from user) * - User messages that only contain tool_result blocks (displayed as collapsed groups) * - Assistant messa
(transcript: TranscriptMessage[])
| 2613 | * - Assistant messages that only contain tool_use blocks (displayed as collapsed groups) |
| 2614 | */ |
| 2615 | function countVisibleMessages(transcript: TranscriptMessage[]): number { |
| 2616 | let count = 0 |
| 2617 | for (const message of transcript) { |
| 2618 | switch (message.type) { |
| 2619 | case 'user': |
| 2620 | // Count user messages with visible content (text, image, not just tool_result or meta) |
| 2621 | if (hasVisibleUserContent(message)) { |
| 2622 | count++ |
| 2623 | } |
| 2624 | break |
| 2625 | case 'assistant': |
| 2626 | // Count assistant messages with text content (not just tool_use) |
| 2627 | if (hasVisibleAssistantContent(message)) { |
| 2628 | count++ |
| 2629 | } |
| 2630 | break |
| 2631 | case 'attachment': |
| 2632 | case 'system': |
| 2633 | case 'progress': |
| 2634 | // These message types are not counted as visible conversation turns |
| 2635 | break |
| 2636 | } |
| 2637 | } |
| 2638 | return count |
| 2639 | } |
| 2640 | |
| 2641 | function convertToLogOption( |
| 2642 | transcript: TranscriptMessage[], |
no test coverage detected