| ... | ... | @@ -65,20 +65,6 @@ export function filterTerminalContextsWithText<T extends { text: string }>( |
| 65 | 65 | return contexts.filter((context) => hasTerminalContextText(context)); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | | function previewTerminalContextText(text: string): string { |
| 69 | | const normalized = normalizeTerminalContextText(text); |
| 70 | | if (normalized.length === 0) { |
| 71 | | return ""; |
| 72 | | } |
| 73 | | const lines = normalized.split("\n"); |
| 74 | | const visibleLines = lines.slice(0, 3); |
| 75 | | if (lines.length > 3) { |
| 76 | | visibleLines.push("..."); |
| 77 | | } |
| 78 | | const preview = visibleLines.join("\n"); |
| 79 | | return preview.length > 180 ? `${preview.slice(0, 177)}...` : preview; |
| 80 | | } |
| 81 | | |
| 82 | 68 | export function normalizeTerminalContextSelection( |
| 83 | 69 | selection: TerminalContextSelection, |
| 84 | 70 | ): TerminalContextSelection | null { |
| ... | ... | @@ -129,27 +115,6 @@ export function formatInlineTerminalContextLabel(selection: { |
| 129 | 115 | return `@${terminalLabel}:${range}`; |
| 130 | 116 | } |
| 131 | 117 | |
| 132 | | export function buildTerminalContextPreviewTitle( |
| 133 | | contexts: ReadonlyArray<TerminalContextSelection>, |
| 134 | | ): string | null { |
| 135 | | if (contexts.length === 0) { |
| 136 | | return null; |
| 137 | | } |
| 138 | | const previewParts: string[] = []; |
| 139 | | for (const context of contexts) { |
| 140 | | const normalized = normalizeTerminalContextSelection(context); |
| 141 | | if (!normalized) continue; |
| 142 | | const preview = previewTerminalContextText(normalized.text); |
| 143 | | previewParts.push( |
| 144 | | preview.length > 0 |
| 145 | | ? `${formatTerminalContextLabel(normalized)}\n${preview}` |
| 146 | | : formatTerminalContextLabel(normalized), |
| 147 | | ); |
| 148 | | } |
| 149 | | const previews = previewParts.join("\n\n"); |
| 150 | | return previews.length > 0 ? previews : null; |
| 151 | | } |
| 152 | | |
| 153 | 118 | function buildTerminalContextBodyLines(selection: TerminalContextSelection): string[] { |
| 154 | 119 | return normalizeTerminalContextText(selection.text) |
| 155 | 120 | .split("\n") |