Repository navigation
fix: cache system proxy - #6990
Conversation
- 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]>
WalkthroughThis 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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: 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 forfetchProxy.
It’s a new abstraction with a non-obviousforceRefreshbehavior; 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.
| const handleRefresh = () => { | ||
| fetchProxy(true); | ||
| }; |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
should we add an option to clear the cached proxy? @lohit-bruno
- 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]>
jira
Description
bruno-cli: fetch system proxy once before request loop and store in optionsbruno-electron: initialize system proxy cache at app startupgetSystemProxy()calls with cached valuesContribution Checklist:
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
Performance Improvements
✏️ Tip: You can customize this high-level summary in your review settings.