-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add UI for file regex editing #5025
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| # File Regex UI Implementation for Modes Tab | ||
|
|
||
| ## Summary | ||
|
|
||
| I have successfully implemented a UI in the modes tab for displaying and editing the file regex for the edit files tool group. This allows users to configure which files can be edited when a specific mode is active. | ||
|
|
||
| ## Features Implemented | ||
|
|
||
| ### 1. **Display Current File Regex** | ||
|
|
||
| - Shows the current file regex pattern and description for the edit tool group | ||
| - Displays "all files" when no regex is configured | ||
| - Shows either the description or the regex pattern (formatted as `/pattern/`) | ||
|
|
||
| ### 2. **Edit Mode UI** | ||
|
|
||
| - **File Regex Input**: Text input field for entering regex patterns (e.g., `.*\.(js|ts|jsx|tsx)$`) | ||
| - **Description Input**: Text input field for entering a human-readable description (e.g., "JavaScript/TypeScript files") | ||
| - **Save/Cancel Buttons**: Action buttons to save or discard changes | ||
|
|
||
| ### 3. **Edit Button** | ||
|
|
||
| - Small edit icon button that appears next to the file regex display | ||
| - Only visible for custom modes (built-in modes cannot be edited) | ||
| - Triggers the edit mode when clicked | ||
|
|
||
| ### 4. **Input Validation** | ||
|
|
||
| - Handles both existing file regex configurations and new ones | ||
| - Properly converts simple "edit" groups to array format with options | ||
| - Preserves existing options when updating | ||
|
|
||
| ## Files Modified | ||
|
|
||
| ### 1. `webview-ui/src/components/modes/ModesView.tsx` | ||
|
|
||
| #### **State Added:** | ||
|
|
||
| ```typescript | ||
| const [editingFileRegex, setEditingFileRegex] = useState<string | null>(null) | ||
| const [fileRegexValue, setFileRegexValue] = useState("") | ||
| const [fileRegexDescription, setFileRegexDescription] = useState("") | ||
| ``` | ||
|
|
||
| #### **Functions Added:** | ||
|
|
||
| - `startEditingFileRegex()`: Initializes edit mode with current values | ||
| - `saveFileRegex()`: Saves changes to the mode configuration | ||
| - `cancelEditingFileRegex()`: Cancels editing and resets state | ||
|
|
||
| #### **UI Changes:** | ||
|
|
||
| - Replaced static file regex display with conditional rendering | ||
| - Added input fields and buttons that appear when editing | ||
| - Added edit button that shows only for custom modes | ||
|
|
||
| ### 2. `webview-ui/src/i18n/locales/en/prompts.json` | ||
|
|
||
| #### **Translation Keys Added:** | ||
|
|
||
| ```json | ||
| { | ||
| "tools": { | ||
| "fileRegex": "File Regex", | ||
| "description": "Description", | ||
| "save": "Save", | ||
| "cancel": "Cancel", | ||
| "editFileRegex": "Edit file regex" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Technical Implementation Details | ||
|
|
||
| ### **Data Structure Handling** | ||
|
|
||
| The implementation properly handles the `GroupEntry` union type: | ||
|
|
||
| - Simple string groups: `"edit"` | ||
| - Array groups with options: `["edit", { fileRegex: "pattern", description: "desc" }]` | ||
|
|
||
| ### **Type Safety** | ||
|
|
||
| - Uses proper TypeScript types throughout | ||
| - Handles the `GroupEntry` type correctly | ||
| - Maintains type safety when updating group configurations | ||
|
|
||
| ### **User Experience** | ||
|
|
||
| - Immediate visual feedback when entering edit mode | ||
| - Clear labeling of input fields with placeholders | ||
| - Non-destructive editing (changes only saved on explicit save) | ||
| - Edit button only appears for modes that can be modified | ||
|
|
||
| ## Usage | ||
|
|
||
| 1. **Navigate to Modes Tab**: Open the prompts/modes configuration | ||
| 2. **Select Custom Mode**: Choose a custom mode (not built-in) | ||
| 3. **Find Edit Tool Group**: Look for the "Edit Files" tool group section | ||
| 4. **Click Edit Button**: Click the small edit icon next to the file regex display | ||
| 5. **Configure Regex**: Enter the desired file pattern and description | ||
| 6. **Save Changes**: Click "Save" to apply or "Cancel" to discard | ||
|
|
||
| ## Example Use Cases | ||
|
|
||
| - **JavaScript Projects**: `.*\.(js|jsx|ts|tsx)$` - "JavaScript/TypeScript files" | ||
| - **Python Projects**: `.*\.py$` - "Python files" | ||
| - **Documentation**: `.*\.(md|txt|rst)$` - "Documentation files" | ||
| - **Config Files**: `.*\.(json|yaml|yml|toml)$` - "Configuration files" | ||
|
|
||
| ## Benefits | ||
|
|
||
| 1. **Enhanced Control**: Users can precisely control which files modes can edit | ||
| 2. **Safety**: Prevents accidental modification of sensitive files | ||
| 3. **Workflow Optimization**: Modes can be tailored for specific file types | ||
| 4. **User-Friendly**: Intuitive UI that doesn't require manual JSON editing | ||
| 5. **Backward Compatible**: Works with existing mode configurations | ||
|
|
||
| The implementation follows the existing code patterns and design system used throughout the Roo Code extension, ensuring consistency and maintainability. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The placeholder texts for the file regex and description inputs are hardcoded (e.g. 'e.g., .*.(js|ts|jsx|tsx)$'). To support localization consistently, please use translation keys instead of inline examples.
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.