@@ -24,11 +24,7 @@ import {
2424import LegacyThreadSidebar from "./LegacySidebar" ;
2525import ThreadSidebar from "./Sidebar" ;
2626import { SettingsSidebarNav } from "./settings/SettingsSidebarNav" ;
27- import {
28- SidebarChromeHeader ,
29- SidebarChromeIntrinsicWidthProbe ,
30- SidebarWindowControlsContext ,
31- } from "./sidebar/SidebarChrome" ;
27+ import { SidebarChromeHeader , SidebarChromeIntrinsicWidthProbe } from "./sidebar/SidebarChrome" ;
3228import {
3329 resolveSidebarStageFocusRingOffsetClass ,
3430 useSidebarStageBackdropVariant ,
@@ -167,7 +163,10 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
167163 // and a clamped drag ends with an unchanged width, which skips the re-render
168164 // that would otherwise refresh a render-time snapshot.
169165 const viewportWidth = useSyncExternalStore ( subscribeToViewportWidth , readViewportWidth ) ;
170- const sidebarMaximumWidth = resolveThreadSidebarMaximumWidth ( viewportWidth , sidebarMinimumWidth ) ;
166+ const sidebarMaximumWidth = Math . max (
167+ sidebarMinimumWidth ,
168+ resolveThreadSidebarMaximumWidth ( viewportWidth ) ,
169+ ) ;
171170 const renderedSidebarWidth = Math . min (
172171 sidebarMaximumWidth ,
173172 Math . max ( sidebarMinimumWidth , sidebarWidth ) ,
@@ -178,7 +177,9 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
178177 } catch ( error ) {
179178 console . error ( "Could not clear persisted thread sidebar width." , error ) ;
180179 }
181- setSidebarWidth ( resolveInitialThreadSidebarWidth ( null , viewportWidth , sidebarMinimumWidth ) ) ;
180+ setSidebarWidth (
181+ Math . max ( sidebarMinimumWidth , resolveInitialThreadSidebarWidth ( null , viewportWidth ) ) ,
182+ ) ;
182183 } ;
183184 const [ isWindowFullscreen , setIsWindowFullscreen ] = useState ( ( ) => {
184185 const getWindowFullscreenState = window . desktopBridge ?. getWindowFullscreenState ;
@@ -243,35 +244,39 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
243244 < SidebarChromeIntrinsicWidthProbe onWidthChange = { updateSidebarMinimumWidth } />
244245 ) : null }
245246 < ProjectProjectionRetention />
246- < SidebarWindowControlsContext value = { isMacosDesktop && ! isWindowFullscreen } >
247- < Sidebar
248- side = "left"
249- collapsible = "offcanvas"
250- data-app-sidebar = ""
251- className = "border-r border-sidebar-border bg-sidebar text-sidebar-foreground"
252- resizable = { {
253- maxWidth : sidebarMaximumWidth ,
254- minWidth : sidebarMinimumWidth ,
255- shouldAcceptWidth : ( { currentWidth, nextWidth, wrapper } ) =>
256- nextWidth <= currentWidth ||
257- wrapper . clientWidth - nextWidth >= THREAD_MAIN_CONTENT_MIN_WIDTH ,
258- storageKey : THREAD_SIDEBAR_WIDTH_STORAGE_KEY ,
259- onResize : setSidebarWidth ,
260- } }
261- >
262- { isOnSettings ? (
263- < >
264- < SidebarChromeHeader isElectron = { isElectron } />
265- < SettingsSidebarNav pathname = { pathname } />
266- </ >
267- ) : legacySidebarEnabled ? (
268- < LegacyThreadSidebar />
269- ) : (
270- < ThreadSidebar />
271- ) }
272- < SidebarRail onDoubleClick = { resetSidebarWidth } />
273- </ Sidebar >
274- </ SidebarWindowControlsContext >
247+ { /* The drawer is portaled, so its header inset must be set on the popup. */ }
248+ < Sidebar
249+ side = "left"
250+ collapsible = "offcanvas"
251+ data-app-sidebar = ""
252+ className = { cn (
253+ "border-r border-sidebar-border bg-sidebar text-sidebar-foreground" ,
254+ isMacosDesktop &&
255+ ! isWindowFullscreen &&
256+ "[--sidebar-drawer-controls-inset:var(--desktop-window-controls-inset,90px)]" ,
257+ ) }
258+ resizable = { {
259+ maxWidth : sidebarMaximumWidth ,
260+ minWidth : sidebarMinimumWidth ,
261+ shouldAcceptWidth : ( { currentWidth, nextWidth, wrapper } ) =>
262+ nextWidth <= currentWidth ||
263+ wrapper . clientWidth - nextWidth >= THREAD_MAIN_CONTENT_MIN_WIDTH ,
264+ storageKey : THREAD_SIDEBAR_WIDTH_STORAGE_KEY ,
265+ onResize : setSidebarWidth ,
266+ } }
267+ >
268+ { isOnSettings ? (
269+ < >
270+ < SidebarChromeHeader isElectron = { isElectron } />
271+ < SettingsSidebarNav pathname = { pathname } />
272+ </ >
273+ ) : legacySidebarEnabled ? (
274+ < LegacyThreadSidebar />
275+ ) : (
276+ < ThreadSidebar />
277+ ) }
278+ < SidebarRail onDoubleClick = { resetSidebarWidth } />
279+ </ Sidebar >
275280 { children }
276281 < SidebarControl />
277282 </ SidebarProvider >
0 commit comments