authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-05 00:30:19-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-05 00:30:19-07:00
logb7fc81dea2b7c963c34a365b82644ce963df19a2
tree79d3af2004c612a477fc44d3f81da023d28d0f6b
parentc9b76e6f5d382fb83caafe419f75ead87a3dbabb
signature Signed by PGP key B5690EEEBB952194

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


2 files changed, 0 insertions(+), 50 deletions(-)

apps/web/src/lib/terminalContext.test.ts-15
...@@ -3,7 +3,6 @@ import { describe, expect, it } from "vite-plus/test";...@@ -3,7 +3,6 @@ import { describe, expect, it } from "vite-plus/test";
33
4import {4import {
5 appendTerminalContextsToPrompt,5 appendTerminalContextsToPrompt,
6 buildTerminalContextPreviewTitle,
7 buildTerminalContextBlock,6 buildTerminalContextBlock,
8 countInlineTerminalContextPlaceholders,7 countInlineTerminalContextPlaceholders,
9 deriveDisplayedUserMessageState,8 deriveDisplayedUserMessageState,
...@@ -135,20 +134,6 @@ describe("terminalContext", () => {...@@ -135,20 +134,6 @@ describe("terminalContext", () => {
135 });134 });
136 });135 });
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
152 it("tracks inline terminal context placeholders in prompt text", () => {137 it("tracks inline terminal context placeholders in prompt text", () => {
153 const placeholder = INLINE_TERMINAL_CONTEXT_PLACEHOLDER;138 const placeholder = INLINE_TERMINAL_CONTEXT_PLACEHOLDER;
154 expect(countInlineTerminalContextPlaceholders(`a${placeholder}b${placeholder}`)).toBe(2);139 expect(countInlineTerminalContextPlaceholders(`a${placeholder}b${placeholder}`)).toBe(2);
apps/web/src/lib/terminalContext.ts-35
...@@ -65,20 +65,6 @@ export function filterTerminalContextsWithText<T extends { text: string }>(...@@ -65,20 +65,6 @@ export function filterTerminalContextsWithText<T extends { text: string }>(
65 return contexts.filter((context) => hasTerminalContextText(context));65 return contexts.filter((context) => hasTerminalContextText(context));
66}66}
6767
68function 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
82export function normalizeTerminalContextSelection(68export function normalizeTerminalContextSelection(
83 selection: TerminalContextSelection,69 selection: TerminalContextSelection,
84): TerminalContextSelection | null {70): TerminalContextSelection | null {
...@@ -129,27 +115,6 @@ export function formatInlineTerminalContextLabel(selection: {...@@ -129,27 +115,6 @@ export function formatInlineTerminalContextLabel(selection: {
129 return `@${terminalLabel}:${range}`;115 return `@${terminalLabel}:${range}`;
130}116}
131117
132export 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
153function buildTerminalContextBodyLines(selection: TerminalContextSelection): string[] {118function buildTerminalContextBodyLines(selection: TerminalContextSelection): string[] {
154 return normalizeTerminalContextText(selection.text)119 return normalizeTerminalContextText(selection.text)
155 .split("\n")120 .split("\n")