-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Import export modes #5074
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
Conversation
|
✅ No security or compliance issues detected. Reviewed everything up to 23f5bca. Security Overview
Detected Code ChangesThe diff is too large to display a summary of code changes. Reply to this PR with |
hannesrudolph
left a comment
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.
Thanks for addressing all the feedback from the Copilot review! I can confirm that all the critical issues have been fixed in the latest commit:
✅ Localization is now properly handled - The confirmation check now uses t("prompts:consolidateRules.confirmText").toLowerCase() instead of the hard-coded "confirm"
✅ Translation parameters are correct - Using { slug: consolidateRulesMode } to match the expected parameter
✅ All UI text is localized - Including the "Advanced" section title
✅ Dead code removed - The unused loadRuleFiles call has been cleaned up
The consolidate rules feature is a valuable addition that makes custom modes more portable and easier to share. The implementation is solid with:
- Proper error handling
- Comprehensive i18n support across 18 languages
- Clean UI with loading states and confirmation dialogs
- Good separation of concerns between frontend and backend
One minor note: there's still an unused import for loadRuleFiles on line 14 of CustomModesManager.ts, but that's a trivial cleanup that doesn't affect functionality.
Great work on this feature! 🚀
ab07e0e to
e217e73
Compare
daniel-lxs
left a comment
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 updated the code so the button is hidden if the .roomodes file doesn’t exist or doesn’t include the selected mode.
Previously, the button was always visible, and clicking 'Confirm' would silently fail if the file was missing or didn’t contain the selected mode.
|
Wow @mrubens this is a really good idea. Brilliant really. |
|
What do you think the main use case is here? People sharing modes with each other? If so, I wonder if we should just have an export button instead of deleting the rules files and moving the rules into the extension state. Maybe also worth thinking a little about where we want these rules to evolve in the long term. |
…t/export - Add path traversal validation to prevent writing files outside workspace - Replace all 'any' types with proper TypeScript interfaces - Add comprehensive JSDoc documentation for public methods - Fix concurrent operation handling in UI with isImporting state - Add missing 'importing' translation keys in all locales - Add security-focused test cases for path validation - Improve error handling and logging throughout Addresses all critical issues identified in PR review
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
- Fix import button getting stuck on 'Importing...' when user cancels file dialog - Add missing 'importing' translation key to all locales - Prevent error logging for user cancellation in import flow Fixes #5047
…d import - Fix path traversal test to use platform-aware paths with path.resolve() - Remove unused loadRuleFiles import from CustomModesManager.ts - Addresses review feedback for cross-platform compatibility
- Make mockWorkspacePath and mockRoomodes path construction consistent - Use path.join() to properly construct mockRoomodes path - This should fix the Windows test failures related to path mismatches
72d0193 to
c74bd6b
Compare
- Modified importModeWithRules to treat global imports same as project-level
- Rules files now created in global .roo/rules-{slug}/ folder
- Updated all translation files to reflect new behavior
- Fixes issue where rules were being squashed into custom instructions
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.
Pull Request Overview
This PR implements import/export functionality for custom modes, including their associated rules, and updates the backend, frontend, internationalization, and tests to support these new features.
- Adds export/import message types and handlers in the webview and extension message interfaces.
- Updates the UI in ModesView.tsx to incorporate export/import buttons and dialogs including loading state feedback.
- Enhances the CustomModesManager to read, merge, and write custom modes along with rules files, and updates tests and global settings accordingly.
Reviewed Changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| webview-ui/src/i18n/locales/*/prompts.json | Added new translation keys for import/export modes in multiple locales. |
| webview-ui/src/components/modes/ModesView.tsx | Added export/import states, buttons, dialogs, and related message handling for mode exports/imports. |
| src/shared/WebviewMessage.ts & ExtensionMessage.ts | Introduced new message types to support export/import operations. |
| src/core/webview/webviewMessageHandler.ts | Implemented message handler cases for exportMode, importMode, and checkRulesDirectory. |
| src/core/config/CustomModesManager.ts | Extended backend logic to support exporting and importing mode configurations and associated rule files. |
| src/core/config/tests/CustomModesManager.spec.ts | Updated tests to validate import/export behavior and rules folder handling. |
| packages/types/src/global-settings.ts | Extended global settings schema to include lastModeExportPath and lastModeImportPath. |
Comments suppressed due to low confidence (1)
…n and improve type safety
- Add customPrompts parameter to exportModeWithRules() method - Remove inefficient parse/stringify cycle in webview message handler - Merge custom prompts directly during export creation instead of post-processing
…omPrompts parameter - Add PromptComponent import from @roo-code/types - Update exportModeWithRules method signature to use proper typing - Enhances code maintainability and type safety
- Remove recursive: true from checkRulesDirectoryHasContent() - Remove recursive: true from exportModeWithRules() - Code only processes files at root level, recursive flag was misleading
- Changed 'Import mode' to 'Import Mode' to match 'Export Mode' - Both buttons now use consistent title case
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Co-authored-by: Daniel Riccio <[email protected]> Co-authored-by: Daniel <[email protected]>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Co-authored-by: Daniel Riccio <[email protected]> Co-authored-by: Daniel <[email protected]>
Description
Adds the ability to import and export custom modes, including any associated rules from the
.roo/rules-{slug}/folders. This feature makes it easy to share custom modes between projects and users.Feature Overview
The import/export feature provides:
.roo/rules-{slug}/folders in the exportImplementation Details
Backend Changes
src/core/config/CustomModesManager.tscheckRulesDirectoryHasContent()- checks if a mode has rules to include in exportexportModeWithRules()- exports mode configuration with rules filesimportModeWithRules()- imports mode and handles rules based on target levelMessage Handling
src/shared/WebviewMessage.ts- AddedexportMode,importMode, andcheckRulesDirectorymessage typessrc/shared/ExtensionMessage.ts- Added result message types for UI feedbacksrc/core/webview/webviewMessageHandler.ts- Added handlers for import/export operationsFrontend Changes
webview-ui/src/components/modes/ModesView.tsxUI/UX Features
.roo/rules-{slug}/folder structureInternationalization
Translation Support (18 languages)
exportModesection with title, description, and exporting stateimportModesection with level selection and descriptionsUser Workflow
Export
Import
.roo/rules-{slug}/Technical Approach
Benefits
Verification
Important
Adds import/export functionality for custom modes with rules, supporting global and project-level imports, and updates UI and translations for 18 languages.
.roo/rules-{slug}/.CustomModesManager.ts: ImplementscheckRulesDirectoryHasContent(),exportModeWithRules(), andimportModeWithRules().webviewMessageHandler.ts: HandlesexportMode,importMode, andcheckRulesDirectorymessages.ModesView.tsx: Adds UI for exporting and importing modes, including loading states and import level selection.This description was created by
for 23f5bca. You can customize this summary. It will automatically update as commits are pushed.