GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@Hona

@Hona Hona commented Nov 21, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Screenshots

Diagrams of real measured bounds, not screen captures: the grey box is the display's work area, the blue box the window's frame as Windows reported it (GetWindowRect, plus whether it was maximized or minimized), before the window was closed with its close button and after the app started again. One display only.

State Before After
Maximized, then minimized, then closed Before: minimized After: minimized
Started again Before: comes back restored, not maximized After: comes back maximized
Snapped right, then closed, then started again Before: comes back snapped After: comes back snapped

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.

Issue for this PR

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

Type of change

  • Bug fix

What does this PR do?

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.

How did you verify your code works?

  • 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.
  • On Windows, one display: maximized-then-minimized and snapped windows closed and started again, before and after (diagrams above).
  • Not tested: a second display and Win+Shift+Arrow moves.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #56970

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Hona
fix(desktop): reopen snapped, moved and minimized windows where they …
2d47007
…were on Windows
opencodejr[bot]
opencodejr Bot reviewed Nov 21, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Hona
Merge remote-tracking branch 'origin/dev' into window-placement
04acab3
opencodejr[bot]
opencodejr Bot reviewed Nov 21, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Hona
Hona merged commit 3aff591 into dev Nov 21, 2026
12 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Hona
Hona deleted the window-placement branch November 21, 2026 10:28
@neriousy neriousy mentioned this pull request Nov 23, 2026
desktop: remember window position and size across restarts #56970
Closed
@BrewTestBot BrewTestBot mentioned this pull request Nov 23, 2026
opencode 2.4.0 Homebrew/homebrew-core#327368
Merged
@amrkmn amrkmn mentioned this pull request Nov 23, 2026
opencode 2.4.0 amrkmn/homebrew-tap#1251
Closed
1 task
@github-actions github-actions Bot mentioned this pull request Nov 23, 2026
feat: opencode release v2.4.0 sprisa/opencode-server#95
Merged
@scottames-github-bot scottames-github-bot Bot mentioned this pull request Nov 27, 2026
chore(deps): update ⬆️ mise-packages scottames/dots#1181
Merged
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Hona
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.