Repository navigation
Add: rename folder option while creating workspace - #6481
Conversation
WalkthroughThe change introduces a folder-name management system to the workspace creation component. It adds a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
packages/bruno-app/src/components/WorkspaceSidebar/CreateWorkspace/index.js (2)
114-119: Consider touching the folder name field when auto-generating.The auto-generated
workspaceFolderNameis never marked as "touched," so validation errors won't display until form submission. IfsanitizeNameproduces an invalid result, users might be confused when an error suddenly appears on a field they never directly interacted with.🔎 Optional improvement to show validation immediately
onChange={(e) => { formik.handleChange(e); if (!isEditing) { - formik.setFieldValue('workspaceFolderName', sanitizeName(e.target.value)); + formik.setFieldValue('workspaceFolderName', sanitizeName(e.target.value)); + formik.setFieldTouched('workspaceFolderName', true); } }}This ensures validation feedback appears immediately for the auto-generated folder name.
141-155: Consider adding a reset option for manually edited folder names.The toggle icons allow entering and exiting edit mode, but there's no way for users to reset a manually-edited folder name back to the auto-generated one (without clearing the workspace name entirely). This could be useful if a user makes manual edits but then wants to revert.
💡 Possible enhancement
You could add a small "reset" button or icon next to the back arrow that re-applies
sanitizeName(workspaceName)when clicked. For example:{isEditing && ( <div className="flex gap-2"> <IconRefresh className="cursor-pointer opacity-50 hover:opacity-80" size={16} title="Reset to auto-generated" onClick={() => { formik.setFieldValue('workspaceFolderName', sanitizeName(formik.values.workspaceName)); }} /> <IconArrowBackUp className="cursor-pointer opacity-50 hover:opacity-80" size={16} onClick={() => setIsEditing(false)} /> </div> )}This is purely optional and depends on whether users are likely to need this workflow.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/bruno-app/src/components/WorkspaceSidebar/CreateWorkspace/index.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (CODING_STANDARDS.md)
**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions.() => {}is good
No space between function name and parentheses.func()notfunc ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly
Files:
packages/bruno-app/src/components/WorkspaceSidebar/CreateWorkspace/index.js
🧠 Learnings (1)
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.
Applied to files:
packages/bruno-app/src/components/WorkspaceSidebar/CreateWorkspace/index.js
🧬 Code graph analysis (1)
packages/bruno-app/src/components/WorkspaceSidebar/CreateWorkspace/index.js (3)
packages/bruno-app/src/components/Help/index.js (1)
Help(11-38)packages/bruno-app/src/components/Icons/IconEdit/index.js (1)
IconEdit(3-17)packages/bruno-app/src/components/PathDisplay/index.js (1)
PathDisplay(6-24)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Unit Tests
- GitHub Check: Playwright E2E Tests
- GitHub Check: CLI Tests
- GitHub Check: SSL Tests - macOS
- GitHub Check: SSL Tests - Windows
- GitHub Check: SSL Tests - Linux
🔇 Additional comments (5)
packages/bruno-app/src/components/WorkspaceSidebar/CreateWorkspace/index.js (5)
1-14: LGTM! Clean imports.All new imports are properly used and follow the project's coding standards.
21-21: LGTM! Appropriate state initialization.The
isEditingstate correctly defaults tofalse, allowing the folder name to display in view mode initially while auto-syncing with the workspace name.
23-29: LGTM! Consistent form structure.The
workspaceFolderNamefield is properly initialized following the same pattern as other form fields.
57-57: Verify thecreateWorkspaceActionsignature matches the new parameters.The submission logic now passes
workspaceFolderNameas a separate parameter. Ensure the action function signature has been updated to accept(workspaceName, workspaceFolderName, workspaceLocation).The verification script from the previous comment will check this signature.
127-177: LGTM! Well-structured conditional folder name UI.The conditional rendering, toggle between edit and view modes, Help tooltip, and error handling are all implemented cleanly. The UX flow is intuitive.
| workspaceFolderName: Yup.string() | ||
| .min(1, 'must be at least 1 character') | ||
| .max(255, 'must be 255 characters or less') | ||
| .test('is-valid-folder-name', function (value) { | ||
| const isValid = validateName(value); | ||
| return isValid ? true : this.createError({ message: validateNameError(value) }); | ||
| }) | ||
| .required('folder name is required'), |
There was a problem hiding this comment.
Consider adding uniqueness validation for folder names.
The validation for workspaceFolderName checks format and length, but unlike workspaceName (lines 35-40), it doesn't verify uniqueness. If two workspaces are created in the same location with the same folder name, a filesystem collision could occur.
🔎 Suggested uniqueness check
workspaceFolderName: Yup.string()
.min(1, 'must be at least 1 character')
.max(255, 'must be 255 characters or less')
.test('is-valid-folder-name', function (value) {
const isValid = validateName(value);
return isValid ? true : this.createError({ message: validateNameError(value) });
})
+ .test('unique-folder-name', 'A workspace folder with this name already exists in this location', function (value) {
+ if (!value || !this.parent.workspaceLocation) return true;
+ const folderPath = `${this.parent.workspaceLocation}/${value}`;
+ return !workspaces.some((w) => w.path === folderPath);
+ })
.required('folder name is required'),Note: This assumes workspaces have a path property. Adjust based on your actual workspace data structure.
Run the following script to check the workspace data structure and verify if path-based uniqueness checking is feasible:
#!/bin/bash
# Description: Examine workspace structure and createWorkspaceAction signature
# Check workspace data structure
ast-grep --pattern 'workspaces: {
$$$
}'
# Check createWorkspaceAction signature
ast-grep --pattern 'export $_ createWorkspaceAction($$$) {
$$$
}'
# Look for existing folder collision handling
rg -A 5 -B 2 'createWorkspaceAction|workspace.*folder|folder.*collision'🤖 Prompt for AI Agents
In packages/bruno-app/src/components/WorkspaceSidebar/CreateWorkspace/index.js
around lines 41-48, the workspaceFolderName Yup schema validates format/length
but not uniqueness; add a uniqueness test similar to workspaceName that checks
other workspaces for a folder collision (consider path + folder name or
this.parent.path or validation context for workspace list), make the check trim
and case-insensitive, and return this.createError(...) on collision; if existing
workspace list must be fetched, implement an async Yup.test and ensure the
validator receives workspaces via validation context/options so it can
synchronously check without side effects.
| value={formik.values.workspaceFolderName || ''} | ||
| /> | ||
| ) : ( | ||
| <PathDisplay baseName={formik.values.workspaceFolderName} /> |
There was a problem hiding this comment.
Pass iconType="folder" to PathDisplay.
The PathDisplay component defaults to iconType="file" but this is displaying a folder name. Pass iconType="folder" for correct semantics.
🔎 Proposed fix
-<PathDisplay baseName={formik.values.workspaceFolderName} />
+<PathDisplay baseName={formik.values.workspaceFolderName} iconType="folder" />📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <PathDisplay baseName={formik.values.workspaceFolderName} /> | |
| <PathDisplay baseName={formik.values.workspaceFolderName} iconType="folder" /> |
🤖 Prompt for AI Agents
In packages/bruno-app/src/components/WorkspaceSidebar/CreateWorkspace/index.js
around line 171, PathDisplay is rendering a folder name but defaults to
iconType="file"; update the JSX to pass iconType="folder" to PathDisplay (i.e.,
add the prop iconType="folder" to the component) so it renders the correct
folder icon/semantics.
Description
JIRA
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.