@@ -6,7 +6,7 @@ import { Button, EmptyState } from "@corbits/react-ui";
66import { WorkbenchLoadingState } from "@/chat" ;
77import { QueryClientProvider } from "@tanstack/react-query" ;
88import { BoldIconProvider , WarningCircle } from "@/lib/icons" ;
9- import { useMemo } from "react" ;
9+ import { useMemo , useState } from "react" ;
1010
1111import { AuthScreen } from "./auth-screen" ;
1212import { BenchProvider } from "./bench-context" ;
@@ -18,7 +18,8 @@ import { OnboardingPage } from "./pages/onboarding-page";
1818import { ProvisioningErrorPage } from "./pages/provisioning-error-page" ;
1919import { createAppQueryClient } from "./query-client" ;
2020import { Redirect } from "./redirect" ;
21- import { APP_ROUTES , LOGIN_PATH , matchesRoute , ONBOARDING_PATH } from "./routes" ;
21+ import { SettingsDialog } from "./pages/settings-dialog" ;
22+ import { APP_ROUTES , LOGIN_PATH , matchesRoute , ONBOARDING_PATH , SETTINGS_PATH } from "./routes" ;
2223import type { SessionState , SessionUser } from "./session" ;
2324import { AppShell } from "./shell/app-shell" ;
2425import { ComposerInsertionProvider } from "./shell/composer-insertion" ;
@@ -62,17 +63,30 @@ function Shell({
6263 // cache; wired to `onSignOut` so a session going invalid anywhere routes
6364 // the whole shell back to login, not just one stuck panel.
6465 const queryClient = useMemo ( ( ) => createAppQueryClient ( onSignOut ) , [ onSignOut ] ) ;
65- const route = APP_ROUTES . find ( ( candidate ) => matchesRoute ( candidate . path , path ) ) ;
66+ // Settings is a dialog over the last page, so that page stays mounted
67+ // behind it; a cold load of /settings falls back to /new.
68+ const settingsOpen = matchesRoute ( SETTINGS_PATH , path ) ;
69+ const [ backdropPath , setBackdropPath ] = useState ( settingsOpen ? "/new" : path ) ;
70+ if ( ! settingsOpen && backdropPath !== path ) setBackdropPath ( path ) ;
71+ const pagePath = settingsOpen ? backdropPath : path ;
72+ const route = APP_ROUTES . find ( ( candidate ) => matchesRoute ( candidate . path , pagePath ) ) ;
6673 return (
6774 < QueryClientProvider client = { queryClient } >
6875 < NavigationProvider navigate = { navigate } onSignOut = { onSignOut } user = { user } >
6976 < BenchProvider >
7077 < ComposerInsertionProvider >
7178 < ShellChromeProvider path = { path } navigate = { navigate } >
7279 < CommandPaletteProvider path = { path } navigate = { navigate } >
73- < AppShell path = { path } user = { user } onSignOut = { onSignOut } >
74- { route === undefined ? < NotFoundPage /> : route . render ( path , navigate ) }
80+ < AppShell path = { pagePath } user = { user } onSignOut = { onSignOut } >
81+ { route === undefined ? < NotFoundPage /> : route . render ( pagePath , navigate ) }
7582 </ AppShell >
83+ { settingsOpen ? (
84+ < SettingsDialog
85+ path = { path }
86+ navigate = { navigate }
87+ onClose = { ( ) => navigate ( backdropPath ) }
88+ />
89+ ) : null }
7690 </ CommandPaletteProvider >
7791 </ ShellChromeProvider >
7892 </ ComposerInsertionProvider >
0 commit comments