Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions apps/web/src/lib/terminalContext.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { describe, expect, it } from "vite-plus/test";

import {
appendTerminalContextsToPrompt,
buildTerminalContextPreviewTitle,
buildTerminalContextBlock,
countInlineTerminalContextPlaceholders,
deriveDisplayedUserMessageState,
Expand Down Expand Up @@ -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);
Expand Down
35 changes: 0 additions & 35 deletions apps/web/src/lib/terminalContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand Down
Loading