Skip to content

fix: sample collection creation race condition#7665

Merged
bijin-bruno merged 1 commit intomainfrom
feat/fix-sample-collection
Apr 3, 2026
Merged

fix: sample collection creation race condition#7665
bijin-bruno merged 1 commit intomainfrom
feat/fix-sample-collection

Conversation

@bijin-bruno
Copy link
Copy Markdown
Collaborator

@bijin-bruno bijin-bruno commented Apr 2, 2026

Description

Fixes a race condition.
The sidebar filters collections to only show those belonging to the active workspace.
This PR guarantees the sample collection's main:collection-opened event is sent to the renderer only after the default workspace exists, so openCollectionEvent can properly associate the collection with the workspace and the sidebar filter will include it.

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

Bug Fixes

  • Fixed a startup initialization timing issue where collections could load before the workspace sidebar structure was fully prepared. Collections now load after workspace initialization is complete for improved startup reliability.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 2, 2026

Walkthrough

Modified IPC event timing in the onboarding flow to align sample collection delivery with workspace readiness. Changed from listening to main:renderer-ready to main:workspaces-ready in onboarding.js, with a corresponding new event emission in workspace.js initialization.

Changes

Cohort / File(s) Summary
Onboarding Timing Adjustment
packages/bruno-electron/src/app/onboarding.js
Changed deferred main:collection-opened message trigger from main:renderer-ready to main:workspaces-ready event.
Workspace Ready Signal
packages/bruno-electron/src/ipc/workspace.js
Added ipcMain.emit('main:workspaces-ready', win) after workspace initialization completes to signal readiness to listeners.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

size/M

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno

Poem

🔄 When renderer wakes, it's just too soon,
Workspaces need their time to bloom.
A signal sent when all is set,
Collections open—perfect fit. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main fix: addressing a race condition in sample collection creation by ensuring proper synchronization with workspace initialization.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/fix-sample-collection

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 and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 2, 2026

CLI Test Results

  1 files  ±0  190 suites  ±0   55s ⏱️ -17s
426 tests ±0  426 ✅ ±0  0 💤 ±0  0 ❌ ±0 
507 runs  ±0  500 ✅ ±0  7 💤 ±0  0 ❌ ±0 

Results for commit 96859a6. ± Comparison against base commit bae5934.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (1)
packages/bruno-electron/src/app/onboarding.js (1)

99-101: ⚠️ Potential issue | 🟡 Minor

Stale comment references old event name.

Line 100 still says "deferred until main:renderer-ready is emitted" but the code now waits for main:workspaces-ready.

Proposed fix
       // Store collection info to open after renderer is ready
-      // The main:collection-opened event is deferred until main:renderer-ready is emitted
+      // The main:collection-opened event is deferred until main:workspaces-ready is emitted
       pendingSampleCollection = { mainWindow, ...collectionInfo };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-electron/src/app/onboarding.js` around lines 99 - 101, Update
the stale comment above the pendingSampleCollection assignment to reference the
new event name: replace mention of "main:renderer-ready" with
"main:workspaces-ready" so it accurately reflects when the
main:collection-opened event is deferred; confirm the comment sits next to the
pendingSampleCollection variable and mentions both main:collection-opened and
main:workspaces-ready for clarity.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/bruno-electron/src/app/onboarding.js`:
- Around line 99-101: Update the stale comment above the pendingSampleCollection
assignment to reference the new event name: replace mention of
"main:renderer-ready" with "main:workspaces-ready" so it accurately reflects
when the main:collection-opened event is deferred; confirm the comment sits next
to the pendingSampleCollection variable and mentions both main:collection-opened
and main:workspaces-ready for clarity.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a7b30559-b6c9-4b54-9311-e3523d3adb89

📥 Commits

Reviewing files that changed from the base of the PR and between bae5934 and 96859a6.

📒 Files selected for processing (2)
  • packages/bruno-electron/src/app/onboarding.js
  • packages/bruno-electron/src/ipc/workspace.js

@bijin-bruno bijin-bruno merged commit f112c4f into main Apr 3, 2026
13 checks passed
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.

1 participant