fix: lag when moving Electron window (issue #5203)#6771
fix: lag when moving Electron window (issue #5203)#6771bijin-bruno merged 1 commit intousebruno:mainfrom
Conversation
WalkthroughThe change introduces debouncing to window bounds persistence by wrapping the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 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
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: 0
🧹 Nitpick comments (2)
packages/bruno-electron/src/index.js (2)
224-233: Excellent debounce implementation that addresses the lag issue.The trailing debounce pattern is correctly implemented and will eliminate the performance problem of saving on every move event. The 100ms delay is well-chosen for this use case.
♻️ Optional: Add maximized check inside timeout for edge case
For additional robustness, consider checking the maximized state inside the timeout callback as well, in case the window is maximized during the 100ms delay:
const handleBoundsChange = () => { - if (!mainWindow.isMaximized()) { - if (boundsTimeout) { - clearTimeout(boundsTimeout); - } - boundsTimeout = setTimeout(() => { + if (boundsTimeout) { + clearTimeout(boundsTimeout); + } + boundsTimeout = setTimeout(() => { + if (!mainWindow.isMaximized()) { saveBounds(mainWindow); - }, 100); - } + } + }, 100); };This ensures bounds are only saved if the window is still not maximized when the timeout fires.
224-233: Consider cleanup on window lifecycle events.While not critical, clearing the timeout on window close and maximize events would be more defensive.
♻️ Optional: Add timeout cleanup
On window close (around line 258):
mainWindow.on('close', (e) => { e.preventDefault(); + if (boundsTimeout) { + clearTimeout(boundsTimeout); + } terminalManager.cleanup(mainWindow.webContents); ipcMain.emit('main:start-quit-flow'); });On maximize (around line 239):
mainWindow.on('maximize', () => { + if (boundsTimeout) { + clearTimeout(boundsTimeout); + } saveMaximized(true); mainWindow.webContents.send('main:window-maximized'); });
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 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()notfunc ()
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 (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/index.js
🧬 Code graph analysis (1)
packages/bruno-electron/src/index.js (1)
packages/bruno-js/src/sandbox/quickjs/shims/bruno-request.js (1)
setTimeout(115-117)
⏰ 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 - macOS
- GitHub Check: SSL Tests - Linux
- GitHub Check: Unit Tests
- GitHub Check: SSL Tests - Windows
- GitHub Check: CLI Tests
- GitHub Check: Playwright E2E Tests
🔇 Additional comments (1)
packages/bruno-electron/src/index.js (1)
223-223: LGTM! Good scope for the timeout variable.The variable is appropriately scoped to the window lifecycle within the 'ready' callback.
Description
This PR fixes the lag when moving the Electron window reported in issue #5203.
The problem was caused by continuously saving the window position on every move event, which led to performance issues.
To solve this, I added a debounced timeout so the window position is saved only after movement stops, instead of on every frame.
This significantly improves window movement smoothness and removes the lag.
Contribution 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
✏️ Tip: You can customize this high-level summary in your review settings.