The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.
Chat: on Windows a file's preview opens below the window's buttons (#217)
WEBGRS1f142461b49c
diff --git a/.changeset/preview-below-window-buttons.md b/.changeset/preview-below-window-buttons.mdnew file mode 100644index 0000000..3beb891--- /dev/null+++ b/.changeset/preview-below-window-buttons.md@@ -0,0 +1,5 @@+---+"@openfilm/desktop": patch+---++Windows: a file's preview in the chat opens below the window's buttons, so its close button is no longer right under the one that quits OpenFilm.diff --git a/apps/desktop/chat/src/components/PreviewFrame.tsx b/apps/desktop/chat/src/components/PreviewFrame.tsxindex 0d91231..6278108 100644--- a/apps/desktop/chat/src/components/PreviewFrame.tsx+++ b/apps/desktop/chat/src/components/PreviewFrame.tsx@@ -7,6 +7,7 @@ import { X } from 'lucide-react';import { Tooltip } from './Tooltip';import { useT } from '@/i18n';import { chatLayer } from '@/lib/chat-layer';+import { previewTop } from '@/lib/preview-top';/** A button in the top bar. The lightbox is black, so these use shades of white rather than the UI tokens. */export const PREVIEW_BTN =@@ -102,7 +103,7 @@ export function PreviewFrame({return createPortal(<div className="fixed inset-0 z-[10100] flex items-center justify-center bg-black/65 p-4 backdrop-blur-sm sm:p-8"- style={{ paddingTop: 'max(1rem, var(--inset-titlebar-h, 0px))', WebkitAppRegion: 'no-drag' } as React.CSSProperties}+ style={{ paddingTop: previewTop(navigator.platform), WebkitAppRegion: 'no-drag' } as React.CSSProperties}onClick={onClose}><div ref={box} tabIndex={-1} role="dialog" aria-modal="true" aria-label={name}className="relative isolate flex h-[min(900px,92dvh)] min-h-0 w-full max-w-[1480px] flex-col overflow-hidden rounded-2xl border border-white/10 bg-[#181818] shadow-2xl outline-none"diff --git a/apps/desktop/chat/src/lib/preview-top.ts b/apps/desktop/chat/src/lib/preview-top.tsnew file mode 100644index 0000000..5b38a4f--- /dev/null+++ b/apps/desktop/chat/src/lib/preview-top.ts@@ -0,0 +1,15 @@+/**+ * Where the lightbox (PreviewFrame) starts at the top of the window. On Windows the window's own buttons are drawn+ * over the page's top right (src/main.mjs, `titleBarOverlay`), above anything the page draws: the lightbox starts+ * below them, so its close button is never under the window's, which quits OpenFilm.+ *+ * Pure: no React, no bridge, so `node --test` runs it (src/preview-top.test.mjs).+ */++/** How tall Windows draws the window's buttons over the page: `titleBarOverlay`'s height in src/main.mjs. */+export const WINDOW_BUTTONS_H = 32;++/** The lightbox's top padding, as CSS, on this platform (`navigator.platform`). */+export function previewTop(platform: string): string {+ return platform.startsWith('Win') ? `${WINDOW_BUTTONS_H + 8}px` : 'max(1rem, var(--inset-titlebar-h, 0px))';+}diff --git a/apps/desktop/src/preview-top.test.mjs b/apps/desktop/src/preview-top.test.mjsnew file mode 100644index 0000000..3956a4e--- /dev/null+++ b/apps/desktop/src/preview-top.test.mjs@@ -0,0 +1,17 @@+import { test } from 'node:test';+import assert from 'node:assert/strict';+import { readFileSync } from 'node:fs';+import { WINDOW_BUTTONS_H, previewTop } from '../chat/src/lib/preview-top.ts';++test('on Windows the lightbox starts below the window\'s buttons; elsewhere where it did', () => {+ assert.equal(previewTop('Win32'), `${WINDOW_BUTTONS_H + 8}px`);+ assert.equal(previewTop('MacIntel'), 'max(1rem, var(--inset-titlebar-h, 0px))');+ assert.equal(previewTop('Linux x86_64'), 'max(1rem, var(--inset-titlebar-h, 0px))');+});++test('the buttons\' height is the one the window draws them at (main.mjs, titleBarOverlay)', () => {+ const main = readFileSync(new URL('./main.mjs', import.meta.url), 'utf8');+ const overlay = main.match(/const overlayColours = [^\n]*height: (\d+)/);+ assert.ok(overlay, 'main.mjs sets the title bar overlay\'s height');+ assert.equal(Number(overlay[1]), WINDOW_BUTTONS_H);+});