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, 23:15 UTC
fix(desktop): allow half-screen tiling on scaled displays (#19232)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Tanner Polley committed
Oct 19, 2026 at 22:15 UTC
9497ab5db3ee6f60c0e6de10062119c27cb05f13
10 files changed
+49
-33
apps/desktop/src/settings/DesktopAppSettings.test.ts
+10
-3
@@ -283,7 +283,7 @@ describe("DesktopSettings", () => {
283
Effect.gen(function* () {
284
const settings = yield* DesktopAppSettings.DesktopAppSettings;
285
yield* writeSettingsPatch({
286
- mainWindowBounds: { x: 10.5, y: 20, width: 839, height: 620 },
286
+ mainWindowBounds: { x: 10, y: 20, width: 599, height: 620 },
287
mainWindowMaximized: true,
288
serverExposureMode: "network-accessible",
289
});
@@ -342,17 +342,24 @@ describe("DesktopSettings", () => {
342
const fileSystem = yield* FileSystem.FileSystem;
343
const settings = yield* DesktopAppSettings.DesktopAppSettings;
344
345
- yield* settings.setMainWindowBounds({ x: -1200, y: 40, width: 1440, height: 960 }, true);
345
+ yield* settings.setMainWindowBounds({ x: -1200, y: 40, width: 600, height: 620 }, true);
346
yield* settings.setServerExposureMode("network-accessible");
347
348
const persisted = yield* decodeDesktopSettingsPatch(
349
yield* fileSystem.readFileString(environment.desktopSettingsPath),
350
);
351
assert.deepEqual(persisted, {
352
- mainWindowBounds: { x: -1200, y: 40, width: 1440, height: 960 },
352
+ mainWindowBounds: { x: -1200, y: 40, width: 600, height: 620 },
353
mainWindowMaximized: true,
354
serverExposureMode: "network-accessible",
355
} satisfies typeof DesktopSettingsPatch.Type);
356
+
357
+ const restored = yield* Effect.gen(function* () {
358
+ const freshSettings = yield* DesktopAppSettings.DesktopAppSettings;
359
+ return yield* freshSettings.load;
360
+ }).pipe(Effect.provide(DesktopAppSettings.layer));
361
+ assert.deepEqual(restored.mainWindowBounds, persisted.mainWindowBounds);
362
+ assert.isTrue(restored.mainWindowMaximized);
363
}),
364
),
365
);
apps/desktop/src/settings/DesktopAppSettings.ts
+2
-2
@@ -48,8 +48,8 @@ export interface DesktopSettingsChange {
48
}
49
50
const DEFAULT_TAILSCALE_SERVE_PORT = 443;
51
-const MIN_MAIN_WINDOW_SIZE = {
52
- width: 840,
51
+export const MIN_MAIN_WINDOW_SIZE = {
52
+ width: 600,
53
height: 620,
54
} as const;
55
export const DesktopWindowBoundsSchema = Schema.Struct({
apps/desktop/src/window/DesktopWindow.test.ts
+8
-6
@@ -660,6 +660,8 @@ describe("DesktopWindow", () => {
660
assert.equal(yield* Ref.get(createCount), 1);
661
assert.equal(createdWindowOptions[0]?.width, 1100);
662
assert.equal(createdWindowOptions[0]?.height, 780);
663
+ assert.equal(createdWindowOptions[0]?.minWidth, 600);
664
+ assert.equal(createdWindowOptions[0]?.minHeight, 620);
665
assert.isUndefined(createdWindowOptions[0]?.x);
666
assert.isUndefined(createdWindowOptions[0]?.y);
667
assert.isTrue(createdWindowOptions[0]?.disableAutoHideCursor);
@@ -918,7 +920,7 @@ describe("DesktopWindow", () => {
920
createdWindowOptions,
921
desktopSettings: {
922
...DesktopAppSettings.DEFAULT_DESKTOP_SETTINGS,
921
- mainWindowBounds: { x: 120, y: 80, width: 1320, height: 880 },
923
+ mainWindowBounds: { x: 120, y: 80, width: 768, height: 780 },
924
},
925
});
926
@@ -926,8 +928,8 @@ describe("DesktopWindow", () => {
928
const desktopWindow = yield* DesktopWindow.DesktopWindow;
929
yield* desktopWindow.handleBackendReady(new URL("http://127.0.0.1:3773"));
930
929
- assert.equal(createdWindowOptions[0]?.width, 1320);
930
- assert.equal(createdWindowOptions[0]?.height, 880);
931
+ assert.equal(createdWindowOptions[0]?.width, 768);
932
+ assert.equal(createdWindowOptions[0]?.height, 780);
933
assert.equal(createdWindowOptions[0]?.x, 120);
934
assert.equal(createdWindowOptions[0]?.y, 80);
935
}).pipe(Effect.provide(layer));
@@ -1152,14 +1154,14 @@ describe("DesktopWindow", () => {
1154
move();
1155
yield* TestClock.adjust(250);
1156
1155
- fakeWindow.getBounds.mockReturnValue({ x: 160, y: 100, width: 1360, height: 900 });
1157
+ fakeWindow.getBounds.mockReturnValue({ x: 160, y: 100, width: 664, height: 780 });
1158
resize();
1159
yield* TestClock.adjust(499);
1160
assert.deepEqual(mainWindowBoundsUpdates, []);
1161
1162
yield* TestClock.adjust(1);
1163
yield* Effect.promise(() => Promise.resolve());
1162
- assert.deepEqual(mainWindowBoundsUpdates, [{ x: 160, y: 100, width: 1360, height: 900 }]);
1164
+ assert.deepEqual(mainWindowBoundsUpdates, [{ x: 160, y: 100, width: 664, height: 780 }]);
1165
}).pipe(Effect.provide(layer));
1166
}),
1167
);
@@ -1241,7 +1243,7 @@ describe("DesktopWindow", () => {
1243
it.effect("does not persist bounds that fail the domain schema", () =>
1244
Effect.gen(function* () {
1245
const fakeWindow = makeFakeBrowserWindow();
1244
- fakeWindow.getBounds.mockReturnValue({ x: 100.4, y: 80.2, width: 839.4, height: 619.4 });
1246
+ fakeWindow.getBounds.mockReturnValue({ x: 100, y: 80, width: 599, height: 620 });
1247
const createCount = yield* Ref.make(0);
1248
const mainWindow = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());
1249
const mainWindowBoundsUpdates: DesktopAppSettings.DesktopWindowBounds[] = [];
apps/desktop/src/window/DesktopWindow.ts
+2
-2
@@ -383,8 +383,8 @@ export const make = Effect.gen(function* () {
383
if (yield* Ref.get(desktopState.quitting)) return Option.none();
384
const window = yield* electronWindow.create({
385
...initialBounds,
386
- minWidth: 840,
387
- minHeight: 620,
386
+ minWidth: DesktopAppSettings.MIN_MAIN_WINDOW_SIZE.width,
387
+ minHeight: DesktopAppSettings.MIN_MAIN_WINDOW_SIZE.height,
388
show: false,
389
autoHideMenuBar: true,
390
...(environment.platform === "darwin" ? { disableAutoHideCursor: true } : {}),
apps/web/src/components/AppSidebarLayout.tsx
+1
@@ -321,6 +321,7 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
321
className="h-dvh! min-h-0!"
322
data-panel-animations={routePanelAnimationsActive ? "true" : "false"}
323
defaultOpen
324
+ mobileBreakpoint={sidebarMinimumWidth + THREAD_MAIN_CONTENT_MIN_WIDTH}
325
style={sidebarProviderStyle}
326
>
327
<SidebarBrandWidthProbe onWidthChange={setBrandWidth} />
apps/web/src/components/LegacySidebar.tsx
+1
-2
@@ -204,7 +204,6 @@ import {
204
import { sortThreads } from "../lib/threadSort";
205
import { SidebarChromeFooter, SidebarChromeHeader } from "./sidebar/SidebarChrome";
206
import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
207
-import { useIsMobile } from "~/hooks/useMediaQuery";
207
import { CommandDialogTrigger } from "./ui/command";
208
import { useClientSettings, updateClientSettings } from "~/hooks/useSettings";
209
import { primaryServerKeybindingsAtom } from "../state/server";
@@ -420,7 +419,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
419
environmentId: thread.environmentId,
420
threadId: thread.id,
421
});
423
- const isMobile = useIsMobile();
422
+ const { isMobile } = useSidebar();
423
const discoveredPorts = useThreadDiscoveredPorts({
424
environmentId: thread.environmentId,
425
threadId: thread.id,
apps/web/src/components/sidebar/SidebarChrome.tsx
+12
-9
@@ -36,6 +36,7 @@ export const SidebarChromeHeader = memo(function SidebarChromeHeader({
36
}: {
37
isElectron: boolean;
38
}) {
39
+ const { isMobile } = useSidebar();
40
const stageLabel = useEnvironmentStageLabel();
41
const environmentIdentificationMode = useEnvironmentIdentificationMode();
42
const backdropVariant = resolveSidebarStageBackdropVariant(
@@ -55,15 +56,17 @@ export const SidebarChromeHeader = memo(function SidebarChromeHeader({
56
)}
57
>
58
{backdropVariant ? <SidebarStageBackdrop variant={backdropVariant} /> : null}
58
- <div className="relative top-[calc(var(--workspace-controls-top)-env(safe-area-inset-top))] z-10 ml-[calc(var(--workspace-controls-left)+1px-env(safe-area-inset-left))] flex shrink-0 items-center md:hidden">
59
- <SidebarTrigger
60
- variant={backdropVariant ? "media-navigation" : "ghost"}
61
- className="relative top-auto translate-y-0"
62
- aria-label="Toggle main sidebar"
63
- />
64
- </div>
59
+ {isMobile ? (
60
+ <div className="relative top-[calc(var(--workspace-controls-top)-env(safe-area-inset-top))] z-10 ml-[calc(var(--workspace-controls-left)+1px-env(safe-area-inset-left))] flex shrink-0 items-center">
61
+ <SidebarTrigger
62
+ variant={backdropVariant ? "media-navigation" : "ghost"}
63
+ className="relative top-auto translate-y-0"
64
+ aria-label="Toggle main sidebar"
65
+ />
66
+ </div>
67
+ ) : null}
68
<div className="relative z-10 flex h-8 min-w-0 flex-1 flex-wrap content-start items-center gap-x-2 overflow-hidden py-0.5">
66
- <SidebarBrand onBackdrop={backdropVariant !== null} />
69
+ {!isMobile ? <SidebarBrand onBackdrop={backdropVariant !== null} /> : null}
70
{pillLabel ? (
71
<div className="ml-1 flex h-7 items-center">
72
<Badge data-environment-identification="pill" size="sm" variant="secondary">
@@ -105,7 +108,7 @@ function SidebarBrand({ onBackdrop }: { onBackdrop: boolean }) {
108
<Link
109
aria-label="Go to threads"
110
className={cn(
108
- "relative z-10 ml-[var(--workspace-titlebar-content-left)] hidden h-7 w-fit min-w-0 shrink-0 items-center overflow-hidden rounded-md outline-hidden ring-ring focus-visible:ring-2 focus-visible:ring-inset md:flex",
111
+ "relative z-10 ml-[var(--workspace-titlebar-content-left)] flex h-7 w-fit min-w-0 shrink-0 items-center overflow-hidden rounded-md outline-hidden ring-ring focus-visible:ring-2 focus-visible:ring-inset",
112
onBackdrop ? "text-white" : "text-foreground",
113
)}
114
to="/"
apps/web/src/components/ui/sidebar.tsx
+12
-4
@@ -17,7 +17,7 @@ import {
17
} from "~/components/ui/sheet";
18
import { Tooltip, TooltipPopup, TooltipTrigger } from "~/components/ui/tooltip";
19
import { useResizeDrag } from "~/hooks/useResizeDrag";
20
-import { useIsMobile } from "~/hooks/useMediaQuery";
20
+import { useMediaQuery } from "~/hooks/useMediaQuery";
21
import { getLocalStorageItem, setLocalStorageItem } from "~/hooks/useLocalStorage";
22
import { resolveSidebarState, type ResponsiveSidebarState } from "./sidebarState";
23
import * as Schema from "effect/Schema";
@@ -96,6 +96,7 @@ function useSidebarVisibility() {
96
97
function SidebarProvider({
98
defaultOpen = true,
99
+ mobileBreakpoint,
100
open: openProp,
101
onOpenChange: setOpenProp,
102
className,
@@ -104,11 +105,17 @@ function SidebarProvider({
105
...props
106
}: React.ComponentProps<"div"> & {
107
defaultOpen?: boolean;
108
+ mobileBreakpoint?: number;
109
open?: boolean;
110
onOpenChange?: (open: boolean) => void;
111
}) {
110
- const isMobile = useIsMobile();
112
+ const isMobile = useMediaQuery(
113
+ mobileBreakpoint === undefined ? "max-md" : { max: mobileBreakpoint },
114
+ );
115
const [openMobile, setOpenMobile] = React.useState(false);
116
+ if (!isMobile && openMobile) {
117
+ setOpenMobile(false);
118
+ }
119
const [mobileSheetMounted, setMobileSheetMounted] = React.useState(false);
120
const setMobileSheetElement = (element: HTMLDivElement | null) => {
121
setMobileSheetMounted(element !== null);
@@ -158,6 +165,7 @@ function SidebarProvider({
165
SIDEBAR_TITLEBAR_CONTROL_SIZE,
166
className,
167
)}
168
+ data-sidebar-mobile={isMobile}
169
data-sidebar-state={state}
170
data-slot="sidebar-wrapper"
171
style={
@@ -298,7 +306,7 @@ function Sidebar({
306
<SidebarInstanceContext value={instanceContextValue}>
307
<div
308
ref={desktopSidebarRef}
301
- className="group peer hidden text-sidebar-foreground md:block"
309
+ className="group peer text-sidebar-foreground"
310
data-collapsible={state === "collapsed" ? collapsible : ""}
311
data-side={side}
312
data-slot="sidebar"
@@ -319,7 +327,7 @@ function Sidebar({
327
/>
328
<div
329
className={cn(
322
- "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) md:flex",
330
+ "fixed inset-y-0 z-10 flex h-svh w-(--sidebar-width)",
331
"[[data-panel-animations=true]_&]:transition-[left,right,width] [[data-panel-animations=true]_&]:[transition-duration:var(--panel-animation-duration)] [[data-panel-animations=true]_&]:ease-out",
332
side === "left"
333
? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
apps/web/src/hooks/useMediaQuery.ts
-4
@@ -77,7 +77,3 @@ export function useMediaQuery(query: BreakpointQuery | MediaQueryInput | (string
77
78
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
79
}
80
-
81
-export function useIsMobile(): boolean {
82
- return useMediaQuery("max-md");
83
-}
apps/web/src/workspaceTitlebar.ts
+1
-1
@@ -1,2 +1,2 @@
1
export const COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS =
2
- "[[data-sidebar-state=collapsed]_&]:pl-[var(--workspace-titlebar-content-left)] max-md:[[data-sidebar-state=expanded]_&]:pl-[var(--workspace-titlebar-content-left)]";
2
+ "[[data-sidebar-state=collapsed]_&]:pl-[var(--workspace-titlebar-content-left)] [[data-sidebar-mobile=true][data-sidebar-state=expanded]_&]:pl-[var(--workspace-titlebar-content-left)]";