(entries: TranscriptEntry[], columns: number)
| 633 | } |
| 634 | |
| 635 | function buildTranscriptLines(entries: TranscriptEntry[], columns: number) { |
| 636 | const labelWidth = 7 |
| 637 | const textWidth = Math.max(20, columns - labelWidth - 4) |
| 638 | |
| 639 | return entries.flatMap((entry) => { |
| 640 | const renderedLines = trimTrailingBlankLines( |
| 641 | entry.kind === "assistant" |
| 642 | ? renderMarkdownLines(entry.text || "...", textWidth) |
| 643 | : wrapText(entry.text || "...", textWidth).map((text) => ({ |
| 644 | parts: [{ text }], |
| 645 | })) |
| 646 | ) |
| 647 | |
| 648 | return renderedLines.map((line, index) => ({ |
| 649 | id: `${entry.id}-${index}`, |
| 650 | kind: entry.kind, |
| 651 | label: index === 0 ? entry.label : "", |
| 652 | parts: line.parts, |
| 653 | })) |
| 654 | }) |
| 655 | } |
| 656 | |
| 657 | function trimTrailingBlankLines(lines: Array<{ parts: TranscriptPart[] }>) { |
| 658 | let end = lines.length |
no test coverage detected