Repository navigation
feat: integrate Git remote for collections - #7879
Conversation
WalkthroughAdds Git-remote support for workspace collections: UI components and modals, Redux thunks, Electron IPC handlers, and workspace-config utilities to persist/clear remotes and manage per-collection .gitignore entries; sidebar shows “ghost” remote-only collections. ChangesGit Remote integration
Sequence Diagram(s)sequenceDiagram
participant UI as CollectionsList UI
participant Redux as Redux Store
participant IPC as Electron IPC
participant Config as Workspace Config
participant FS as File System
participant Broadcast as Workspace Broadcast
rect rgba(100, 150, 200, 0.5)
Note over UI,Broadcast: Connect Collection to Git
UI->>Redux: Dispatch connectCollectionToGit(workspaceUid, collectionPath, remoteUrl)
Redux->>IPC: Invoke renderer:connect-collection-to-git
IPC->>Config: Validate remoteUrl & locate workspace
Config->>FS: Write remote to workspace.yml
Config->>FS: Add collection path to .gitignore
Config->>Broadcast: Emit main:workspace-config-updated
Broadcast->>Redux: Update workspace config in store
IPC-->>Redux: Resolve thunk success
Redux-->>UI: Show toast "Git remote connected"
end
sequenceDiagram
participant UI as CollectionsList UI
participant Redux as Redux Store
participant IPC as Electron IPC
participant Config as Workspace Config
participant FS as File System
participant Broadcast as Workspace Broadcast
rect rgba(200, 100, 100, 0.5)
Note over UI,Broadcast: Disconnect Collection from Git
UI->>Redux: Dispatch disconnectCollectionFromGit(workspaceUid, collectionPath)
Redux->>IPC: Invoke renderer:disconnect-collection-from-git
IPC->>Config: Locate workspace & collection
Config->>FS: Clear remote from workspace.yml
Config->>FS: Remove collection path from .gitignore
Config->>Broadcast: Emit main:workspace-config-updated
Broadcast->>Redux: Update workspace config in store
IPC-->>Redux: Resolve thunk success
Redux-->>UI: Show toast "Git remote removed"
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/bruno-electron/src/ipc/workspace.js (1)
583-600: Consider: The regex validation may be redundant with the frontend validation.The frontend already validates via
isGitRepositoryUrl(which usesgit-url-parse). This backend regex is a simpler pattern check. While defense-in-depth is good, the two validations use different logic:
- Frontend:
git-url-parselibrary with protocol/owner/source checks- Backend: Regex pattern match
This could lead to edge cases where one accepts a URL the other rejects. If intentional as a basic sanity check, that's fine. Otherwise, consider aligning validation logic.
🤖 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 583 - 600, The backend regex in the ipcMain handler for 'renderer:connect-collection-to-git' can disagree with the frontend's isGitRepositoryUrl; instead of the ad-hoc regex in that handler, either remove the regex check entirely (rely on frontend + setCollectionGitRemote errors) or align validation by using the same logic/library: import or reimplement the frontend's isGitRepositoryUrl (or use git-url-parse) in this module, trim remoteUrl, validate with that function, and throw the same error message when invalid; keep the surrounding try/catch and calls to setCollectionGitRemote and broadcastWorkspaceConfig unchanged.
🤖 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/providers/ReduxStore/slices/workspaces/actions.js`:
- Around line 339-342: The workspace can get stuck because cached
updatedWorkspace.collections retain notFoundLocally and get filtered out; update
loadWorkspaceCollections() so cached collections are revalidated before
filtering: for each item in updatedWorkspace.collections check the current
filesystem (e.g., fs.existsSync or the existing path-exists helper) and clear or
ignore notFoundLocally when the path now exists, then build collectionPaths (the
logic around collectionPaths, normalizePath and alreadyOpenCollections) from
that revalidated list; alternatively, if any cached collection has
notFoundLocally true but its path now exists, invalidate/refresh the cache so
the collection is included.
In `@packages/bruno-electron/src/utils/workspace-config.js`:
- Around line 379-396: The removeCollectionFromWorkspaceGitignore function
currently removes any matching collection line unconditionally; change it to
only remove entries that Bruno created by (1) marking Bruno-managed entries when
adding them (use addCollectionToWorkspaceGitignore / getCollectionGitignoreEntry
to write entries wrapped in clear start/end markers or a per-entry comment
token) and (2) when removing in removeCollectionFromWorkspaceGitignore, only
delete lines within that managed marker/block or lines that contain the
Bruno-specific token; if no managed marker/token is found, leave the user's
lines untouched. Update both add and remove code paths (and the logic used in
the similar block at 426-445) to use the same marker/token convention so only
Bruno-owned entries are modified.
---
Nitpick comments:
In `@packages/bruno-electron/src/ipc/workspace.js`:
- Around line 583-600: The backend regex in the ipcMain handler for
'renderer:connect-collection-to-git' can disagree with the frontend's
isGitRepositoryUrl; instead of the ad-hoc regex in that handler, either remove
the regex check entirely (rely on frontend + setCollectionGitRemote errors) or
align validation by using the same logic/library: import or reimplement the
frontend's isGitRepositoryUrl (or use git-url-parse) in this module, trim
remoteUrl, validate with that function, and throw the same error message when
invalid; keep the surrounding try/catch and calls to setCollectionGitRemote and
broadcastWorkspaceConfig unchanged.
🪄 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: a1f00461-729c-4476-a3be-fd06c0be6ce3
📒 Files selected for processing (11)
packages/bruno-app/src/components/Sidebar/Collections/GitRemoteCollectionRow/StyledWrapper.jspackages/bruno-app/src/components/Sidebar/Collections/GitRemoteCollectionRow/index.jspackages/bruno-app/src/components/Sidebar/Collections/index.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceOverview/CollectionsList/ConnectGitRemote/index.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceOverview/CollectionsList/RemoveGitRemote/index.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceOverview/CollectionsList/StyledWrapper.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceOverview/CollectionsList/index.jspackages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.jspackages/bruno-electron/src/ipc/workspace.jspackages/bruno-electron/src/utils/workspace-config.jspackages/bruno-electron/tests/utils/workspace-config.spec.js
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/workspace/git-backed-collections/git-backed-collections.spec.ts (1)
157-172: ⚡ Quick winReplace Tailwind utility class
.text-red-500with adata-testidlocator.These selectors can break when the DOM structure changes — and a Tailwind colour class is particularly fragile since any styling change (e.g., switching to a different error shade) would silently break these assertions without touching any logic. The
ConnectGitRemotecomponent renders the error as<div className="text-red-500">with nodata-testid.Add
data-testid="remote-url-error"to that<div>inConnectGitRemote/index.jsand update both assertions here:♻️ Proposed fix (test + component)
In
packages/bruno-app/src/components/WorkspaceHome/WorkspaceOverview/CollectionsList/ConnectGitRemote/index.js:- <div className="text-red-500">{formik.errors.remoteUrl}</div> + <div className="text-red-500" data-testid="remote-url-error">{formik.errors.remoteUrl}</div>In
git-backed-collections.spec.ts(apply to both occurrences):- await expect(modal.locator('.text-red-500').first()).toBeVisible({ timeout: 2000 }); + await expect(modal.getByTestId('remote-url-error')).toBeVisible({ timeout: 2000 });As per coding guidelines,
data-testidshould be added to testable elements for Playwright.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/workspace/git-backed-collections/git-backed-collections.spec.ts` around lines 157 - 172, Add a stable test id to the error element in the ConnectGitRemote component and update the two failing assertions in the git-backed-collections.spec.ts to use it: modify the error div rendered by ConnectGitRemote (currently has class "text-red-500") to include data-testid="remote-url-error", then in the test replace modal.locator('.text-red-500').first() with modal.locator('[data-testid="remote-url-error"]').first() for both the "Empty URL..." and "Malformed URL..." steps so assertions no longer rely on Tailwind classes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/workspace/git-backed-collections/git-backed-collections.spec.ts`:
- Around line 30-34: The helper readGitignoreLines currently splits on '\n'
which leaves a trailing '\r' on Windows; update readGitignoreLines to split
using a CRLF-safe pattern (e.g., split on /\r?\n/) or normalize line endings
(replace CRLF with LF) before splitting, and optionally trim or filter empty
lines so comparisons like toContain('collections/sample-coll/') match reliably;
locate and modify the readGitignoreLines function to implement this change.
---
Nitpick comments:
In `@tests/workspace/git-backed-collections/git-backed-collections.spec.ts`:
- Around line 157-172: Add a stable test id to the error element in the
ConnectGitRemote component and update the two failing assertions in the
git-backed-collections.spec.ts to use it: modify the error div rendered by
ConnectGitRemote (currently has class "text-red-500") to include
data-testid="remote-url-error", then in the test replace
modal.locator('.text-red-500').first() with
modal.locator('[data-testid="remote-url-error"]').first() for both the "Empty
URL..." and "Malformed URL..." steps so assertions no longer rely on Tailwind
classes.
🪄 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: 947d3fe7-0405-49b2-96b4-ce686833a032
📒 Files selected for processing (7)
tests/workspace/git-backed-collections/fixtures/workspace-with-collection/.gitignoretests/workspace/git-backed-collections/fixtures/workspace-with-collection/collections/sample-coll/bruno.jsontests/workspace/git-backed-collections/fixtures/workspace-with-collection/workspace.ymltests/workspace/git-backed-collections/fixtures/workspace-with-ghost/.gitignoretests/workspace/git-backed-collections/fixtures/workspace-with-ghost/workspace.ymltests/workspace/git-backed-collections/git-backed-collections.spec.tstests/workspace/git-backed-collections/init-user-data/preferences.json
✅ Files skipped from review due to trivial changes (5)
- tests/workspace/git-backed-collections/fixtures/workspace-with-collection/.gitignore
- tests/workspace/git-backed-collections/init-user-data/preferences.json
- tests/workspace/git-backed-collections/fixtures/workspace-with-collection/collections/sample-coll/bruno.json
- tests/workspace/git-backed-collections/fixtures/workspace-with-ghost/.gitignore
- tests/workspace/git-backed-collections/fixtures/workspace-with-collection/workspace.yml
JIRA
Description
Add remote backed collection support for workspaces
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