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): keep maximized state when saved bounds exceed the display by tneemo · Pull Request #58442 · anomalyco/opencode

Conversation

@tneemo

@tneemo tneemo commented Oct 23, 2026 •
edited by opencode-agent Bot
Loading

Uh oh!

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

Copy link
Copy Markdown

Issue for this PR

Closes #58247

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When the window is maximized, manageWindowState keeps saving the normal (unmaximized) bounds. On a display shorter than the 1280x800 default (e.g. 1388x781), those bounds can be a few pixels taller than the display (y: 34, height: 783). On the next launch resolveWindowState rejects them and returns the default-size fallback, but that fallback dropped isMaximized/isFullScreen and always put the window on the primary display at 0,0. So the window never reopened maximized, and on a multi-monitor setup it also jumped to the primary display.

The fallback now:

  • keeps isMaximized and isFullScreen from the saved state
  • picks the display the saved bounds belong to via displays.matching() (the same screen.getDisplayMatching() used when the state is recorded), falling back to the primary display only if that display is no longer connected
  • places the window at that display's global origin (display.x/display.y) instead of 0,0, so monitors to the right, to the left (negative x) or a primary display not at the origin all work
  • caps the default size to that display, so 1280x800 no longer comes back larger than a small screen

Related: #57088 changes how edge-snapped bounds are accepted. It doesn't cover this case, but both PRs touch resolveWindowState.

How did you verify your code works?

  • Added regression tests:
    • the exact state from the issue on a single 1388x781 display (maximized and fullscreen)
    • the size cap
    • overflowing bounds on a second monitor at x: 1920 and at x: -1440, which stay on that monitor with the maximized flag kept
    • falling back to a primary display that does not start at 0,0
  • The new tests fail on dev and pass with the fix. The test displays use an Electron-like matching helper (largest overlap, else primary).
  • cd packages/desktop && bun run test: 136 pass, 1 skip, 0 fail.
  • bun run check (lint + typecheck across the monorepo) passes.
  • oxlint shows no new warnings.

Screenshots / recordings

N/A, not a UI change.

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
@tneemo
fix(desktop): keep maximized state when saved bounds exceed the display
213874d
Copilot AI balanced review requested due to automatic review settings October 23, 2026 12:12
@tneemo
tneemo requested review from Brendonovich and Hona as code owners October 23, 2026 12:12
Copilot AI reviewed Oct 23, 2026

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Sorry, something went wrong.

Uh oh!

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

All reactions
opencode-agent[bot]
opencode-agent Bot reviewed Oct 23, 2026
View reviewed changes

@opencode-agent opencode-agent 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 fix works. I ran the #58247 reproduction against the real window-state.ts on a single 1388×781 display. On the base, the window never reopens maximized and the oversized bounds are saved again on every launch. With this PR, it reopens maximized from the second launch on, and the saved state settles to bounds that fit the display, so the loop ends. The new tests fail on the base and pass with the change. I didn't run the Electron app itself.

Public API: unchanged. This is internal desktop main-process logic, and the window-state file format is the same.

One small point, inline: the fallback to the primary display can't trigger in practice, so it, sameBounds and its test can be dropped.

Related: #56970

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread packages/desktop/src/main/windows/window-state.ts

const matched = displays.matching({ x: state.x, y: state.y, width: state.width, height: state.height })

const display = displays.all().find((bounds) => sameBounds(bounds, matched)) ?? displays.primary()

@opencode-agent opencode-agent Bot Oct 23, 2026

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.

In the real app, displays.matching is screen.getDisplayMatching(bounds).bounds (windows/index.ts, windows/early.ts). It always returns one of the currently connected displays, so the displays.all().find(sameBounds) ?? displays.primary() fallback never triggers. Using const display = displays.matching({ ... }) directly would keep the fix smaller. You could then drop sameBounds and the "matched display is no longer current" test, which only checks a matching stub that returns a display that isn't connected.

Sorry, something went wrong.

Uh oh!

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

All reactions
@LeON-Nie-code LeON-Nie-code mentioned this pull request Oct 27, 2026
fix(desktop): restore edge-snapped window bounds #57088
Closed
3 tasks done
@github-actions

github-actions Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot closed this Nov 23, 2026
@github-actions github-actions Bot added the automated-pr-cleanup label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@opencode-agent opencode-agent[bot] opencode-agent[bot] left review comments
@Hona Hona Awaiting requested review from Hona
@Brendonovich Brendonovich Awaiting requested review from Brendonovich

Uh oh!

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

Assignees

No one assigned

Labels

automated-pr-cleanup

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

desktop: maximized state lost when saved bounds exceed the display

Uh oh!

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

2 participants

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