Repository navigation
fix(migration): migrate collection to yml in-place to preserve open tabs and uids - #8553
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 (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThe migration flow now updates collection state and open tabs in place during BRU-to-YML conversion. The IPC handler re-attaches the collection watcher after success. New reducer tests, Playwright specs, and fixtures cover nested collections, open tabs, and sibling collection state. ChangesIn-place migration flow and tests
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Renderer
participant MigrationIPC
participant Watcher
participant Redux
Renderer->>MigrationIPC: Migrate collection to YML
MigrationIPC->>Watcher: Re-attach watcher to YML collection
MigrationIPC-->>Renderer: Return updated config
Renderer->>Redux: Update collection and tab paths
Redux-->>Renderer: Select settings overview tab
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.44.1)packages/bruno-app/src/providers/ReduxStore/slices/collections/index.jsast-grep timed out on this file packages/bruno-electron/src/ipc/collection.jsast-grep timed out on this file 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 |
d1421fd to
a58ff0d
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
tests/collection/migrate-to-yml-nested-multi/migrate-to-yml-nested-multi.spec.ts (1)
32-32: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftMultiple raw selectors inlined directly in the spec.
#request-url .CodeMirror,.bruno-modal,getByRole('button', {name:'Convert to YML'}),.request-tab .tab-label,getByTestId('collection-settings-tab-overview'), etc. are used directly here instead of throughtests/utils/page/*page modules.
As per path instructions: "Centralize locators and actions in page modules undertests/utils/page/*; never inline raw selectors in a spec." Consider extracting these into the shared locator/page-module layer (extendingbuildCommonLocators, which is already partially used here for the sidebar/folder locators).Also applies to: 38-38, 43-50, 60-60, 63-63, 68-70, 80-80
🤖 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/collection/migrate-to-yml-nested-multi/migrate-to-yml-nested-multi.spec.ts` at line 32, The spec is inlining multiple raw selectors instead of using shared page modules. Move the affected locators and actions from migrate-to-yml-nested-multi.spec.ts into the existing tests/utils/page/* layer, preferably by extending buildCommonLocators and the relevant page objects. Replace direct uses like request-url .CodeMirror, .bruno-modal, getByRole('button', {name:'Convert to YML'}), .request-tab .tab-label, and collection-settings-tab-overview with the centralized helpers, then update the spec to call those page-module methods.Source: Path instructions
tests/collection/migrate-to-yml/keep-request-tab-open.spec.ts (1)
19-19: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftSame raw-selector inlining pattern as
migrate-to-yml-nested-multi.spec.ts.
.item-name,#request-url,#sidebar-collection-name,getByTestId('collection-settings-tab-overview'),.bruno-modal,.request-tab .tab-labelare inlined directly rather than routed throughtests/utils/page/*. As per path instructions: "Centralize locators and actions in page modules undertests/utils/page/*; never inline raw selectors in a spec."Also applies to: 21-23, 27-41, 52-52, 54-54, 59-59
🤖 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/collection/migrate-to-yml/keep-request-tab-open.spec.ts` at line 19, The spec is still inlining raw selectors and direct page actions instead of using the shared page modules. Update keep-request-tab-open.spec.ts to route all locator usage through the relevant helpers in tests/utils/page/*, replacing direct references such as item-name, request-url, sidebar collection name, collection settings overview tab, Bruno modal, and request tab label with the centralized symbols. Use the existing page-object methods alongside keepRequestTabOpen and any related collection/request helpers so the spec only expresses behavior, not selectors.Source: Path instructions
🤖 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/providers/ReduxStore/slices/collections/index.js`:
- Around line 316-326: The migrateCollectionToYmlInPlace reducer updates
collection.brunoConfig but leaves any existing collection.draft.brunoConfig
stale, which can later overwrite the migration in saveCollectionDraft. Update
migrateCollectionToYmlInPlace in the collections slice so that when a draft
exists it also syncs collection.draft.brunoConfig alongside
collection.brunoConfig before setting collection.format to yml.
- Around line 328-341: The YML migration in the collection path rewrite logic is
still touching transient items and not keeping draft config in sync. Update the
rewrite flow around rewriteItemPaths in collections/index.js to skip any item
with item.isTransient so temp-directory requests remain on .bru, and when a
collection has a draft, copy the migrated brunoConfig into
collection.draft.brunoConfig as well. Make sure the fix applies consistently to
nested items handled by rewriteItemPaths and any collection-level config
migration path in the same reducer.
In `@packages/bruno-electron/src/ipc/collection.js`:
- Around line 2782-2789: The watcher reattach path in the migration flow is
swallowing a failure from addWatcher and only writing to console, so the UI
still reports success while live sync is broken. Update the try/catch around
watcher.addWatcher in collection.js to surface the failure through the app’s
user-facing notification or log/telemetry path (and not just console.error), so
the degraded state is visible after migration. Keep the existing migration
success flow intact, but make the watcher reattachment error explicit using the
watcher.addWatcher and mainWindow context.
---
Nitpick comments:
In
`@tests/collection/migrate-to-yml-nested-multi/migrate-to-yml-nested-multi.spec.ts`:
- Line 32: The spec is inlining multiple raw selectors instead of using shared
page modules. Move the affected locators and actions from
migrate-to-yml-nested-multi.spec.ts into the existing tests/utils/page/* layer,
preferably by extending buildCommonLocators and the relevant page objects.
Replace direct uses like request-url .CodeMirror, .bruno-modal,
getByRole('button', {name:'Convert to YML'}), .request-tab .tab-label, and
collection-settings-tab-overview with the centralized helpers, then update the
spec to call those page-module methods.
In `@tests/collection/migrate-to-yml/keep-request-tab-open.spec.ts`:
- Line 19: The spec is still inlining raw selectors and direct page actions
instead of using the shared page modules. Update keep-request-tab-open.spec.ts
to route all locator usage through the relevant helpers in tests/utils/page/*,
replacing direct references such as item-name, request-url, sidebar collection
name, collection settings overview tab, Bruno modal, and request tab label with
the centralized symbols. Use the existing page-object methods alongside
keepRequestTabOpen and any related collection/request helpers so the spec only
expresses behavior, not selectors.
🪄 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: bf0bcc82-6664-473b-9e99-f4563f0f8c91
📒 Files selected for processing (14)
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/index.jspackages/bruno-app/src/providers/ReduxStore/slices/tabs.jspackages/bruno-electron/src/ipc/collection.jstests/collection/migrate-to-yml-nested-multi/fixtures/collections/other-collection/bruno.jsontests/collection/migrate-to-yml-nested-multi/fixtures/collections/other-collection/keep-req.brutests/collection/migrate-to-yml-nested-multi/fixtures/collections/source-collection/api/users.brutests/collection/migrate-to-yml-nested-multi/fixtures/collections/source-collection/api/v2/deep.brutests/collection/migrate-to-yml-nested-multi/fixtures/collections/source-collection/bruno.jsontests/collection/migrate-to-yml-nested-multi/fixtures/collections/source-collection/root-req.brutests/collection/migrate-to-yml-nested-multi/init-user-data/preferences.jsontests/collection/migrate-to-yml-nested-multi/migrate-to-yml-nested-multi.spec.tstests/collection/migrate-to-yml/keep-request-tab-open.spec.tstests/collection/migrate-to-yml/migrate-to-yml.spec.ts
💤 Files with no reviewable changes (1)
- tests/collection/migrate-to-yml/migrate-to-yml.spec.ts
…g on yml migration
JIRA: BRU-3683
Description
Issue: When migrating a Bruno collection from the Bru format to YAML, any requests kept open during the conversion break and display a "Request No Longer Exists" error. This affects both transient and normal requests, and worsens with nested folders — deeply nested open requests are lost, and expanded folders collapse.
Cause & Resolution: During migration the collection was fully torn down and rebuilt in Redux (remove → close all tabs → reopen → remount). This closed every open tab, regenerated item UIDs, and left the open tab/snapshot paths still pointing at the deleted .bru files — so the tabs resolved to nothing and rendered "Request No Longer Exists". Added a fix that migrates the collection in place instead of remounting: it rewrites the item and tab paths from .bru to .yml at every nesting depth, remaps the persisted snapshot tab paths, and preserves the UIDs (and folder expansion state) throughout the bru-to-YAML conversion. Open tabs now stay open and resolve correctly against the migrated .yml files.
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