Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves window state management on desktop platforms by adding bounds validation and implementing delayed persistence to reduce redundant disk operations.
Key changes:
- Introduced window bounds clamping to prevent invalid or out-of-range dimensions
- Refactored window state persistence with delayed writes using a timer to debounce rapid window events
- Separated window state save/restore logic into dedicated methods
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/desktop/window_manager_helper/window_manager_helper.dart | Added bounds clamping logic and new save/restore methods for window state persistence |
| lib/desktop/window_manager_helper/_wm_helper_windows_impl.dart | Extracted save/restore logic from getBounds into separate methods |
| lib/desktop/window_manager_helper/_wm_helper_macos_impl.dart | Extracted save/restore logic and refactored display detection into a helper method |
| lib/desktop/init.dart | Implemented delayed window state persistence using a timer and removed direct window bounds management |
| integration_test/utils.dart | Renamed variable from window to windowManagerHelper for clarity |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fdennis
left a comment
There was a problem hiding this comment.
Tested on my Win 11. Worked very well for me and I tried various random scenarios and numbers for width, height, top, left.
| _saveWindowManagerPropertiesTimer?.cancel(); | ||
| _saveWindowManagerPropertiesTimer = Timer( | ||
| const Duration( | ||
| milliseconds: 500, // lower values result in invalid display properties |
There was a problem hiding this comment.
Do we need a timer here? Is its purpose to prevent writing/saving too frequently? Was this an issue in the old code?
There was a problem hiding this comment.
Exactly that. The timer prevents racing conditions when persisting the values.
Improve robustness against invalid or out-of-range window states and rapid window events
Fixes #2036