@@ -312,7 +312,7 @@ function registerAppShellCommands(router: AnyRouter, shellElement: Element): ()
312312 } ;
313313}
314314
315- function SidebarControl ( ) {
315+ function SidebarControl ( { showSidebar } : { readonly showSidebar : boolean } ) {
316316 const router = useRouter ( ) ;
317317 const usagePageOpen = useLocation ( { select : ( location ) => location . pathname === "/usage" } ) ;
318318 const keybindings = useAtomValue ( primaryServerKeybindingsAtom ) ;
@@ -326,6 +326,8 @@ function SidebarControl() {
326326
327327 // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- window keydown listener that toggles the sidebar on its shortcut
328328 useEffect ( ( ) => {
329+ // A hidden sidebar would still save the toggle, so the shortcut does nothing without one.
330+ if ( ! showSidebar ) return ;
329331 const onKeyDown = ( event : KeyboardEvent ) => {
330332 if ( event . defaultPrevented ) return ;
331333 if (
@@ -362,7 +364,7 @@ function SidebarControl() {
362364 window . removeEventListener ( "keydown" , onKeyDown , true ) ;
363365 unsubscribe ?.( ) ;
364366 } ;
365- } , [ keybindings , toggleSidebar , usagePageOpen ] ) ;
367+ } , [ keybindings , showSidebar , toggleSidebar , usagePageOpen ] ) ;
366368
367369 // The control lives as long as the shell, so it carries the shell's commands. Created
368370 // once so re-renders never re-register them.
@@ -380,28 +382,36 @@ function SidebarControl() {
380382 ) }
381383 data-sidebar-control = ""
382384 >
383- < Tooltip >
384- < TooltipTrigger
385- render = {
386- < SidebarTrigger
387- variant = { isSidebarVisible && stageBackdropVariant ? "media-navigation" : "ghost" }
388- className = { cn (
389- "pointer-events-auto" ,
390- isSidebarVisible && stageBackdropVariant && "relative top-auto translate-y-0" ,
391- ) }
392- aria-label = "Toggle main sidebar"
393- />
394- }
395- />
396- < TooltipPopup side = "bottom" >
397- Toggle main sidebar{ shortcutLabel ? ` (${ shortcutLabel } )` : "" }
398- </ TooltipPopup >
399- </ Tooltip >
385+ { showSidebar ? (
386+ < Tooltip >
387+ < TooltipTrigger
388+ render = {
389+ < SidebarTrigger
390+ variant = { isSidebarVisible && stageBackdropVariant ? "media-navigation" : "ghost" }
391+ className = { cn (
392+ "pointer-events-auto" ,
393+ isSidebarVisible && stageBackdropVariant && "relative top-auto translate-y-0" ,
394+ ) }
395+ aria-label = "Toggle main sidebar"
396+ />
397+ }
398+ />
399+ < TooltipPopup side = "bottom" >
400+ Toggle main sidebar{ shortcutLabel ? ` (${ shortcutLabel } )` : "" }
401+ </ TooltipPopup >
402+ </ Tooltip >
403+ ) : null }
400404 </ div >
401405 ) ;
402406}
403407
404- export function AppSidebarLayout ( { children } : { children : ReactNode } ) {
408+ export function AppSidebarLayout ( {
409+ children,
410+ showSidebar = true ,
411+ } : {
412+ children : ReactNode ;
413+ showSidebar ?: boolean ;
414+ } ) {
405415 const sidebarArea = workspaceAreaProps ( "sidebar" , 0 , "Threads" ) ;
406416 const [ sidebarRouteReveal ] = useState < SidebarRouteReveal > ( ( ) => ( {
407417 observedKey : null ,
@@ -450,31 +460,35 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
450460 storageKey = "chat_thread_sidebar_open"
451461 style = { sidebarProviderStyle }
452462 >
453- < SidebarBrandWidthProbe isElectron = { isElectron } onWidthChange = { setBrandWidth } />
454- < Sidebar
455- side = "left"
456- collapsible = "offcanvas"
457- data-app-sidebar = ""
458- { ...sidebarArea }
459- role = "navigation"
460- aria-label = "Threads"
461- resizable = { {
462- maxWidth : sidebarMaximumWidth ,
463- minWidth : sidebarMinimumWidth ,
464- shouldAcceptWidth : ( { currentWidth, nextWidth, wrapper } ) =>
465- nextWidth <= currentWidth ||
466- wrapper . clientWidth - nextWidth >= THREAD_MAIN_CONTENT_MIN_WIDTH ,
467- storageKey : THREAD_SIDEBAR_WIDTH_STORAGE_KEY ,
468- onResize : setSidebarWidth ,
469- } }
470- style = { windowControlsInsetStyle }
471- >
472- < ThreadSidebar routeReveal = { sidebarRouteReveal } />
473- < SidebarRail onDoubleClick = { resetSidebarWidth } />
474- </ Sidebar >
463+ { showSidebar ? (
464+ < >
465+ < SidebarBrandWidthProbe isElectron = { isElectron } onWidthChange = { setBrandWidth } />
466+ < Sidebar
467+ side = "left"
468+ collapsible = "offcanvas"
469+ data-app-sidebar = ""
470+ { ...sidebarArea }
471+ role = "navigation"
472+ aria-label = "Threads"
473+ resizable = { {
474+ maxWidth : sidebarMaximumWidth ,
475+ minWidth : sidebarMinimumWidth ,
476+ shouldAcceptWidth : ( { currentWidth, nextWidth, wrapper } ) =>
477+ nextWidth <= currentWidth ||
478+ wrapper . clientWidth - nextWidth >= THREAD_MAIN_CONTENT_MIN_WIDTH ,
479+ storageKey : THREAD_SIDEBAR_WIDTH_STORAGE_KEY ,
480+ onResize : setSidebarWidth ,
481+ } }
482+ style = { windowControlsInsetStyle }
483+ >
484+ < ThreadSidebar routeReveal = { sidebarRouteReveal } />
485+ < SidebarRail onDoubleClick = { resetSidebarWidth } />
486+ </ Sidebar >
487+ </ >
488+ ) : null }
475489 { children }
476490 < BackgroundThreadAnnouncer />
477- < SidebarControl />
491+ < SidebarControl showSidebar = { showSidebar } />
478492 { isElectron ? < HistorySwipeNavigation /> : null }
479493 </ SidebarProvider >
480494 </ PanelAnimationSuppressionProvider >
0 commit comments