Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(desktop): stop auto-collapsing the sidebar when an app opens
Diego Zacarias2f75f6751dd7
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex 03332af95..111dc8629 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -260,13 +260,6 @@ export function App() {const [sidebarCollapsed, setSidebarCollapsed] = React.useState<boolean>(getInitialSidebarCollapsed)- const sidebarCollapsedRef = React.useRef(sidebarCollapsed)- sidebarCollapsedRef.current = sidebarCollapsed- // When opening an app auto-collapses the sidebar, this remembers the user's- // prior state so closing the app can restore it. `null` = no app-driven- // collapse is in effect (no app open, or the user has since taken manual- // control of the sidebar while an app was open).- const sidebarCollapsedBeforeAppRef = React.useRef<boolean | null>(null)const [activeSandboxUiApp, setActiveSandboxUiApp] = React.useState<ActiveSandboxUiApp | null>(null)@@ -896,12 +889,9 @@ export function App() {void window.clerum.pluginSdk?.setTheme?.(themeMode)?.catch?.(() => undefined)}, [themeMode])- // Persist only user-driven sidebar changes. Auto-collapse on app open (and the- // restore on close) is ephemeral and must not overwrite the saved preference.+ // Persist the user's sidebar change so the collapsed/expanded choice survives+ // across sessions.const handleSidebarCollapsedChange = React.useCallback((next: boolean) => {- // The user took manual control: their choice wins for the rest of the app- // session, and closing the app must not override it.- sidebarCollapsedBeforeAppRef.current = nullsetSidebarCollapsed(next)try {window.localStorage.setItem(SIDEBAR_COLLAPSED_KEY, next ? '1' : '0')@@ -910,26 +900,6 @@ export function App() {}}, [])- // Opening an app collapses the sidebar to hand the app more workspace; closing- // it restores whatever the sidebar was before — unless the user manually- // toggled the sidebar while the app was open, in which case their choice- // stands (see handleSidebarCollapsedChange). Keyed on the open/closed edge so- // switching directly between apps neither re-collapses nor re-remembers.- const isSandboxUiAppOpen = Boolean(activeSandboxUiApp)- React.useEffect(() => {- if (isSandboxUiAppOpen) {- if (sidebarCollapsedBeforeAppRef.current === null) {- sidebarCollapsedBeforeAppRef.current = sidebarCollapsedRef.current- setSidebarCollapsed(true)- }- return- }- if (sidebarCollapsedBeforeAppRef.current !== null) {- setSidebarCollapsed(sidebarCollapsedBeforeAppRef.current)- sidebarCollapsedBeforeAppRef.current = null- }- }, [isSandboxUiAppOpen])-React.useEffect(() => {void window.clerum.app.rendererReady().catch(error => {console.warn('[Desktop] Could not signal renderer readiness:', error)@@ -1151,8 +1121,8 @@ export function App() {if (!replacedByAnotherApp) {// Deactivating to a non-app surface (chat/files/settings via strip, sidebar// nav, or closing the tab): drop the embed's React state now so anything- // gated on a live app (sidebar auto-collapse, drawer-with-embed) reacts in- // this commit. On an app→app switch the incoming launch already owns this+ // gated on a live app (drawer-with-embed) reacts in this commit. On an+ // app→app switch the incoming launch already owns this// state, so leave it. This restores the reset the removed unmount cleanup// used to do for paths that never call `leaveSandboxForChat` (sidebar nav).setActiveSandboxUiApp(null)diff --git a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsxindex e3be3721a..c7de1de4a 100644--- a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx+++ b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx@@ -421,7 +421,10 @@ describe('App deep-link orchestration', () => {})})- it('collapses the sidebar when an app opens and restores it when the app closes', () => {+ // With universal-tabs an open app is a `kind:'app'` tab in the global strip, so+ // opening/closing an app no longer auto-collapses or restores the sidebar. The+ // manual toggle and its persistence are the only things that move the sidebar.+ it('does not collapse or restore the sidebar when an app opens and closes', () => {window.localStorage.clear()currentController = makeController({initialExperienceLoading: false,@@ -437,15 +440,19 @@ describe('App deep-link orchestration', () => {defaultPath: '/',})})- expect(sidebarHarness.props?.collapsed).toBe(true)- // Auto-collapse is ephemeral: it must not overwrite the saved preference.+ // Guard against a vacuous assertion: the app must actually be active for+ // "the sidebar didn't move" to mean anything.+ expect(sandboxUiPageHarness.props?.shortcutApp?.appRef).toBe('ns/app')+ // Opening an app leaves the sidebar exactly as it was, and touches nothing in+ // the saved preference.+ expect(sidebarHarness.props?.collapsed).toBe(false)expect(window.localStorage.getItem(SIDEBAR_COLLAPSED_KEY)).toBeNull()act(() => sandboxUiPageHarness.props?.onEmbeddedAppBack?.())expect(sidebarHarness.props?.collapsed).toBe(false)})- it('lets a manual sidebar toggle win while an app is open', () => {+ it('keeps the manual sidebar toggle and its persistence intact while an app is open', () => {window.localStorage.clear()currentController = makeController({initialExperienceLoading: false,@@ -460,56 +467,25 @@ describe('App deep-link orchestration', () => {defaultPath: '/',})})- expect(sidebarHarness.props?.collapsed).toBe(true)-- // The user expands the sidebar back while the app is still open.- act(() => sidebarHarness.props?.onCollapsedChange?.(false))expect(sidebarHarness.props?.collapsed).toBe(false)- // A manual toggle is user-driven, so it persists.- expect(window.localStorage.getItem(SIDEBAR_COLLAPSED_KEY)).toBe('0')- // Closing the app must not override the user's manual choice.- act(() => sandboxUiPageHarness.props?.onEmbeddedAppBack?.())- expect(sidebarHarness.props?.collapsed).toBe(false)- })-- it('keeps a manual expand when switching directly between apps', () => {- window.localStorage.clear()- currentController = makeController({- initialExperienceLoading: false,- navItem: DESKTOP_ROUTES.apps,- } as Partial<AppController>)- render(<App />)-- act(() => {- sandboxUiPageHarness.props?.onEmbeddedAppOpening?.({- appRef: 'ns/app-a',- label: 'App A',- defaultPath: '/',- })- })+ // The user collapses the sidebar manually while the app is open: it collapses+ // and the choice persists.+ act(() => sidebarHarness.props?.onCollapsedChange?.(true))expect(sidebarHarness.props?.collapsed).toBe(true)+ expect(window.localStorage.getItem(SIDEBAR_COLLAPSED_KEY)).toBe('1')- // The user expands the sidebar back while app A is open.+ // Expanding again is likewise user-driven and persists.act(() => sidebarHarness.props?.onCollapsedChange?.(false))expect(sidebarHarness.props?.collapsed).toBe(false)expect(window.localStorage.getItem(SIDEBAR_COLLAPSED_KEY)).toBe('0')- // Switching straight to another app keeps the open/closed edge unchanged, so- // the auto-collapse effect must not re-collapse nor re-remember: the manual- // expand stands.- act(() => {- sandboxUiPageHarness.props?.onEmbeddedAppOpening?.({- appRef: 'ns/app-b',- label: 'App B',- defaultPath: '/',- })- })+ // Closing the app leaves the user's manual state untouched.+ act(() => sandboxUiPageHarness.props?.onEmbeddedAppBack?.())expect(sidebarHarness.props?.collapsed).toBe(false)- expect(window.localStorage.getItem(SIDEBAR_COLLAPSED_KEY)).toBe('0')})- it('restores a saved collapsed preference after an app closes', () => {+ it('respects a saved collapsed preference regardless of app open/close', () => {window.localStorage.clear()window.localStorage.setItem(SIDEBAR_COLLAPSED_KEY, '1')currentController = makeController({@@ -526,6 +502,8 @@ describe('App deep-link orchestration', () => {defaultPath: '/',})})+ // Guard against a vacuous assertion: the app must actually be active here.+ expect(sandboxUiPageHarness.props?.shortcutApp?.appRef).toBe('ns/app')expect(sidebarHarness.props?.collapsed).toBe(true)act(() => sandboxUiPageHarness.props?.onEmbeddedAppRemoved?.())