Skip to content

feat: bruno app instances handling updates#6748

Merged
bijin-bruno merged 4 commits intousebruno:mainfrom
lohit-bruno:bruno_app_instances_handling
Jan 21, 2026
Merged

feat: bruno app instances handling updates#6748
bijin-bruno merged 4 commits intousebruno:mainfrom
lohit-bruno:bruno_app_instances_handling

Conversation

@lohit-bruno
Copy link
Collaborator

@lohit-bruno lohit-bruno commented Jan 8, 2026

Description

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

    • Single-instance mode enabled by default with an environment override.
    • App restores/focuses the main window when handling protocol links and defers processing until ready.
  • Bug Fixes

    • More reliable registration and handling of bruno:// protocol links across platforms.
    • Improved behavior when a second instance is launched: primary instance is focused and protocol links are forwarded.
  • Chores / Tests

    • Added environment toggle to disable single-instance behavior for test/launcher scenarios.
  • Chores

    • Releases single-instance lock on quit to allow takeover by new instances.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 8, 2026

Walkthrough

Implements single-instance behavior and centralizes bruno:// protocol handling in the primary instance; adds window focus/restore logic for protocol opens and second-instance events; stores/defers URLs until window is ready; exposes an env toggle via Playwright to disable single-instance for tests. (41 words)

Changes

Cohort / File(s) Summary
Single-instance & protocol flow
packages/bruno-electron/src/index.js
Add focusMainWindow helper; parse appProtocolUrl from argv early; enable single-instance lock by default with env-toggle override; primary instance registers bruno:// handler and Linux MIME; handle second-instance to focus/restore window and extract/pass protocol URL; integrate macOS open-url into stored/late handling; call protocol handler after first-finish-load; release lock on before-quit.
Playwright / test launcher env
playwright/index.ts
Add environment variable DISABLE_SINGLE_INSTANCE='true' to the env passed to the Electron launcher to disable single-instance during tests.

Sequence Diagram(s)

sequenceDiagram
  participant OS
  participant NewInstance
  participant PrimaryInstance
  participant MainWindow

  OS->>NewInstance: user opens bruno:// link or launches app
  NewInstance->>PrimaryInstance: attempt single-instance lock / pass argv (second-instance)
  alt Lock acquired (primary)
    PrimaryInstance->>PrimaryInstance: register bruno:// handler, register MIME (Linux)
    PrimaryInstance->>MainWindow: create/restore window
    MainWindow->>PrimaryInstance: first-finish-load event
    PrimaryInstance->>PrimaryInstance: handle stored appProtocolUrl (if any)
  else Lock not acquired (secondary)
    NewInstance->>PrimaryInstance: send argv including protocol URL
    PrimaryInstance->>PrimaryInstance: extract protocol URL, store if not ready
    PrimaryInstance->>MainWindow: focus/restore window
    PrimaryInstance->>MainWindow: process protocol URL (when ready)
    NewInstance->>NewInstance: quit
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested labels

size/L

Suggested reviewers

  • helloanoop
  • naman-bruno
  • bijin-bruno

Poem

A single lock, a focused pane, 🔒🪟
Protocols routed, none remain astray,
Second instances bow and fade away,
URLs wait until the window's day,
Bruno runs — one process leads the way. 🎶

🚥 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 accurately describes the main change: implementing single-instance behavior and protocol URL handling for the Bruno Electron app, with related test configuration updates.
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

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee7239f and 04567a2.

📒 Files selected for processing (1)
  • playwright/index.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • playwright/index.ts
🧠 Learnings (1)
📓 Common learnings
Learnt from: kanakkholwal
Repo: usebruno/bruno PR: 6767
File: packages/bruno-app/src/components/ResponseExample/index.js:221-226
Timestamp: 2026-01-09T18:25:23.407Z
Learning: Bruno is an Electron-only application, so `window.ipcRenderer` will always be available and does not require existence checks.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: CLI Tests
  • GitHub Check: Unit Tests
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: CLI Tests
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: Unit Tests
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Linux
🔇 Additional comments (1)
playwright/index.ts (1)

87-97: LGTM!

Adding DISABLE_SINGLE_INSTANCE: 'true' here is the right call. Playwright's worker-scoped fixtures can spawn multiple Electron instances in parallel, and single-instance enforcement would cause lock contention or outright failures. Placement is consistent with the other test-specific env overrides.


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.

Copy link
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.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @packages/bruno-app/src/components/Preferences/General/index.js:
- Around line 125-128: When updating the preferences, don't replace the whole
general object—merge it; update the code that sets general to spread the
existing preferences.general first and then override specific keys from
newPreferences (e.g., use general: { ...preferences.general,
defaultCollectionLocation: newPreferences.defaultCollectionLocation,
singleInstance: newPreferences.singleInstance }) so other keys like
defaultWorkspacePath are preserved.
🧹 Nitpick comments (1)
packages/bruno-electron/src/index.js (1)

122-126: Silent failure on xdg-mime command.

The empty catch block swallows all errors. While this is likely intentional (non-critical registration), consider logging at debug level for troubleshooting.

♻️ Suggested improvement
   if (isLinux) {
     try {
       execSync('xdg-mime default bruno.desktop x-scheme-handler/bruno');
-    } catch (err) {}
+    } catch (err) {
+      console.debug('Failed to set xdg-mime default:', err.message);
+    }
   }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 578fa72 and a906678.

📒 Files selected for processing (3)
  • packages/bruno-app/src/components/Preferences/General/index.js
  • packages/bruno-electron/src/index.js
  • packages/bruno-electron/src/store/preferences.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-electron/src/store/preferences.js
  • packages/bruno-electron/src/index.js
  • packages/bruno-app/src/components/Preferences/General/index.js
🧠 Learnings (1)
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.

Applied to files:

  • packages/bruno-electron/src/store/preferences.js
  • packages/bruno-electron/src/index.js
  • packages/bruno-app/src/components/Preferences/General/index.js
🧬 Code graph analysis (2)
packages/bruno-electron/src/store/preferences.js (2)
packages/bruno-electron/src/app/collections.js (1)
  • Yup (4-4)
packages/bruno-cli/src/runner/prepare-request.js (1)
  • get (1-1)
packages/bruno-electron/src/index.js (3)
packages/bruno-electron/src/utils/deeplink.js (2)
  • getAppProtocolUrlFromArgv (4-6)
  • handleAppProtocolUrl (9-15)
packages/bruno-electron/src/store/preferences.js (2)
  • process (280-280)
  • preferencesUtil (248-306)
packages/bruno-electron/src/utils/arch.js (1)
  • isMac (2-2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: Unit Tests
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: CLI Tests
🔇 Additional comments (11)
packages/bruno-electron/src/store/preferences.js (3)

52-56: LGTM - Default preferences extended correctly.

The singleInstance: true default aligns with the expected behavior where single-instance mode is enabled by default. The defaultWorkspacePath addition appears to be scaffolding for a related feature.


107-111: LGTM - Schema validation is consistent.

Both new fields follow the existing validation patterns. The singleInstance boolean and defaultWorkspacePath string constraints match their counterparts in the defaults.


302-306: LGTM - Utility method follows established patterns.

shouldUseSingleInstance() mirrors the structure of other preference accessors in preferencesUtil. Default fallback to true is consistent with defaultPreferences.

packages/bruno-electron/src/index.js (5)

63-63: LGTM - Import added for preferences utility.

Clean import placement alongside other store imports.


94-102: LGTM - Helper function is clean and reusable.

focusMainWindow properly handles the minimized state before focusing. Used in both open-url and second-instance handlers, reducing duplication.


128-147: LGTM - Platform-specific protocol handling.

macOS open-url and cross-platform second-instance handlers are properly implemented. Both focus the main window and delegate URL handling to handleAppProtocolUrl.


348-352: LGTM - Lock release on quit.

Properly guarded with both useSingleInstance and gotTheLock checks to avoid releasing a lock that was never acquired.


107-113: No issue—electron-store handles the early preference read safely.

The clearInvalidConfig: true option in the Store constructor automatically clears corrupted or inaccessible preference files. Even if that occurs, the code has nested fallback defaults: the store returns an empty object, which merges with defaultPreferences, and shouldUseSingleInstance() itself provides another fallback default of true. The call is safe at module initialization, and no unhandled startup failure is possible.

packages/bruno-app/src/components/Preferences/General/index.js (3)

63-65: LGTM - Schema validation added correctly.

singleInstance: Yup.boolean() follows the existing validation pattern for boolean preferences.


87-89: LGTM - Initial value extraction is consistent.

Uses get() with default true, matching the server-side default in preferences.js.


304-316: LGTM - UI implementation is clean.

Checkbox follows the established pattern. The "(requires restart)" note in the label clearly communicates the behavior to users.

Comment on lines 125 to 128
general: {
defaultCollectionLocation: newPreferences.defaultCollectionLocation
defaultCollectionLocation: newPreferences.defaultCollectionLocation,
singleInstance: newPreferences.singleInstance
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Potential data loss: general object is replaced, not merged.

The general object is completely overwritten, which would discard any other properties (e.g., defaultWorkspacePath added in preferences.js). Spread the existing general properties to preserve them.

🐛 Proposed fix
         general: {
+          ...preferences.general,
           defaultCollectionLocation: newPreferences.defaultCollectionLocation,
           singleInstance: newPreferences.singleInstance
         }
📝 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
general: {
defaultCollectionLocation: newPreferences.defaultCollectionLocation
defaultCollectionLocation: newPreferences.defaultCollectionLocation,
singleInstance: newPreferences.singleInstance
}
general: {
...preferences.general,
defaultCollectionLocation: newPreferences.defaultCollectionLocation,
singleInstance: newPreferences.singleInstance
}
🤖 Prompt for AI Agents
In @packages/bruno-app/src/components/Preferences/General/index.js around lines
125 - 128, When updating the preferences, don't replace the whole general
object—merge it; update the code that sets general to spread the existing
preferences.general first and then override specific keys from newPreferences
(e.g., use general: { ...preferences.general, defaultCollectionLocation:
newPreferences.defaultCollectionLocation, singleInstance:
newPreferences.singleInstance }) so other keys like defaultWorkspacePath are
preserved.

@pull-request-size pull-request-size bot added size/M and removed size/L labels Jan 13, 2026
Copy link
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.

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In @packages/bruno-electron/src/index.js:
- Around line 122-126: The empty catch swallowing errors around the execSync
call hides failures when registering the xdg-mime handler; update the catch for
the execSync('xdg-mime default bruno.desktop x-scheme-handler/bruno') inside the
isLinux branch to log the error (e.g., console.error or the app logger) with a
clear message like "Failed to register xdg-mime handler for bruno" and include
the caught err object so failures are visible for debugging while preserving the
existing control flow.
- Line 63: The import const { preferencesUtil } =
require('./store/preferences'); is unused in this file; remove that unused
import line (or, if you intended to use it, wire up preferencesUtil where
needed—e.g., calls to preferencesUtil.get/set in the initialization logic) so
the symbol preferencesUtil is either referenced or eliminated to avoid dead code
and linter complaints.
- Around line 128-137: The open-url handler may call handleAppProtocolUrl with a
null mainWindow if the window isn't created yet; change the app.on('open-url')
callback to queue the incoming URL when mainWindow is falsy (store it in a
module-scoped pendingProtocolUrl variable) and still call focusMainWindow(),
then after mainWindow is created/ready (in the code that constructs mainWindow
or in a ready/ready-to-show handler) check pendingProtocolUrl and call
handleAppProtocolUrl(pendingProtocolUrl, mainWindow) and clear the pending
value; ensure any existing calls to focusMainWindow or handleAppProtocolUrl
check for mainWindow and use the queued URL flow so protocol URLs are processed
only once the window exists.
- Line 134: Calls to handleAppProtocolUrl are passing an extra mainWindow
argument even though the function signature handleAppProtocolUrl(url) only
accepts a single url parameter; update each call site that invokes
handleAppProtocolUrl(...) (including the calls currently passing two arguments)
to pass only the url argument, removing the unused mainWindow parameter so the
call matches the handleAppProtocolUrl function signature.
🧹 Nitpick comments (2)
packages/bruno-electron/src/index.js (2)

139-147: Same null reference risk in second-instance handler.

While less likely, mainWindow could theoretically be null here too. Add a guard for defensive coding.

Proposed fix
   // Handle second instance attempts - focus primary window on all platforms
   app.on('second-instance', (event, commandLine) => {
-    focusMainWindow();
     // Extract and handle protocol URL from the second instance attempt
     const url = getAppProtocolUrlFromArgv(commandLine);
-    if (url) {
-      handleAppProtocolUrl(url, mainWindow);
+    if (mainWindow) {
+      focusMainWindow();
+      if (url) {
+        handleAppProtocolUrl(url, mainWindow);
+      }
+    } else if (url) {
+      appProtocolUrl = url;
     }
   });

349-352: Redundant lock release.

Electron automatically releases the single instance lock when the app terminates. This explicit release is harmless but unnecessary.

If you prefer explicit cleanup for clarity, that's fine. Otherwise, these lines can be removed.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a906678 and 9d12bb9.

📒 Files selected for processing (1)
  • packages/bruno-electron/src/index.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-electron/src/index.js
🧠 Learnings (2)
📚 Learning: 2026-01-09T18:25:23.407Z
Learnt from: kanakkholwal
Repo: usebruno/bruno PR: 6767
File: packages/bruno-app/src/components/ResponseExample/index.js:221-226
Timestamp: 2026-01-09T18:25:23.407Z
Learning: Bruno is an Electron-only application, so `window.ipcRenderer` will always be available and does not require existence checks.

Applied to files:

  • packages/bruno-electron/src/index.js
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.

Applied to files:

  • packages/bruno-electron/src/index.js
🧬 Code graph analysis (1)
packages/bruno-electron/src/index.js (3)
packages/bruno-electron/src/utils/deeplink.js (2)
  • getAppProtocolUrlFromArgv (4-6)
  • handleAppProtocolUrl (9-15)
packages/bruno-electron/src/utils/arch.js (1)
  • isMac (2-2)
packages/bruno-electron/src/ipc/network/index.js (4)
  • url (173-173)
  • url (187-187)
  • url (201-201)
  • url (215-215)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: CLI Tests
  • GitHub Check: Unit Tests
  • GitHub Check: Playwright E2E Tests
🔇 Additional comments (1)
packages/bruno-electron/src/index.js (1)

94-102: LGTM!

Clean helper extraction. Properly handles the minimized state before focusing.

Copy link
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.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @packages/bruno-electron/src/index.js:
- Around line 121-125: The current isLinux block swallows errors from the
execSync('xdg-mime default bruno.desktop x-scheme-handler/bruno') call; update
the catch to log a warning with the caught error so protocol handler
registration failures are visible (e.g., in the catch for the execSync
invocation inside the isLinux conditional, call the app or console logger to
emit a warning message that includes err and context like "Failed to register
x-scheme-handler/bruno").
🧹 Nitpick comments (1)
packages/bruno-electron/src/index.js (1)

127-151: LGTM!

Protocol handling logic correctly covers both macOS open-url events and second-instance scenarios. Storing the URL when the window isn't ready prevents URL loss during app startup.

Minor: Consider prefixing the unused event parameter with underscore on line 144 (_event) to signal intent.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9d12bb9 and ee7239f.

📒 Files selected for processing (1)
  • packages/bruno-electron/src/index.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-electron/src/index.js
🧠 Learnings (3)
📚 Learning: 2026-01-09T18:25:23.407Z
Learnt from: kanakkholwal
Repo: usebruno/bruno PR: 6767
File: packages/bruno-app/src/components/ResponseExample/index.js:221-226
Timestamp: 2026-01-09T18:25:23.407Z
Learning: Bruno is an Electron-only application, so `window.ipcRenderer` will always be available and does not require existence checks.

Applied to files:

  • packages/bruno-electron/src/index.js
📚 Learning: 2025-12-02T07:24:50.311Z
Learnt from: bijin-bruno
Repo: usebruno/bruno PR: 6263
File: packages/bruno-requests/src/auth/oauth2-helper.ts:249-249
Timestamp: 2025-12-02T07:24:50.311Z
Learning: In OAuth2 Basic Auth headers for Bruno, clientSecret is optional and can be omitted. When constructing the Authorization header in `packages/bruno-requests/src/auth/oauth2-helper.ts`, use `clientSecret || ''` instead of `clientSecret!` to properly handle cases where only clientId is provided, per community requests.

Applied to files:

  • packages/bruno-electron/src/index.js
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.

Applied to files:

  • packages/bruno-electron/src/index.js
🧬 Code graph analysis (1)
packages/bruno-electron/src/index.js (5)
packages/bruno-electron/src/utils/deeplink.js (2)
  • getAppProtocolUrlFromArgv (4-6)
  • handleAppProtocolUrl (9-15)
packages/bruno-electron/src/utils/arch.js (1)
  • isMac (2-2)
packages/bruno-electron/src/ipc/network/interpolate-vars.js (1)
  • url (153-153)
packages/bruno-electron/src/utils/oauth2.js (4)
  • url (155-155)
  • url (382-382)
  • url (510-510)
  • url (645-645)
packages/bruno-electron/src/ipc/network/prepare-request.js (1)
  • url (312-312)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Unit Tests
  • GitHub Check: CLI Tests
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Linux
🔇 Additional comments (4)
packages/bruno-electron/src/index.js (4)

93-101: LGTM!

Clean extraction of the window focus/restore logic. Used appropriately in both the open-url and second-instance handlers.


106-119: LGTM!

Single instance lock logic is correctly implemented. The environment variable toggle provides a useful escape hatch for debugging or specific deployment scenarios.


352-356: Verify: Early lock release may cause race conditions.

Releasing the single instance lock in before-quit (before windows close and the process exits) creates a window where another instance could acquire the lock and start initializing while this instance is still shutting down.

Electron automatically releases the lock when the process terminates. Is there a specific scenario requiring this early release? If not, consider removing these lines to avoid potential race conditions.


295-299: LGTM!

Call signature correctly matches the handleAppProtocolUrl function definition which only requires the URL parameter.

Comment on lines +121 to +125
if (isLinux) {
try {
execSync('xdg-mime default bruno.desktop x-scheme-handler/bruno');
} catch (err) {}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Silent error swallowing hinders debugging.

The empty catch block discards errors from the xdg-mime command. While the app can continue without this registration, logging a warning would help diagnose protocol handler issues on Linux systems.

Proposed fix
   if (isLinux) {
     try {
       execSync('xdg-mime default bruno.desktop x-scheme-handler/bruno');
-    } catch (err) {}
+    } catch (err) {
+      console.warn('Failed to register xdg-mime handler for bruno://', err.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
if (isLinux) {
try {
execSync('xdg-mime default bruno.desktop x-scheme-handler/bruno');
} catch (err) {}
}
if (isLinux) {
try {
execSync('xdg-mime default bruno.desktop x-scheme-handler/bruno');
} catch (err) {
console.warn('Failed to register xdg-mime handler for bruno://', err.message);
}
}
🤖 Prompt for AI Agents
In @packages/bruno-electron/src/index.js around lines 121 - 125, The current
isLinux block swallows errors from the execSync('xdg-mime default bruno.desktop
x-scheme-handler/bruno') call; update the catch to log a warning with the caught
error so protocol handler registration failures are visible (e.g., in the catch
for the execSync invocation inside the isLinux conditional, call the app or
console logger to emit a warning message that includes err and context like
"Failed to register x-scheme-handler/bruno").

bijin-bruno
bijin-bruno previously approved these changes Jan 13, 2026
@bijin-bruno bijin-bruno merged commit 3e92c44 into usebruno:main Jan 21, 2026
14 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 27, 2026
6 tasks
FraCata00 pushed a commit to FraCata00/bruno that referenced this pull request Feb 9, 2026
…_handling

feat: `bruno app instances` handling updates
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