Skip to content

Add: rename folder option while creating workspace - #6481

Merged
bijin-bruno merged 1 commit into
usebruno:mainfrom
naman-bruno:add/folder-name-workspace
Dec 22, 2025
Merged

bijin-bruno merged 1 commit into
usebruno:mainfrom
naman-bruno:add/folder-name-workspace

Conversation

@naman-bruno

@naman-bruno naman-bruno commented Dec 22, 2025 •

Copy link
Copy Markdown
Collaborator

Description

JIRA

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

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

  • New Features
    • Users can now customize the folder name when creating a workspace
    • Help text provides guidance on proper folder naming conventions
    • Folder names are automatically sanitized and validated in real-time
    • Toggle between viewing and editing folder names with a dedicated interface
    • Folder name validation is required before workspace creation

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 22, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The change introduces a folder-name management system to the workspace creation component. It adds a new workspaceFolderName field with validation, auto-sanitization triggered by workspace name input, conditional UI rendering, and an editable toggle for the folder name display. The submission logic is updated to pass the folder name instead of workspace name.

Changes

Cohort / File(s) Summary
Workspace Folder Name Field Addition
packages/bruno-app/src/components/WorkspaceSidebar/CreateWorkspace/index.js
Introduces workspaceFolderName state with validation rules; adds auto-sanitization via sanitizeName on workspace name input; implements isEditing toggle for folder name input/display; conditionally renders folder-name UI only after non-empty workspace name provided; updates workspace creation submission to use workspaceFolderName instead of workspaceName for the folder parameter.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Validation logic for workspaceFolderName and its integration with form state
  • Auto-sanitization behavior triggered on workspace name input and potential edge cases
  • Conditional rendering logic to ensure it doesn't break existing workspace creation flow
  • Submission logic to verify workspaceFolderName is correctly passed to createWorkspaceAction

Suggested reviewers

  • bijin-bruno
  • lohit-bruno
  • helloanoop

Poem

A folder blooms where names take root,
Sanitized and validated—no dispute. 📁
Toggle edit, display with grace,
Workspace creation finds its place. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main feature: adding a folder rename option during workspace creation, which matches the core functionality in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 workspaceFolderName is never marked as "touched," so validation errors won't display until form submission. If sanitizeName produces 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

📥 Commits

Reviewing files that changed from the base of the PR and between cba164b and fc078e4.

📒 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() not func ()
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 isEditing state correctly defaults to false, allowing the folder name to display in view mode initially while auto-syncing with the workspace name.


23-29: LGTM! Consistent form structure.

The workspaceFolderName field is properly initialized following the same pattern as other form fields.


57-57: Verify the createWorkspaceAction signature matches the new parameters.

The submission logic now passes workspaceFolderName as 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.

Comment on lines +41 to +48
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'),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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} />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
<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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants