|
|
@@ -69,14 +69,31 @@ const PromptsSettings = ({
|
|
|
}, [])
|
|
|
|
|
|
const updateSupportPrompt = (type: SupportPromptType, value: string | undefined) => {
|
|
|
+ // Don't trim during editing to preserve intentional whitespace
|
|
|
+ // Use nullish coalescing to preserve empty strings
|
|
|
+ const finalValue = value ?? undefined
|
|
|
+
|
|
|
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 }
|
|
|
+ if (finalValue === undefined) {
|
|
|
+ delete updatedPrompts[type]
|
|
|
+ } else {
|
|
|
+ updatedPrompts[type] = finalValue
|
|
|
+ }
|
|
|
+ setCustomSupportPrompts(updatedPrompts)
|
|
|
} else {
|
|
|
- const updatedPrompts = { ...customSupportPrompts, [type]: value }
|
|
|
+ const updatedPrompts = { ...customSupportPrompts }
|
|
|
+ if (finalValue === undefined) {
|
|
|
+ delete updatedPrompts[type]
|
|
|
+ } else {
|
|
|
+ updatedPrompts[type] = finalValue
|
|
|
+ }
|
|
|
setCustomSupportPrompts(updatedPrompts)
|
|
|
}
|
|
|
}
|
|
|
@@ -88,6 +105,10 @@ const PromptsSettings = ({
|
|
|
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]
|
|
|
@@ -97,7 +118,8 @@ const PromptsSettings = ({
|
|
|
|
|
|
const getSupportPromptValue = (type: SupportPromptType): string => {
|
|
|
if (type === "CONDENSE") {
|
|
|
- return customCondensingPrompt || supportPrompt.default.CONDENSE
|
|
|
+ // Preserve empty string - only fall back to default when value is nullish
|
|
|
+ return customCondensingPrompt ?? supportPrompt.default.CONDENSE
|
|
|
}
|
|
|
return supportPrompt.get(customSupportPrompts, type)
|
|
|
}
|
|
|
@@ -158,12 +180,11 @@ const PromptsSettings = ({
|
|
|
<VSCodeTextArea
|
|
|
resize="vertical"
|
|
|
value={getSupportPromptValue(activeSupportOption)}
|
|
|
- onChange={(e) => {
|
|
|
+ onInput={(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"
|