Skip to content

fix: cache system proxy - #6990

Merged
bijin-bruno merged 1 commit into
usebruno:mainfrom
lohit-bruno:system_proxy_updates
Jan 30, 2026
Merged

bijin-bruno merged 1 commit into
usebruno:mainfrom
lohit-bruno:system_proxy_updates

Conversation

@lohit-bruno

@lohit-bruno lohit-bruno commented Jan 30, 2026 •

Copy link
Copy Markdown
Collaborator

jira

Description

  • bruno-cli: fetch system proxy once before request loop and store in options
  • bruno-electron: initialize system proxy cache at app startup
  • Add refresh button in preferences to manually update cached system proxy
  • Replace per-request getSystemProxy() calls with cached values

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

    • Added a manual refresh button in System Proxy settings to allow users to update proxy configuration without restarting the application.
  • Performance Improvements

    • System proxy configuration is now cached at application startup, reducing unnecessary proxy lookups during network requests.

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

- bruno-cli: fetch system proxy once before request loop and store in options
- bruno-electron: initialize system proxy cache at app startup
- Add refresh button in preferences to manually update cached system proxy
- Replace per-request getSystemProxy() calls with cached values

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jan 30, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

This PR introduces system proxy caching across the Bruno application stack. Instead of fetching system proxy settings repeatedly at runtime, the proxy is now cached during Electron app initialization and reused throughout the application. The changes include a new caching module, updated IPC handlers to serve cached values, CLI integration to use cached proxy, and UI enhancements to allow manual proxy refresh.

Changes

Cohort / File(s) Summary
System Proxy Caching Module
packages/bruno-electron/src/store/system-proxy.js
New module providing initializeSystemProxy(), refreshSystemProxy(), and getCachedSystemProxy() functions to manage in-memory system proxy caching with error handling and fallback defaults.
Electron App Initialization
packages/bruno-electron/src/index.js
Initializes system proxy cache early during app readiness via initializeSystemProxy() call, running asynchronously before menu and window setup.
IPC Layer
packages/bruno-electron/src/ipc/preferences.js, packages/bruno-electron/src/ipc/network/cert-utils.js
Updated IPC handlers to serve cached system proxy via getCachedSystemProxy() instead of runtime fetches. Adds new renderer:refresh-system-proxy IPC channel for explicit refresh triggers.
Redux Store
packages/bruno-app/src/providers/ReduxStore/slices/app.js
Introduces refreshSystemProxy thunk action that triggers IPC renderer:refresh-system-proxy to manually refresh the cached proxy from the renderer process.
UI Component
packages/bruno-app/src/components/Preferences/ProxySettings/SystemProxy/index.js
Adds manual Refresh control with icon to System Proxy settings, implementing fetchProxy abstraction that delegates between initial load and forced refresh paths.
CLI Integration
packages/bruno-cli/src/commands/run.js, packages/bruno-cli/src/runner/run-single-request.js
CLI fetches system proxy once at startup and caches in options.cachedSystemProxy; run-single-request uses cached value instead of runtime getSystemProxy() calls for all proxy decisions.

Sequence Diagram(s)

sequenceDiagram
    participant App as Electron App
    participant Cache as System Proxy Cache
    participant IPC as IPC Handler
    participant Renderer as Renderer (UI)
    
    App->>Cache: initializeSystemProxy()
    activate Cache
    Cache->>Cache: Fetch & store proxy config
    deactivate Cache
    
    Renderer->>IPC: renderer:get-system-proxy-variables
    activate IPC
    IPC->>Cache: getCachedSystemProxy()
    Cache-->>IPC: Return cached proxy
    IPC-->>Renderer: Proxy data (cached)
    deactivate IPC
    
    Note over Renderer: User clicks Refresh button
    Renderer->>IPC: renderer:refresh-system-proxy
    activate IPC
    IPC->>Cache: refreshSystemProxy()
    activate Cache
    Cache->>Cache: Re-fetch & update cache
    deactivate Cache
    IPC-->>Renderer: Updated proxy data
    deactivate IPC
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • PR #6423: Modifies CLI's run-single-request proxy and OAuth2 logic with TLS/client-cert enhancements, shares overlapping changes in proxy handling paths.

Suggested labels

size/XL

Suggested reviewers

  • helloanoop
  • naman-bruno
  • bijin-bruno

Poem

🔄 Proxy data cached at dawn,
No more runtime fetches drawn,
Refresh when needed, fresh and fleet,
System proxy caching—complete! ⚡

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title 'feat: cache system proxy' accurately reflects the main objective of the changeset—implementing system proxy caching across multiple packages.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@lohit-bruno lohit-bruno changed the title feat: cache system proxy fix: cache system proxy Jan 30, 2026

@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: 1

🤖 Fix all issues with AI agents
In
`@packages/bruno-app/src/components/Preferences/ProxySettings/SystemProxy/index.js`:
- Around line 28-30: Replace the non-accessible <span onClick> that calls the
one-line wrapper handleRefresh with an actual <button> and inline the call to
fetchProxy(true) directly in the button's onClick; remove the unnecessary
handleRefresh function. Do the same for any other one-line wrapper handlers in
this component (the span-based onClick handlers around the Refresh/force-refresh
UI): convert them to <button> elements and call fetchProxy(...) inline instead
of delegating through trivial wrapper functions.
🧹 Nitpick comments (3)
packages/bruno-app/src/providers/ReduxStore/slices/app.js (1)

251-261: Add a brief JSDoc for the new refresh thunk.
Keeps the new abstraction documented alongside other IPC thunks.

As per coding guidelines, Add JSDoc comments to abstractions for additional details.

packages/bruno-electron/src/store/system-proxy.js (1)

5-19: Add JSDoc for the cache lifecycle helpers.
Helps document the intended behavior for initialization and error fallback.

As per coding guidelines, Add JSDoc comments to abstractions for additional details.

packages/bruno-app/src/components/Preferences/ProxySettings/SystemProxy/index.js (1)

14-22: Add JSDoc for fetchProxy.
It’s a new abstraction with a non-obvious forceRefresh behavior; a short JSDoc will help.

Suggested change
+  /**
+   * Fetches system proxy values, optionally forcing a refresh.
+   * `@param` {boolean} forceRefresh
+   * `@returns` {void}
+   */
   const fetchProxy = (forceRefresh = false) => {

As per coding guidelines Add JSDoc comments to abstractions for additional details.

Comment on lines +28 to +30
const handleRefresh = () => {
fetchProxy(true);
};

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.

⚠️ Potential issue | 🟠 Major

Use a button for Refresh and inline the one‑liner handler.
<span onClick> isn’t keyboard accessible, and handleRefresh is just a pass‑through.

Suggested change
-  const handleRefresh = () => {
-    fetchProxy(true);
-  };
...
-        <span
-          className="text-link cursor-pointer hover:underline default-collection-location-browse flex flex-row items-center"
-          onClick={handleRefresh}
-        >
+        <button
+          type="button"
+          className="text-link cursor-pointer hover:underline default-collection-location-browse flex flex-row items-center"
+          onClick={() => fetchProxy(true)}
+        >
           <IconRefresh size={14} strokeWidth={1.5} className="mr-1" />
           Refresh
-        </span>
+        </button>

As per coding guidelines Avoid single-line abstractions where all that's being done is increasing the call stack with one additional function.

Also applies to: 89-95

🤖 Prompt for AI Agents
In
`@packages/bruno-app/src/components/Preferences/ProxySettings/SystemProxy/index.js`
around lines 28 - 30, Replace the non-accessible <span onClick> that calls the
one-line wrapper handleRefresh with an actual <button> and inline the call to
fetchProxy(true) directly in the button's onClick; remove the unnecessary
handleRefresh function. Do the same for any other one-line wrapper handlers in
this component (the span-based onClick handlers around the Refresh/force-refresh
UI): convert them to <button> elements and call fetchProxy(...) inline instead
of delegating through trivial wrapper functions.


const refreshSystemProxy = async () => {
try {
cachedSystemProxy = await getSystemProxy();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should we add an option to clear the cached proxy? @lohit-bruno

@bijin-bruno
bijin-bruno merged commit 3112380 into usebruno:main Jan 30, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jul 8, 2026
6 tasks
maxenceleblanc pushed a commit to maxenceleblanc/curly_cats2 that referenced this pull request Jul 20, 2026
- bruno-cli: fetch system proxy once before request loop and store in options
- bruno-electron: initialize system proxy cache at app startup
- Add refresh button in preferences to manually update cached system proxy
- Replace per-request getSystemProxy() calls with cached values

Co-authored-by: Claude Opus 4.5 <[email protected]>
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.

3 participants