Skip to content

fix(migration): migrate collection to yml in-place to preserve open tabs and uids - #8553

Merged
utkarsh-bruno merged 3 commits into
usebruno:mainfrom
ravindra-bruno:fix/bru-3683
Jul 10, 2026
Merged

utkarsh-bruno merged 3 commits into
usebruno:mainfrom
ravindra-bruno:fix/bru-3683

Conversation

@ravindra-bruno

@ravindra-bruno ravindra-bruno commented Jul 9, 2026 •

Copy link
Copy Markdown
Collaborator

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:

  • 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

Please see here for more information.

Summary by CodeRabbit

  • New Features
    • “Convert to YML” now performs an in-place collection migration while preserving nested UI state, including open tabs and expanded folders.
    • After conversion, tab paths are updated to the YML extension and the collection settings overview is selected.
  • Bug Fixes
    • Improved migration stability to prevent migrated request tabs from breaking or showing missing-request errors.
    • Re-enabled filesystem watching after successful migrations so changes are reflected reliably.
  • Tests
    • Added/updated end-to-end and reducer tests covering nested multi-collection migration and tab behavior.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 69ef5e50-b11e-4108-b6f6-89eaeaa8b28c

📥 Commits

Reviewing files that changed from the base of the PR and between a9ae22d and ec8b548.

📒 Files selected for processing (2)
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js
  • packages/bruno-electron/src/ipc/collection.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/bruno-electron/src/ipc/collection.js
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js

Walkthrough

The 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.

Changes

In-place migration flow and tests

Layer / File(s) Summary
In-place migration reducers
packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js, packages/bruno-app/src/providers/ReduxStore/slices/tabs.js
Adds reducers that update collection, environment, and tab paths from .bru to .yml.
Migration thunk and watcher re-attach
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js, packages/bruno-electron/src/ipc/collection.js
Dispatches in-place state updates after migration, selects the settings overview tab, and re-attaches the watcher after successful IPC migration.
Migration fixtures and specs
tests/collection/migrate-to-yml-nested-multi/*, tests/collection/migrate-to-yml/*, packages/bruno-app/src/providers/ReduxStore/slices/collections/*spec.js, packages/bruno-app/src/providers/ReduxStore/slices/tabs-migrate.spec.js
Adds reducer coverage, nested migration scenarios, open-tab coverage, and supporting collection fixtures.

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
Loading

Possibly related PRs

Suggested labels: size/XL

Suggested reviewers: helloanoop, lohit-bruno, naman-bruno, bijin-bruno, sid-bruno, utkarsh-bruno, vijayh-bruno

Poem

Tabs stay open, paths turn bright,
BRU becomes YML overnight.
Watchers wake and folders stay,
Tests keep migration on its way.

🚥 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 summarizes the main change: in-place YML migration to preserve open tabs and item UIDs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.js

ast-grep timed out on this file

packages/bruno-electron/src/ipc/collection.js

ast-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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 lift

Multiple 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 through tests/utils/page/* page modules.
As per path instructions: "Centralize locators and actions in page modules under tests/utils/page/*; never inline raw selectors in a spec." Consider extracting these into the shared locator/page-module layer (extending buildCommonLocators, 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 lift

Same 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-label are inlined directly rather than routed through tests/utils/page/*. As per path instructions: "Centralize locators and actions in page modules under tests/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

📥 Commits

Reviewing files that changed from the base of the PR and between ff2f2d0 and a58ff0d.

📒 Files selected for processing (14)
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js
  • packages/bruno-app/src/providers/ReduxStore/slices/tabs.js
  • packages/bruno-electron/src/ipc/collection.js
  • tests/collection/migrate-to-yml-nested-multi/fixtures/collections/other-collection/bruno.json
  • tests/collection/migrate-to-yml-nested-multi/fixtures/collections/other-collection/keep-req.bru
  • tests/collection/migrate-to-yml-nested-multi/fixtures/collections/source-collection/api/users.bru
  • tests/collection/migrate-to-yml-nested-multi/fixtures/collections/source-collection/api/v2/deep.bru
  • tests/collection/migrate-to-yml-nested-multi/fixtures/collections/source-collection/bruno.json
  • tests/collection/migrate-to-yml-nested-multi/fixtures/collections/source-collection/root-req.bru
  • tests/collection/migrate-to-yml-nested-multi/init-user-data/preferences.json
  • tests/collection/migrate-to-yml-nested-multi/migrate-to-yml-nested-multi.spec.ts
  • tests/collection/migrate-to-yml/keep-request-tab-open.spec.ts
  • tests/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

@pull-request-size pull-request-size Bot added size/XL and removed size/L labels Jul 9, 2026
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.

2 participants