Skip to content

Commit 2a00b49

Browse files
elianivaPrasangAPrajapati
authored andcommitted
fix(modes): custom modes under custom path not showing (RooCodeInc#8499)
1 parent f2f0d6e commit 2a00b49

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

src/core/prompts/instructions/create-mode.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import * as path from "path"
22
import * as vscode from "vscode"
33

44
import { GlobalFileNames } from "../../../shared/globalFileNames"
5+
import { getSettingsDirectoryPath } from "../../../utils/storage"
56

67
export async function createModeInstructions(context: vscode.ExtensionContext | undefined): Promise<string> {
78
if (!context) throw new Error("Missing VSCode Extension Context")
89

9-
const settingsDir = path.join(context.globalStorageUri.fsPath, "settings")
10+
const settingsDir = await getSettingsDirectoryPath(context.globalStorageUri.fsPath)
1011
const customModesPath = path.join(settingsDir, GlobalFileNames.customModes)
1112

1213
return `

src/core/prompts/sections/modes.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import * as path from "path"
21
import * as vscode from "vscode"
3-
import { promises as fs } from "fs"
42

53
import type { ModeConfig } from "@roo-code/types"
64

75
import { getAllModesWithPrompts } from "../../../shared/modes"
6+
import { ensureSettingsDirectoryExists } from "../../../utils/globalContext"
87

98
export async function getModesSection(context: vscode.ExtensionContext): Promise<string> {
10-
const settingsDir = path.join(context.globalStorageUri.fsPath, "settings")
11-
await fs.mkdir(settingsDir, { recursive: true })
9+
// Make sure path gets created
10+
await ensureSettingsDirectoryExists(context)
1211

1312
// Get all modes with their overrides from extension state
1413
const allModes = await getAllModesWithPrompts(context)

src/utils/globalContext.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
import { mkdir } from "fs/promises"
2-
import { join } from "path"
31
import { ExtensionContext } from "vscode"
4-
5-
export async function getGlobalFsPath(context: ExtensionContext): Promise<string> {
6-
return context.globalStorageUri.fsPath
7-
}
2+
import { getSettingsDirectoryPath } from "./storage"
83

94
export async function ensureSettingsDirectoryExists(context: ExtensionContext): Promise<string> {
10-
const settingsDir = join(context.globalStorageUri.fsPath, "settings")
11-
await mkdir(settingsDir, { recursive: true })
12-
return settingsDir
5+
// getSettingsDirectoryPath already handles the custom storage path setting
6+
return await getSettingsDirectoryPath(context.globalStorageUri.fsPath)
137
}

src/utils/migrateSettings.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as path from "path"
33
import * as fs from "fs/promises"
44
import { fileExistsAtPath } from "./fs"
55
import { GlobalFileNames } from "../shared/globalFileNames"
6+
import { getSettingsDirectoryPath } from "./storage"
67
import * as yaml from "yaml"
78

89
const deprecatedCustomModesJSONFilename = "custom_modes.json"
@@ -26,7 +27,7 @@ export async function migrateSettings(
2627
]
2728

2829
try {
29-
const settingsDir = path.join(context.globalStorageUri.fsPath, "settings")
30+
const settingsDir = await getSettingsDirectoryPath(context.globalStorageUri.fsPath)
3031

3132
// Check if settings directory exists first
3233
if (!(await fileExistsAtPath(settingsDir))) {

0 commit comments

Comments
 (0)