diff --git a/.changeset/fix-condensing-prompt.md b/.changeset/fix-condensing-prompt.md new file mode 100644 index 00000000000..d37e37d263e --- /dev/null +++ b/.changeset/fix-condensing-prompt.md @@ -0,0 +1,5 @@ +--- +"kilo-code": patch +--- + +Fix context condensing prompt not saving properly diff --git a/webview-ui/src/components/settings/PromptsSettings.tsx b/webview-ui/src/components/settings/PromptsSettings.tsx index c5ab742c0a4..c5f22942844 100644 --- a/webview-ui/src/components/settings/PromptsSettings.tsx +++ b/webview-ui/src/components/settings/PromptsSettings.tsx @@ -54,6 +54,10 @@ const PromptsSettings = ({ const [testPrompt, setTestPrompt] = useState("") const [isEnhancing, setIsEnhancing] = useState(false) const [activeSupportOption, setActiveSupportOption] = useState("ENHANCE") + // kilocode_change start + // Local state for condensing prompt to prevent flickering during typing + const [localCondensingPrompt, setLocalCondensingPrompt] = useState(undefined) + // kilocode_change end useEffect(() => { const handler = (event: MessageEvent) => { @@ -70,6 +74,15 @@ const PromptsSettings = ({ return () => window.removeEventListener("message", handler) }, []) + // kilocode_change start + // Initialize local condensing prompt when switching to CONDENSE tab + useEffect(() => { + if (activeSupportOption === "CONDENSE") { + setLocalCondensingPrompt(customCondensingPrompt) + } + }, [activeSupportOption, customCondensingPrompt]) + // kilocode_change end + const updateSupportPrompt = (type: SupportPromptType, value: string | undefined) => { // Don't trim during editing to preserve intentional whitespace // Use nullish coalescing to preserve empty strings @@ -120,8 +133,11 @@ const PromptsSettings = ({ const getSupportPromptValue = (type: SupportPromptType): string => { if (type === "CONDENSE") { - // Preserve empty string - only fall back to default when value is nullish - return customCondensingPrompt ?? supportPrompt.default.CONDENSE + // kilocode_change start + // Use local state during editing to prevent flickering + // Fall back to extension state, then to default + return localCondensingPrompt ?? customCondensingPrompt ?? supportPrompt.default.CONDENSE + // kilocode_change end } return supportPrompt.get(customSupportPrompts, type) } @@ -186,8 +202,26 @@ const PromptsSettings = ({ const value = (e as unknown as CustomEvent)?.detail?.target?.value ?? ((e as any).target as HTMLTextAreaElement).value + // kilocode_change start + // For CONDENSE, update local state immediately to prevent flickering + if (activeSupportOption === "CONDENSE") { + setLocalCondensingPrompt(value) + } + // kilocode_change end updateSupportPrompt(activeSupportOption, value) }} + // kilocode_change start + onBlur={(e) => { + // For CONDENSE, sync with extension state on blur + if (activeSupportOption === "CONDENSE") { + const value = + (e as unknown as CustomEvent)?.detail?.target?.value ?? + ((e as any).target as HTMLTextAreaElement).value + setLocalCondensingPrompt(undefined) + updateSupportPrompt(activeSupportOption, value) + } + }} + // kilocode_change end rows={6} className="w-full" />