diff --git a/webview-ui/src/components/settings/ContextManagementSettings.tsx b/webview-ui/src/components/settings/ContextManagementSettings.tsx index 2b28e894e9f..cef71534930 100644 --- a/webview-ui/src/components/settings/ContextManagementSettings.tsx +++ b/webview-ui/src/components/settings/ContextManagementSettings.tsx @@ -1,11 +1,23 @@ import { HTMLAttributes } from "react" import React from "react" import { useAppTranslation } from "@/i18n/TranslationContext" -import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react" +import { VSCodeCheckbox, VSCodeTextArea } from "@vscode/webview-ui-toolkit/react" import { FoldVertical } from "lucide-react" +import { supportPrompt } from "@roo/support-prompt" + import { cn } from "@/lib/utils" -import { Input, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Slider, Button } from "@/components/ui" +import { + Input, + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, + Slider, + Button, + StandardTooltip, +} from "@/components/ui" import { SetCachedStateField } from "./types" import { SectionHeader } from "./SectionHeader" @@ -32,6 +44,8 @@ type ContextManagementSettingsProps = HTMLAttributes & { includeCurrentTime?: boolean includeCurrentCost?: boolean maxGitStatusFiles?: number + customSupportPrompts: Record + setCustomSupportPrompts: (prompts: Record) => void setCachedStateField: SetCachedStateField< | "autoCondenseContext" | "autoCondenseContextPercent" @@ -73,12 +87,37 @@ export const ContextManagementSettings = ({ includeCurrentTime, includeCurrentCost, maxGitStatusFiles, + customSupportPrompts, + setCustomSupportPrompts, className, ...props }: ContextManagementSettingsProps) => { const { t } = useAppTranslation() const [selectedThresholdProfile, setSelectedThresholdProfile] = React.useState("default") + // Helper function to get the CONDENSE prompt value + const getCondensePromptValue = (): string => { + return supportPrompt.get(customSupportPrompts, "CONDENSE") + } + + // Helper function to update the CONDENSE prompt + const updateCondensePrompt = (value: string | undefined) => { + const updatedPrompts = { ...customSupportPrompts } + if (value === undefined) { + delete updatedPrompts["CONDENSE"] + } else { + updatedPrompts["CONDENSE"] = value + } + setCustomSupportPrompts(updatedPrompts) + } + + // Helper function to reset the CONDENSE prompt to default + const handleCondenseReset = () => { + const updatedPrompts = { ...customSupportPrompts } + delete updatedPrompts["CONDENSE"] + setCustomSupportPrompts(updatedPrompts) + } + // Helper function to get the current threshold value based on selected profile const getCurrentThresholdValue = () => { if (selectedThresholdProfile === "default") { @@ -470,6 +509,38 @@ export const ContextManagementSettings = ({
+ {/* Context Condensing Prompt Editor */} + +
+ + + + +
+
+ {t("prompts:supportPrompts.types.CONDENSE.description")} +
+ { + const value = + (e as unknown as CustomEvent)?.detail?.target?.value ?? + ((e as any).target as HTMLTextAreaElement).value + updateCondensePrompt(value) + }} + rows={6} + className="w-full" + data-testid="condense-prompt-textarea" + /> +
+ + {/* Auto Condense Context */} - {Object.keys(supportPrompt.default).map((type) => ( - - {t(`prompts:supportPrompts.types.${type}.label`)} - - ))} + {Object.keys(supportPrompt.default) + .filter((type) => type !== "CONDENSE") + .map((type) => ( + + {t(`prompts:supportPrompts.types.${type}.label`)} + + ))}
diff --git a/webview-ui/src/components/settings/SettingsView.tsx b/webview-ui/src/components/settings/SettingsView.tsx index bb56c1c955d..792e23bf611 100644 --- a/webview-ui/src/components/settings/SettingsView.tsx +++ b/webview-ui/src/components/settings/SettingsView.tsx @@ -863,6 +863,8 @@ const SettingsView = forwardRef(({ onDone, t includeCurrentTime={includeCurrentTime} includeCurrentCost={includeCurrentCost} maxGitStatusFiles={maxGitStatusFiles} + customSupportPrompts={customSupportPrompts || {}} + setCustomSupportPrompts={setCustomSupportPromptsField} setCachedStateField={setCachedStateField} /> )} diff --git a/webview-ui/src/components/settings/__tests__/ContextManagementSettings.spec.tsx b/webview-ui/src/components/settings/__tests__/ContextManagementSettings.spec.tsx index 8381702b577..b508d093404 100644 --- a/webview-ui/src/components/settings/__tests__/ContextManagementSettings.spec.tsx +++ b/webview-ui/src/components/settings/__tests__/ContextManagementSettings.spec.tsx @@ -56,6 +56,7 @@ vi.mock("@/components/ui", () => ({ SelectValue: ({ children, ...props }: any) =>
{children}
, SelectContent: ({ children, ...props }: any) =>
{children}
, SelectItem: ({ children, ...props }: any) =>
{children}
, + StandardTooltip: ({ children, content }: any) =>
{children}
, })) // Mock vscode utilities - this is necessary since we're not in a VSCode environment @@ -87,7 +88,6 @@ describe("ContextManagementSettings", () => { const defaultProps = { autoCondenseContext: false, autoCondenseContextPercent: 80, - customCondensingPrompt: undefined, listApiConfigMeta: [], maxOpenTabsContext: 20, maxWorkspaceFiles: 200, @@ -98,6 +98,8 @@ describe("ContextManagementSettings", () => { includeDiagnosticMessages: true, maxDiagnosticMessages: 50, writeDelayMs: 1000, + customSupportPrompts: {}, + setCustomSupportPrompts: vi.fn(), setCachedStateField: vi.fn(), }