fix(desktop): restore snapped windows at display edges#23110
Problem
A snapped window saved at x=1921, width=1280 on a secondary display ending at x=3200 is rejected because its right edge exceeds the display by 1 DIP. Startup falls back to the default window on the primary display.
Change
Allow 1 DIP of overflow at each display edge when validating saved window bounds. Preserve the original saved bounds object, which the restore path uses to enable persistence. Larger overflow and disconnected-display fallback remain unchanged.
Scope and approval
Fixes #21563 GitCafe: https://git.cafe/pingdotgg/t3code/issues/21563 Triaged bug via the automated issue flow; GitCafe mirror https://git.cafe/pingdotgg/t3code/pulls/23110. The maintainer accepted the edge-overflow failure in #21563; this fixes that accepted case only. The maximized-window report #4841, small-display sizing in #13125, and the separate in-process recentering report remain outside this fix.
Verification
Before/after unit-runtime transcript: existing window tests pass 20/20 on main; adding the reporter's exact regression fails with 20 passing; the fix passes 32/32 across window and settings tests. The final test also asserts object identity, rejects 2 DIP and substantial overflow, and retains the existing disconnected-display case.
Commands: node_modules/.bin/vp test run apps/desktop/src/window/DesktopWindow.test.ts apps/desktop/src/settings/DesktopAppSettings.test.ts; scoped vp lint on both changed files; tsc --noEmit -p apps/desktop/tsconfig.json. All passed. Current main was merged before the final tests. Two independent isolated code reviews (GPT-6.1 Sol and Claude Opus 5.5) and two sequential proof audits (Sol, then Opus) found no blockers; both proof auditors independently reran focused tests.
Unverified desktop: this Linux VM has no displays. Evidence is mocked-Electron unit runtime, not native window coordinates or screenshots. Actual snapping and restoration on macOS/Windows/Linux multi-display setups require a native check. Web/mobile, provider adapters, remote connections, contracts and RPC surfaces are unaffected.
Implementation and red tests: Claude Opus 5.5 through the Claude harness; integration and proof: GPT-6.1 Sol through the Codex harness in T3 Code; independent reviews and proof audits: both models.
Checks
Failing2
- Build and TypecheckGitHubFailed
- CheckGitHubFailed
Added 3 commits
Approvability
Verdict: Approved at 8505e5b
Macroscope's review found this PR approvable — This narrowly scoped desktop bug fix adjusts saved-window validation to tolerate a one-DIP rounding discrepancy at display edges while preserving fallback behavior for larger overflow. The accompanying unit test covers the regression and boundary cases.
You can add or adjust custom eligibility rules. Learn more.
Thread transfer impact
⚠️ The latest CI run did not produce a thread transfer result for 8505e5b.
This comment will update automatically after the next completed run.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Team
- Run ID:
31fe3797-cd6d-4e17-861a-dd37eea56c77
📥 Commits
Reviewing files that changed from the base of the PR and between 86fa9e0a0c4e3cdadff15d25583978ec80a80834 and 8505e5b40fbc2f20830622f8f2f6d565f00a8435.
📒 Files selected for processing: 2
apps/desktop/src/window/DesktopWindow.test.tsapps/desktop/src/window/DesktopWindow.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
📝 Walkthrough
windowFitsWithinDisplaynow allows persisted bounds to extend up to 1 DIP beyond display edges. Tests cover bounds within that tolerance, larger overflow, and fully off-screen bounds.Changes: Window Bounds
Layer / File(s) Summary Tolerant display bounds
apps/desktop/src/window/DesktopWindow.ts,apps/desktop/src/window/DesktopWindow.test.tsThe display-fit check allows a 1-DIP edge tolerance. Tests verify that one-pixel overflow is accepted and larger overflow or fully off-screen bounds are rejected. Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers:
maria-rcks
Merge Risk: ⚪ Minimal · up to 8505e
No actionable merge-blocking risk was found in the changed window restoration behavior.
Pre-merge checks: Passed 4
Check name Status Explanation Title check Passed The title clearly and concisely describes the main change: restoring snapped desktop windows at display edges. 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 description follows the required template. It explains the problem, change, scope, approval context, focused verification, test results, unverified native-display checks, and tool usage. It clearl… Full details: Description check
Explanation
The description follows the required template. It explains the problem, change, scope, approval context, focused verification, test results, unverified native-display checks, and tool usage. It clearly identifies out-of-scope behavior.
✨ Finishing Touches: 💡 1
-
🛠️ Fix failing CI checks: 💡
- Commit to this branch
- Create a new PR
📝 Generate docstrings
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
- Commit to this branch
- 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.