Skip to content

Commit df7a9c3

Browse files
author
Bruno Bergher
committed
Properly loads short descriptions in settings
1 parent 3afab13 commit df7a9c3

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/shared/modes.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,12 @@ export function getModeSelection(mode: string, promptComponent?: PromptComponent
193193

194194
const roleDefinition = modeToUse?.roleDefinition || ""
195195
const baseInstructions = modeToUse?.customInstructions || ""
196+
const description = (customMode || builtInMode)?.description || ""
196197

197198
return {
198199
roleDefinition,
199200
baseInstructions,
201+
description,
200202
}
201203
}
202204

@@ -287,6 +289,7 @@ export const defaultPrompts: Readonly<CustomModePrompts> = Object.freeze(
287289
roleDefinition: mode.roleDefinition,
288290
whenToUse: mode.whenToUse,
289291
customInstructions: mode.customInstructions,
292+
// Note: description is not included here as it's not part of the PromptComponent interface
290293
},
291294
]),
292295
),
@@ -303,6 +306,7 @@ export async function getAllModesWithPrompts(context: vscode.ExtensionContext):
303306
roleDefinition: customModePrompts[mode.slug]?.roleDefinition ?? mode.roleDefinition,
304307
whenToUse: customModePrompts[mode.slug]?.whenToUse ?? mode.whenToUse,
305308
customInstructions: customModePrompts[mode.slug]?.customInstructions ?? mode.customInstructions,
309+
// description is not overridable via customModePrompts, so we keep the original
306310
}))
307311
}
308312

@@ -326,6 +330,8 @@ export async function getFullModeDetails(
326330
// Get the base custom instructions
327331
const baseCustomInstructions = promptComponent?.customInstructions || baseMode.customInstructions || ""
328332
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 || ""
329335

330336
// If we have cwd, load and combine all custom instructions
331337
let fullCustomInstructions = baseCustomInstructions
@@ -344,6 +350,7 @@ export async function getFullModeDetails(
344350
...baseMode,
345351
roleDefinition: promptComponent?.roleDefinition || baseMode.roleDefinition,
346352
whenToUse: baseWhenToUse,
353+
description: baseDescription,
347354
customInstructions: fullCustomInstructions,
348355
}
349356
}
@@ -358,6 +365,16 @@ export function getRoleDefinition(modeSlug: string, customModes?: ModeConfig[]):
358365
return mode.roleDefinition
359366
}
360367

368+
// Helper function to safely get description
369+
export function getDescription(modeSlug: string, customModes?: ModeConfig[]): string {
370+
const mode = getModeBySlug(modeSlug, customModes)
371+
if (!mode) {
372+
console.warn(`No mode found for slug: ${modeSlug}`)
373+
return ""
374+
}
375+
return mode.description ?? ""
376+
}
377+
361378
// Helper function to safely get whenToUse
362379
export function getWhenToUse(modeSlug: string, customModes?: ModeConfig[]): string {
363380
const mode = getModeBySlug(modeSlug, customModes)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
Mode,
1616
getRoleDefinition,
1717
getWhenToUse,
18+
getDescription,
1819
getCustomInstructions,
1920
getAllModes,
2021
findModeBySlug as findCustomModeBySlug,
@@ -736,7 +737,7 @@ const ModesView = ({ onDone }: ModesViewProps) => {
736737
value={(() => {
737738
const customMode = findModeBySlug(visualMode, customModes)
738739
const prompt = customModePrompts?.[visualMode] as PromptComponent
739-
return customMode?.description ?? prompt?.description ?? ""
740+
return customMode?.description ?? prompt?.description ?? getDescription(visualMode)
740741
})()}
741742
onChange={(e) => {
742743
const value =

0 commit comments

Comments
 (0)