Skip to content

feat: adding bru to yml migration - #8794

Closed
utkarsh-bruno wants to merge 2 commits into
usebruno:mainfrom
utkarsh-bruno:feat/bru-yml
Closed

utkarsh-bruno wants to merge 2 commits into
usebruno:mainfrom
utkarsh-bruno:feat/bru-yml

Conversation

@utkarsh-bruno

@utkarsh-bruno utkarsh-bruno commented Jul 28, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Added a BRU-only “Migrate to YML” area to Collection Overview with a “Convert to YML” confirmation flow, disabled/loading state during migration, and success/error toasts.
Added a dismissible “Migrate to YML” pill in the collection header (dismissal is remembered), plus an export/backup option inside the migration flow.

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.

Summary by CodeRabbit

  • New Features

    • Added a guided migration flow for converting collections from BRU to YML format.
    • Migration progress, phases, cancellation, and backup export are now available in the modal.
    • Collections automatically reload after migration, with relevant tabs closed and the Overview page displayed.
  • Bug Fixes

    • Prevented duplicate collection mounting while a mount is already in progress.
    • Preserved folder ordering metadata when converting between formats.
    • Improved cleanup and recovery when migration is cancelled or interrupted.
  • Tests

    • Added coverage for migration progress, cancellation, recovery, nested collections, and format metadata.

@utkarsh-bruno utkarsh-bruno changed the title Feat/bru yml feat: adding bru to yml migration Jul 28, 2026
@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The PR replaces local YML migration modals and in-place Redux updates with a centralized migration modal, Redux lifecycle state, Electron IPC orchestration, staged filesystem conversion with rollback, expanded filestore workers, and cancellation/progress tests.

Changes

YML migration UI and state

Layer / File(s) Summary
Migration modal and application wiring
packages/bruno-app/src/components/MigrateCollectionToYmlModal/*, packages/bruno-app/src/components/CollectionSettings/..., packages/bruno-app/src/providers/App/*, tests/utils/page/*
Migration is opened through Redux, rendered globally, reports progress, supports cancellation and ZIP backup export, and uses shared Playwright locators.
Renderer migration orchestration
packages/bruno-app/src/providers/ReduxStore/slices/collection-migration.js, packages/bruno-app/src/providers/ReduxStore/slices/collections/*, packages/bruno-app/src/providers/ReduxStore/slices/tabs.js
Redux tracks migration status and progress while the collection thunk closes tabs, flushes snapshots, hides the collection, remounts it, restores UI state, and derives format from disk configuration.

Electron and filestore flow

Layer / File(s) Summary
Electron migration and cache lifecycle
packages/bruno-electron/src/ipc/*, packages/bruno-electron/src/services/mount/*, packages/bruno-electron/src/cache/*, packages/bruno-electron/src/store/*
The main process converts BRU files to YML with collision checks, progress, cancellation, rollback, collection reopening, and targeted cache/index cleanup.
Filestore worker support
packages/bruno-filestore/src/index.ts, packages/bruno-filestore/src/workers/*, packages/bruno-filestore/src/formats/yml/*
Worker tasks now parse and stringify folders and environments, while folder sequence metadata is preserved only when explicitly numeric.

Validation

Layer / File(s) Summary
Migration coverage and fixtures
packages/bruno-electron/src/ipc/yml-migration.spec.js, packages/bruno-app/src/providers/ReduxStore/slices/*.spec.js, tests/collection/migrate-to-yml*/*
Tests cover successful conversion, progress, cancellation, collisions, rollback, format updates, tab closure, collection reopening, and preservation of unrelated collections.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested reviewers: bijin-bruno, helloanoop, lohit-bruno

Poem

BRU files march through a YML gate,
Progress bars count their changing state.
Tabs fold softly, caches clear,
Rollbacks keep the originals near.
IPC guides the careful flight—
Collections return in YML light.

🚥 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 clearly matches the main change: adding a BRU-to-YML migration flow.
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

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/bruno-app/src/components/RequestTabs/CollectionHeader/index.js (2)

716-747: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

"Migrate to YML" pill is dead code — the whole block is JSX-commented out.

This entire pill (button + dismiss button + showMigrateToYmlModal dispatch) sits inside {/* ... */}, so it never renders. The diff even updates the onClick handler here (to dispatch showMigrateToYmlModal) without uncommenting it — the PR's stated "dismissible collection-header pill" deliverable is therefore not shipped, and the migrate-yml-pill/migrate-yml-pill-dismiss testids referenced by the new Playwright locators (tests/utils/page/collection/migrate-to-yml.ts) will never resolve to a real element.

🐛 Uncomment the pill block
-              {/* {collection.format === 'bru' && !migratePillDismissed && (
+              {collection.format === 'bru' && !migratePillDismissed && (
                 <div
                   className="migrate-yml-pill"
                   data-testid="migrate-yml-pill"
                   title="Migrate this collection to YML"
                 >
                   ...
                 </div>
-              )} */}
+              )}
🤖 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/components/RequestTabs/CollectionHeader/index.js`
around lines 716 - 747, Uncomment the entire “Migrate to YML” pill JSX block in
the collection header so it renders when collection.format is “bru” and
migratePillDismissed is false. Preserve the existing showMigrateToYmlModal
dispatch, dismissMigratePill handler, and
migrate-yml-pill/migrate-yml-pill-dismiss test IDs.

52-61: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Pill dismissal keys off raw collection.pathname string equality.

readDismissedCollections/dismissMigratePill store and compare collection.pathname verbatim via .includes(). On case-insensitive filesystems (macOS/Windows) or if the path is later reported with different casing/separators, a dismissed collection could stop matching and the pill would reappear (or vice versa). As per path instructions, "Never assume case-sensitive or case-insensitive filesystems." Normalize (e.g. lower-case + path.normalize-equivalent) before storing/comparing.

Also applies to: 104-123

🤖 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/components/RequestTabs/CollectionHeader/index.js`
around lines 52 - 61, Normalize collection paths consistently before storing or
comparing dismissal keys in readDismissedCollections and dismissMigratePill.
Apply a path-normalization helper that handles separator differences and casing,
then use the normalized collection.pathname for both persistence and .includes()
checks while preserving the existing dismissal behavior.

Source: Path instructions

🧹 Nitpick comments (6)
packages/bruno-filestore/src/formats/yml/parseFolder.spec.ts (2)

54-65: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression coverage for seq: 0.

Both tests currently use only truthy numeric values, so the former seq || 1 behavior could regress unnoticed.

  • packages/bruno-filestore/src/formats/yml/parseFolder.spec.ts#L54-L65: parse seq: 0 and assert meta.seq is 0.
  • packages/bruno-filestore/src/formats/yml/stringifyFolder.spec.ts#L49-L65: stringify meta.seq: 0 and assert the round trip preserves 0.

As per coding guidelines, tests should cover realistic edge cases and failure-prone behavior.

🤖 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-filestore/src/formats/yml/parseFolder.spec.ts` around lines 54
- 65, Add regression tests for the falsy numeric sequence value: in
packages/bruno-filestore/src/formats/yml/parseFolder.spec.ts lines 54-65, add a
parseFolder case with seq: 0 and assert meta.seq is 0; in
packages/bruno-filestore/src/formats/yml/stringifyFolder.spec.ts lines 49-65,
add a stringify/round-trip case with meta.seq set to 0 and assert the value
remains 0. Use the existing test structures and helpers.

Source: Coding guidelines


58-64: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid unguarded optional chaining in the new sequence assertions.

Both tests should narrow parsed metadata before accessing seq.

  • packages/bruno-filestore/src/formats/yml/parseFolder.spec.ts#L58-L64: replace meta?.seq with access through a defined local metadata value.
  • packages/bruno-filestore/src/formats/yml/stringifyFolder.spec.ts#L56-L64: apply the same narrowing before asserting the round-trip sequence.

As per coding guidelines, TypeScript optional chaining must be followed immediately by a fallback, early return, or guard.

🤖 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-filestore/src/formats/yml/parseFolder.spec.ts` around lines 58
- 64, Update the sequence assertions in
packages/bruno-filestore/src/formats/yml/parseFolder.spec.ts lines 58-64 and
packages/bruno-filestore/src/formats/yml/stringifyFolder.spec.ts lines 56-64 to
narrow the parsed metadata into a defined local value before accessing seq.
Replace the unguarded meta?.seq usage in both sites while preserving the
existing undefined and numeric sequence expectations.

Source: Coding guidelines

packages/bruno-electron/src/ipc/yml-migration.spec.js (1)

217-224: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated unlink-failure mock across two tests.

The "fail on the 3rd unlink call" mock setup is copy-pasted verbatim between the "restores removed sources..." and "keeps the backup and reports..." tests. Extracting a small helper (e.g. mockUnlinkFailureOnCall(n)) would keep both tests focused on their distinct assertions.

♻️ Proposed helper
+const mockUnlinkFailureOnCall = (n, message) => {
+  const realUnlink = fs.promises.unlink.bind(fs.promises);
+  let calls = 0;
+  return jest.spyOn(fs.promises, 'unlink').mockImplementation(async (target) => {
+    if (++calls === n) {
+      throw new Error(message);
+    }
+    return realUnlink(target);
+  });
+};

Also applies to: 233-240

🤖 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/yml-migration.spec.js` around lines 217 -
224, Extract the duplicated fs.promises.unlink failure setup into a shared
helper near the affected tests, such as mockUnlinkFailureOnCall(n), that
preserves the real unlink behavior and throws the simulated EPERM error on the
specified call. Replace the inline mock blocks in both “restores removed
sources...” and “keeps the backup and reports...” tests with calls to this
helper.
tests/collection/migrate-to-yml/migrate-to-yml.spec.ts (1)

38-50: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Redundant duplicate click and inline selectors instead of centralized locators.

openCollection(page, 'migration-test') (line 39) already clicks #sidebar-collection-name filtered to this collection; line 40 clicks the exact same element again right after, and line 46 does so a third time in the next step. Lines 40, 46 and 47 also inline raw selectors (page.locator('#sidebar-collection-name')..., page.getByTestId('collection-settings-tab-overview')) instead of reusing openCollection and the centralized paneTabs.collectionSettingsTab('overview') locator. This pattern repeats at lines 122 and 131, and is shared with migrate-to-yml-cancel.spec.ts and migrate-to-yml-nested-multi.spec.ts — see the consolidated comment.

🤖 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/migrate-to-yml.spec.ts` around lines 38 - 50,
Remove the redundant collection-name clicks after openCollection and replace the
inline collection and settings-tab selectors with the centralized openCollection
and paneTabs.collectionSettingsTab('overview') helpers. Apply the same cleanup
to the repeated occurrences in this test and the related migrate-to-yml test
files, preserving the existing navigation and assertions.

Source: Path instructions

tests/collection/migrate-to-yml-cancel/migrate-to-yml-cancel.spec.ts (1)

50-73: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Inline raw selectors instead of centralized page-object locators.

Lines 52, 69, 70, and 71 hand-roll page.locator('#sidebar-collection-name').filter(...) and page.getByTestId('collection-settings-tab-overview') instead of reusing the already-imported openCollection(page, name) helper and the loc.paneTabs.collectionSettingsTab('overview') locator exposed in tests/utils/page/locators.ts. As per path instructions, "Centralize locators and actions in page modules under tests/utils/page/*; do not inline raw selectors in specs." This is shared with other migration specs — see the consolidated comment.

🤖 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-cancel/migrate-to-yml-cancel.spec.ts` around
lines 50 - 73, Replace the inline sidebar and settings-tab selectors in the
migration test with the existing page-object APIs: use openCollection(page,
'migration-test') for reopening/selecting the collection and
loc.paneTabs.collectionSettingsTab('overview') for the overview tab. Reuse the
appropriate centralized collection locator for the visibility assertions,
removing all raw selector expressions from this spec.

Source: Path instructions

tests/collection/migrate-to-yml-nested-multi/migrate-to-yml-nested-multi.spec.ts (1)

41-67: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Inline getByTestId('collection-settings-tab-overview') instead of the centralized locator.

Lines 43 and 66 use page.getByTestId('collection-settings-tab-overview') directly even though the rest of this test already uses loc.sidebar.collection/loc.tabs.*. tests/utils/page/locators.ts exposes paneTabs.collectionSettingsTab('overview') for exactly this. Shared with other migration specs — see the consolidated comment.

🤖 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`
around lines 41 - 67, Replace the direct
page.getByTestId('collection-settings-tab-overview') calls in the migration and
final verification steps with the centralized
locators.paneTabs.collectionSettingsTab('overview') helper. Use the shared
locator consistently while preserving the existing click and visibility
assertions.

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-electron/src/ipc/yml-migration.js`:
- Around line 245-255: Guard the webContents.send calls in emitProgress and
reportError by checking whether mainWindow.webContents is destroyed before
sending. Preserve progress and error reporting when the window is available,
while skipping sends after destruction so migration rollback and catch handling
remain deterministic.

In `@packages/bruno-electron/src/services/mount/manager.js`:
- Around line 99-115: Update the mount flow around the try/finally block in
mount() to remove the partially mounted entry from this.#mounts when `#reconcile`,
`#emitTree`, or watcher registration fails. Preserve loading-state cleanup in the
finally block, rethrow the original error, and ensure a subsequent mount() does
not take the renderer-reload fast path without reattaching watchers.

In `@tests/collection/migrate-to-yml/migrate-to-yml.spec.ts`:
- Line 14: Remove the skip from the primary migration suite by changing the
test.describe.skip wrapper in “Migrate collection from bru to yml format” to an
active test.describe, while leaving the nested multi-collection coverage and
existing test behavior unchanged.

---

Outside diff comments:
In `@packages/bruno-app/src/components/RequestTabs/CollectionHeader/index.js`:
- Around line 716-747: Uncomment the entire “Migrate to YML” pill JSX block in
the collection header so it renders when collection.format is “bru” and
migratePillDismissed is false. Preserve the existing showMigrateToYmlModal
dispatch, dismissMigratePill handler, and
migrate-yml-pill/migrate-yml-pill-dismiss test IDs.
- Around line 52-61: Normalize collection paths consistently before storing or
comparing dismissal keys in readDismissedCollections and dismissMigratePill.
Apply a path-normalization helper that handles separator differences and casing,
then use the normalized collection.pathname for both persistence and .includes()
checks while preserving the existing dismissal behavior.

---

Nitpick comments:
In `@packages/bruno-electron/src/ipc/yml-migration.spec.js`:
- Around line 217-224: Extract the duplicated fs.promises.unlink failure setup
into a shared helper near the affected tests, such as
mockUnlinkFailureOnCall(n), that preserves the real unlink behavior and throws
the simulated EPERM error on the specified call. Replace the inline mock blocks
in both “restores removed sources...” and “keeps the backup and reports...”
tests with calls to this helper.

In `@packages/bruno-filestore/src/formats/yml/parseFolder.spec.ts`:
- Around line 54-65: Add regression tests for the falsy numeric sequence value:
in packages/bruno-filestore/src/formats/yml/parseFolder.spec.ts lines 54-65, add
a parseFolder case with seq: 0 and assert meta.seq is 0; in
packages/bruno-filestore/src/formats/yml/stringifyFolder.spec.ts lines 49-65,
add a stringify/round-trip case with meta.seq set to 0 and assert the value
remains 0. Use the existing test structures and helpers.
- Around line 58-64: Update the sequence assertions in
packages/bruno-filestore/src/formats/yml/parseFolder.spec.ts lines 58-64 and
packages/bruno-filestore/src/formats/yml/stringifyFolder.spec.ts lines 56-64 to
narrow the parsed metadata into a defined local value before accessing seq.
Replace the unguarded meta?.seq usage in both sites while preserving the
existing undefined and numeric sequence expectations.

In `@tests/collection/migrate-to-yml-cancel/migrate-to-yml-cancel.spec.ts`:
- Around line 50-73: Replace the inline sidebar and settings-tab selectors in
the migration test with the existing page-object APIs: use openCollection(page,
'migration-test') for reopening/selecting the collection and
loc.paneTabs.collectionSettingsTab('overview') for the overview tab. Reuse the
appropriate centralized collection locator for the visibility assertions,
removing all raw selector expressions from this spec.

In
`@tests/collection/migrate-to-yml-nested-multi/migrate-to-yml-nested-multi.spec.ts`:
- Around line 41-67: Replace the direct
page.getByTestId('collection-settings-tab-overview') calls in the migration and
final verification steps with the centralized
locators.paneTabs.collectionSettingsTab('overview') helper. Use the shared
locator consistently while preserving the existing click and visibility
assertions.

In `@tests/collection/migrate-to-yml/migrate-to-yml.spec.ts`:
- Around line 38-50: Remove the redundant collection-name clicks after
openCollection and replace the inline collection and settings-tab selectors with
the centralized openCollection and paneTabs.collectionSettingsTab('overview')
helpers. Apply the same cleanup to the repeated occurrences in this test and the
related migrate-to-yml test files, preserving the existing navigation and
assertions.
🪄 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 Plus

Run ID: f917a2cf-70be-4955-9595-d3b2de3d6105

📥 Commits

Reviewing files that changed from the base of the PR and between f9051fc and 53455c3.

📒 Files selected for processing (55)
  • packages/bruno-app/src/components/CollectionSettings/Overview/Migration/MigrateToYmlModal/index.js
  • packages/bruno-app/src/components/CollectionSettings/Overview/Migration/index.js
  • packages/bruno-app/src/components/MigrateCollectionToYmlModal/StyledWrapper.js
  • packages/bruno-app/src/components/MigrateCollectionToYmlModal/index.js
  • packages/bruno-app/src/components/RequestTabs/CollectionHeader/index.js
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js
  • packages/bruno-app/src/providers/App/index.js
  • packages/bruno-app/src/providers/App/useIpcEvents.js
  • packages/bruno-app/src/providers/ReduxStore/index.js
  • packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/middleware.js
  • packages/bruno-app/src/providers/ReduxStore/slices/collection-migration.js
  • packages/bruno-app/src/providers/ReduxStore/slices/collection-migration.spec.js
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/collection-format.spec.js
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/migrate-in-place.spec.js
  • packages/bruno-app/src/providers/ReduxStore/slices/tabs-migrate.spec.js
  • packages/bruno-app/src/providers/ReduxStore/slices/tabs.js
  • packages/bruno-electron/src/cache/requestUids.js
  • packages/bruno-electron/src/index.js
  • packages/bruno-electron/src/ipc/collection.js
  • packages/bruno-electron/src/ipc/mount.js
  • packages/bruno-electron/src/ipc/workspace.js
  • packages/bruno-electron/src/ipc/yml-migration.js
  • packages/bruno-electron/src/ipc/yml-migration.spec.js
  • packages/bruno-electron/src/services/mount/file-index.js
  • packages/bruno-electron/src/services/mount/manager.js
  • packages/bruno-electron/src/services/mount/manager.spec.js
  • packages/bruno-electron/src/services/snapshot/index.js
  • packages/bruno-electron/src/store/bruno-config.js
  • packages/bruno-electron/tests/services/snapshot-remap.spec.js
  • packages/bruno-filestore/src/formats/yml/parseFolder.spec.ts
  • packages/bruno-filestore/src/formats/yml/parseFolder.ts
  • packages/bruno-filestore/src/formats/yml/stringifyFolder.spec.ts
  • packages/bruno-filestore/src/formats/yml/stringifyFolder.ts
  • packages/bruno-filestore/src/index.ts
  • packages/bruno-filestore/src/workers/WorkerQueue/index.ts
  • packages/bruno-filestore/src/workers/index.ts
  • packages/bruno-filestore/src/workers/worker-script.ts
  • tests/collection/migrate-to-yml-cancel/fixtures/collection/api/folder.bru
  • tests/collection/migrate-to-yml-cancel/fixtures/collection/api/get-users.bru
  • tests/collection/migrate-to-yml-cancel/fixtures/collection/bruno.json
  • tests/collection/migrate-to-yml-cancel/fixtures/collection/collection.bru
  • tests/collection/migrate-to-yml-cancel/fixtures/collection/environments/Local.bru
  • tests/collection/migrate-to-yml-cancel/fixtures/collection/environments/Production.bru
  • tests/collection/migrate-to-yml-cancel/fixtures/collection/ping.bru
  • tests/collection/migrate-to-yml-cancel/fixtures/collection/post-json.bru
  • tests/collection/migrate-to-yml-cancel/init-user-data/preferences.json
  • tests/collection/migrate-to-yml-cancel/migrate-to-yml-cancel.spec.ts
  • 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
  • tests/utils/page/collection/migrate-to-yml.ts
  • tests/utils/page/index.ts
  • tests/utils/page/locators.ts
💤 Files with no reviewable changes (9)
  • packages/bruno-app/src/providers/ReduxStore/slices/tabs-migrate.spec.js
  • tests/collection/migrate-to-yml/keep-request-tab-open.spec.ts
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/migrate-in-place.spec.js
  • packages/bruno-app/src/components/CollectionSettings/Overview/Migration/MigrateToYmlModal/index.js
  • packages/bruno-electron/tests/services/snapshot-remap.spec.js
  • packages/bruno-electron/src/services/mount/manager.spec.js
  • packages/bruno-electron/src/services/snapshot/index.js
  • packages/bruno-electron/src/ipc/collection.js
  • packages/bruno-app/src/providers/ReduxStore/slices/tabs.js

Comment on lines +245 to +255
const emitProgress = (phase, current, total) => {
mainWindow.webContents.send('main:collection-migration-progress', { collectionUid, phase, current, total });
};
const checkCancelled = () => {
if (migrationCancellations.has(collectionUid)) {
throw new Error(MIGRATION_CANCELLED_MESSAGE);
}
};
const reportError = (message) => {
mainWindow.webContents.send('main:display-error', { message });
};

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Guard the webContents.send calls against a destroyed window.

If the user closes the window mid-migration, emitProgress throws from inside phase 2/3 and gets funneled into the rollback path (and reportError can then throw inside the catch). A cheap isDestroyed() check keeps rollback deterministic.

🛡️ Proposed fix
+  const send = (channel, payload) => {
+    if (mainWindow.isDestroyed?.() || mainWindow.webContents?.isDestroyed?.()) return;
+    mainWindow.webContents.send(channel, payload);
+  };
   const emitProgress = (phase, current, total) => {
-    mainWindow.webContents.send('main:collection-migration-progress', { collectionUid, phase, current, total });
+    send('main:collection-migration-progress', { collectionUid, phase, current, total });
   };
@@
   const reportError = (message) => {
-    mainWindow.webContents.send('main:display-error', { message });
+    send('main:display-error', { message });
   };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const emitProgress = (phase, current, total) => {
mainWindow.webContents.send('main:collection-migration-progress', { collectionUid, phase, current, total });
};
const checkCancelled = () => {
if (migrationCancellations.has(collectionUid)) {
throw new Error(MIGRATION_CANCELLED_MESSAGE);
}
};
const reportError = (message) => {
mainWindow.webContents.send('main:display-error', { message });
};
const send = (channel, payload) => {
if (mainWindow.isDestroyed?.() || mainWindow.webContents?.isDestroyed?.()) return;
mainWindow.webContents.send(channel, payload);
};
const emitProgress = (phase, current, total) => {
send('main:collection-migration-progress', { collectionUid, phase, current, total });
};
const checkCancelled = () => {
if (migrationCancellations.has(collectionUid)) {
throw new Error(MIGRATION_CANCELLED_MESSAGE);
}
};
const reportError = (message) => {
send('main:display-error', { message });
};
🤖 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/yml-migration.js` around lines 245 - 255,
Guard the webContents.send calls in emitProgress and reportError by checking
whether mainWindow.webContents is destroyed before sending. Preserve progress
and error reporting when the window is available, while skipping sends after
destruction so migration rollback and catch handling remain deterministic.

Comment on lines 99 to +115
entry.emit.loading(true);
try {
entry.state = this.#getIndex().entries(entry.collectionPath);
entry.state = this.#getIndex().entries(collectionPath);
await this.#reconcile(entry);
await this.#emitTree(collectionUid, entry);

// skip the startup walk (already done) and stage live edits into the cache
const collectionWatcher = require('../../app/collection-watcher');
collectionWatcher.addWatcher(entry.win, entry.collectionPath, collectionUid, entry.brunoConfig, false, false, {
collectionWatcher.addWatcher(entry.win, collectionPath, collectionUid, brunoConfig, false, false, {
ignoreInitial: true,
fileIndex: this.#getIndex()
});
collectionWatcher.addTempDirectoryWatcher(entry.win, entry.tempDirectoryPath, collectionUid, entry.collectionPath);
collectionWatcher.addTempDirectoryWatcher(entry.win, tempDirectoryPath, collectionUid, collectionPath);
} finally {
entry.emit.loading(false);
}
return tempDirectoryPath;

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Failure inside the try leaves a half-mounted entry with no watchers.

this.#mounts.set(collectionUid, entry) already happened at Line 97, so if #reconcile/#emitTree/addWatcher throws, the next mount() call hits the "renderer reload" fast path and returns without ever attaching a collection watcher — live edits stop being picked up until restart. Drop the entry on failure.

🛡️ Proposed fix
     entry.emit.loading(true);
     try {
       entry.state = this.#getIndex().entries(collectionPath);
@@
       collectionWatcher.addTempDirectoryWatcher(entry.win, tempDirectoryPath, collectionUid, collectionPath);
+    } catch (error) {
+      this.#mounts.delete(collectionUid);
+      throw error;
     } finally {
       entry.emit.loading(false);
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
entry.emit.loading(true);
try {
entry.state = this.#getIndex().entries(entry.collectionPath);
entry.state = this.#getIndex().entries(collectionPath);
await this.#reconcile(entry);
await this.#emitTree(collectionUid, entry);
// skip the startup walk (already done) and stage live edits into the cache
const collectionWatcher = require('../../app/collection-watcher');
collectionWatcher.addWatcher(entry.win, entry.collectionPath, collectionUid, entry.brunoConfig, false, false, {
collectionWatcher.addWatcher(entry.win, collectionPath, collectionUid, brunoConfig, false, false, {
ignoreInitial: true,
fileIndex: this.#getIndex()
});
collectionWatcher.addTempDirectoryWatcher(entry.win, entry.tempDirectoryPath, collectionUid, entry.collectionPath);
collectionWatcher.addTempDirectoryWatcher(entry.win, tempDirectoryPath, collectionUid, collectionPath);
} finally {
entry.emit.loading(false);
}
return tempDirectoryPath;
entry.emit.loading(true);
try {
entry.state = this.#getIndex().entries(collectionPath);
await this.#reconcile(entry);
await this.#emitTree(collectionUid, entry);
// skip the startup walk (already done) and stage live edits into the cache
const collectionWatcher = require('../../app/collection-watcher');
collectionWatcher.addWatcher(entry.win, collectionPath, collectionUid, brunoConfig, false, false, {
ignoreInitial: true,
fileIndex: this.#getIndex()
});
collectionWatcher.addTempDirectoryWatcher(entry.win, tempDirectoryPath, collectionUid, collectionPath);
} catch (error) {
this.#mounts.delete(collectionUid);
throw error;
} finally {
entry.emit.loading(false);
}
return tempDirectoryPath;
🤖 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/services/mount/manager.js` around lines 99 - 115,
Update the mount flow around the try/finally block in mount() to remove the
partially mounted entry from this.#mounts when `#reconcile`, `#emitTree`, or watcher
registration fails. Preserve loading-state cleanup in the finally block, rethrow
the original error, and ensure a subsequent mount() does not take the
renderer-reload fast path without reattaching watchers.

sendRequestAndWaitForResponse
} from '../../utils/page';

test.describe.skip('Migrate collection from bru to yml format', () => {

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- candidate files ---'
git ls-files | rg '(^|/)migrate-to-yml.*\.spec\.ts$|tests/collection/migrate-to-yml|migrate-to-yml-nested-multi' || true

echo '--- main spec outline/head ---'
if [ -f tests/collection/migrate-to-yml/migrate-to-yml.spec.ts ]; then
  wc -l tests/collection/migrate-to-yml/migrate-to-yml.spec.ts
  sed -n '1,180p' tests/collection/migrate-to-yml/migrate-to-yml.spec.ts
fi

echo '--- nested spec head/summary ---'
if [ -f tests/collection/migrate-to-yml/migrate-to-yml-nested-multi.spec.ts ]; then
  wc -l tests/collection/migrate-to-yml/migrate-to-yml-nested-multi.spec.ts
  sed -n '1,40p' tests/collection/migrate-to-yml/migrate-to-yml-nested-multi.spec.ts
fi

echo '--- diff for these specs if available ---'
git diff -- tests/collection/migrate-to-yml/migrate-to-yml.spec.ts tests/collection/migrate-to-yml/migrate-to-yml-nested-multi.spec.ts | sed -n '1,220p'

echo '--- PR mention of migrate-to-yml in docs/readme ---'
rg -n "migrate-to-yml|migration|migration-test|migrate|conversion" README.md docs tests -S || true

Repository: usebruno/bruno

Length of output: 28445


Unskip the primary Bru-to-YML migration e2e.

tests/collection/migrate-to-yml/migrate-to-yml.spec.ts still guards the full non-nested migration flow with test.describe.skip, while the nested multi-collection spec runs. Keeping it skipped leaves the core Bru-to-YML conversion path unexercised by this e2e coverage.

🤖 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/migrate-to-yml.spec.ts` at line 14, Remove
the skip from the primary migration suite by changing the test.describe.skip
wrapper in “Migrate collection from bru to yml format” to an active
test.describe, while leaving the nested multi-collection coverage and existing
test behavior unchanged.

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