MCPcopy Create free account
hub / github.com/cursor/cookbook / buildTranscriptLines

Function buildTranscriptLines

sdk/coding-agent-cli/src/tui/App.tsx:635–655  ·  view source on GitHub ↗
(entries: TranscriptEntry[], columns: number)

Source from the content-addressed store, hash-verified

633}
634
635function 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
657function trimTrailingBlankLines(lines: Array<{ parts: TranscriptPart[] }>) {
658 let end = lines.length

Callers 1

AppFunction · 0.85

Calls 3

trimTrailingBlankLinesFunction · 0.85
renderMarkdownLinesFunction · 0.85
wrapTextFunction · 0.85

Tested by

no test coverage detected