Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions webview-ui/src/components/modes/ModesView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ const ModesView = ({ onDone }: ModesViewProps) => {
})()}
onChange={(e) => {
const value =
(e as unknown as CustomEvent)?.detail?.target?.value ||
(e as unknown as CustomEvent)?.detail?.target?.value ??
((e as any).target as HTMLTextAreaElement).value
const customMode = findModeBySlug(visualMode, customModes)
if (customMode) {
Expand Down Expand Up @@ -888,7 +888,7 @@ const ModesView = ({ onDone }: ModesViewProps) => {
})()}
onChange={(e) => {
const value =
(e as unknown as CustomEvent)?.detail?.target?.value ||
(e as unknown as CustomEvent)?.detail?.target?.value ??
((e as any).target as HTMLTextAreaElement).value
const customMode = findModeBySlug(visualMode, customModes)
if (customMode) {
Expand Down Expand Up @@ -943,7 +943,7 @@ const ModesView = ({ onDone }: ModesViewProps) => {
})()}
onChange={(e) => {
const value =
(e as unknown as CustomEvent)?.detail?.target?.value ||
(e as unknown as CustomEvent)?.detail?.target?.value ??
((e as any).target as HTMLTextAreaElement).value
const customMode = findModeBySlug(visualMode, customModes)
if (customMode) {
Expand Down Expand Up @@ -1102,7 +1102,7 @@ const ModesView = ({ onDone }: ModesViewProps) => {
})()}
onChange={(e) => {
const value =
(e as unknown as CustomEvent)?.detail?.target?.value ||
(e as unknown as CustomEvent)?.detail?.target?.value ??
((e as any).target as HTMLTextAreaElement).value
const customMode = findModeBySlug(visualMode, customModes)
if (customMode) {
Expand Down Expand Up @@ -1307,7 +1307,7 @@ const ModesView = ({ onDone }: ModesViewProps) => {
value={customInstructions || ""}
onChange={(e) => {
const value =
(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)
Copy link
Member

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.

vscode.postMessage({
Expand Down
22 changes: 16 additions & 6 deletions webview-ui/src/components/settings/PromptsSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,21 @@ const PromptsSettings = ({ customSupportPrompts, setCustomSupportPrompts }: Prom
}, [])

const updateSupportPrompt = (type: SupportPromptType, value: string | undefined) => {
// Trim the value when storing, but keep empty strings
const trimmedValue = value?.trim()
Copy link
Member

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.

Copy link
Member

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.

const finalValue = trimmedValue === "" ? undefined : trimmedValue
Comment on lines +59 to +61
Copy link

Copilot AI Sep 23, 2025

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.

Suggested change
// 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

Copilot uses AI. Check for mistakes.

if (type === "CONDENSE") {
setCustomCondensingPrompt(value || supportPrompt.default.CONDENSE)
setCustomCondensingPrompt(finalValue || supportPrompt.default.CONDENSE)
Copy link
Member

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.

vscode.postMessage({
type: "updateCondensingPrompt",
text: value || supportPrompt.default.CONDENSE,
text: finalValue || supportPrompt.default.CONDENSE,
Comment on lines +64 to +67
Copy link

Copilot AI Sep 23, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +64 to +67
Copy link

Copilot AI Sep 23, 2025

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.

Copilot uses AI. Check for mistakes.
})
// Also update the customSupportPrompts to trigger change detection
const updatedPrompts = { ...customSupportPrompts, [type]: finalValue }
setCustomSupportPrompts(updatedPrompts)
} else {
const updatedPrompts = { ...customSupportPrompts, [type]: value }
const updatedPrompts = { ...customSupportPrompts, [type]: finalValue }
Copy link
Member

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.

setCustomSupportPrompts(updatedPrompts)
}
}
Expand All @@ -75,6 +82,10 @@ const PromptsSettings = ({ customSupportPrompts, setCustomSupportPrompts }: Prom
type: "updateCondensingPrompt",
text: supportPrompt.default.CONDENSE,
})
// Also update the customSupportPrompts to trigger change detection
const updatedPrompts = { ...customSupportPrompts }
delete updatedPrompts[type]
setCustomSupportPrompts(updatedPrompts)
} else {
const updatedPrompts = { ...customSupportPrompts }
delete updatedPrompts[type]
Expand Down Expand Up @@ -147,10 +158,9 @@ const PromptsSettings = ({ customSupportPrompts, setCustomSupportPrompts }: Prom
value={getSupportPromptValue(activeSupportOption)}
onChange={(e) => {
const value =
(e as unknown as CustomEvent)?.detail?.target?.value ||
(e as unknown as CustomEvent)?.detail?.target?.value ??
((e as any).target as HTMLTextAreaElement).value
const trimmedValue = value.trim()
updateSupportPrompt(activeSupportOption, trimmedValue || undefined)
updateSupportPrompt(activeSupportOption, value)
}}
rows={6}
className="w-full"
Expand Down
Loading