@@ -69,14 +69,31 @@ const PromptsSettings = ({
6969 } , [ ] )
7070
7171 const updateSupportPrompt = ( type : SupportPromptType , value : string | undefined ) => {
72+ // Don't trim during editing to preserve intentional whitespace
73+ // Use nullish coalescing to preserve empty strings
74+ const finalValue = value ?? undefined
75+
7276 if ( type === "CONDENSE" ) {
73- setCustomCondensingPrompt ( value || supportPrompt . default . CONDENSE )
77+ setCustomCondensingPrompt ( finalValue ?? supportPrompt . default . CONDENSE )
7478 vscode . postMessage ( {
7579 type : "updateCondensingPrompt" ,
76- text : value || supportPrompt . default . CONDENSE ,
80+ text : finalValue ?? supportPrompt . default . CONDENSE ,
7781 } )
82+ // Also update the customSupportPrompts to trigger change detection
83+ const updatedPrompts = { ...customSupportPrompts }
84+ if ( finalValue === undefined ) {
85+ delete updatedPrompts [ type ]
86+ } else {
87+ updatedPrompts [ type ] = finalValue
88+ }
89+ setCustomSupportPrompts ( updatedPrompts )
7890 } else {
79- const updatedPrompts = { ...customSupportPrompts , [ type ] : value }
91+ const updatedPrompts = { ...customSupportPrompts }
92+ if ( finalValue === undefined ) {
93+ delete updatedPrompts [ type ]
94+ } else {
95+ updatedPrompts [ type ] = finalValue
96+ }
8097 setCustomSupportPrompts ( updatedPrompts )
8198 }
8299 }
@@ -88,6 +105,10 @@ const PromptsSettings = ({
88105 type : "updateCondensingPrompt" ,
89106 text : supportPrompt . default . CONDENSE ,
90107 } )
108+ // Also update the customSupportPrompts to trigger change detection
109+ const updatedPrompts = { ...customSupportPrompts }
110+ delete updatedPrompts [ type ]
111+ setCustomSupportPrompts ( updatedPrompts )
91112 } else {
92113 const updatedPrompts = { ...customSupportPrompts }
93114 delete updatedPrompts [ type ]
@@ -97,7 +118,8 @@ const PromptsSettings = ({
97118
98119 const getSupportPromptValue = ( type : SupportPromptType ) : string => {
99120 if ( type === "CONDENSE" ) {
100- return customCondensingPrompt || supportPrompt . default . CONDENSE
121+ // Preserve empty string - only fall back to default when value is nullish
122+ return customCondensingPrompt ?? supportPrompt . default . CONDENSE
101123 }
102124 return supportPrompt . get ( customSupportPrompts , type )
103125 }
@@ -158,12 +180,11 @@ const PromptsSettings = ({
158180 < VSCodeTextArea
159181 resize = "vertical"
160182 value = { getSupportPromptValue ( activeSupportOption ) }
161- onChange = { ( e ) => {
183+ onInput = { ( e ) => {
162184 const value =
163- ( e as unknown as CustomEvent ) ?. detail ?. target ?. value ||
185+ ( e as unknown as CustomEvent ) ?. detail ?. target ?. value ??
164186 ( ( e as any ) . target as HTMLTextAreaElement ) . value
165- const trimmedValue = value . trim ( )
166- updateSupportPrompt ( activeSupportOption , trimmedValue || undefined )
187+ updateSupportPrompt ( activeSupportOption , value )
167188 } }
168189 rows = { 6 }
169190 className = "w-full"
0 commit comments