File tree Expand file tree Collapse file tree 3 files changed +35
-2
lines changed
webview-ui/src/components/prompts Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " roo-cline " : patch
3+ ---
4+
5+ Fix bug with clearing custom instructions
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
2121 enhancementApiConfigId,
2222 setEnhancementApiConfigId,
2323 mode,
24- customInstructions
24+ customInstructions,
25+ setCustomInstructions
2526 } = useExtensionState ( )
2627 const [ testPrompt , setTestPrompt ] = useState ( '' )
2728 const [ isEnhancing , setIsEnhancing ] = useState ( false )
@@ -152,6 +153,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
152153 value = { customInstructions ?? '' }
153154 onChange = { ( e ) => {
154155 const value = ( e as CustomEvent ) ?. detail ?. target ?. value || ( ( e as any ) . target as HTMLTextAreaElement ) . value
156+ setCustomInstructions ( value || undefined )
155157 vscode . postMessage ( {
156158 type : "customInstructions" ,
157159 text : value . trim ( ) || undefined
Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ const mockExtensionState = {
1919 ] ,
2020 enhancementApiConfigId : '' ,
2121 setEnhancementApiConfigId : jest . fn ( ) ,
22- mode : 'code'
22+ mode : 'code' ,
23+ customInstructions : 'Initial instructions' ,
24+ setCustomInstructions : jest . fn ( )
2325}
2426
2527const renderPromptsView = ( props = { } ) => {
@@ -131,4 +133,28 @@ describe('PromptsView', () => {
131133 text : 'config1'
132134 } )
133135 } )
136+
137+ it ( 'handles clearing custom instructions correctly' , async ( ) => {
138+ const setCustomInstructions = jest . fn ( )
139+ renderPromptsView ( {
140+ ...mockExtensionState ,
141+ customInstructions : 'Initial instructions' ,
142+ setCustomInstructions
143+ } )
144+
145+ const textarea = screen . getByTestId ( 'global-custom-instructions-textarea' )
146+ const changeEvent = new CustomEvent ( 'change' , {
147+ detail : { target : { value : '' } }
148+ } )
149+ Object . defineProperty ( changeEvent , 'target' , {
150+ value : { value : '' }
151+ } )
152+ await fireEvent ( textarea , changeEvent )
153+
154+ expect ( setCustomInstructions ) . toHaveBeenCalledWith ( undefined )
155+ expect ( vscode . postMessage ) . toHaveBeenCalledWith ( {
156+ type : 'customInstructions' ,
157+ text : undefined
158+ } )
159+ } )
134160} )
You can’t perform that action at this time.
0 commit comments