11import { ArrowLeftIcon , ChartNoAxesColumnIcon , SettingsIcon } from "lucide-react" ;
22import type { ReactNode } from "react" ;
3- import { memo , useCallback , useLayoutEffect , useRef } from "react" ;
3+ import { createContext , memo , use , useCallback , useLayoutEffect , useRef } from "react" ;
44import { Link , useCanGoBack , useLocation , useNavigate } from "@tanstack/react-router" ;
55
66import { useEnvironmentIdentificationMode } from "../../hooks/useSettings" ;
@@ -30,11 +30,15 @@ import { SidebarProviderUpdatePill } from "./SidebarProviderUpdatePill";
3030import { SidebarUpdateArchitectureWarning , SidebarUpdatePill } from "./SidebarUpdatePill" ;
3131import { PullRequestGlyph } from "~/components/pullRequest/pullRequestIcons" ;
3232
33+ // Sheet headers render through a portal, so they cannot inherit SidebarProvider's layout inset.
34+ export const SidebarWindowControlsContext = createContext ( false ) ;
35+
3336export const SidebarChromeHeader = memo ( function SidebarChromeHeader ( {
3437 isElectron,
3538} : {
3639 isElectron : boolean ;
3740} ) {
41+ const reserveWindowControls = use ( SidebarWindowControlsContext ) ;
3842 const stageLabel = useEnvironmentStageLabel ( ) ;
3943 const environmentIdentificationMode = useEnvironmentIdentificationMode ( ) ;
4044 const backdropVariant = resolveSidebarStageBackdropVariant (
@@ -49,8 +53,9 @@ export const SidebarChromeHeader = memo(function SidebarChromeHeader({
4953 return (
5054 < SidebarHeader
5155 className = { cn (
52- "@container/sidebar-header relative h-[var(--workspace-topbar-height)] shrink-0 flex-row items-center px-3 py-0 md:px -0" ,
56+ "@container/sidebar-header relative h-[var(--workspace-topbar-height)] shrink-0 flex-row items-center px-3 py-0 md:pl -0" ,
5357 isElectron && "drag-region" ,
58+ reserveWindowControls && "max-md:pl-[var(--desktop-window-controls-inset,90px)]" ,
5459 ) }
5560 >
5661 { backdropVariant ? < SidebarStageBackdrop variant = { backdropVariant } /> : null }
@@ -66,7 +71,7 @@ export const SidebarChromeHeader = memo(function SidebarChromeHeader({
6671 < div className = "flex h-7 min-w-0 flex-1 flex-wrap content-start items-center gap-x-2 gap-y-0 overflow-hidden" >
6772 < SidebarBrand onBackdrop = { backdropVariant !== null } />
6873 { pillLabel ? (
69- < div className = "ml-1 hidden h-7 shrink-0 items-center @[15rem]/sidebar-header:flex md:flex " >
74+ < div className = "ml-1 flex h-7 shrink-0 items-center" >
7075 < Badge
7176 className = "relative z-10 rounded-full px-1.5 text-muted-foreground"
7277 data-environment-identification = "pill"
@@ -119,13 +124,19 @@ export function SidebarChromeIntrinsicWidthProbe({
119124}
120125
121126function SidebarBrand ( { onBackdrop } : { onBackdrop : boolean } ) {
127+ const { isMobile, setOpenMobile } = useSidebar ( ) ;
128+ const closeMobileSidebar = useCallback ( ( ) => {
129+ if ( isMobile ) setOpenMobile ( false ) ;
130+ } , [ isMobile , setOpenMobile ] ) ;
131+
122132 return (
123133 < Link
124134 aria-label = "Go to threads"
125135 className = { cn (
126- "relative z-10 ml-[var(--workspace-titlebar-content-left)] hidden h-7 w-fit min-w-0 shrink items-center overflow-hidden rounded-md outline-hidden ring-ring focus-visible:ring-2 focus-visible:ring-inset md:flex [flex-basis:max-content]" ,
136+ "relative z-10 flex h-7 w-fit min-w-0 shrink items-center overflow-hidden rounded-md outline-hidden ring-ring focus-visible:ring-2 focus-visible:ring-inset md:ml-[var(--workspace-titlebar-content-left)] [flex-basis:max-content]" ,
127137 onBackdrop ? "text-white" : "text-foreground" ,
128138 ) }
139+ onClick = { closeMobileSidebar }
129140 to = "/"
130141 >
131142 < span className = "flex h-7 min-w-0 flex-wrap content-start gap-1 overflow-hidden text-sm font-medium tracking-tight" >
0 commit comments