Repository navigation
feat(workspace): move external collections into the workspace - #8196
naman-bruno merged 5 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughMoves external collections into the active workspace: adds path containment checks, a Windows-safe filesystem move, Electron IPC orchestration with UID remapping and workspace.yml registration (with rollback), a Redux thunk to coordinate the move, draft-confirmation modals, sidebar action wiring, and integration tests. ChangesMove Collections into Workspace
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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: 3
🧹 Nitpick comments (1)
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js (1)
2463-2471: 💤 Low valueConsider validating
result.newPathbefore proceeding.If the IPC succeeds but
result.newPathis falsy, the collection is removed from Redux without being re-opened—yet the promise resolves, showing a success toast to the user. Based on the IPC contract described in the stack context,newPathshould always be present on success, but defensive validation would make this more robust.💡 Optional: Add early validation
.then(async (result) => { + if (!result?.newPath) { + throw new Error('Move operation did not return new collection path'); + } dispatch(closeAllCollectionTabs({ collectionUid })); dispatch(removeCollectionFromWorkspace({ workspaceUid: activeWorkspace.uid, collectionLocation: collection.pathname })); await waitForNextTick(); dispatch(_removeCollection({ collectionUid })); - if (result?.newPath) { - const openResult = await dispatch(openMultipleCollections([result.newPath], { workspacePath: activeWorkspace.pathname })); - const reopened = (openResult?.opened || []).some( - (openedPath) => normalizePath(openedPath) === normalizePath(result.newPath) - ); - if (!reopened) { - throw new Error('Collection was moved into the workspace but could not be re-opened. Reload the workspace to access it.'); - } + const openResult = await dispatch(openMultipleCollections([result.newPath], { workspacePath: activeWorkspace.pathname })); + const reopened = (openResult?.opened || []).some( + (openedPath) => normalizePath(openedPath) === normalizePath(result.newPath) + ); + if (!reopened) { + throw new Error('Collection was moved into the workspace but could not be re-opened. Reload the workspace to access it.'); } dispatch(ensureActiveTabInCurrentWorkspace()); })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js` around lines 2463 - 2471, The code assumes result.newPath exists after the IPC call; add a defensive check before attempting to re-open the moved collection: validate that result && result.newPath is a non-empty string (or a valid path) and if missing, throw or reject with an explicit error (so the success toast isn't shown and Redux state rollback/compensating logic can run). Update the block around result.newPath and the dispatch(openMultipleCollections([result.newPath], { workspacePath: activeWorkspace.pathname })) call to first assert the value (e.g., if (!result || !result.newPath) throw new Error('Missing newPath after move')), then proceed to call openMultipleCollections and use normalizePath as before to confirm it reopened.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js`:
- Around line 455-460: The new dropdown action object with id
'move-to-workspace' (label 'Move into Workspace', leftSection
IconFileArrowRight, onClick using setShowMoveToWorkspaceModal) lacks a stable
test selector; update the action definition to include a testId/data-testid
property (e.g., testId: 'collection-action-move-to-workspace') so Playwright can
reliably select it, ensuring the added property follows existing action naming
conventions used elsewhere in the component.
In
`@packages/bruno-app/src/components/Sidebar/Collections/Collection/MoveToWorkspace/ConfirmMoveDrafts.js`:
- Around line 173-206: Add stable data-testid attributes to the action buttons
in ConfirmMoveDrafts so Playwright can reliably select them: add
data-testid="save-draft-<id>" (or similar unique key) on the per-item Save
Button tied to handleSaveTransient(item), data-testid="discard-all-and-move" on
the Button that calls handleDiscardAll, data-testid="cancel-move" on the Button
that calls onClose, and data-testid="save-all-and-move" on the Button that calls
handleSaveAll (also consider including state info like
data-testid="save-all-and-move--moving" when isMoving true or deriving tests
from currentDrafts/currentTransientDrafts). Ensure identifiers reference the
existing props/handlers (handleSaveTransient, handleDiscardAll, onClose,
handleSaveAll) and use currentDrafts/currentTransientDrafts to generate any
per-item test ids.
In
`@packages/bruno-app/src/components/Sidebar/Collections/Collection/MoveToWorkspace/index.js`:
- Line 60: Replace the hardcoded path construction for targetLocation with an
OS-agnostic join: instead of using string interpolation
`${activeWorkspace.pathname}/collections`, call the project's path-join helper
(or Node's path.join) to join activeWorkspace.pathname and 'collections' inside
the MoveToWorkspace component (symbol: targetLocation and
activeWorkspace.pathname) so the destination path is platform-independent.
---
Nitpick comments:
In `@packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js`:
- Around line 2463-2471: The code assumes result.newPath exists after the IPC
call; add a defensive check before attempting to re-open the moved collection:
validate that result && result.newPath is a non-empty string (or a valid path)
and if missing, throw or reject with an explicit error (so the success toast
isn't shown and Redux state rollback/compensating logic can run). Update the
block around result.newPath and the
dispatch(openMultipleCollections([result.newPath], { workspacePath:
activeWorkspace.pathname })) call to first assert the value (e.g., if (!result
|| !result.newPath) throw new Error('Missing newPath after move')), then proceed
to call openMultipleCollections and use normalizePath as before to confirm it
reopened.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 98e0eaf1-2ecb-48f3-822d-ff4c307eddf4
📒 Files selected for processing (11)
packages/bruno-app/src/components/Sidebar/Collections/Collection/MoveToWorkspace/ConfirmMoveDrafts.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/MoveToWorkspace/StyledWrapper.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/MoveToWorkspace/index.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/index.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/actions.jspackages/bruno-app/src/utils/common/path.jspackages/bruno-app/src/utils/common/path.spec.jspackages/bruno-app/src/utils/common/path.windows.spec.jspackages/bruno-electron/src/ipc/collection.jspackages/bruno-electron/src/utils/filesystem.jspackages/bruno-electron/src/utils/filesystem.test.js
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/workspace/move-collection-to-workspace.spec.ts (1)
59-68: ⚡ Quick winUse locator variables for repeated test selectors.
In these flow-critical steps, selectors are inlined repeatedly (
page.getByTestId(...),page.getByText(...)). Please extract them into local locator variables for readability and easier maintenance.As per coding guidelines, in
tests/**/**.*you should “Use locator variables for locators.”Also applies to: 148-157
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/workspace/move-collection-to-workspace.spec.ts` around lines 59 - 68, Extract repeated inline selectors into local locator variables: assign page.getByTestId('collection-actions-move-to-workspace') to a variable (e.g., moveActionBtn), reuse the existing moveModal locator for the 'Move' button (e.g., moveButton = locators.modal.button('Move')), and assign page.getByText('Collection moved into workspace') to a successToast variable; then replace the inline calls in the test step (and similarly at lines 148-157) to use these locator variables. Keep references to openCollectionMenu(page, collectionName), moveModal, and locators.modal.button('Move') so the changes are minimal and improve readability/maintenance.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/workspace/move-collection-to-workspace.spec.ts`:
- Around line 148-161: The test currently only checks that the collection was
moved (fs.existsSync on sourcePath/destinationPath) but not that the draft
changes were discarded; after the discard click in the test step (inside the
'Move shows the drafts confirmation, then discard and move' step, after await
page.getByTestId('move-workspace-discard-all').click() and before asserting the
move notification), read the moved collection file(s) at destinationPath (using
the same variables sourcePath/destinationPath and fs) and assert that the
on-disk request content does NOT contain the modified draft change (e.g., the
changed URL or modified body) to prove discard happened; keep existing
expectations (expect(fs.existsSync...)) and also use
locators.sidebar.collection(collectionName) to ensure UI consistency.
---
Nitpick comments:
In `@tests/workspace/move-collection-to-workspace.spec.ts`:
- Around line 59-68: Extract repeated inline selectors into local locator
variables: assign page.getByTestId('collection-actions-move-to-workspace') to a
variable (e.g., moveActionBtn), reuse the existing moveModal locator for the
'Move' button (e.g., moveButton = locators.modal.button('Move')), and assign
page.getByText('Collection moved into workspace') to a successToast variable;
then replace the inline calls in the test step (and similarly at lines 148-157)
to use these locator variables. Keep references to openCollectionMenu(page,
collectionName), moveModal, and locators.modal.button('Move') so the changes are
minimal and improve readability/maintenance.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0aba1750-4c32-4ec1-ad1c-c39d4fa1780e
📒 Files selected for processing (1)
tests/workspace/move-collection-to-workspace.spec.ts
9d8b971 to
4be96ad
Compare
Description
When a collection is opened from a path outside the workspace folder, there is no way to bring it under the workspace. This means the collection cannot be managed by the workspace's Git setup. The only workaround today is to manually move the collection folder into
<workspace>/collectionson disk.JIRA
Solution
Adds a Move into Workspace option to the collection context menu for external collections. It moves the collection's files into
<workspace>/collections/<name>and registers it inworkspace.ymlso it can be managed through workspace Git.The action is only shown when the collection lives outside that workspace root detected via a new shared
isPathExternalToBasePathhelper.Changes
renderer:move-collection-to-workspaceIPC handler.moveCollectionDirectoryfilesystem helper, with unit tests.moveCollectionToWorkspacethunk to coordinate close → move → reopen.isPathExternalToBasePathhelper.Screen Recording
Screen.Recording.2026-06-08.at.11.50.25.AM.mov
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
New Features
Tests