Skip to content
TypeScript

refactor(web): remove unused terminal context preview formatter (#10009)

Julius Marmingeb7fc81dea2b7
diff --git a/apps/web/src/lib/terminalContext.test.ts b/apps/web/src/lib/terminalContext.test.ts
index 4b520c9bef4..199054b1d84 100644
--- a/apps/web/src/lib/terminalContext.test.ts
+++ b/apps/web/src/lib/terminalContext.test.ts
@@ -3,7 +3,6 @@ import { describe, expect, it } from "vite-plus/test";
import {
appendTerminalContextsToPrompt,
- buildTerminalContextPreviewTitle,
buildTerminalContextBlock,
countInlineTerminalContextPlaceholders,
deriveDisplayedUserMessageState,
@@ -135,20 +134,6 @@ describe("terminalContext", () => {
});
});
- it("returns null preview title when every context is invalid", () => {
- expect(
- buildTerminalContextPreviewTitle([
- makeContext({
- terminalId: " ",
- }),
- makeContext({
- id: "context-2",
- text: "\n\n",
- }),
- ]),
- ).toBeNull();
- });
-
it("tracks inline terminal context placeholders in prompt text", () => {
const placeholder = INLINE_TERMINAL_CONTEXT_PLACEHOLDER;
expect(countInlineTerminalContextPlaceholders(`a${placeholder}b${placeholder}`)).toBe(2);
diff --git a/apps/web/src/lib/terminalContext.ts b/apps/web/src/lib/terminalContext.ts
index 72f49a2f22d..4cdbc019255 100644
--- a/apps/web/src/lib/terminalContext.ts
+++ b/apps/web/src/lib/terminalContext.ts
@@ -65,20 +65,6 @@ export function filterTerminalContextsWithText<T extends { text: string }>(
return contexts.filter((context) => hasTerminalContextText(context));
}
-function previewTerminalContextText(text: string): string {
- const normalized = normalizeTerminalContextText(text);
- if (normalized.length === 0) {
- return "";
- }
- const lines = normalized.split("\n");
- const visibleLines = lines.slice(0, 3);
- if (lines.length > 3) {
- visibleLines.push("...");
- }
- const preview = visibleLines.join("\n");
- return preview.length > 180 ? `${preview.slice(0, 177)}...` : preview;
-}
-
export function normalizeTerminalContextSelection(
selection: TerminalContextSelection,
): TerminalContextSelection | null {
@@ -129,27 +115,6 @@ export function formatInlineTerminalContextLabel(selection: {
return `@${terminalLabel}:${range}`;
}
-export function buildTerminalContextPreviewTitle(
- contexts: ReadonlyArray<TerminalContextSelection>,
-): string | null {
- if (contexts.length === 0) {
- return null;
- }
- const previewParts: string[] = [];
- for (const context of contexts) {
- const normalized = normalizeTerminalContextSelection(context);
- if (!normalized) continue;
- const preview = previewTerminalContextText(normalized.text);
- previewParts.push(
- preview.length > 0
- ? `${formatTerminalContextLabel(normalized)}\n${preview}`
- : formatTerminalContextLabel(normalized),
- );
- }
- const previews = previewParts.join("\n\n");
- return previews.length > 0 ? previews : null;
-}
-
function buildTerminalContextBodyLines(selection: TerminalContextSelection): string[] {
return normalizeTerminalContextText(selection.text)
.split("\n")