GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||
GeezerVison is showing github.com — fix(desktop): reopen snapped, moved and minimized windows where they were on Windows by Hona · Pull Request #65323 · anomalyco/opencode Conversation
|
| State | Before | After |
|---|---|---|
| Maximized, then minimized, then closed | ![]() |
![]() |
| Started again | ![]() |
![]() |
| Snapped right, then closed, then started again | ![]() |
![]() |
On this machine a snapped window already came back in place before the change: the taskbar is docked at the left, so the snapped frame's overhang still falls inside the display. On a default bottom taskbar the left snap's 7px overhang is what the 16px slack lets through. A maximized window moved to a second display needs a second display: not captured.
No linked issue. Ported from the native Rune desktop build (anomalyco/rune-desktop, crates/opencode-runtime/src/window/placement.rs and Rune's platform/win32/placement.rs).
Fixes three ways a window reopens in the wrong place on Windows:
| Before | After |
|---|---|
A window snapped to a display's edge (Win+Left, or dragged to the edge) reopens at the default size on the primary display. Windows counts the invisible resize borders in the window's bounds, so a left-half snap starts at x = -7 and fails the "fits on a display" check by a few pixels. |
Bounds may hang up to 16px past a display's edges and still count as fitting. |
| A maximized window moved to another display with Win+Shift+Arrow keeps the restored frame it had on the first display, because bounds are only read while the window is restored. On restore it is centred on the new display instead of where Windows put it. | While maximized, the saved frame comes from getNormalBounds(), the frame Windows keeps for a maximized window and moves with it. |
Closing a minimized window (from the taskbar, or at sign-out) saves it as not maximized, with its display taken from the -32000, -32000 frame Windows gives minimized windows. A maximized window then reopens restored. |
A minimized window's state isn't updated, so it reopens as it was shown before it was minimized. |
Each change applies only when process.platform === "win32"; macOS and Linux keep today's behaviour. manageWindowState now takes the subset of BrowserWindow it uses, so the test can drive it.
bun test src/main/windows/window-state.test.ts (11 pass): new cases for the snapped window (kept on win32, reset on linux), the maximized window's restore frame, and the minimized window, the last two through the real close and closed events and the state file written. On dev, the three Windows cases fail.bun run typecheck:tsc in packages/desktop, bun run lint:changed origin/dev clean.Added by the opencode bot (AI-generated).
Related: #56970
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Looks sound to me. I couldn't run the desktop app on Windows here, so I checked it with the unit tests and by reading the code. All 11 tests in window-state.test.ts pass with this change. Against the base window-state.ts, the three new win32 cases fail and the other 8 pass. typecheck:tsc is clean, and both callers (windows/index.ts and windows/early.ts) still type-check against ManagedWindow.
All three changes only take effect on win32. The early return for minimized windows skips the bad readings (not maximized, frame at -32000), getNormalBounds() while maximized fills in the restored frame while the saved display still comes from the maximized frame, and the 16px slack only loosens the "fits on a display" check. The new tests are small and clear. A live check on a two-display Windows machine (snap left, Win+Shift+Arrow while maximized, closing while minimized) would still be worth doing before release.
The public API is unchanged. The state file format is the same, and ManagedWindow is an internal type in the desktop package.
No blocking concerns.
Related: #56970
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The new commit merges dev and leaves this change exactly as it was: window-state.ts and its test are identical to what I reviewed before. I re-ran window-state.test.ts (11 pass) and typecheck:tsc (clean) on the new head. There are no new concerns, and the public API is unchanged.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.