Skip to content

fix(desktop): preserve main window bounds#3851

Open
anirudhsama wants to merge 4 commits into
pingdotgg:mainfrom
anirudhsama:t3code/preserve-macos-window-size
Open

fix(desktop): preserve main window bounds#3851
anirudhsama wants to merge 4 commits into
pingdotgg:mainfrom
anirudhsama:t3code/preserve-macos-window-size

Conversation

@anirudhsama

@anirudhsama anirudhsama commented Jul 10, 2026

Copy link
Copy Markdown

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 780 default 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

  • 344 desktop tests passed
  • vp run typecheck
  • vp check
  • Regression coverage includes minimized Windows bounds and shutdown write flushing
  • Manually tested size and position restoration after a clean quit and relaunch on a physical macOS device

Checklist

  • This PR is small and focused
  • I explained what changed and why

Note

Persist and restore main window bounds across desktop app sessions

  • Adds mainWindowBounds to DesktopAppSettings, storing validated x/y/width/height with minimum size constraints (840×620). Defaults to null; invalid persisted values are discarded on load.
  • On startup, DesktopWindow restores persisted bounds if they fit within a connected display, otherwise falls back to the default size (1100×780).
  • Window move/resize events trigger debounced persistence (500ms). Maximized/minimized windows persist their normal bounds; fullscreen bounds are skipped.
  • flushMainWindowBounds is called during shutdown to ensure any pending bounds write completes before the app exits.
  • Behavioral Change: BrowserWindow is 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. setMainWindowBounds writes 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 flushMainWindowBounds flush 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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jul 10, 2026
@anirudhsama anirudhsama marked this pull request as ready for review July 10, 2026 09:44
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fab1e5be-20c8-4f71-a758-3f4290058cc1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ 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.

Comment thread apps/desktop/src/window/DesktopWindow.ts
Comment thread apps/desktop/src/window/DesktopWindow.ts
@macroscopeapp

macroscopeapp Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

Comment thread apps/desktop/src/window/DesktopWindow.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: window doesn't remember its place when reopened

1 participant