Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Jun 24, 2025

Description

image

image

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:

  • Export any mode (built-in or custom) to a YAML file
  • Include rules from .roo/rules-{slug}/ folders in the export
  • Import modes at either global or project level
  • Preserve rules structure for project-level imports
  • Merge rules into custom instructions for global imports

Implementation Details

Backend Changes

src/core/config/CustomModesManager.ts

  • Added checkRulesDirectoryHasContent() - checks if a mode has rules to include in export
  • Added exportModeWithRules() - exports mode configuration with rules files
  • Added importModeWithRules() - imports mode and handles rules based on target level

Message Handling

  • src/shared/WebviewMessage.ts - Added exportMode, importMode, and checkRulesDirectory message types
  • src/shared/ExtensionMessage.ts - Added result message types for UI feedback
  • src/core/webview/webviewMessageHandler.ts - Added handlers for import/export operations

Frontend Changes

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

  • Added export button that appears when a mode is selected
  • Added import button with dialog to choose import level (global/project)
  • Shows loading state during export operation
  • Tracks which modes have rules to export

UI/UX Features

  • Export: Click export button to save mode as YAML file with all rules included
  • Import Dialog: Choose between global (all projects) or project-level import
  • Smart Rules Handling:
    • Project imports preserve .roo/rules-{slug}/ folder structure
    • Global imports merge rules into custom instructions field
  • Loading States: Shows "Exporting..." during export operation

Internationalization

Translation Support (18 languages)

  • Added exportMode section with title, description, and exporting state
  • Added importMode section with level selection and descriptions
  • Supports all 18 languages in the extension

User Workflow

Export

  1. Select any mode in the modes view
  2. Click "Export Mode" button
  3. Choose save location for YAML file
  4. Mode and rules are exported together

Import

  1. Click "Import Mode" button
  2. Select YAML file to import
  3. Choose import level:
    • Project: Mode available only in current workspace, rules preserved in .roo/rules-{slug}/
    • Global: Mode available in all projects, rules merged into custom instructions

Technical Approach

  • Non-destructive: Original files remain unchanged during export
  • Flexible Import: Different handling for project vs global imports
  • Clean: Removes old rules folders before importing new ones
  • Portable: Self-contained YAML files for easy sharing

Benefits

  • Sharing: Easy to share custom modes with team members
  • Backup: Export modes before making changes
  • Templates: Create mode templates for different project types
  • Migration: Move modes between global and project levels

Verification

  • All existing tests pass
  • No TypeScript errors
  • No linting errors
  • Export creates valid YAML files
  • Import correctly handles both levels
  • Rules are properly included/excluded based on content
  • UI provides clear feedback during operations

Important

Adds import/export functionality for custom modes with rules, supporting global and project-level imports, and updates UI and translations for 18 languages.

  • Behavior:
    • Adds import/export functionality for modes, including rules from .roo/rules-{slug}/.
    • Supports global and project-level imports, preserving or merging rules accordingly.
  • Backend:
    • CustomModesManager.ts: Implements checkRulesDirectoryHasContent(), exportModeWithRules(), and importModeWithRules().
    • webviewMessageHandler.ts: Handles exportMode, importMode, and checkRulesDirectory messages.
  • Frontend:
    • ModesView.tsx: Adds UI for exporting and importing modes, including loading states and import level selection.
  • Internationalization:
    • Updates translation files for 18 languages to support new import/export features.

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

Copilot AI review requested due to automatic review settings June 24, 2025 18:02
@hannesrudolph hannesrudolph requested review from cte, jr and mrubens as code owners June 24, 2025 18:02
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request UI/UX UI/UX related or focused labels Jun 24, 2025
@delve-auditor
Copy link

delve-auditor bot commented Jun 24, 2025

No security or compliance issues detected. Reviewed everything up to 23f5bca.

Security Overview
  • 🔎 Scanned files: 43 changed file(s)
Detected Code Changes

The diff is too large to display a summary of code changes.

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

This comment was marked as outdated.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jun 24, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jun 24, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jun 24, 2025
Copy link
Collaborator Author

@hannesrudolph hannesrudolph left a 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! 🚀

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jun 24, 2025
@daniel-lxs daniel-lxs force-pushed the fix/consolidate-rules-description-display branch from ab07e0e to e217e73 Compare June 24, 2025 22:02
Copy link
Member

@daniel-lxs daniel-lxs left a 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.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 24, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jun 24, 2025
@hannesrudolph
Copy link
Collaborator Author

Wow @mrubens this is a really good idea. Brilliant really.

@mrubens
Copy link
Collaborator

mrubens commented Jun 25, 2025

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.

@hannesrudolph hannesrudolph marked this pull request as draft June 25, 2025 19:05
hannesrudolph and others added 5 commits June 29, 2025 12:47
…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
@hannesrudolph hannesrudolph force-pushed the fix/consolidate-rules-description-display branch from 72d0193 to c74bd6b Compare June 29, 2025 18:49
- 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
@hannesrudolph hannesrudolph moved this from PR [Needs Review] to PR [Needs Prelim Review] in Roo Code Roadmap Jun 29, 2025
Copy link
Contributor

Copilot AI left a 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)

- 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
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jun 30, 2025
- Changed 'Import mode' to 'Import Mode' to match 'Export Mode'
- Both buttons now use consistent title case
@mrubens mrubens merged commit 70726bc into main Jul 1, 2025
11 checks passed
@mrubens mrubens deleted the fix/consolidate-rules-description-display branch July 1, 2025 21:13
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jul 1, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 1, 2025
hannesrudolph added a commit that referenced this pull request Jul 3, 2025
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]>
utarn pushed a commit to modelharbor/ModelHarbor-Agent that referenced this pull request Jul 4, 2025
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Needs Review size:XXL This PR changes 1000+ lines, ignoring generated files. UI/UX UI/UX related or focused

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants