@devries-cameron20 / t3code Mirror · read-only / commits / d405bd94ac
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 21, 09:45 UTC

fix(web): sidebar width recovers when the window widens after a narrow start (#29520)

Julius Marminge committed Nov 16, 2026 at 18:50 UTC d405bd94ac45ae94b602a9bdacea08b513771c01
3 files changed +37 -12
apps/web/src/components/AppSidebarLayout.tsx
+2 -3
@@ -118,11 +118,10 @@ function readInitialThreadSidebarWidth(): number {
118 try {
119 return resolveInitialThreadSidebarWidth(
120 getLocalStorageItem(THREAD_SIDEBAR_WIDTH_STORAGE_KEY, Schema.Finite),
121 - window.innerWidth,
121 );
122 } catch (error) {
123 console.error("Could not read persisted thread sidebar width.", error);
125 - return resolveInitialThreadSidebarWidth(null, window.innerWidth);
124 + return resolveInitialThreadSidebarWidth(null);
125 }
126 }
127
@@ -441,7 +440,7 @@ export function AppSidebarLayout({
440 } catch (error) {
441 console.error("Could not clear persisted thread sidebar width.", error);
442 }
444 - setSidebarWidth(resolveInitialThreadSidebarWidth(null, viewportWidth));
443 + setSidebarWidth(resolveInitialThreadSidebarWidth(null));
444 };
445 const isWindowFullscreen = useSyncExternalStore(
446 subscribeToWindowFullscreen,
apps/web/src/components/threadSidebarWidth.test.ts new
+31
@@ -0,0 +1,31 @@
1 +import { describe, expect, it } from "vite-plus/test";
2 +
3 +import {
4 + clampThreadSidebarWidth,
5 + resolveInitialThreadSidebarWidth,
6 + resolveThreadSidebarMaximumWidth,
7 + resolveThreadSidebarMinimumWidth,
8 +} from "./threadSidebarWidth";
9 +
10 +function renderedWidth(sidebarWidth: number, viewportWidth: number): number {
11 + const minimumWidth = resolveThreadSidebarMinimumWidth(0);
12 + return clampThreadSidebarWidth(
13 + sidebarWidth,
14 + minimumWidth,
15 + resolveThreadSidebarMaximumWidth(viewportWidth, minimumWidth),
16 + );
17 +}
18 +
19 +describe("thread sidebar width", () => {
20 + it("restores the stored width when the viewport widens after a narrow startup", () => {
21 + const sidebarWidth = resolveInitialThreadSidebarWidth(350);
22 + expect(renderedWidth(sidebarWidth, 840)).toBe(208);
23 + expect(renderedWidth(sidebarWidth, 1638)).toBe(350);
24 + });
25 +
26 + it("restores the default width when the viewport widens after a narrow startup", () => {
27 + const sidebarWidth = resolveInitialThreadSidebarWidth(null);
28 + expect(renderedWidth(sidebarWidth, 840)).toBe(208);
29 + expect(renderedWidth(sidebarWidth, 1638)).toBe(256);
30 + });
31 +});
apps/web/src/components/threadSidebarWidth.ts
+4 -9
@@ -22,13 +22,8 @@ export function clampThreadSidebarWidth(
22 return Math.min(maximumWidth, Math.max(minimumWidth, width));
23 }
24
25 -export function resolveInitialThreadSidebarWidth(
26 - storedWidth: number | null,
27 - viewportWidth: number,
28 -): number {
29 - const preferredWidth =
30 - storedWidth === null
31 - ? THREAD_SIDEBAR_DEFAULT_WIDTH
32 - : Math.max(THREAD_SIDEBAR_MIN_WIDTH, storedWidth);
33 - return Math.min(preferredWidth, resolveThreadSidebarMaximumWidth(viewportWidth));
25 +export function resolveInitialThreadSidebarWidth(storedWidth: number | null): number {
26 + return storedWidth === null
27 + ? THREAD_SIDEBAR_DEFAULT_WIDTH
28 + : Math.max(THREAD_SIDEBAR_MIN_WIDTH, storedWidth);
29 }