Repository navigation
feat(collections): enhance collection management by adding reset functionality and improving tab restoration logic - #8651
utkarsh-bruno wants to merge 10 commits into
Conversation
…tionality and improving tab restoration logic
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughExisting collection reopening resets stale Redux state before remounting. BRU-to-YML migration uses cancellable plan-and-apply IPC with rollback handling, while collection removal clears scoped caches. YML folder sequence fields are preserved only when explicitly numeric. ChangesCollection reopen and tab restoration
BRU-to-YML migration
Collection deletion cleanup
Folder sequence serialization
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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: 3
🤖 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-electron/src/ipc/collection.js`:
- Around line 2720-2740: Update the migration flow around rollback, source
deletion, and the post-write cleanup paths so rollback is permitted only before
the commit point established after successfully writing opencollection.yml.
After BRU source deletion begins, handle cleanup, statistics, and remount
failures without invoking rollback or deleting migrated YML outputs; use the
existing writtenYmlFiles, movedUids, and rolledBack state consistently.
- Around line 2827-2837: The migration write phase in the conversion plan must
not overwrite pre-existing YML targets. Before the first write in the loop over
conversionPlan, validate every ymlPath for collisions and abort before writing
if any target already exists; alternatively, preserve original contents and
restore them during rollback. Ensure writtenYmlFiles and rollback deletion only
include files created by this migration.
- Around line 2703-2705: Move the bruno.json read and parse in the collection
synchronization flow before removeWatcher, or include both operations within the
same guarded try/recovery scope. Ensure failures in readFileSync or JSON.parse
do not leave the watcher permanently detached, while preserving the existing
brunoConfig loading behavior.
🪄 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: c6fc1f7b-8c92-4888-af39-582dd6ebb062
📒 Files selected for processing (21)
packages/bruno-app/src/components/Sidebar/Collections/Collection/index.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/actions.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/file-mode.spec.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/index.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/migrate-in-place.spec.jspackages/bruno-app/src/providers/ReduxStore/slices/tabs-migrate.spec.jspackages/bruno-app/src/providers/ReduxStore/slices/tabs.jspackages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.jspackages/bruno-app/src/utils/snapshot/index.jspackages/bruno-app/src/utils/snapshot/index.spec.jspackages/bruno-electron/src/app/collection-watcher.jspackages/bruno-electron/src/cache/requestUids.jspackages/bruno-electron/src/ipc/collection.jspackages/bruno-electron/src/ipc/mount.jspackages/bruno-electron/src/services/mount/file-index.jspackages/bruno-electron/src/services/mount/manager.jspackages/bruno-electron/src/store/bruno-config.jspackages/bruno-filestore/src/formats/yml/parseFolder.spec.tspackages/bruno-filestore/src/formats/yml/parseFolder.tspackages/bruno-filestore/src/formats/yml/stringifyFolder.spec.tspackages/bruno-filestore/src/formats/yml/stringifyFolder.ts
| const brunoJsonPath = path.join(collectionPathname, 'bruno.json'); | ||
| const brunoJsonContent = fs.readFileSync(brunoJsonPath, 'utf8'); | ||
| const brunoConfig = JSON.parse(brunoJsonContent); |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Load the configuration before detaching the watcher.
These reads occur after removeWatcher but outside the guarded try. Missing or malformed bruno.json therefore leaves live synchronization permanently detached. Read/parse first, or include watcher removal and configuration loading in the same recovery scope.
🧰 Tools
🪛 ast-grep (0.44.1)
[warning] 2703-2703: Filesystem path is not a string literal; a request-/variable-derived path can enable path traversal. Validate and normalize the path before use.
Context: fs.readFileSync(brunoJsonPath, 'utf8')
Note: [CWE-22] Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
(detect-non-literal-fs-filename)
🤖 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-electron/src/ipc/collection.js` around lines 2703 - 2705, Move
the bruno.json read and parse in the collection synchronization flow before
removeWatcher, or include both operations within the same guarded try/recovery
scope. Ensure failures in readFileSync or JSON.parse do not leave the watcher
permanently detached, while preserving the existing brunoConfig loading
behavior.
✅ Addressed in commit 88c19f6
…pped after bruno.json is validated and handling pre-existing yml file collisions
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/bruno-electron/src/ipc/collection.js (1)
2764-2806: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winYield during phase-one conversion so cancellation can be processed.
This loop uses synchronous reads and parsing without an
await, blocking Electron’s main event loop. The cancellation IPC cannot updatemigrationCancellationsuntil planning finishes, making cancellation ineffective during the longest phase.Proposed fix
for (const bruFilePath of bruFiles) { + await new Promise((resolve) => setImmediate(resolve)); checkCancelled(); const basename = path.basename(bruFilePath); const dirname = path.dirname(bruFilePath);🤖 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-electron/src/ipc/collection.js` around lines 2764 - 2806, Update the phase-one conversion loop around the bruFiles iteration to yield to the event loop between synchronous read/parse operations, allowing cancellation IPC to update migrationCancellations while planning is in progress. Preserve the existing checkCancelled behavior, conversionPlan population, and parseErrors handling.
🤖 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/CollectionSettings/Overview/Migration/MigrateToYmlModal/index.js`:
- Around line 51-59: Update the backup export control in MigrateToYmlModal to be
disabled whenever isMigrating is true, preventing ZIP export during migration
and cancellation. Preserve the existing export-disabled behavior by combining
this condition with the current isExporting state.
---
Outside diff comments:
In `@packages/bruno-electron/src/ipc/collection.js`:
- Around line 2764-2806: Update the phase-one conversion loop around the
bruFiles iteration to yield to the event loop between synchronous read/parse
operations, allowing cancellation IPC to update migrationCancellations while
planning is in progress. Preserve the existing checkCancelled behavior,
conversionPlan population, and parseErrors handling.
🪄 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: 503f5638-0a47-484c-91a6-6f392c8fc969
📒 Files selected for processing (8)
packages/bruno-app/src/components/CollectionSettings/Overview/Migration/MigrateToYmlModal/index.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/actions.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/index.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/migrate-in-place.spec.jspackages/bruno-app/src/providers/ReduxStore/slices/tabs-migrate.spec.jspackages/bruno-app/src/providers/ReduxStore/slices/tabs.jspackages/bruno-electron/src/ipc/collection.jspackages/bruno-electron/src/services/snapshot/index.js
💤 Files with no reviewable changes (3)
- packages/bruno-app/src/providers/ReduxStore/slices/collections/migrate-in-place.spec.js
- packages/bruno-electron/src/services/snapshot/index.js
- packages/bruno-app/src/providers/ReduxStore/slices/tabs.js
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/bruno-app/src/providers/ReduxStore/slices/tabs-migrate.spec.js
…y yielding control to check for cancellation
|
Assume I have a git tracked folder and I revert the migration on the same collection, I no longer see the Migrate To YML button anymore. Is that expected ? Can be moved out of scope for the current version but would like to know if it is considered a valid scenario |
…k config only, preventing stale format issues after migration
added a small change to read it the format from the disk and not falling back to the prev. |
…g and improve confirm button logic
…lection is still loading
Description
resetCollectionForReopenaction to clear stale items and environments when reopening collections.openCollectionEventto ensure proper handling of existing collections and prevent stale data.Contribution Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
seqmetadata no longer defaults to position 1 and is preserved only when explicitly provided.Improvements