Skip to content

feat: remember last window size & position on desktop#98

Merged
krazyjakee merged 1 commit into
masterfrom
feat/remember-window-geometry
Jun 9, 2026
Merged

feat: remember last window size & position on desktop#98
krazyjakee merged 1 commit into
masterfrom
feat/remember-window-geometry

Conversation

@krazyjakee

Copy link
Copy Markdown
Contributor

What

Desktop builds now remember the window's last size, position, and maximized state across launches. Previously every launch opened at a fixed default size and forgot where the window had been placed or resized.

How

  • Added the window_manager package — there was no window-management library in the project before.
  • New lib/shared/utils/desktop_window.dart with setupDesktopWindow():
    • On launch, restores saved geometry via waitUntilReadyToShow (centers on first run, no flash at the default size).
    • Installs a WindowListener that persists geometry on move/resize/(un)maximize, debounced 400ms so a drag doesn't write to Hive on every frame.
    • While maximized, only the flag is stored and the last normal bounds are preserved, so un-maximize restores the prior size/position.
    • No-op on web/mobile (the OS owns geometry there).
  • Persisted to a device-global window-state Hive box, opened in setupHive.
  • Wired setupDesktopWindow() into main() after Hive is ready and before runApp(), guarded with try/catch like the rest of startup so a window-manager failure can't block launch.
  • Regenerated native plugin registrants (Linux/macOS/Windows) for the new plugin.

Notes for reviewers

  • Works on Windows/Linux/macOS without native runner changes. On macOS, geometry persistence relies on the App Sandbox already being dropped (fix(updates): enable macOS self-update by dropping the App Sandbox #97), which it is.
  • Verification: flutter analyze passes clean on the changed files. I could not run the app live — the project pins Flutter beta, whose Dart VM requires macOS 14 while my machine is on macOS 13; I validated with the installed stable 3.38.1 toolchain (pub get + analyze). A live launch/resize test on a desktop target is the one thing left to confirm by hand.

🤖 Generated with Claude Code

Desktop builds previously launched at a fixed default size every time and
forgot where the user had placed or sized the window. Add window geometry
persistence so the app restores its last size, position, and maximized state
across launches.

- Add the window_manager package (no prior window-management lib existed).
- New lib/shared/utils/desktop_window.dart: setupDesktopWindow() restores
  saved geometry before the first frame (centers on first run) and installs a
  debounced WindowListener that persists size/position/maximized on
  move/resize/(un)maximize. While maximized it keeps the last normal bounds so
  un-maximize restores correctly. No-op on web/mobile.
- Persist to a device-global `window-state` Hive box opened in setupHive.
- Wire setupDesktopWindow() into main() after Hive is ready and before
  runApp(), guarded so a window-manager failure can't block startup.
- Regenerated native plugin registrants (window_manager registration).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@krazyjakee krazyjakee merged commit 9264dc2 into master Jun 9, 2026
1 check passed
@krazyjakee krazyjakee deleted the feat/remember-window-geometry branch June 9, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant