* 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[])
| 2451 | * - Assistant messages that only contain tool_use blocks (displayed as collapsed groups) |
| 2452 | */ |
| 2453 | function countVisibleMessages(transcript: TranscriptMessage[]): number { |
| 2454 | let count = 0 |
| 2455 | for (const message of transcript) { |
| 2456 | switch (message.type) { |
| 2457 | case 'user': |
| 2458 | // Count user messages with visible content (text, image, not just tool_result or meta) |
| 2459 | if (hasVisibleUserContent(message)) { |
| 2460 | count++ |
| 2461 | } |
| 2462 | break |
| 2463 | case 'assistant': |
| 2464 | // Count assistant messages with text content (not just tool_use) |
| 2465 | if (hasVisibleAssistantContent(message)) { |
| 2466 | count++ |
| 2467 | } |
| 2468 | break |
| 2469 | case 'attachment': |
| 2470 | case 'system': |
| 2471 | case 'progress': |
| 2472 | // These message types are not counted as visible conversation turns |
| 2473 | break |
| 2474 | } |
| 2475 | } |
| 2476 | return count |
| 2477 | } |
| 2478 | |
| 2479 | function convertToLogOption( |
| 2480 | transcript: TranscriptMessage[], |
no test coverage detected