fix(desktop): preserve main window bounds#3851
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 271e8bb. Configure here.
ApprovabilityVerdict: Needs human review This PR adds a new feature to preserve and restore window position/size across sessions. While well-implemented with proper validation and test coverage, it introduces new user-facing behavior and runtime capability (persisting state, display detection, shutdown hooks) that warrants human review. You can customize Macroscope's approvability policy. Learn more. |

What Changed
Persist the desktop main window position and size across launches.
Move and resize updates are debounced. Maximized windows save their normal bounds, and fullscreen bounds are ignored. Saved bounds are restored only when the complete rectangle fits within a currently connected display; otherwise, the app uses the existing
1100 x 780default size and lets Electron choose the position.Why
The desktop app currently creates every main window with fixed dimensions and no persisted position, so restarting resets the user's window layout.
Fixes #1829.
Verification
vp run typecheckvp checkChecklist
Note
Persist and restore main window bounds across desktop app sessions
mainWindowBoundstoDesktopAppSettings, storing validated x/y/width/height with minimum size constraints (840×620). Defaults tonull; invalid persisted values are discarded on load.DesktopWindowrestores persisted bounds if they fit within a connected display, otherwise falls back to the default size (1100×780).flushMainWindowBoundsis called during shutdown to ensure any pending bounds write completes before the app exits.BrowserWindowis now created with explicit size/position and minimum size constraints, changing the default window size for users without persisted bounds.Macroscope summarized b11feec.
Note
Low Risk
Localized desktop UX and settings persistence following existing write patterns; no auth, network, or data-model changes beyond optional window geometry in desktop settings.
Overview
The desktop app persists the main window position and size in desktop settings (
mainWindowBounds) and restores them on launch, instead of always opening at the fixed default size.Settings: New bounds field with schema validation (integer coords, minimum 840×620). Invalid on-disk values are cleared on load.
setMainWindowBoundswrites sparse settings like other desktop prefs.Window behavior: On create, saved bounds are applied only if the full rectangle fits a currently connected display; otherwise the app falls back to 1100×780 and lets Electron place the window. Move/resize updates are debounced (500ms); close and
flushMainWindowBoundsflush pending writes. Maximized/minimized paths persist normal bounds; fullscreen skips persistence. Shutdown now flushes bounds before completing quit.Tests cover restore logic, debouncing, edge cases, and mock service stubs for the new APIs.
Reviewed by Cursor Bugbot for commit b11feec. Bugbot is set up for automated code reviews on this repo. Configure here.