diff --git a/webview-ui/src/components/modes/ModesView.tsx b/webview-ui/src/components/modes/ModesView.tsx index 170d03b0e4..16cef65e1f 100644 --- a/webview-ui/src/components/modes/ModesView.tsx +++ b/webview-ui/src/components/modes/ModesView.tsx @@ -833,7 +833,7 @@ const ModesView = ({ onDone }: ModesViewProps) => { })()} onChange={(e) => { const value = - (e as unknown as CustomEvent)?.detail?.target?.value || + (e as unknown as CustomEvent)?.detail?.target?.value ?? ((e as any).target as HTMLTextAreaElement).value const customMode = findModeBySlug(visualMode, customModes) if (customMode) { @@ -888,7 +888,7 @@ const ModesView = ({ onDone }: ModesViewProps) => { })()} onChange={(e) => { const value = - (e as unknown as CustomEvent)?.detail?.target?.value || + (e as unknown as CustomEvent)?.detail?.target?.value ?? ((e as any).target as HTMLTextAreaElement).value const customMode = findModeBySlug(visualMode, customModes) if (customMode) { @@ -943,7 +943,7 @@ const ModesView = ({ onDone }: ModesViewProps) => { })()} onChange={(e) => { const value = - (e as unknown as CustomEvent)?.detail?.target?.value || + (e as unknown as CustomEvent)?.detail?.target?.value ?? ((e as any).target as HTMLTextAreaElement).value const customMode = findModeBySlug(visualMode, customModes) if (customMode) { @@ -1102,7 +1102,7 @@ const ModesView = ({ onDone }: ModesViewProps) => { })()} onChange={(e) => { const value = - (e as unknown as CustomEvent)?.detail?.target?.value || + (e as unknown as CustomEvent)?.detail?.target?.value ?? ((e as any).target as HTMLTextAreaElement).value const customMode = findModeBySlug(visualMode, customModes) if (customMode) { @@ -1307,7 +1307,7 @@ const ModesView = ({ onDone }: ModesViewProps) => { value={customInstructions || ""} onChange={(e) => { const value = - (e as unknown as CustomEvent)?.detail?.target?.value || + (e as unknown as CustomEvent)?.detail?.target?.value ?? ((e as any).target as HTMLTextAreaElement).value setCustomInstructions(value || undefined) vscode.postMessage({ diff --git a/webview-ui/src/components/settings/PromptsSettings.tsx b/webview-ui/src/components/settings/PromptsSettings.tsx index a71132d62b..c4b9e632d5 100644 --- a/webview-ui/src/components/settings/PromptsSettings.tsx +++ b/webview-ui/src/components/settings/PromptsSettings.tsx @@ -56,14 +56,21 @@ const PromptsSettings = ({ customSupportPrompts, setCustomSupportPrompts }: Prom }, []) const updateSupportPrompt = (type: SupportPromptType, value: string | undefined) => { + // Trim the value when storing, but keep empty strings + const trimmedValue = value?.trim() + const finalValue = trimmedValue === "" ? undefined : trimmedValue + if (type === "CONDENSE") { - setCustomCondensingPrompt(value || supportPrompt.default.CONDENSE) + setCustomCondensingPrompt(finalValue || supportPrompt.default.CONDENSE) vscode.postMessage({ type: "updateCondensingPrompt", - text: value || supportPrompt.default.CONDENSE, + text: finalValue || supportPrompt.default.CONDENSE, }) + // Also update the customSupportPrompts to trigger change detection + const updatedPrompts = { ...customSupportPrompts, [type]: finalValue } + setCustomSupportPrompts(updatedPrompts) } else { - const updatedPrompts = { ...customSupportPrompts, [type]: value } + const updatedPrompts = { ...customSupportPrompts, [type]: finalValue } setCustomSupportPrompts(updatedPrompts) } } @@ -75,6 +82,10 @@ const PromptsSettings = ({ customSupportPrompts, setCustomSupportPrompts }: Prom type: "updateCondensingPrompt", text: supportPrompt.default.CONDENSE, }) + // Also update the customSupportPrompts to trigger change detection + const updatedPrompts = { ...customSupportPrompts } + delete updatedPrompts[type] + setCustomSupportPrompts(updatedPrompts) } else { const updatedPrompts = { ...customSupportPrompts } delete updatedPrompts[type] @@ -147,10 +158,9 @@ const PromptsSettings = ({ customSupportPrompts, setCustomSupportPrompts }: Prom value={getSupportPromptValue(activeSupportOption)} onChange={(e) => { const value = - (e as unknown as CustomEvent)?.detail?.target?.value || + (e as unknown as CustomEvent)?.detail?.target?.value ?? ((e as any).target as HTMLTextAreaElement).value - const trimmedValue = value.trim() - updateSupportPrompt(activeSupportOption, trimmedValue || undefined) + updateSupportPrompt(activeSupportOption, value) }} rows={6} className="w-full"