File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,10 +78,8 @@ export default function RootLayout({ children }: { children: React.ReactNode })
7878 // window yields a width >= MIN instead of a sub-minimum sliver.
7979 var defaultSidebarWidth = 248;
8080 try {
81- // Collapse is owned by the sidebar_collapsed cookie (the same
82- // source the server renders structure from) and must never depend
83- // on localStorage parsing succeeding. Read it first, then read the
84- // persisted width defensively in its own try.
81+ // Collapse comes from the cookie (independent of localStorage
82+ // parsing); the persisted width is read defensively below.
8583 var hasCookie = document.cookie.indexOf('sidebar_collapsed=') !== -1;
8684 var collapsed = document.cookie.indexOf('sidebar_collapsed=1') !== -1;
8785
Original file line number Diff line number Diff line change @@ -394,14 +394,18 @@ export const Sidebar = memo(function Sidebar({ initialCollapsed = false }: Sideb
394394 const toggleCollapsed = useSidebarStore ( ( state ) => state . toggleCollapsed )
395395 const isOnWorkflowPage = ! ! workflowId
396396
397- // The server renders from the `sidebar_collapsed` cookie (via `initialCollapsed`);
398- // the client store seeds from the same cookie, so both agree on the first paint.
399- // Until the store reports hydration we read the prop to guarantee that match,
400- // then the store takes over.
397+ /**
398+ * The server renders from the `sidebar_collapsed` cookie (via `initialCollapsed`)
399+ * and the client store seeds from the same cookie, so both agree on the first
400+ * paint. The prop is read until the store reports hydration to guarantee that
401+ * match, after which the store takes over.
402+ */
401403 const isCollapsed = hasHydrated ? storeIsCollapsed : initialCollapsed
402404
403- // Hydrate the persisted width before paint (collapse already came from the
404- // cookie). Pre-paint so any width-dependent layout settles in the same commit.
405+ /**
406+ * Hydrates the persisted width before paint (collapse already came from the
407+ * cookie) so any width-dependent layout settles in the same commit.
408+ */
405409 useLayoutEffect ( ( ) => {
406410 void useSidebarStore . persist . rehydrate ( )
407411 } , [ ] )
Original file line number Diff line number Diff line change @@ -93,10 +93,12 @@ export const useSidebarStore = create<SidebarState>()(
9393 applySidebarWidth ( width )
9494 }
9595 } ,
96- // Only width is persisted; collapse lives in the cookie.
96+ /** Only width is persisted; collapse lives in the cookie. */
9797 partialize : ( state ) => ( { sidebarWidth : state . sidebarWidth } ) ,
98- // Never let a legacy persisted `isCollapsed` override the cookie-seeded
99- // value — the cookie is the source of truth (handles migration cleanly).
98+ /**
99+ * Never lets a legacy persisted `isCollapsed` override the cookie-seeded
100+ * value — the cookie is the source of truth (handles migration cleanly).
101+ */
100102 merge : ( persisted , current ) => ( {
101103 ...current ,
102104 ...( persisted as Partial < SidebarState > ) ,
You can’t perform that action at this time.
0 commit comments