Repository navigation
feat: adding bru to yml migration - #8794
utkarsh-bruno wants to merge 2 commits into
Conversation
WalkthroughThe 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. ChangesYML migration UI and state
Electron and filestore flow
Validation
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
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 +
showMigrateToYmlModaldispatch) sits inside{/* ... */}, so it never renders. The diff even updates theonClickhandler here (to dispatchshowMigrateToYmlModal) without uncommenting it — the PR's stated "dismissible collection-header pill" deliverable is therefore not shipped, and themigrate-yml-pill/migrate-yml-pill-dismisstestids 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 winPill dismissal keys off raw
collection.pathnamestring equality.
readDismissedCollections/dismissMigratePillstore and comparecollection.pathnameverbatim 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 winAdd regression coverage for
seq: 0.Both tests currently use only truthy numeric values, so the former
seq || 1behavior could regress unnoticed.
packages/bruno-filestore/src/formats/yml/parseFolder.spec.ts#L54-L65: parseseq: 0and assertmeta.seqis0.packages/bruno-filestore/src/formats/yml/stringifyFolder.spec.ts#L49-L65: stringifymeta.seq: 0and assert the round trip preserves0.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 winAvoid 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: replacemeta?.seqwith 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 winDuplicated
unlink-failure mock across two tests.The "fail on the 3rd
unlinkcall" 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 winRedundant duplicate click and inline selectors instead of centralized locators.
openCollection(page, 'migration-test')(line 39) already clicks#sidebar-collection-namefiltered 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 reusingopenCollectionand the centralizedpaneTabs.collectionSettingsTab('overview')locator. This pattern repeats at lines 122 and 131, and is shared withmigrate-to-yml-cancel.spec.tsandmigrate-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 winInline raw selectors instead of centralized page-object locators.
Lines 52, 69, 70, and 71 hand-roll
page.locator('#sidebar-collection-name').filter(...)andpage.getByTestId('collection-settings-tab-overview')instead of reusing the already-importedopenCollection(page, name)helper and theloc.paneTabs.collectionSettingsTab('overview')locator exposed intests/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 winInline
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 usesloc.sidebar.collection/loc.tabs.*.tests/utils/page/locators.tsexposespaneTabs.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
📒 Files selected for processing (55)
packages/bruno-app/src/components/CollectionSettings/Overview/Migration/MigrateToYmlModal/index.jspackages/bruno-app/src/components/CollectionSettings/Overview/Migration/index.jspackages/bruno-app/src/components/MigrateCollectionToYmlModal/StyledWrapper.jspackages/bruno-app/src/components/MigrateCollectionToYmlModal/index.jspackages/bruno-app/src/components/RequestTabs/CollectionHeader/index.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/index.jspackages/bruno-app/src/providers/App/index.jspackages/bruno-app/src/providers/App/useIpcEvents.jspackages/bruno-app/src/providers/ReduxStore/index.jspackages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/middleware.jspackages/bruno-app/src/providers/ReduxStore/slices/collection-migration.jspackages/bruno-app/src/providers/ReduxStore/slices/collection-migration.spec.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/actions.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/collection-format.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-electron/src/cache/requestUids.jspackages/bruno-electron/src/index.jspackages/bruno-electron/src/ipc/collection.jspackages/bruno-electron/src/ipc/mount.jspackages/bruno-electron/src/ipc/workspace.jspackages/bruno-electron/src/ipc/yml-migration.jspackages/bruno-electron/src/ipc/yml-migration.spec.jspackages/bruno-electron/src/services/mount/file-index.jspackages/bruno-electron/src/services/mount/manager.jspackages/bruno-electron/src/services/mount/manager.spec.jspackages/bruno-electron/src/services/snapshot/index.jspackages/bruno-electron/src/store/bruno-config.jspackages/bruno-electron/tests/services/snapshot-remap.spec.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.tspackages/bruno-filestore/src/index.tspackages/bruno-filestore/src/workers/WorkerQueue/index.tspackages/bruno-filestore/src/workers/index.tspackages/bruno-filestore/src/workers/worker-script.tstests/collection/migrate-to-yml-cancel/fixtures/collection/api/folder.brutests/collection/migrate-to-yml-cancel/fixtures/collection/api/get-users.brutests/collection/migrate-to-yml-cancel/fixtures/collection/bruno.jsontests/collection/migrate-to-yml-cancel/fixtures/collection/collection.brutests/collection/migrate-to-yml-cancel/fixtures/collection/environments/Local.brutests/collection/migrate-to-yml-cancel/fixtures/collection/environments/Production.brutests/collection/migrate-to-yml-cancel/fixtures/collection/ping.brutests/collection/migrate-to-yml-cancel/fixtures/collection/post-json.brutests/collection/migrate-to-yml-cancel/init-user-data/preferences.jsontests/collection/migrate-to-yml-cancel/migrate-to-yml-cancel.spec.tstests/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.tstests/utils/page/collection/migrate-to-yml.tstests/utils/page/index.tstests/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
| 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 }); | ||
| }; |
There was a problem hiding this comment.
🩺 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.
| 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.
| 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; |
There was a problem hiding this comment.
🩺 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.
| 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', () => { |
There was a problem hiding this comment.
📐 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 || trueRepository: 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.
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:
Summary by CodeRabbit
New Features
Bug Fixes
Tests