@devries-cameron20 / t3code Mirror · read-only / commits / 9c7750dc16
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 02:00 UTC

fix(desktop): a window saved 1px past a display edge reopens where it was (#28638)

Abhishek B R committed Nov 9, 2026 at 19:58 UTC 9c7750dc16acc3ccae5f26cb94182954f69182ec
2 files changed +32 -4
apps/desktop/src/window/DesktopWindow.test.ts
+24
@@ -479,6 +479,30 @@ describe("DesktopWindow", () => {
479 );
480 });
481
482 + it("restores a window saved 1px past a display edge, and nothing further out", () => {
483 + const displays = [
484 + { x: 0, y: 0, width: 1920, height: 1280 },
485 + { x: 1920, y: 0, width: 1280, height: 1920 },
486 + ];
487 + const snappedBounds = { x: 1921, y: 30, width: 1280, height: 945 };
488 +
489 + assert.strictEqual(
490 + DesktopWindow.resolveInitialMainWindowBounds(snappedBounds, displays),
491 + snappedBounds,
492 + );
493 + for (const bounds of [
494 + { x: 1922, y: 30, width: 1280, height: 945 },
495 + { x: 1918, y: 30, width: 1280, height: 945 },
496 + { x: 1921, y: -2, width: 1279, height: 945 },
497 + { x: 1920, y: 976, width: 1280, height: 946 },
498 + ]) {
499 + assert.deepEqual(
500 + DesktopWindow.resolveInitialMainWindowBounds(bounds, displays),
501 + DesktopAppSettings.DEFAULT_MAIN_WINDOW_SIZE,
502 + );
503 + }
504 + });
505 +
506 it("rejects renderer navigations whose origin only serializes as null", () => {
507 for (const applicationUrl of ["t3code://app/", "t3code-dev://app/"]) {
508 assert.isTrue(
apps/desktop/src/window/DesktopWindow.ts
+8 -4
@@ -148,15 +148,19 @@ function getInitialWindowBackgroundColor(shouldUseDarkColors: boolean): string {
148
149 type DisplayBounds = Pick<Electron.Rectangle, "x" | "y" | "width" | "height">;
150
151 +// A window snapped to a display edge can be reported 1px past that edge.
152 +const SAVED_BOUNDS_EDGE_TOLERANCE_PX = 1;
153 +
154 function windowFitsWithinDisplay(
155 windowBounds: DesktopAppSettings.DesktopWindowBounds,
156 displayBounds: DisplayBounds,
157 ): boolean {
158 + const tolerance = SAVED_BOUNDS_EDGE_TOLERANCE_PX;
159 return (
156 - windowBounds.x >= displayBounds.x &&
157 - windowBounds.y >= displayBounds.y &&
158 - windowBounds.x + windowBounds.width <= displayBounds.x + displayBounds.width &&
159 - windowBounds.y + windowBounds.height <= displayBounds.y + displayBounds.height
160 + windowBounds.x >= displayBounds.x - tolerance &&
161 + windowBounds.y >= displayBounds.y - tolerance &&
162 + windowBounds.x + windowBounds.width <= displayBounds.x + displayBounds.width + tolerance &&
163 + windowBounds.y + windowBounds.height <= displayBounds.y + displayBounds.height + tolerance
164 );
165 }
166