diff --git a/apps/desktop/tests/main-startup.spec.ts b/apps/desktop/tests/main-startup.spec.ts index 3df37cb4ae..b83754ea27 100644 --- a/apps/desktop/tests/main-startup.spec.ts +++ b/apps/desktop/tests/main-startup.spec.ts @@ -74,6 +74,8 @@ const harness = await vi.hoisted(async () => { super(); if (windowFailure !== undefined) throw windowFailure; windows.push(this); if (options.modal) policyBlocked.resolve() } isDestroyed() { return this.destroyed } + fullscreen = false + isFullScreen() { return this.fullscreen } isMinimized() { return false } isFocused() { return true } async loadURL(url: string) { @@ -518,6 +520,39 @@ describe('desktop main startup', () => { expect(harness.hosts).toHaveLength(0) }) + it('relays the macOS fullscreen state on transitions and after each load', async () => { + vi.spyOn(process, 'platform', 'get').mockReturnValue('darwin') + await import('../src/main.ts') + await harness.preparing.promise + const window = harness.windows[0]! + const sent = () => window.webContents.send.mock.calls.filter(([channel]) => channel === DESKTOP_IPC.windowFullscreen) + expect(sent()).toHaveLength(0) + window.fullscreen = true + window.emit('enter-full-screen') + expect(sent().at(-1)).toEqual([DESKTOP_IPC.windowFullscreen, true]) + // A reload re-registers the preload listener; the finished load resends + // the current state so fullscreen CSS survives the reload. + window.webContents.emit('did-finish-load') + expect(sent().at(-1)).toEqual([DESKTOP_IPC.windowFullscreen, true]) + window.fullscreen = false + window.emit('leave-full-screen') + expect(sent().at(-1)).toEqual([DESKTOP_IPC.windowFullscreen, false]) + const relayed = sent().length + window.destroyed = true + window.emit('enter-full-screen') + expect(sent()).toHaveLength(relayed) + }) + + it.each(['win32', 'linux'] as const)('registers no fullscreen relay on %s', async (platform) => { + vi.spyOn(process, 'platform', 'get').mockReturnValue(platform) + await import('../src/main.ts') + await harness.preparing.promise + const window = harness.windows[0]! + window.emit('enter-full-screen') + window.webContents.emit('did-finish-load') + expect(window.webContents.send.mock.calls.filter(([channel]) => channel === DESKTOP_IPC.windowFullscreen)).toHaveLength(0) + }) + it('follows the Windows primary document language and palette without trusting other frames', async () => { vi.spyOn(process, 'platform', 'get').mockReturnValue('win32') await import('../src/main.ts') diff --git a/apps/desktop/tests/preload-platform.client.spec.ts b/apps/desktop/tests/preload-platform.client.spec.ts new file mode 100644 index 0000000000..fbf6902db0 --- /dev/null +++ b/apps/desktop/tests/preload-platform.client.spec.ts @@ -0,0 +1,33 @@ +// @vitest-environment jsdom +import { afterEach, expect, it, vi } from 'vitest' +import { DESKTOP_IPC } from '../src/ipc.ts' +import { syncWindowFullscreen } from '../src/preload-platform.ts' + +const on = vi.hoisted(() => vi.fn()) +vi.mock('electron', () => ({ ipcRenderer: { on } })) + +afterEach(() => { + delete document.documentElement.dataset.fullscreen + vi.restoreAllMocks() + on.mockClear() +}) + +it.each(['win32', 'linux'] as const)('subscribes no fullscreen channel on %s', (platform) => { + vi.spyOn(process, 'platform', 'get').mockReturnValue(platform) + syncWindowFullscreen() + expect(on).not.toHaveBeenCalled() +}) + +it('mirrors the sent fullscreen state onto html[data-fullscreen] on darwin', () => { + vi.spyOn(process, 'platform', 'get').mockReturnValue('darwin') + syncWindowFullscreen() + expect(on).toHaveBeenCalledExactlyOnceWith(DESKTOP_IPC.windowFullscreen, expect.any(Function)) + const handler = on.mock.calls[0]?.[1] as (event: unknown, fullscreen: boolean) => void + handler({}, true) + expect(document.documentElement.dataset.fullscreen).toBe('true') + handler({}, false) + expect(document.documentElement.dataset.fullscreen).toBeUndefined() + // A repeated windowed report stays a no-op rather than toggling the flag. + handler({}, false) + expect(document.documentElement.dataset.fullscreen).toBeUndefined() +}) diff --git a/packages/client/ui-layout/src/client/AppFrame.tsx b/packages/client/ui-layout/src/client/AppFrame.tsx index 7b39e777a9..e9ed81aa47 100644 --- a/packages/client/ui-layout/src/client/AppFrame.tsx +++ b/packages/client/ui-layout/src/client/AppFrame.tsx @@ -266,11 +266,12 @@ export function AppFrame({ ), [usePanelInfo, renderSlot]) const overlays = useMemo(() => renderSlot('shell.overlay', {}), [renderSlot]) // Window-chrome seat over the main panels' top-left corner: only a fully - // hidden sidebar column (macOS desktop collapse) leaves window chrome - // without a home. AppFrame.module.css publishes the matching + // hidden sidebar column on macOS desktop leaves window chrome without a + // home — the Windows zero-width collapse keeps its controls in the caption + // row (ui-sidebar). AppFrame.module.css publishes the matching // --dsh-frame-leading-clearance under the same collapsed condition. const leading = useMemo(() => renderSlot('shell.leading', {}), [renderSlot]) - const leadingMounted = sidebarCollapsed && collapsedWidth === 0 + const leadingMounted = darwin && sidebarCollapsed return (