( blocks: ContentBlock[] | undefined, isAgentComplete?: boolean, )
| 734 | * @param isAgentComplete - Whether the parent agent has finished (status === 'complete') |
| 735 | */ |
| 736 | export function getMultiPromptPreview( |
| 737 | blocks: ContentBlock[] | undefined, |
| 738 | isAgentComplete?: boolean, |
| 739 | ): string | null { |
| 740 | const progress = getMultiPromptProgress(blocks) |
| 741 | if (!progress) return null |
| 742 | |
| 743 | const { total, completed, failed, isSelecting, isSelectorComplete } = progress |
| 744 | const finished = completed + failed |
| 745 | |
| 746 | // Agent is fully complete - show final state with selection info |
| 747 | // Use multi-line format: line 1 = count, lines 2-3 = reason (truncated to fit) |
| 748 | if (isAgentComplete) { |
| 749 | const reason = extractSelectionReason(blocks) |
| 750 | if (reason) { |
| 751 | // Capitalize first letter and truncate to 2 lines (line 1 is the count) |
| 752 | const formattedReason = reason.charAt(0).toUpperCase() + reason.slice(1) |
| 753 | const lines = formattedReason.split('\n') |
| 754 | const truncatedReason = |
| 755 | lines.length > 2 |
| 756 | ? lines.slice(0, 2).join('\n').trimEnd() + '...' |
| 757 | : formattedReason |
| 758 | return `${total} proposals evaluated\n${truncatedReason}` |
| 759 | } |
| 760 | return `${total} proposals evaluated` |
| 761 | } |
| 762 | |
| 763 | // Selector completed but agent still running = applying phase |
| 764 | if (isSelectorComplete) { |
| 765 | return 'Applying selected changes...' |
| 766 | } |
| 767 | |
| 768 | if (isSelecting) { |
| 769 | return `${total} proposals complete • Selecting best...` |
| 770 | } |
| 771 | |
| 772 | if (finished === total && total > 0) { |
| 773 | if (failed > 0) { |
| 774 | return `${completed}/${total} proposals complete (${failed} failed)` |
| 775 | } |
| 776 | return `${total} proposals complete` |
| 777 | } |
| 778 | |
| 779 | if (finished > 0) { |
| 780 | if (failed > 0) { |
| 781 | return `${completed}/${total} complete, ${failed} failed...` |
| 782 | } |
| 783 | return `${completed}/${total} proposals complete...` |
| 784 | } |
| 785 | |
| 786 | return `Generating ${total} proposals...` |
| 787 | } |
no test coverage detected