diff --git a/.changeset/kind-nails-jog.md b/.changeset/kind-nails-jog.md new file mode 100644 index 0000000..252f9d3 --- /dev/null +++ b/.changeset/kind-nails-jog.md @@ -0,0 +1,5 @@ +--- +"roo-cline": patch +--- + +Fix bug with clearing custom instructions diff --git a/webview-ui/src/components/prompts/PromptsView.tsx b/webview-ui/src/components/prompts/PromptsView.tsx index 4ae7659..85e9038 100644 --- a/webview-ui/src/components/prompts/PromptsView.tsx +++ b/webview-ui/src/components/prompts/PromptsView.tsx @@ -21,7 +21,8 @@ const PromptsView = ({ onDone }: PromptsViewProps) => { enhancementApiConfigId, setEnhancementApiConfigId, mode, - customInstructions + customInstructions, + setCustomInstructions } = useExtensionState() const [testPrompt, setTestPrompt] = useState('') const [isEnhancing, setIsEnhancing] = useState(false) @@ -152,6 +153,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => { value={customInstructions ?? ''} onChange={(e) => { const value = (e as CustomEvent)?.detail?.target?.value || ((e as any).target as HTMLTextAreaElement).value + setCustomInstructions(value || undefined) vscode.postMessage({ type: "customInstructions", text: value.trim() || undefined diff --git a/webview-ui/src/components/prompts/__tests__/PromptsView.test.tsx b/webview-ui/src/components/prompts/__tests__/PromptsView.test.tsx index 311702f..2ccc7f1 100644 --- a/webview-ui/src/components/prompts/__tests__/PromptsView.test.tsx +++ b/webview-ui/src/components/prompts/__tests__/PromptsView.test.tsx @@ -19,7 +19,9 @@ const mockExtensionState = { ], enhancementApiConfigId: '', setEnhancementApiConfigId: jest.fn(), - mode: 'code' + mode: 'code', + customInstructions: 'Initial instructions', + setCustomInstructions: jest.fn() } const renderPromptsView = (props = {}) => { @@ -131,4 +133,28 @@ describe('PromptsView', () => { 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 + }) + }) }) \ No newline at end of file