Skip to content

fix(desktop): a window snapped to a display edge reopens where it was - #21590

Closed
fixfon wants to merge 1 commit into
pingdotgg:mainfrom
fixfon:fix/21563-snapped-window-bounds
Closed

fixfon wants to merge 1 commit into
pingdotgg:mainfrom
fixfon:fix/21563-snapped-window-bounds

Conversation

@fixfon

@fixfon fixfon commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A window snapped to the edge of a display reopens at the default size on the primary display after a relaunch (#21563, first part). The snapped window is persisted up to 1px past the display edge, e.g. {"x":1921,"y":30,"width":1280,"height":945} on a display spanning x 1920 to 3200, so the right edge is 3201. windowFitsWithinDisplay requires the saved bounds to lie entirely within one display, so resolveInitialMainWindowBounds finds no display that fits and falls back to the default size.

Change

windowFitsWithinDisplay in apps/desktop/src/window/DesktopWindow.ts accepts bounds that overhang a display by at most 1px on any edge. Nothing else changes. The second part of the issue (a window re-created in the same process moving to x=640) is not covered, since it was not accepted.

Scope and approval

Triaged and accepted by the maintainer, first part only: #21563 (comment)

Verification

New unit test in apps/desktop/src/window/DesktopWindow.test.ts, restores bounds that overhang a snapped display edge by at most 1px. With a primary 1920x1080 display and a secondary display at x=1920, it checks that the issue's snapped bounds are restored, and that bounds 2px past the edge or entirely off every display still fall back to the default. Without the change it fails (expected { width: 1100, height: 780 } to deeply equal { x: 1921, y: 30, width: 1280, … }); with it the whole file passes (21 tests after the rebase onto main; #22557 pruned the file's other tests). Format, lint and apps/desktop typecheck are clean.

I did not check this in the app: it needs a second physical display, so the unit test is the only evidence.

Part of #21563

Claude Sonnet 5.5 (xhigh) via T3 Code.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Oct 19, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 1b018b2

Macroscope's review found this PR approvable — This is a narrowly scoped desktop bug fix that restores saved window positions when snapping produces a documented 1px display-edge overhang, while retaining fallback behavior for windows farther off-screen. It includes focused regression tests and does not affect product defaults, schemas, deployment, or static-analysis settings.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5f194be5-edbe-405c-87af-9996d78f9025
📥 Commits

Reviewing files that changed from the base of the PR and between 1b018b2 and 9999a85.

📒 Files selected for processing: 2
  • apps/desktop/src/window/DesktopWindow.test.ts
  • apps/desktop/src/window/DesktopWindow.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The saved-window-bounds check now allows a one-pixel overhang beyond a display edge. Tests cover one-pixel and two-pixel overhangs, plus an off-display position.

Changes: Window Bounds Restoration

Layer / File(s) Summary
Bounds tolerance and restoration test
apps/desktop/src/window/DesktopWindow.ts, apps/desktop/src/window/DesktopWindow.test.ts
windowFitsWithinDisplay allows saved bounds to extend up to one pixel beyond a display edge. Tests verify that a one-pixel overhang is restored, while a two-pixel overhang or off-display position uses the default window bounds.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to 9999a

No actionable merge-blocking risk is established by the reviewed change.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: restoring a desktop window to its saved position after it was snapped to a display edge.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The pull request description includes all required sections. It clearly states the problem, expected behavior, implementation, approved scope, focused test coverage, observed results, unverified app-l…
Full details: Description check

Explanation

The pull request description includes all required sections. It clearly states the problem, expected behavior, implementation, approved scope, focused test coverage, observed results, unverified app-level behavior, and agent details. It also identifies the excluded second issue.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

A snapped window is persisted up to 1px past the display edge, and windowFitsWithinDisplay required strict containment, so resolveInitialMainWindowBounds discarded the saved bounds and fell back to the default size on the primary display. Allow a 1px overhang on each edge.

Part of pingdotgg#21563
@maria-rcks

Copy link
Copy Markdown
Collaborator

Note

Written by gpt-6.1-sol on behalf of Maria

This PR does not meet the verification requirement.

The diff changes restored desktop window placement, but the body explicitly says the app was not checked and provides only a unit-test result, with no before/after screenshots of the snapped-window restoration.

Attach before/after captures from a desktop run with the reported display layout, show the snapped window surviving relaunch, and retain the focused one-pixel and off-screen regression results before requesting reconsideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants