-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(custom-instructions): migrate custom instructions to file-based storage #4002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…storage See discussion: RooCodeInc#4000 Migrated the storage of "Custom Instructions for All Modes" from VS Code's global state to a dedicated file: `...Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/custom_instructions.md`. Key changes include: - Implemented a migration utility to automatically move existing custom instructions from global state to the new file upon extension update. - Introduced new commands and UI buttons within the Prompts view to: - Open the `custom_instructions.md` file directly in the editor for easy editing. - Refresh the custom instructions in the UI by re-reading them from the file, ensuring changes made directly to the file are reflected. - The `updateCustomInstructions` function now writes/deletes the file instead of updating global state. - The initial state and refreshes now read custom instructions directly from the file. This change provides a more robust and user-friendly way to manage custom instructions, allowing for external editing and version control.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @devxpain, This looks like a great idea, it should help a lot with the memory issues we are having.
I left some questions that are worth looking into to prevent potential issues with the file.
But overall I like what you did here, let me know if you want to discuss this further.
content = await fs.readFile(customInstructionsFilePath, "utf-8") | ||
} catch (error) { | ||
if ((error as NodeJS.ErrnoException).code !== "ENOENT") { | ||
throw error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed we're silently catching ENOENT errors here but throwing others. Is this intentional? Should we be consistent with error handling across all the new methods?
const customInstructionsFilePath = path.join(settingsDir, GlobalFileNames.customInstructions) | ||
|
||
if (customInstructionsContent && !(await fileExistsAtPath(customInstructionsFilePath))) { | ||
await fs.writeFile(customInstructionsFilePath, customInstructionsContent, "utf-8") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the migration fails partway through (e.g., file write succeeds but globalState update fails)? Should we wrap this in a try-catch and potentially rollback on failure to prevent data loss?
type: "refreshCustomInstructions", | ||
}) | ||
}} | ||
title={t("prompts:globalCustomInstructions.refreshFile")}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When users click the refresh button, should we provide some visual feedback (like a brief loading state or toast notification) to confirm the refresh happened? Right now it might not be clear if the action succeeded.
const settingsDirPath = await this.ensureSettingsDirectoryExists() | ||
const customInstructionsFilePath = path.join(settingsDirPath, GlobalFileNames.customInstructions) | ||
const fileUri = vscode.Uri.file(customInstructionsFilePath) | ||
await vscode.commands.executeCommand("vscode.open", fileUri, { preview: false, preserveFocus: true }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the custom instructions file doesn't exist when a user clicks the open button? Should we create an empty file first to avoid VSCode showing an error?
await vscode.commands.executeCommand("workbench.action.files.revert", fileUri) | ||
} | ||
|
||
async refreshCustomInstructions(): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed there aren't any tests for these new methods. Should we add test coverage for:
File creation/deletion behavior
Migration logic
Error handling scenarios
The new UI interactions?
Hi @daniel-lxs, thanks for your feedback and review! |
Related GitHub Issue
Discussions: #4000
Description
Migrated the storage of "Custom Instructions for All Modes" from VS Code's global state to a dedicated file:
...Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/custom_instructions.md
.Key changes include:
custom_instructions.md
file directly in the editor for easy editing.updateCustomInstructions
function now writes/deletes the file instead of updating global state.This change provides a more robust and user-friendly way to manage custom instructions, allowing for external editing and version control.
Test Procedure
Build .vsix and install then test manually
Type of Change
src
or test files.Pre-Submission Checklist
npm run lint
).console.log
) has been removed.npm test
).main
branch.npm run changeset
if this PR includes user-facing changes or dependency updates.Screenshots / Videos
Documentation Updates
Additional Notes
Get in Touch
Important
Migrate custom instructions from VS Code's global state to a file-based system with new UI and commands for management.
custom_instructions.md
file inClineProvider.ts
.openCustomInstructionsFile
andrefreshCustomInstructions
commands inwebviewMessageHandler.ts
.PromptsView.tsx
to include UI buttons for opening and refreshing custom instructions.migrateSettings.ts
to move instructions from global state to file.PromptsView.tsx
for opening and refreshing thecustom_instructions.md
file.prompts.json
to include new strings for custom instructions management.This description was created by
for 799a1cd. You can customize this summary. It will automatically update as commits are pushed.