The VS Code of video editing, built for agents.
TypeScript
Add Windows title bar support and refactor dashboard components
konstantin-paulus0d332f417c17
diff --git a/apps/web/src/components/dashboard/projects-view.tsx b/apps/web/src/components/dashboard/projects-view.tsxindex 8841cf78..f36ca673 100644--- a/apps/web/src/components/dashboard/projects-view.tsx+++ b/apps/web/src/components/dashboard/projects-view.tsx@@ -3,7 +3,7 @@* file, You can obtain one at http://mozilla.org/MPL/2.0/. */import { toast } from "somoto";-import { For, createMemo, createResource, createSignal } from "solid-js";+import { For, createMemo, createResource, createSignal, type Accessor } from "solid-js";import { useNavigate } from "@solidjs/router";import {@@ -31,6 +31,7 @@ import { projectRoute, useReturnHere } from "@/hooks/use-project-route";import { Icon } from "../ui/icon";import { track } from "@/lib/analytics";import {+ isWindowsDesktop,listProjects,projectKey,projectsRevision,@@ -39,10 +40,14 @@ import {import type { ProjectSortOption } from "./types";-export function DashboardProjectsView() {+type DashboardProjectsViewProps = {+ search: Accessor<string>;+ onSearchChange: (value: string) => void;+};++export function DashboardProjectsView(props: DashboardProjectsViewProps) {const navigate = useNavigate();const returnHere = useReturnHere();- const [search, setSearch] = createSignal("");const [sort, setSort] = createSignal<ProjectSortOption>("last-viewed");const [projects, { refetch: refetchProjects }] = createResource(projectsRevision, () => listProjects());const [selectedProject, setSelectedProject] = createSignal<string | null>(null);@@ -52,7 +57,7 @@ export function DashboardProjectsView() {const selectedSortOption = () =>SORT_OPTIONS.find((option) => option.id === sort()) ?? SORT_OPTIONS[0];- const normalizedSearch = createMemo(() => search().trim().toLowerCase());+ const normalizedSearch = createMemo(() => props.search().trim().toLowerCase());const filteredProjects = createMemo(() => {const query = normalizedSearch();@@ -113,9 +118,10 @@ export function DashboardProjectsView() {return (<DashboardSearchPanel- value={search}- onChange={setSearch}+ value={props.search}+ onChange={props.onSearchChange}placeholder="Search in projects"+ showBar={!isWindowsDesktop()}><DashboardViewSectionclass="pb-4"diff --git a/apps/web/src/components/dashboard/search-bar.tsx b/apps/web/src/components/dashboard/search-bar.tsxindex 28f98f47..6b8fee5a 100644--- a/apps/web/src/components/dashboard/search-bar.tsx+++ b/apps/web/src/components/dashboard/search-bar.tsx@@ -2,28 +2,32 @@* License, v. 2.0. If a copy of the MPL was not distributed with this* file, You can obtain one at http://mozilla.org/MPL/2.0/. */-import { type Accessor, type JSX } from "solid-js";+import { Show, type Accessor, type JSX } from "solid-js";import { Icon } from "@/components/ui/icon";import { TextField } from "@/components/ui/text-field";+import { cx } from "@/lib/cva";type DashboardSearchBarProps = {value: Accessor<string>;onChange: (value: string) => void;placeholder: string;+ class?: string;};type DashboardSearchPanelProps = {value: Accessor<string>;onChange: (value: string) => void;placeholder: string;+ /** False where the search field lives elsewhere (the Windows title bar). */+ showBar?: boolean;children: JSX.Element;};export function DashboardSearchBar(props: DashboardSearchBarProps) {return (- <div class="flex h-12 shrink-0 items-center border-b border-border px-4">- <TextField class="relative flex h-7 w-full items-center gap-0">+ <div class={cx("flex h-12 shrink-0 items-center border-b border-border px-4", props.class)}>+ <TextField class="relative flex h-7 w-full items-center gap-0" style="-webkit-app-region: no-drag;"><div class="grid size-7 place-items-center overflow-clip text-muted-foreground"><Icon name="search" class="size-6" /></div>@@ -49,11 +53,13 @@ export function DashboardSearchBar(props: DashboardSearchBarProps) {export function DashboardSearchPanel(props: DashboardSearchPanelProps) {return (<div class="flex min-h-0 flex-1 flex-col">- <DashboardSearchBar- value={props.value}- onChange={props.onChange}- placeholder={props.placeholder}- />+ <Show when={props.showBar ?? true}>+ <DashboardSearchBar+ value={props.value}+ onChange={props.onChange}+ placeholder={props.placeholder}+ />+ </Show>{props.children}</div>);diff --git a/apps/web/src/components/sidebar-left/sidebar-left.tsx b/apps/web/src/components/sidebar-left/sidebar-left.tsxindex 33416655..b9da38a6 100644--- a/apps/web/src/components/sidebar-left/sidebar-left.tsx+++ b/apps/web/src/components/sidebar-left/sidebar-left.tsx@@ -13,12 +13,17 @@ import { Icon } from "../ui/icon";import { ProjectMenu } from "./project-menu";import { useProject } from "@/context/project";import { cx } from "@/lib/cva";+import { isWindowsDesktop } from "@/projects";+import { WindowsTitleBar } from "../ui/windows-title-bar";export function SidebarLeft() {return (<div class="flex flex-col h-full overflow-hidden">- <ElectronHeader />- <ProjectHeader />+ {/* On Windows the title bar carries the menu, the toggles and the name. */}+ <Show when={!isWindowsDesktop()}>+ <ElectronHeader />+ <ProjectHeader />+ </Show><div classList={{ contents: sidebarTab() === "assets", hidden: sidebarTab() === "chat" }}><Assets /></div>@@ -29,32 +34,71 @@ export function SidebarLeft() {);}+function LayoutToggles() {+ const { toggleTimeline, toggleUI } = useLayout();++ return (+ <div class="flex items-center gap-1 relative z-30" style="-webkit-app-region: no-drag;">+ <Button variant="ghost" size="icon" class="text-muted-foreground" onClick={toggleTimeline}>+ <Icon name="sidebar-timeline" />+ </Button>+ <Button variant="ghost" size="icon" class="text-muted-foreground" onClick={toggleUI}>+ <Icon name="sidebar" />+ </Button>+ </div>+ )+}+export function ElectronHeader() {const { isDesktop, isFullscreen } = useEditorApi();- const { toggleTimeline, toggleUI } = useLayout();return (<Show when={isDesktop}><div class="h-10 border-b border-border shrink-0 pr-4 pl-1.5 gap-1 relative flex items-center"><div class="flex-1 h-full data-[fullscreen=true]:flex-none transition-all duration-100 ease-out" data-fullscreen={isFullscreen()} />- <div class="flex items-center gap-1 relative z-30" style="-webkit-app-region: no-drag;">- <Button variant="ghost" size="icon" class="text-muted-foreground" onClick={toggleTimeline}>- <Icon name="sidebar-timeline" />- </Button>- <Button variant="ghost" size="icon" class="text-muted-foreground" onClick={toggleUI}>- <Icon name="sidebar" />- </Button>- </div>+ <LayoutToggles /></div></Show>)}-type ProjectHeaderProps = {+type EditorTitleBarProps = {+ leftWidth: number;+ controlsWidth: number;+}++/** The editor's Windows title bar: project menu and layout toggles, the project name centered. */+export function EditorTitleBar(props: EditorTitleBarProps) {+ return (+ <WindowsTitleBar+ leftWidth={props.leftWidth}+ controlsWidth={props.controlsWidth}+ left={+ <>+ <div class="flex shrink-0 items-center" style="-webkit-app-region: no-drag;">+ <ProjectMenu />+ </div>+ <span class="min-w-0 flex-1 truncate text-xs text-muted-foreground font-450">Diffusion Studio</span>+ <LayoutToggles />+ </>+ }+ >+ <div+ class="absolute left-1/2 top-1/2 flex max-w-[30%] -translate-x-1/2 -translate-y-1/2"+ style="-webkit-app-region: no-drag;"+ >+ <ProjectNameInput class="ml-0 w-auto min-w-8 max-w-full field-sizing-content text-center" />+ </div>+ </WindowsTitleBar>+ )+}++type ProjectNameInputProps = {class?: string;}-export function ProjectHeader(props: ProjectHeaderProps) {+/** The project name, renamed in place: Enter commits, Escape or blur reverts. */+function ProjectNameInput(props: ProjectNameInputProps) {const project = useProject();const [projectNameDraft, setProjectNameDraft] = createSignal<string | null>(null);@@ -96,20 +140,30 @@ export function ProjectHeader(props: ProjectHeaderProps) {}};+ return (+ <input+ type="text"+ value={projectNameDraft() ?? project.name()}+ onInput={handleProjectNameInput}+ onFocus={handleFocusNameInput}+ onBlur={handleBlurNameInput}+ onKeyDown={handleKeyDownNameInput}+ placeholder="Project name"+ class={cx("w-full bg-transparent focus-ring px-1 h-5 ml-1 rounded text-xs text-muted-foreground font-450 outline-none", props.class)}+ />+ )+}++type ProjectHeaderProps = {+ class?: string;+}++export function ProjectHeader(props: ProjectHeaderProps) {return (<div class={cx("h-12 shrink-0 flex items-center gap-1 pr-4 pl-2.5", props.class)}><ProjectMenu /><div class="flex items-center w-full">- <input- type="text"- value={projectNameDraft() ?? project.name()}- onInput={handleProjectNameInput}- onFocus={handleFocusNameInput}- onBlur={handleBlurNameInput}- onKeyDown={handleKeyDownNameInput}- placeholder="Project name"- class="w-full bg-transparent focus-ring px-1 h-5 ml-1 rounded text-xs text-muted-foreground font-450 outline-none"- />+ <ProjectNameInput /></div></div>)diff --git a/apps/web/src/components/sidebar-right/inspector/inspector-header.tsx b/apps/web/src/components/sidebar-right/inspector/inspector-header.tsxindex ad161f64..3b00f62a 100644--- a/apps/web/src/components/sidebar-right/inspector/inspector-header.tsx+++ b/apps/web/src/components/sidebar-right/inspector/inspector-header.tsx@@ -24,7 +24,7 @@ export function InspectorHeader() {const zoomLabel = () => `${Math.round(scale() * 100)}%`;return (- <div class="h-12 shrink-0 flex items-center pl-4 pr-[calc(1rem+var(--titlebar-controls-width))]">+ <div class="h-12 shrink-0 flex items-center px-4"><span class="text-[12px] leading-5 font-450 text-foreground">Editor</span><DropdownMenu placement="bottom-end"><DropdownMenuTrigger<typeof Button>diff --git a/apps/web/src/components/ui/windows-title-bar.tsx b/apps/web/src/components/ui/windows-title-bar.tsxnew file mode 100644index 00000000..f0f2a277--- /dev/null+++ b/apps/web/src/components/ui/windows-title-bar.tsx@@ -0,0 +1,46 @@+/* This Source Code Form is subject to the terms of the Mozilla Public+ * License, v. 2.0. If a copy of the MPL was not distributed with this+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */++import { Show, type JSX } from "solid-js";++import { isWindowsDesktop } from "@/projects";++type WindowsTitleBarProps = {+ /** Width of the left cell, so its border continues the sidebar divider below. */+ leftWidth: number;+ /** Width of the cell the native window controls sit in. */+ controlsWidth: number;+ left: JSX.Element;+ children?: JSX.Element;+};++/**+ * The title bar of the Windows desktop build: a fixed row under the native+ * minimize/maximize/close overlay. The whole row drags the window, so anything+ * interactive inside it has to opt out with `-webkit-app-region: no-drag`.+ * Renders nothing on other platforms; pages clear it with `--titlebar-height`.+ */+export function WindowsTitleBar(props: WindowsTitleBarProps) {+ return (+ <Show when={isWindowsDesktop()}>+ <div+ class="fixed inset-x-0 top-0 z-20 flex h-(--titlebar-height) bg-sidebar"+ style="-webkit-app-region: drag;"+ >+ <div+ class="flex h-full shrink-0 items-center gap-2 border-r border-border-strong pl-3 pr-4 transition-[width] duration-200 ease-out motion-reduce:transition-none"+ style={{ width: `${props.leftWidth}px` }}+ >+ {props.left}+ </div>+ {/* Not positioned on purpose: absolute children center on the whole bar. */}+ <div class="h-full min-w-0 flex-1">{props.children}</div>+ <div+ class="h-full min-w-(--titlebar-controls-width) shrink-0 border-l border-border-strong"+ style={{ width: `${props.controlsWidth}px` }}+ />+ </div>+ </Show>+ );+}diff --git a/apps/web/src/index.css b/apps/web/src/index.cssindex 50ff89c4..a54fa381 100644--- a/apps/web/src/index.css+++ b/apps/web/src/index.css@@ -230,6 +230,14 @@DPI, and 0 wherever there is no overlay (web, macOS, fullscreen). */:root {--titlebar-controls-width: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw));+ --titlebar-height: 0px;+}++/* Windows desktop: the dashboard and the editor draw their own title bar+ (`WindowsTitleBar`) as a fixed row under the native controls, and pad their+ root by this height. It matches `WINDOWS_OVERLAY_HEIGHT` in the main process. */+[data-platform="win32"] {+ --titlebar-height: 40px;}/* macOS desktop: the BrowserWindow uses native vibrancy, so the page keeps adiff --git a/apps/web/src/pages/dashboard.tsx b/apps/web/src/pages/dashboard.tsxindex 5a84c957..3fc30de0 100644--- a/apps/web/src/pages/dashboard.tsx+++ b/apps/web/src/pages/dashboard.tsx@@ -14,6 +14,7 @@ import { DashboardHelpView } from "@/components/dashboard/help-view";import { DashboardHomeView } from "@/components/dashboard/home-view";import { DashboardMcpView } from "@/components/dashboard/mcp-view";import { DashboardProjectsView } from "@/components/dashboard/projects-view";+import { DashboardSearchBar } from "@/components/dashboard/search-bar";import { DashboardSettingsView } from "@/components/dashboard/settings-view";import {DashboardSidebarConnectCard,@@ -24,10 +25,12 @@ import {DashboardSidebarTopSpacer,DashboardSidebarUser,} from "@/components/dashboard/sidebar";+import { Icon } from "@/components/ui/icon";import { Separator } from "@/components/ui/separator";+import { WindowsTitleBar } from "@/components/ui/windows-title-bar";import { useFullscreenState } from "@/hooks/use-fullscreen-state";import { connectedAgents, fetchMcpStatus } from "@/lib/mcp";-import { isDesktop, openProjectFolder, pickProjectFolder } from "@/projects";+import { isDesktop, isWindowsDesktop, openProjectFolder, pickProjectFolder } from "@/projects";import { isInputTarget } from "@/utils";import type { DashboardView } from "@/components/dashboard/types";@@ -55,6 +58,11 @@ const SETTINGS_VIEWS: readonly DashboardView[] = ["help",];+// The title bar's left cell spans the sidebar (`w-69`) plus its 1px separator,+// so both borders fall on the same line.+const TITLE_BAR_SIDEBAR_WIDTH = 277;+const TITLE_BAR_CONTROLS_WIDTH = 283;+function parseView(value: string | string[] | undefined): DashboardView {const raw = Array.isArray(value) ? value[0] : value;return DASHBOARD_VIEWS.find((v) => v === raw) ?? "home";@@ -125,13 +133,49 @@ export function DashboardPage() {if (isSettingsView(view())) setView("home");};+ // The project search lives here rather than in the projects view because+ // the Windows title bar offers it on every view: typing there lands on the+ // projects it filters. Leaving the projects view drops the query.+ const [projectSearch, setProjectSearch] = createSignal("");++ const searchFromTitleBar = (value: string) => {+ setProjectSearch(value);+ if (value && view() !== "projects") {+ setSettingsNavOpen(false);+ setView("projects");+ }+ };++ createEffect(() => {+ if (view() !== "projects") setProjectSearch("");+ });+return (- <div class="flex h-screen w-full min-h-0 flex-row overflow-hidden bg-sidebar">+ <div class="flex h-screen w-full min-h-0 flex-row overflow-hidden bg-sidebar pt-(--titlebar-height)">+ <WindowsTitleBar+ leftWidth={TITLE_BAR_SIDEBAR_WIDTH}+ controlsWidth={TITLE_BAR_CONTROLS_WIDTH}+ left={+ <>+ <Icon name="diffusion-logo" class="size-6 shrink-0 text-muted-foreground" />+ <p class="min-w-0 flex-1 truncate text-xs font-450 text-muted-foreground">Diffusion Studio</p>+ <p class="shrink-0 text-xxs text-muted-foreground">v{APP_VERSION}</p>+ </>+ }+ >+ <DashboardSearchBar+ class="h-full"+ value={projectSearch}+ onChange={searchFromTitleBar}+ placeholder="Search in projects"+ />+ </WindowsTitleBar><aside class="relative flex min-h-0 w-69 shrink-0 flex-col">- <Show when={!!window.desktop && !isFullscreen()}>+ <Show when={isDesktop() && !isWindowsDesktop() && !isFullscreen()}><div class="absolute inset-x-0 top-0 h-10 z-20" style="-webkit-app-region: drag;" /></Show>- <Show when={!settingsNavOpen()} fallback={<DashboardSidebarTopSpacer />}>+ {/* The Windows title bar already carries the logo, name and version. */}+ <Show when={!settingsNavOpen() && !isWindowsDesktop()} fallback={<DashboardSidebarTopSpacer />}><DashboardSidebarHeader /></Show><DashboardSidebarNav@@ -176,7 +220,7 @@ export function DashboardPage() {<DashboardHomeView /></Match><Match when={view() === "projects"}>- <DashboardProjectsView />+ <DashboardProjectsView search={projectSearch} onSearchChange={setProjectSearch} /></Match><Match when={view() === "ai-credits"}><DashboardAiCreditsView />diff --git a/apps/web/src/pages/editor.tsx b/apps/web/src/pages/editor.tsxindex 18381309..28a6b752 100644--- a/apps/web/src/pages/editor.tsx+++ b/apps/web/src/pages/editor.tsx@@ -7,7 +7,7 @@ import { Canvas } from "@/components/canvas";import { leftSidebarWidth } from "@/agent-chat";import { Timeline, Layers } from "@/components/timeline";import { Soundboard, Inspector } from "@/components/sidebar-right";-import { FloatingProjectHeader, SidebarLeft } from "@/components/sidebar-left";+import { EditorTitleBar, FloatingProjectHeader, SidebarLeft } from "@/components/sidebar-left";import { useLayout, MIN_TIMELINE_HEIGHT } from "@/context/layout";import { useEditorApi } from "@/dapi";import { RULER_HEIGHT } from "@/engine/timeline";@@ -24,7 +24,7 @@ import { attachProjectConfig, isProjectConfigFile } from '@/engine/project-confiimport { loadProjectBundle, rememberProjectBundle } from '@/lib/db';import { isCacheFile } from '@diffusionstudio/assets';import { createEditWriter } from '@/projects/edits';-import { compileProject, refreshProject, watchProject } from '@/projects/host';+import { compileProject, isWindowsDesktop, refreshProject, watchProject } from '@/projects/host';import { captureProjectCover } from '@/projects/cover';import { useProject } from "@/context/project";import { useEngineContext } from "@/engine";@@ -33,6 +33,7 @@ import type { Mount } from '@diffusionstudio/reconciler';import type { EditWriter } from '@/projects/edits';const MIN_CANVAS_HEIGHT = 200;+const INSPECTOR_WIDTH = 264;export function EditorPage() {const { uiVisible, timelineMinimized, timelineHeight, setTimelineHeight } = useLayout();@@ -203,7 +204,7 @@ export function EditorPage() {const height = timelineMinimized() ? RULER_HEIGHT : timelineHeight();return {- 'grid-template-columns': `${leftSidebarWidth()}px 1px 1fr 1px 264px`,+ 'grid-template-columns': `${leftSidebarWidth()}px 1px 1fr 1px ${INSPECTOR_WIDTH}px`,'grid-template-rows': `1fr 1px ${height}px`,...(animateColumns() ? { transition: 'grid-template-columns 200ms ease-out' } : {}),};@@ -238,14 +239,15 @@ export function EditorPage() {return (<div- class="bg-sidebar h-screen w-full overflow-hidden grid"+ class="bg-sidebar h-screen w-full overflow-hidden grid pt-(--titlebar-height)"classList={{'grid-cols-[1fr]': !uiVisible(),'grid-rows-[1fr]': !uiVisible(),}}style={timelineStyles()}>- <Show when={isDesktop && !isFullscreen()}>+ <EditorTitleBar leftWidth={leftSidebarWidth() + 1} controlsWidth={INSPECTOR_WIDTH + 1} />+ <Show when={isDesktop && !isWindowsDesktop() && !isFullscreen()}><div class="fixed top-0 left-0 right-0 h-10 z-20" style="-webkit-app-region: drag;" /></Show><Show when={uiVisible()}>@@ -285,7 +287,8 @@ export function EditorPage() {<Soundboard /></Show></Show>- <Show when={!uiVisible()}>+ {/* The Windows title bar stays up with the UI hidden and offers the same. */}+ <Show when={!uiVisible() && !isWindowsDesktop()}><FloatingProjectHeader /></Show></div>diff --git a/apps/web/src/projects/host.ts b/apps/web/src/projects/host.tsindex 335a813c..5c8653ae 100644--- a/apps/web/src/projects/host.ts+++ b/apps/web/src/projects/host.ts@@ -57,6 +57,8 @@ export function markProjectsChanged(): void {}export const isDesktop = (): boolean => !!window.desktop;+export const isWindowsDesktop = (): boolean => window.desktop?.platform === "win32";+export const isMacOSDesktop = (): boolean => window.desktop?.platform === "darwin";/** Puts `project` on the list (or marks it just opened) and tells the views. */async function remember(project: ProjectInfo): Promise<void> {