Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Sep 18, 2025

Description

This PR fixes an issue where the custom storage path setting was not being respected when loading global custom modes. The extension would always look for custom modes in the default storage location, even when a custom path was configured.

Problem

When users configured a custom storage path via the roo-cline.customStoragePath setting, the extension would:

  • Correctly save new modes to the custom location
  • But fail to load them because it was looking in the default location

Solution

Updated ensureSettingsDirectoryExists() to use getSettingsDirectoryPath() which properly respects the custom storage path setting. This ensures that all operations (read/write) for global settings use the same path resolution logic.

Changes Made

  1. src/utils/globalContext.ts: Updated ensureSettingsDirectoryExists() to use getSettingsDirectoryPath() instead of hardcoding the path
  2. src/core/prompts/instructions/create-mode.ts: Updated to use getSettingsDirectoryPath() for displaying the correct path in instructions
  3. src/utils/migrateSettings.ts: Updated to use getSettingsDirectoryPath() for consistency

Testing

  • ✅ All existing tests pass
  • ✅ Manually tested with custom storage path configured
  • ✅ Verified that custom modes are now loaded from the custom storage location

Impact

This fix ensures that:

  • CustomModesManager.getCustomModesFilePath() correctly uses the custom storage path
  • SimpleInstaller.getModeFilePath() correctly uses the custom storage path
  • All global settings operations are consistent in their path resolution

Fixes #8122


Important

Fixes custom storage path handling for global custom modes by updating path resolution logic in key functions.

  • Behavior:
    • Fixes issue where custom storage path was ignored for global custom modes.
    • Updates ensureSettingsDirectoryExists() in globalContext.ts to use getSettingsDirectoryPath().
    • Updates createModeInstructions() in create-mode.ts to use getStorageBasePath().
    • Updates migrateSettings() in migrateSettings.ts to use getStorageBasePath().
  • Functions:
    • getStorageBasePath() in storage.ts now optionally avoids creating directories for path resolution.
    • getSettingsDirectoryPath() in storage.ts ensures directory creation.
  • Testing:
    • All existing tests pass.
    • Manually tested with custom storage path configured.
    • Verified custom modes load from custom storage location.

This description was created by Ellipsis for 604a606. You can customize this summary. It will automatically update as commits are pushed.

- Update ensureSettingsDirectoryExists() to use getSettingsDirectoryPath()
- This ensures custom storage path setting is honored when loading custom modes
- Also update createModeInstructions() and migrateSettings() for consistency

Fixes #8122
@roomote roomote bot requested review from cte, jr and mrubens as code owners September 18, 2025 01:52
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Sep 18, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 18, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing my own code is like debugging in a mirror - everything looks backwards but somehow still broken.

await mkdir(settingsDir, { recursive: true })
// Use getSettingsDirectoryPath which respects the custom storage path setting
const settingsDir = await getSettingsDirectoryPath(context.globalStorageUri.fsPath)
// getSettingsDirectoryPath already creates the directory, so we just return the path
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment on line 11 accurate? Since getSettingsDirectoryPath already creates the directory (as seen in storage.ts line 66), could we simplify this function to just be a direct pass-through? Something like:

Suggested change
// getSettingsDirectoryPath already creates the directory, so we just return the path
export async function ensureSettingsDirectoryExists(context: ExtensionContext): Promise<string> {
return getSettingsDirectoryPath(context.globalStorageUri.fsPath)
}

This would eliminate the redundant variable assignment and make the code more concise.

await mkdir(settingsDir, { recursive: true })
// Use getSettingsDirectoryPath which respects the custom storage path setting
const settingsDir = await getSettingsDirectoryPath(context.globalStorageUri.fsPath)
// getSettingsDirectoryPath already creates the directory, so we just return the path
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor observation: The original function had explicit mkdir with error handling, but now we're delegating all error handling to getSettingsDirectoryPath. Is this intentional? The errors will still bubble up, but we lose the ability to add any function-specific error context here if needed in the future.


const settingsDir = path.join(context.globalStorageUri.fsPath, "settings")
// Use getSettingsDirectoryPath to respect custom storage path setting
const settingsDir = await getSettingsDirectoryPath(context.globalStorageUri.fsPath)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good consistency update! This ensures the help text shows the correct path when a custom storage location is configured. Users will see the actual path where their modes will be saved.

… use no-create in migrations and instructions to avoid side effects
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Sep 23, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 23, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[BUG] Custom storage path not used for custom modes (global YAML ignored)

4 participants