TypeScript
fix(web): render settings sidebar immediately (#9563)
maria2b10398cca3f
diff --git a/apps/web/src/components/AppSidebarLayout.tsx b/apps/web/src/components/AppSidebarLayout.tsxindex 1780c8b9acb..3bef170bcf5 100644--- a/apps/web/src/components/AppSidebarLayout.tsx+++ b/apps/web/src/components/AppSidebarLayout.tsx@@ -1,8 +1,6 @@import { useAtomValue } from "@effect/atom-react";import * as Schema from "effect/Schema";import {- lazy,- Suspense,useEffect,useState,useSyncExternalStore,@@ -20,6 +18,7 @@ import { useEnvironmentIdentificationMode, useLegacySidebarEnabled } from "../hoimport { usePanelAnimationSettings } from "../panelAnimations";import LegacyThreadSidebar from "./LegacySidebar";import ThreadSidebar from "./Sidebar";+import { SettingsSidebarNav } from "./settings/SettingsSidebarNav";import { SidebarChromeHeader } from "./sidebar/SidebarChrome";import {resolveSidebarStageFocusRingOffsetClass,@@ -45,14 +44,6 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";const MACOS_TRAFFIC_LIGHTS_LEFT_INSET = "90px";-// The settings nav (and the Clerk profile surfaces behind it) only renders on-// settings routes; lazy-loading it keeps that subtree out of the startup chunk.-const SettingsSidebarNav = lazy(() =>- import("./settings/SettingsSidebarNav").then((module) => ({- default: module.SettingsSidebarNav,- })),-);-function subscribeToViewportWidth(onChange: () => void): () => void {window.addEventListener("resize", onChange);return () => window.removeEventListener("resize", onChange);@@ -247,9 +238,7 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {{isOnSettings ? (<><SidebarChromeHeader isElectron={isElectron} />- <Suspense fallback={null}>- <SettingsSidebarNav pathname={pathname} />- </Suspense>+ <SettingsSidebarNav pathname={pathname} /></>) : legacySidebarEnabled ? (<LegacyThreadSidebar />diff --git a/apps/web/src/components/settings/SettingsSidebarNav.tsx b/apps/web/src/components/settings/SettingsSidebarNav.tsxindex f703ba09f8c..2716569c571 100644--- a/apps/web/src/components/settings/SettingsSidebarNav.tsx+++ b/apps/web/src/components/settings/SettingsSidebarNav.tsx@@ -1,4 +1,6 @@import {+ lazy,+ Suspense,useCallback,useEffect,useMemo,@@ -36,7 +38,6 @@ import {SidebarMenuSubItem,useSidebar,} from "../ui/sidebar";-import { T3ConnectSidebarAvatar, T3ConnectSidebarSignIn } from "../clerk/T3ConnectSidebarSignIn";import { SidebarUtilityMenu } from "../sidebar/SidebarChrome";import { scrollToSettingsTarget } from "./settingsLayout";import {@@ -47,6 +48,17 @@ import {} from "./settingsSearch";import { useAvailableSettingsSearchItems } from "./useAvailableSettingsSearchItems";+const T3ConnectSidebarSignIn = lazy(() =>+ import("../clerk/T3ConnectSidebarSignIn").then((module) => ({+ default: module.T3ConnectSidebarSignIn,+ })),+);+const T3ConnectSidebarAvatar = lazy(() =>+ import("../clerk/T3ConnectSidebarSignIn").then((module) => ({+ default: module.T3ConnectSidebarAvatar,+ })),+);+const SETTINGS_SECTION_ICONS: Readonly<Record<SettingsPath, ComponentType<{ className?: string }>>> = {@@ -370,12 +382,16 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) {</SidebarGroup></SidebarContent><SidebarFooter className="p-[var(--sidebar-content-inset)]">- <T3ConnectSidebarSignIn />+ <Suspense fallback={null}>+ <T3ConnectSidebarSignIn />+ </Suspense><div className="flex items-center gap-1"><div className="min-w-0 flex-1"><SidebarUtilityMenu /></div>- <T3ConnectSidebarAvatar />+ <Suspense fallback={null}>+ <T3ConnectSidebarAvatar />+ </Suspense></div></SidebarFooter></>