-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: resolve save button activation in prompts settings (#5780) #6026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: resolve save button activation in prompts settings (#5780) #6026
Conversation
) - Replace logical OR (||) with nullish coalescing (??) in onChange handlers - Fixes issue where empty strings were treated as falsy, preventing proper event handling - Applied fix to PromptsSettings.tsx and 5 similar instances in ModesView.tsx - Ensures Save button activates immediately when editing prompt text
- Update CONDENSE prompt handling to also call setCustomSupportPrompts - This ensures the parent SettingsView component detects changes - Fixes issue where Save button remained disabled when editing prompts
- Move trimming logic into updateSupportPrompt function - This ensures the onChange event triggers immediately on any input - Empty strings are converted to undefined only when storing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug where the Save button in the Prompts settings doesn't activate immediately when users start typing in text areas. The issue was caused by improper handling of empty strings in onChange events and missing change detection for certain prompt types.
Key Changes
- Replaced logical OR (
||) with nullish coalescing (??) operators in onChange handlers to properly handle empty strings - Added proper change detection for CONDENSE prompt type to ensure the Save button activates
- Applied consistent value trimming and processing logic across all prompt handling
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| webview-ui/src/components/settings/PromptsSettings.tsx | Fixed onChange event handling and added change detection for CONDENSE prompts |
| webview-ui/src/components/modes/ModesView.tsx | Updated onChange handlers to use nullish coalescing operator |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // Trim the value when storing, but keep empty strings | ||
| const trimmedValue = value?.trim() | ||
| const finalValue = trimmedValue === "" ? undefined : trimmedValue |
Copilot
AI
Sep 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The logic for handling empty strings could be simplified. Consider using const finalValue = value?.trim() || undefined which achieves the same result more concisely.
| // Trim the value when storing, but keep empty strings | |
| const trimmedValue = value?.trim() | |
| const finalValue = trimmedValue === "" ? undefined : trimmedValue | |
| // Trim the value when storing, and treat empty strings as undefined | |
| const finalValue = value?.trim() || undefined |
| setCustomCondensingPrompt(finalValue || supportPrompt.default.CONDENSE) | ||
| vscode.postMessage({ | ||
| type: "updateCondensingPrompt", | ||
| text: value || supportPrompt.default.CONDENSE, | ||
| text: finalValue || supportPrompt.default.CONDENSE, |
Copilot
AI
Sep 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The fallback to supportPrompt.default.CONDENSE is duplicated. Consider extracting this to a variable to avoid repetition: const promptValue = finalValue || supportPrompt.default.CONDENSE.
| setCustomCondensingPrompt(finalValue || supportPrompt.default.CONDENSE) | ||
| vscode.postMessage({ | ||
| type: "updateCondensingPrompt", | ||
| text: value || supportPrompt.default.CONDENSE, | ||
| text: finalValue || supportPrompt.default.CONDENSE, |
Copilot
AI
Sep 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The fallback to supportPrompt.default.CONDENSE is duplicated. Consider extracting this to a variable to avoid repetition: const promptValue = finalValue || supportPrompt.default.CONDENSE.
daniel-lxs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found issues that need attention.
|
|
||
| const updateSupportPrompt = (type: SupportPromptType, value: string | undefined) => { | ||
| // Trim the value when storing, but keep empty strings | ||
| const trimmedValue = value?.trim() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty strings are converted to undefined; this can repopulate defaults while clearing. Keep '' during editing and only coerce to undefined on save.
|
|
||
| const updateSupportPrompt = (type: SupportPromptType, value: string | undefined) => { | ||
| // Trim the value when storing, but keep empty strings | ||
| const trimmedValue = value?.trim() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trimming on every keystroke can remove intentional whitespace; trim only on save.
| setCustomSupportPrompts(updatedPrompts) | ||
| } else { | ||
| const updatedPrompts = { ...customSupportPrompts, [type]: value } | ||
| const updatedPrompts = { ...customSupportPrompts, [type]: finalValue } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-CONDENSE branch sets [type]: finalValue even when undefined; delete the key instead to fall back and keep change detection predictable.
|
|
||
| if (type === "CONDENSE") { | ||
| setCustomCondensingPrompt(value || supportPrompt.default.CONDENSE) | ||
| setCustomCondensingPrompt(finalValue || supportPrompt.default.CONDENSE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use nullish coalescing (??) instead of || for fallback so empty strings don’t revert to defaults.
| (e as unknown as CustomEvent)?.detail?.target?.value || | ||
| (e as unknown as CustomEvent)?.detail?.target?.value ?? | ||
| ((e as any).target as HTMLTextAreaElement).value | ||
| setCustomInstructions(value || undefined) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setCustomInstructions uses value || undefined; use value ?? undefined to preserve empty strings.
|
@roomote-agent Create a new PR based on this branch and incorporate the review comments left on this one, I'll close this PR but I won't delete the branch just yet so you can get the changes. |
|
I've seen your request @daniel-lxs. I'll create a new PR based on the branch 'fix/issue-5780-save-button-activation' and incorporate the review comments. Working on it now. |
- Use nullish coalescing (??) instead of logical OR (||) to preserve empty strings - Remove trimming during editing to preserve intentional whitespace - Delete keys when undefined instead of setting them to undefined - Properly handle empty strings vs undefined values for better change detection Addresses review comments from PR #6026
|
✅ Task completed successfully! I've created a new PR #8267 based on your branch that incorporates all the review comments: Changes made based on review feedback:
CI Status: All checks have passed ✅
The new PR is ready for review. Thanks for the initial work on this fix! |
Related GitHub Issue
Closes: #5780
Roo Code Task Context (Optional)
No Roo Code task context for this PR
Description
This PR fixes the issue where the Save button in the Prompts settings doesn't activate immediately when editing text. The user had to click outside the input area for the button to become active.
The issue had two parts:
||) which treats empty strings as falsy values, causing incorrect fallback behavior.Key changes:
||with??(nullish coalescing) in onChange handlers across PromptsSettings.tsx and ModesView.tsxsetCustomSupportPromptsto ensure proper change detectionTest Procedure
Automated Testing:
Manual Testing:
Pre-Submission Checklist
Screenshots / Videos
No UI changes in this PR (The fix is behavioral - the Save button now activates immediately when typing, but there are no visual changes to the UI itself)
Documentation Updates
Additional Notes
This fix was initially identified by @daniel-lxs in the issue comments. The solution ensures:
Get in Touch
Discord username not provided
Important
Fixes Save button activation in Prompts settings by replacing
||with??in event handlers to handle empty strings correctly.PromptsSettings.tsxandModesView.tsxby replacing||with??inonChangehandlers to handle empty strings correctly.setCustomSupportPromptsis called forCONDENSEprompt type to trigger change detection.This description was created by
for 358a76b. You can customize this summary. It will automatically update as commits are pushed.