Skip to content

Commit a5018d5

Browse files
author
Bruno Bergher
committed
Only allow for customizing shoprt descriptions of custom modes, leaving built-in ones intact
1 parent 5dc5c31 commit a5018d5

File tree

2 files changed

+67
-53
lines changed

2 files changed

+67
-53
lines changed

src/shared/modes.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ export const defaultPrompts: Readonly<CustomModePrompts> = Object.freeze(
289289
roleDefinition: mode.roleDefinition,
290290
whenToUse: mode.whenToUse,
291291
customInstructions: mode.customInstructions,
292-
// Note: description is not included here as it's not part of the PromptComponent interface
292+
description: mode.description,
293293
},
294294
]),
295295
),
@@ -330,8 +330,7 @@ export async function getFullModeDetails(
330330
// Get the base custom instructions
331331
const baseCustomInstructions = promptComponent?.customInstructions || baseMode.customInstructions || ""
332332
const baseWhenToUse = promptComponent?.whenToUse || baseMode.whenToUse || ""
333-
// Description is not part of PromptComponent, so we use it directly from the mode
334-
const baseDescription = baseMode.description || ""
333+
const baseDescription = promptComponent?.description || baseMode.description || ""
335334

336335
// If we have cwd, load and combine all custom instructions
337336
let fullCustomInstructions = baseCustomInstructions

webview-ui/src/components/modes/ModesView.tsx

Lines changed: 65 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ const ModesView = ({ onDone }: ModesViewProps) => {
209209
// Field-specific error states
210210
const [nameError, setNameError] = useState<string>("")
211211
const [slugError, setSlugError] = useState<string>("")
212+
const [descriptionError, setDescriptionError] = useState<string>("")
212213
const [roleDefinitionError, setRoleDefinitionError] = useState<string>("")
213214
const [groupsError, setGroupsError] = useState<string>("")
214215

@@ -226,6 +227,7 @@ const ModesView = ({ onDone }: ModesViewProps) => {
226227
// Reset error states
227228
setNameError("")
228229
setSlugError("")
230+
setDescriptionError("")
229231
setRoleDefinitionError("")
230232
setGroupsError("")
231233
}, [])
@@ -259,6 +261,7 @@ const ModesView = ({ onDone }: ModesViewProps) => {
259261
// Clear previous errors
260262
setNameError("")
261263
setSlugError("")
264+
setDescriptionError("")
262265
setRoleDefinitionError("")
263266
setGroupsError("")
264267

@@ -289,6 +292,9 @@ const ModesView = ({ onDone }: ModesViewProps) => {
289292
case "slug":
290293
setSlugError(message)
291294
break
295+
case "description":
296+
setDescriptionError(message)
297+
break
292298
case "roleDefinition":
293299
setRoleDefinitionError(message)
294300
break
@@ -619,6 +625,7 @@ const ModesView = ({ onDone }: ModesViewProps) => {
619625
</div>
620626
</div>
621627

628+
{/* Name section */}
622629
<div className="mb-5">
623630
{/* Only show name and delete for custom modes */}
624631
{visualMode && findModeBySlug(visualMode, customModes) && (
@@ -657,6 +664,8 @@ const ModesView = ({ onDone }: ModesViewProps) => {
657664
</div>
658665
</div>
659666
)}
667+
668+
{/* Role Definition section */}
660669
<div className="mb-4">
661670
<div className="flex justify-between items-center mb-1">
662671
<div className="font-bold">{t("prompts:roleDefinition.title")}</div>
@@ -716,57 +725,60 @@ const ModesView = ({ onDone }: ModesViewProps) => {
716725
</div>
717726

718727
{/* Description section */}
719-
<div className="mb-4">
720-
<div className="flex justify-between items-center mb-1">
721-
<div className="font-bold">{t("prompts:description.title")}</div>
722-
{!findModeBySlug(visualMode, customModes) && (
723-
<Button
724-
variant="ghost"
725-
size="icon"
726-
onClick={() => {
727-
const currentMode = getCurrentMode()
728-
if (currentMode?.slug) {
729-
handleAgentReset(currentMode.slug, "description")
730-
}
731-
}}
732-
title={t("prompts:description.resetToDefault")}
733-
data-testid="description-reset">
734-
<span className="codicon codicon-discard"></span>
735-
</Button>
736-
)}
737-
</div>
738-
<div className="text-sm text-vscode-descriptionForeground mb-2">
739-
{t("prompts:description.description")}
728+
{/* Only show description for custom modes */}
729+
{visualMode && findModeBySlug(visualMode, customModes) && (
730+
<div className="mb-4">
731+
<div className="flex justify-between items-center mb-1">
732+
<div className="font-bold">{t("prompts:description.title")}</div>
733+
{!findModeBySlug(visualMode, customModes) && (
734+
<Button
735+
variant="ghost"
736+
size="icon"
737+
onClick={() => {
738+
const currentMode = getCurrentMode()
739+
if (currentMode?.slug) {
740+
handleAgentReset(currentMode.slug, "description")
741+
}
742+
}}
743+
title={t("prompts:description.resetToDefault")}
744+
data-testid="description-reset">
745+
<span className="codicon codicon-discard"></span>
746+
</Button>
747+
)}
748+
</div>
749+
<div className="text-sm text-vscode-descriptionForeground mb-2">
750+
{t("prompts:description.description")}
751+
</div>
752+
<VSCodeTextField
753+
value={(() => {
754+
const customMode = findModeBySlug(visualMode, customModes)
755+
const prompt = customModePrompts?.[visualMode] as PromptComponent
756+
return customMode?.description ?? prompt?.description ?? getDescription(visualMode)
757+
})()}
758+
onChange={(e) => {
759+
const value =
760+
(e as unknown as CustomEvent)?.detail?.target?.value ||
761+
((e as any).target as HTMLTextAreaElement).value
762+
const customMode = findModeBySlug(visualMode, customModes)
763+
if (customMode) {
764+
// For custom modes, update the JSON file
765+
updateCustomMode(visualMode, {
766+
...customMode,
767+
description: value.trim() || undefined,
768+
source: customMode.source || "global",
769+
})
770+
} else {
771+
// For built-in modes, update the prompts
772+
updateAgentPrompt(visualMode, {
773+
description: value.trim() || undefined,
774+
})
775+
}
776+
}}
777+
className="w-full"
778+
data-testid={`${getCurrentMode()?.slug || "code"}-description-textfield`}
779+
/>
740780
</div>
741-
<VSCodeTextField
742-
value={(() => {
743-
const customMode = findModeBySlug(visualMode, customModes)
744-
const prompt = customModePrompts?.[visualMode] as PromptComponent
745-
return customMode?.description ?? prompt?.description ?? getDescription(visualMode)
746-
})()}
747-
onChange={(e) => {
748-
const value =
749-
(e as unknown as CustomEvent)?.detail?.target?.value ||
750-
((e as any).target as HTMLTextAreaElement).value
751-
const customMode = findModeBySlug(visualMode, customModes)
752-
if (customMode) {
753-
// For custom modes, update the JSON file
754-
updateCustomMode(visualMode, {
755-
...customMode,
756-
description: value.trim() || undefined,
757-
source: customMode.source || "global",
758-
})
759-
} else {
760-
// For built-in modes, update the prompts
761-
updateAgentPrompt(visualMode, {
762-
description: value.trim() || undefined,
763-
})
764-
}
765-
}}
766-
className="w-full"
767-
data-testid={`${getCurrentMode()?.slug || "code"}-description-textfield`}
768-
/>
769-
</div>
781+
)}
770782

771783
{/* When to Use section */}
772784
<div className="mb-4">
@@ -1264,6 +1276,9 @@ const ModesView = ({ onDone }: ModesViewProps) => {
12641276
}}
12651277
className="w-full"
12661278
/>
1279+
{descriptionError && (
1280+
<div className="text-xs text-vscode-errorForeground mt-1">{descriptionError}</div>
1281+
)}
12671282
</div>
12681283

12691284
<div className="mb-4">

0 commit comments

Comments
 (0)