@devries-cameron20 / t3code-1 / commits / da11342e03
Fork 0

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

Fix live sidebar resize limits and defer Alchemy runtime context (#4655)

Julius Marminge committed Jul 27, 2026 at 18:07 UTC da11342e03dbf2bf46058d66b9c4f4eab8047a5a
1 file changed +21 -2
apps/web/src/components/AppSidebarLayout.tsx
+21 -2
@@ -1,6 +1,12 @@
1 import { useAtomValue } from "@effect/atom-react";
2 import * as Schema from "effect/Schema";
3 -import { useEffect, useState, type CSSProperties, type ReactNode } from "react";
3 +import {
4 + useEffect,
5 + useState,
6 + useSyncExternalStore,
7 + type CSSProperties,
8 + type ReactNode,
9 +} from "react";
10 import { useLocation, useNavigate } from "@tanstack/react-router";
11
12 import { isElectron } from "../env";
@@ -31,6 +37,15 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
37
38 const MACOS_TRAFFIC_LIGHTS_LEFT_INSET = "90px";
39
40 +function subscribeToViewportWidth(onChange: () => void): () => void {
41 + window.addEventListener("resize", onChange);
42 + return () => window.removeEventListener("resize", onChange);
43 +}
44 +
45 +function readViewportWidth(): number {
46 + return window.innerWidth;
47 +}
48 +
49 function readInitialThreadSidebarWidth(): number {
50 try {
51 return resolveInitialThreadSidebarWidth(
@@ -109,7 +124,11 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
124 const useSidebarV2Theme = useSidebarV2 || isOnSettings;
125 const isMacosDesktop = isElectron && isMacPlatform(navigator.platform);
126 const [sidebarWidth, setSidebarWidth] = useState(readInitialThreadSidebarWidth);
112 - const sidebarMaximumWidth = resolveThreadSidebarMaximumWidth(window.innerWidth);
127 + // Subscribed rather than read once: the clamp must track live window size,
128 + // and a clamped drag ends with an unchanged width, which skips the re-render
129 + // that would otherwise refresh a render-time snapshot.
130 + const viewportWidth = useSyncExternalStore(subscribeToViewportWidth, readViewportWidth);
131 + const sidebarMaximumWidth = resolveThreadSidebarMaximumWidth(viewportWidth);
132 const [isWindowFullscreen, setIsWindowFullscreen] = useState(() => {
133 const getWindowFullscreenState = window.desktopBridge?.getWindowFullscreenState;
134 return isMacosDesktop && typeof getWindowFullscreenState === "function"