Skip to content

feat: allow user to change default workspace location (#6816)#7485

Open
mikiubo wants to merge 1 commit intousebruno:mainfrom
mikiubo:feature/default_workspace_change
Open

feat: allow user to change default workspace location (#6816)#7485
mikiubo wants to merge 1 commit intousebruno:mainfrom
mikiubo:feature/default_workspace_change

Conversation

@mikiubo
Copy link

@mikiubo mikiubo commented Mar 13, 2026

Add "Set as default" option to workspace context menu, persist the default workspace in lastOpenedWorkspaces to prevent losing it on change, and preserve the original workspace name instead of always overriding it with "My Workspace".

Description

image

fixes: #6816

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

Summary by CodeRabbit

  • New Features

    • Added "Set as default" action in the workspace context menu to mark any workspace as your default.
  • Improvements

    • Preserve custom workspace names when a workspace is designated as default.
    • Ensure the default workspace is recorded among recently opened workspaces so it appears in open/tracking flows.
    • State update now supports changing a workspace identifier and keeps the active workspace reference in sync.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

This PR adds a "Set as default" action in Manage Workspace, implements an IPC handler to persist a default workspace path, adjusts default-name derivation to prefer an explicit workspace name, and extends the Redux updateWorkspace reducer to accept an optional newUid for UID updates.

Changes

Cohort / File(s) Summary
Manage Workspace UI
packages/bruno-app/src/components/ManageWorkspace/index.js
Adds "Set as default" context action and handleSetAsDefault which calls IPC to set default path, updates workspace types, dispatches updateWorkspace, and shows success/failure toasts.
Electron IPC / Workspace flow
packages/bruno-electron/src/ipc/workspace.js
Adds renderer:set-default-workspace-path handler; ensures lastOpenedWorkspaces.add(workspacePath) is applied when opening workspaces and when renderer-ready finds a default; validates path and returns previous default UID on success.
Workspace config name handling
packages/bruno-electron/src/app/apiSpecs.js, packages/bruno-electron/src/app/workspace-watcher.js
When preparing/ emitting default workspace config, preserve workspaceConfig.name if present; otherwise fall back to DEFAULT_WORKSPACE_NAME.
Redux workspaces slice
packages/bruno-app/src/providers/ReduxStore/slices/workspaces/index.js
updateWorkspace reducer now accepts optional newUid in payload, updates target workspace.uid and activeWorkspaceUid when applicable.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant ManageWorkspace as ManageWorkspace (UI)
    participant ipcRenderer as ipcRenderer
    participant ipcMain as ipcMain (Electron)
    participant WorkspaceMgr as WorkspaceManager
    participant Redux as Redux Store
    participant Toast as Toast Notification

    User->>ManageWorkspace: Click "Set as default"
    ManageWorkspace->>ManageWorkspace: Skip if already default
    ManageWorkspace->>ipcRenderer: invoke renderer:set-default-workspace-path(workspacePath)
    ipcRenderer->>ipcMain: IPC call
    ipcMain->>WorkspaceMgr: validate & set default workspace path
    WorkspaceMgr->>WorkspaceMgr: get previous default UID
    WorkspaceMgr->>WorkspaceMgr: revert previous default type (if any)
    WorkspaceMgr->>WorkspaceMgr: mark new default type
    ipcMain-->>ipcRenderer: return { success, previousDefaultUid }
    ipcRenderer->>Redux: dispatch updateWorkspace({ uid: previousDefaultUid, ... }) (and for new default)
    Redux->>Redux: apply updates, handle newUid -> update activeWorkspaceUid if needed
    ManageWorkspace->>Toast: show success/failure
    Toast->>User: display notification
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • lohit-bruno
  • bijin-bruno
  • helloanoop

Poem

🌟 A workspace chosen, a banner unfurled,
IPC whispers across the Electron world,
Redux updates the UID and type,
Toasts sing success — all set up right,
One path now leads, the default pearled.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main feature: allowing users to change the default workspace location via a new UI option.
Linked Issues check ✅ Passed The PR implements all core requirements: adds 'Set as default' option to workspace menu, persists default workspace location, and preserves workspace names instead of overriding them.
Out of Scope Changes check ✅ Passed All changes directly support the feature scope: UI additions for 'Set as default', IPC handler for persistence, Redux state updates, and workspace name handling adjustments.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@wwwnuk
Copy link

wwwnuk commented Mar 13, 2026 via email

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bruno-app/src/components/ManageWorkspace/index.js`:
- Around line 64-98: The IPC handler that calls savePreferences must also update
the in-memory cache on the singleton defaultWorkspaceManager so the session
reflects the new default immediately; in the
ipcMain.handle('renderer:save-preferences') flow, after await
savePreferences(preferences) (and only if
preferences?.general?.defaultWorkspacePath is present), require the
defaultWorkspaceManager and call its
setDefaultWorkspacePath(preferences.general.defaultWorkspacePath) so the
manager's this.defaultWorkspacePath is updated; keep the existing error handling
and await the setDefaultWorkspacePath call to ensure cache and disk stay in
sync.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fd496433-82ed-42f9-a9c8-f92ba71d25af

📥 Commits

Reviewing files that changed from the base of the PR and between 83ddfc3 and e0d4272.

📒 Files selected for processing (2)
  • packages/bruno-app/src/components/ManageWorkspace/index.js
  • packages/bruno-electron/src/ipc/workspace.js

@mikiubo mikiubo force-pushed the feature/default_workspace_change branch from e0d4272 to ad1ea07 Compare March 13, 2026 22:02
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bruno-electron/src/ipc/workspace.js`:
- Around line 625-632: The handler for 'renderer:set-default-workspace-path'
currently accepts any path and swallows persistence issues; update the
ipcMain.handle implementation to first validate the incoming workspacePath
(e.g., confirm it exists and is a directory using fs.stat or an existing
validation helper) and reject invalid paths with a thrown error, then call await
defaultWorkspaceManager.setDefaultWorkspacePath(workspacePath) and do not
swallow errors — either remove the try/catch or rethrow caught errors so
persistence failures bubble up; additionally, after the call assert persistence
succeeded (for example by comparing
defaultWorkspaceManager.getDefaultWorkspacePath() to workspacePath) and throw if
they differ so the renderer never receives { success: true } for an invalid or
non-persisted default.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2c49b3a1-15fc-435c-ac35-737f99b666d7

📥 Commits

Reviewing files that changed from the base of the PR and between e0d4272 and ad1ea07.

📒 Files selected for processing (2)
  • packages/bruno-app/src/components/ManageWorkspace/index.js
  • packages/bruno-electron/src/ipc/workspace.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bruno-app/src/components/ManageWorkspace/index.js

@mikiubo mikiubo force-pushed the feature/default_workspace_change branch from ad1ea07 to 91f3fad Compare March 14, 2026 08:47
@pull-request-size pull-request-size bot added size/L and removed size/M labels Mar 14, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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/Environments/EnvironmentSettings/EnvironmentList/StyledWrapper.js (1)

116-122: Consider avoiding !important unless strictly necessary.

Multiple !important declarations here may indicate specificity conflicts. If these are needed to override inherited styles from a parent component, consider restructuring the CSS hierarchy instead.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/StyledWrapper.js`
around lines 116 - 122, The .section-header rules in StyledWrapper.js use
multiple !important declarations; remove the !important flags and instead
resolve specificity by either increasing selector specificity (e.g., target the
styled component wrapper + .section-header or use a nested selector), or convert
these rules into the styled-component that renders the section header so the
styles are applied directly (e.g., add props or a dedicated styled component for
SectionHeader) to avoid needing !important; update the CSS in StyledWrapper.js
by removing !important and applying one of these specificity/structural
approaches to ensure the intended margins/padding/border-radius are respected.
packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/StyledWrapper.js (1)

117-123: Inconsistent styling with sibling component.

This .section-header block omits !important while packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/StyledWrapper.js uses !important on the same properties. Consider unifying the approach across both files.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/StyledWrapper.js`
around lines 117 - 123, The .section-header rule in StyledWrapper.js is missing
the !important flags used by the sibling component; update the CSS declarations
for .section-header (margin-inline, padding-left, padding-right, padding-block,
and border-radius if necessary) to include !important on the same properties so
the styling is consistent with the other EnvironmentList StyledWrapper and
avoids specificity mismatches.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bruno-app/src/components/ManageWorkspace/index.js`:
- Around line 65-66: The "Set as default" menu item is still rendered for
workspaces without a pathname; update the render logic in ManageWorkspace (where
workspace and currentDefault are used) to skip or hide the "Set as default"
action when workspace.pathname is falsy or workspace.type === 'default'. Locate
the menu item rendering for the SetAsDefault action and add the same guard used
earlier (workspace.type === 'default' || !workspace.pathname) so the menu option
is not shown for pathless workspaces.
- Around line 69-73: Guard the remap dispatch so you don't create duplicate
'default' UIDs: only call dispatch(updateWorkspace({ uid: currentDefault.uid,
newUid: result.previousDefaultUid, type: 'workspace' })) when both
currentDefault and result.previousDefaultUid are truthy; otherwise skip that
remap before you dispatch updateWorkspace({ uid: workspace.uid, newUid:
'default', type: 'default' }) and show the toast, ensuring you reference
currentDefault, result.previousDefaultUid, dispatch(updateWorkspace...), and
workspace.uid to locate the change.

---

Nitpick comments:
In
`@packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/StyledWrapper.js`:
- Around line 116-122: The .section-header rules in StyledWrapper.js use
multiple !important declarations; remove the !important flags and instead
resolve specificity by either increasing selector specificity (e.g., target the
styled component wrapper + .section-header or use a nested selector), or convert
these rules into the styled-component that renders the section header so the
styles are applied directly (e.g., add props or a dedicated styled component for
SectionHeader) to avoid needing !important; update the CSS in StyledWrapper.js
by removing !important and applying one of these specificity/structural
approaches to ensure the intended margins/padding/border-radius are respected.

In
`@packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/StyledWrapper.js`:
- Around line 117-123: The .section-header rule in StyledWrapper.js is missing
the !important flags used by the sibling component; update the CSS declarations
for .section-header (margin-inline, padding-left, padding-right, padding-block,
and border-radius if necessary) to include !important on the same properties so
the styling is consistent with the other EnvironmentList StyledWrapper and
avoids specificity mismatches.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8baab5c5-fa8a-459d-b380-bcb8fefb473f

📥 Commits

Reviewing files that changed from the base of the PR and between ad1ea07 and 91f3fad.

📒 Files selected for processing (11)
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/StyledWrapper.js
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/StyledWrapper.js
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js
  • packages/bruno-app/src/components/ManageWorkspace/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/StyledWrapper.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/StyledWrapper.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/index.js
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaces/index.js
  • packages/bruno-electron/src/app/apiSpecs.js
  • packages/bruno-electron/src/app/workspace-watcher.js
  • packages/bruno-electron/src/ipc/workspace.js

@mikiubo mikiubo force-pushed the feature/default_workspace_change branch from 91f3fad to 6ebf8ba Compare March 14, 2026 09:07
@pull-request-size pull-request-size bot added size/M and removed size/L labels Mar 14, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
packages/bruno-electron/src/ipc/workspace.js (1)

625-639: ⚠️ Potential issue | 🟠 Major

Do not return success if default workspace persistence can fail silently.

defaultWorkspaceManager.setDefaultWorkspacePath() (in packages/bruno-electron/src/store/default-workspace.js) catches preference write failures, so this handler can still return { success: true } even when the update is not persisted. Please make persistence failures bubble up before returning success.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-electron/src/ipc/workspace.js` around lines 625 - 639, The
handler renderer:set-default-workspace-path currently assumes
defaultWorkspaceManager.setDefaultWorkspacePath succeeded, but that method
swallows preference-write errors so persistence can fail silently; update the
flow so persistence failures bubble up: either modify
defaultWorkspaceManager.setDefaultWorkspacePath (in default-workspace.js) to
throw on write failure instead of catching/suppressing, or make it return a
success boolean and have the ipc handler check that result and throw if false
before returning { success: true }; ensure you reference the
getWorkspaceUid(previousDefaultPath) usage remains unchanged and only return
success after confirmed persistence.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/bruno-electron/src/ipc/workspace.js`:
- Around line 625-639: The handler renderer:set-default-workspace-path currently
assumes defaultWorkspaceManager.setDefaultWorkspacePath succeeded, but that
method swallows preference-write errors so persistence can fail silently; update
the flow so persistence failures bubble up: either modify
defaultWorkspaceManager.setDefaultWorkspacePath (in default-workspace.js) to
throw on write failure instead of catching/suppressing, or make it return a
success boolean and have the ipc handler check that result and throw if false
before returning { success: true }; ensure you reference the
getWorkspaceUid(previousDefaultPath) usage remains unchanged and only return
success after confirmed persistence.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c2867c96-6d2a-4bb3-b144-8ebfca077af2

📥 Commits

Reviewing files that changed from the base of the PR and between 91f3fad and 6ebf8ba.

📒 Files selected for processing (5)
  • packages/bruno-app/src/components/ManageWorkspace/index.js
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaces/index.js
  • packages/bruno-electron/src/app/apiSpecs.js
  • packages/bruno-electron/src/app/workspace-watcher.js
  • packages/bruno-electron/src/ipc/workspace.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bruno-app/src/components/ManageWorkspace/index.js

@mikiubo mikiubo force-pushed the feature/default_workspace_change branch from 6ebf8ba to 6717787 Compare March 14, 2026 09:28
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/bruno-app/src/components/ManageWorkspace/index.js (1)

182-186: Filter out falsy items from the menu array.

When workspace.pathname is falsy, line 185 evaluates to false, which gets included in the items array. This causes React console warnings (missing keys) and empty menu items rendered in the DOM.

Proposed fix
                   items={[
                     { id: 'rename', label: 'Rename', onClick: () => handleRenameClick(workspace) },
                     { id: 'remove', label: 'Remove', onClick: () => handleCloseClick(workspace) },
                     workspace.pathname && { id: 'set_as_default', label: 'Set as default', onClick: () => handleSetAsDefault(workspace) }
-                  ]}
+                  ].filter(Boolean)}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-app/src/components/ManageWorkspace/index.js` around lines 182
- 186, The items array passed to the menu includes a falsy boolean when
workspace.pathname is falsy, causing empty menu entries; update the construction
of the items array in ManageWorkspace so only valid objects are included (e.g.,
build the array with the three item objects and then remove falsy entries via
.filter(Boolean) or conditionally push the set_as_default object), targeting the
items assignment where handleRenameClick, handleCloseClick, and
handleSetAsDefault are used.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/bruno-app/src/components/ManageWorkspace/index.js`:
- Around line 182-186: The items array passed to the menu includes a falsy
boolean when workspace.pathname is falsy, causing empty menu entries; update the
construction of the items array in ManageWorkspace so only valid objects are
included (e.g., build the array with the three item objects and then remove
falsy entries via .filter(Boolean) or conditionally push the set_as_default
object), targeting the items assignment where handleRenameClick,
handleCloseClick, and handleSetAsDefault are used.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 471d4314-a16e-40bf-bd60-e4a26ad18733

📥 Commits

Reviewing files that changed from the base of the PR and between 6ebf8ba and 6717787.

📒 Files selected for processing (5)
  • packages/bruno-app/src/components/ManageWorkspace/index.js
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaces/index.js
  • packages/bruno-electron/src/app/apiSpecs.js
  • packages/bruno-electron/src/app/workspace-watcher.js
  • packages/bruno-electron/src/ipc/workspace.js

Add "Set as default" option to workspace context menu, persist the
default workspace in lastOpenedWorkspaces to prevent losing it on
change, and preserve the original workspace name instead of always
overriding it with "My Workspace".
@mikiubo mikiubo force-pushed the feature/default_workspace_change branch from 6717787 to 7cf2a33 Compare March 14, 2026 09:37
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.

Change default workspace location

2 participants