Skip to content

Commit f2d25dd

Browse files
committed
Fix bug with clearing custom instructions
1 parent 4493b55 commit f2d25dd

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

.changeset/kind-nails-jog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": patch
3+
---
4+
5+
Fix bug with clearing custom instructions

webview-ui/src/components/prompts/PromptsView.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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

webview-ui/src/components/prompts/__tests__/PromptsView.test.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff 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

2527
const 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
})

0 commit comments

Comments
 (0)