Skip to content

Commit e7ed2fc

Browse files
refactor(web): remove unused terminal context preview formatter
1 parent d2c3e2e commit e7ed2fc

2 files changed

Lines changed: 0 additions & 50 deletions

File tree

‎apps/web/src/lib/terminalContext.test.ts‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { describe, expect, it } from "vite-plus/test";
33

44
import {
55
appendTerminalContextsToPrompt,
6-
buildTerminalContextPreviewTitle,
76
buildTerminalContextBlock,
87
countInlineTerminalContextPlaceholders,
98
deriveDisplayedUserMessageState,
@@ -135,20 +134,6 @@ describe("terminalContext", () => {
135134
});
136135
});
137136

138-
it("returns null preview title when every context is invalid", () => {
139-
expect(
140-
buildTerminalContextPreviewTitle([
141-
makeContext({
142-
terminalId: " ",
143-
}),
144-
makeContext({
145-
id: "context-2",
146-
text: "\n\n",
147-
}),
148-
]),
149-
).toBeNull();
150-
});
151-
152137
it("tracks inline terminal context placeholders in prompt text", () => {
153138
const placeholder = INLINE_TERMINAL_CONTEXT_PLACEHOLDER;
154139
expect(countInlineTerminalContextPlaceholders(`a${placeholder}b${placeholder}`)).toBe(2);

‎apps/web/src/lib/terminalContext.ts‎

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,6 @@ export function filterTerminalContextsWithText<T extends { text: string }>(
6565
return contexts.filter((context) => hasTerminalContextText(context));
6666
}
6767

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-
8268
export function normalizeTerminalContextSelection(
8369
selection: TerminalContextSelection,
8470
): TerminalContextSelection | null {
@@ -129,27 +115,6 @@ export function formatInlineTerminalContextLabel(selection: {
129115
return `@${terminalLabel}:${range}`;
130116
}
131117

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-
153118
function buildTerminalContextBodyLines(selection: TerminalContextSelection): string[] {
154119
return normalizeTerminalContextText(selection.text)
155120
.split("\n")

0 commit comments

Comments
 (0)