mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
Fix bug with clearing custom instructions
This commit is contained in:
5
.changeset/kind-nails-jog.md
Normal file
5
.changeset/kind-nails-jog.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"roo-cline": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix bug with clearing custom instructions
|
||||||
@@ -21,7 +21,8 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
|
|||||||
enhancementApiConfigId,
|
enhancementApiConfigId,
|
||||||
setEnhancementApiConfigId,
|
setEnhancementApiConfigId,
|
||||||
mode,
|
mode,
|
||||||
customInstructions
|
customInstructions,
|
||||||
|
setCustomInstructions
|
||||||
} = useExtensionState()
|
} = useExtensionState()
|
||||||
const [testPrompt, setTestPrompt] = useState('')
|
const [testPrompt, setTestPrompt] = useState('')
|
||||||
const [isEnhancing, setIsEnhancing] = useState(false)
|
const [isEnhancing, setIsEnhancing] = useState(false)
|
||||||
@@ -152,6 +153,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
|
|||||||
value={customInstructions ?? ''}
|
value={customInstructions ?? ''}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const value = (e as CustomEvent)?.detail?.target?.value || ((e as any).target as HTMLTextAreaElement).value
|
const value = (e as CustomEvent)?.detail?.target?.value || ((e as any).target as HTMLTextAreaElement).value
|
||||||
|
setCustomInstructions(value || undefined)
|
||||||
vscode.postMessage({
|
vscode.postMessage({
|
||||||
type: "customInstructions",
|
type: "customInstructions",
|
||||||
text: value.trim() || undefined
|
text: value.trim() || undefined
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ const mockExtensionState = {
|
|||||||
],
|
],
|
||||||
enhancementApiConfigId: '',
|
enhancementApiConfigId: '',
|
||||||
setEnhancementApiConfigId: jest.fn(),
|
setEnhancementApiConfigId: jest.fn(),
|
||||||
mode: 'code'
|
mode: 'code',
|
||||||
|
customInstructions: 'Initial instructions',
|
||||||
|
setCustomInstructions: jest.fn()
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderPromptsView = (props = {}) => {
|
const renderPromptsView = (props = {}) => {
|
||||||
@@ -131,4 +133,28 @@ describe('PromptsView', () => {
|
|||||||
text: 'config1'
|
text: 'config1'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('handles clearing custom instructions correctly', async () => {
|
||||||
|
const setCustomInstructions = jest.fn()
|
||||||
|
renderPromptsView({
|
||||||
|
...mockExtensionState,
|
||||||
|
customInstructions: 'Initial instructions',
|
||||||
|
setCustomInstructions
|
||||||
|
})
|
||||||
|
|
||||||
|
const textarea = screen.getByTestId('global-custom-instructions-textarea')
|
||||||
|
const changeEvent = new CustomEvent('change', {
|
||||||
|
detail: { target: { value: '' } }
|
||||||
|
})
|
||||||
|
Object.defineProperty(changeEvent, 'target', {
|
||||||
|
value: { value: '' }
|
||||||
|
})
|
||||||
|
await fireEvent(textarea, changeEvent)
|
||||||
|
|
||||||
|
expect(setCustomInstructions).toHaveBeenCalledWith(undefined)
|
||||||
|
expect(vscode.postMessage).toHaveBeenCalledWith({
|
||||||
|
type: 'customInstructions',
|
||||||
|
text: undefined
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user