diff --git a/apps/desktop/src/app/right-sidebar/terminal/persistent.test.tsx b/apps/desktop/src/app/right-sidebar/terminal/persistent.test.tsx index 77eeb480d6..a9c013301b 100644 --- a/apps/desktop/src/app/right-sidebar/terminal/persistent.test.tsx +++ b/apps/desktop/src/app/right-sidebar/terminal/persistent.test.tsx @@ -2,10 +2,17 @@ import { act, type ReactNode } from 'react' import { createRoot, type Root } from 'react-dom/client' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { hiddenPaneProps, PANE_HIDDEN_ATTR } from '@/components/pane-shell/pane-visibility' import { $paneStates } from '@/store/panes' +import { $terminalTakeover } from '../store' + import { PersistentTerminal, TerminalSlot } from './persistent' +vi.mock('../store', async () => ({ + $terminalTakeover: (await import('nanostores')).atom(false) +})) + vi.mock('./terminals', () => ({ ensureTerminal: vi.fn() })) @@ -125,6 +132,17 @@ function Harness() { ) } +function HiddenPaneHarness({ hidden }: { hidden: boolean }) { + return ( + <> +
+ +
+ undefined} /> + + ) +} + describe('PersistentTerminal rect tracking', () => { beforeEach(() => { ;(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true @@ -164,6 +182,7 @@ describe('PersistentTerminal rect tracking', () => { afterEach(() => { cleanup() + $terminalTakeover.set(false) vi.unstubAllGlobals() vi.restoreAllMocks() setVisibility(false) @@ -333,4 +352,62 @@ describe('PersistentTerminal rect tracking', () => { expect(raf.pending()).toBe(1) }) + + it('hides the overlay but keeps its workspace mounted when the terminal tab becomes inactive', () => { + const raf = installRaf() + vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue(rect(10, 20, 200, 100)) + $terminalTakeover.set(true) + + render(