Skip to content

Write HTML. Render video. Built for agents.

feat(studio): panel tabs take the decided Current design (#4266)

Miguel Ángela57e095468d1
diff --git a/packages/studio/src/components/EditorShell.tsx b/packages/studio/src/components/EditorShell.tsx
index 64ec21aa4f..f0380125b9 100644
--- a/packages/studio/src/components/EditorShell.tsx
+++ b/packages/studio/src/components/EditorShell.tsx
@@ -286,9 +286,7 @@ function EditorShellBody({
return (
<div
ref={containerRef}
- // Shell canvas is a step LIGHTER than the near-black panel cards so the
- // gaps between panels read as visible seams (CapCut-style).
- className="flex flex-col flex-1 min-h-0 bg-panel-surface"
+ className="flex flex-col flex-1 min-h-0"
onKeyDown={handleKeyDown}
tabIndex={-1}
>
diff --git a/packages/studio/src/components/StudioLeftPanels.tsx b/packages/studio/src/components/StudioLeftPanels.tsx
index 96d80b356a..f1a55d0cc8 100644
--- a/packages/studio/src/components/StudioLeftPanels.tsx
+++ b/packages/studio/src/components/StudioLeftPanels.tsx
@@ -28,7 +28,7 @@ interface StudioLeftPanelsProps {
function PanelColumn({ footer, children }: { footer: ReactNode; children: ReactNode }) {
return (
- <div className="flex h-full min-h-0 flex-col overflow-hidden bg-neutral-950">
+ <div className="flex h-full min-h-0 flex-col overflow-hidden">
<div className="flex min-h-0 flex-1 flex-col">{children}</div>
{footer}
</div>
diff --git a/packages/studio/src/components/dock/Dock.tsx b/packages/studio/src/components/dock/Dock.tsx
index 022ae80af3..842045a62e 100644
--- a/packages/studio/src/components/dock/Dock.tsx
+++ b/packages/studio/src/components/dock/Dock.tsx
@@ -16,6 +16,9 @@ import {
} from "dockview-react";
import { readStudioUiPreferences, writeStudioUiPreferences } from "../../utils/studioUiPreferences";
import { installDockAccessibility } from "./dockAccessibility";
+import { DockStripActions } from "./DockStripActions";
+import { DockTab } from "./DockTab";
+import { installTabFill } from "./dockTabFill";
import { addRegisteredPanel, applySideMinimums, buildEditLayout } from "./dockLayout";
import { DOCK_PANEL_COMPONENT } from "./dockLayoutSchema";
import { useDockLayoutStore, type DockController, type DockSnapshot } from "./dockLayoutStore";
@@ -150,6 +153,7 @@ function Root({ projectId, children }: { projectId: string | null; children: Rea
applySideMinimums(api);
const root = api.groups[0]?.element.closest<HTMLElement>(".hf-dock");
const disposeAccessibility = root ? installDockAccessibility(api, root) : () => {};
+ const disposeTabFill = root ? installTabFill(api, root) : () => {};
// The dock spans the window (buildEditLayout sizes against it too); its own box lags a resize.
const resizeObserver = new ResizeObserver(() => applySideMinimums(api, window.innerWidth));
if (root) resizeObserver.observe(root);
@@ -189,6 +193,7 @@ function Root({ projectId, children }: { projectId: string | null; children: Rea
clearTimeout(timer);
for (const subscription of subscriptions) subscription.dispose();
disposeAccessibility();
+ disposeTabFill();
resizeObserver.disconnect();
useDockLayoutStore.getState().detach();
};
@@ -202,8 +207,11 @@ function Root({ projectId, children }: { projectId: string | null; children: Rea
key={projectId ?? ""}
className="hf-dock flex-1 min-h-0"
components={COMPONENTS}
+ defaultTabComponent={DockTab}
+ rightHeaderActionsComponent={DockStripActions}
defaultRenderer="always"
disableFloatingGroups
+ disableTabsOverflowList
onReady={onReady}
/>
{children}
diff --git a/packages/studio/src/components/dock/DockStripActions.tsx b/packages/studio/src/components/dock/DockStripActions.tsx
new file mode 100644
index 0000000000..d3f0589ac6
--- /dev/null
+++ b/packages/studio/src/components/dock/DockStripActions.tsx
@@ -0,0 +1,63 @@
+import { useCallback, useSyncExternalStore } from "react";
+import { CornersIn, CornersOut, DotsThree, X } from "@phosphor-icons/react";
+import type { IDockviewHeaderActionsProps } from "dockview-react";
+import { IconButton, Menu, MenuCheckboxItem, MenuItem, MenuSeparator } from "../ui";
+import { useDockLayoutStore } from "./dockLayoutStore";
+import { PANEL_DEFINITIONS, isPanelId, panelsInZone } from "./panelRegistry";
+
+/** Panel menu, maximise and close group, drawn on the active group's strip only. */
+export function DockStripActions({
+ api,
+ containerApi,
+ panels,
+ isGroupActive,
+}: IDockviewHeaderActionsProps) {
+ const subscribe = useCallback(
+ (onChange: () => void) => {
+ const subscription = containerApi.onDidMaximizedGroupChange(onChange);
+ return () => subscription.dispose();
+ },
+ [containerApi],
+ );
+ const maximized = useSyncExternalStore(subscribe, () => api.isMaximized());
+ const openPanels = useDockLayoutStore((state) => state.openPanels);
+ const togglePanel = useDockLayoutStore((state) => state.togglePanel);
+ const resetLayout = useDockLayoutStore((state) => state.resetLayout);
+ if (!isGroupActive) return null;
+
+ const first = panels.find((panel) => isPanelId(panel.id))?.id;
+ const menuPanels = isPanelId(first) ? panelsInZone(PANEL_DEFINITIONS[first].zone) : [];
+ return (
+ <div className="hf-dock-strip-actions">
+ <Menu
+ align="end"
+ aria-label="Panel menu"
+ trigger={<IconButton size="sm" aria-label="Panel menu" icon={<DotsThree size={16} />} />}
+ >
+ {menuPanels.map((id) => (
+ <MenuCheckboxItem
+ key={id}
+ checked={openPanels.has(id)}
+ onCheckedChange={() => togglePanel(id)}
+ >
+ {PANEL_DEFINITIONS[id].title}
+ </MenuCheckboxItem>
+ ))}
+ <MenuSeparator />
+ <MenuItem onClick={resetLayout}>Reset layout</MenuItem>
+ </Menu>
+ <IconButton
+ size="sm"
+ aria-label={maximized ? "Restore panel" : "Maximize panel"}
+ icon={maximized ? <CornersIn size={16} /> : <CornersOut size={16} />}
+ onClick={() => (maximized ? api.exitMaximized() : api.maximize())}
+ />
+ <IconButton
+ size="sm"
+ aria-label="Close group"
+ icon={<X size={16} />}
+ onClick={() => api.close()}
+ />
+ </div>
+ );
+}
diff --git a/packages/studio/src/components/dock/DockTab.tsx b/packages/studio/src/components/dock/DockTab.tsx
new file mode 100644
index 0000000000..2de514c929
--- /dev/null
+++ b/packages/studio/src/components/dock/DockTab.tsx
@@ -0,0 +1,68 @@
+import { useCallback, useSyncExternalStore } from "react";
+import {
+ BracketsCurly,
+ ChartBarHorizontal,
+ Code,
+ FilmSlate,
+ Image,
+ Layout,
+ Monitor,
+ Presentation,
+ SlidersHorizontal,
+ SquaresFour,
+ Stack,
+ X,
+ type Icon,
+} from "@phosphor-icons/react";
+import type { IDockviewPanelHeaderProps } from "dockview-react";
+import { isPanelId, type PanelId } from "./panelRegistry";
+
+const TAB_ICONS: Record<PanelId, Icon> = {
+ preview: Monitor,
+ timeline: ChartBarHorizontal,
+ compositions: Layout,
+ assets: Image,
+ code: Code,
+ catalog: SquaresFour,
+ design: SlidersHorizontal,
+ layers: Stack,
+ renders: FilmSlate,
+ variables: BracketsCurly,
+ slideshow: Presentation,
+};
+
+/**
+ * A dock tab. dock.css shows the type icon and close glyph on the shown tab only, keyed on
+ * dockview's own tab class, so they swap in the frame the tab changes rather than a render later.
+ */
+export function DockTab({ api }: IDockviewPanelHeaderProps) {
+ const subscribe = useCallback(
+ (onChange: () => void) => {
+ const subscription = api.onDidTitleChange(onChange);
+ return () => subscription.dispose();
+ },
+ [api],
+ );
+ const title = useSyncExternalStore(subscribe, () => api.title ?? "");
+ const TypeIcon = isPanelId(api.id) ? TAB_ICONS[api.id] : null;
+ return (
+ <div className="hf-dock-tab">
+ {TypeIcon ? <TypeIcon className="hf-dock-tab-icon" size={14} aria-hidden /> : null}
+ <span className="hf-dock-tab-label">{title}</span>
+ {/* Same shape as dockview's own close control: a tab cannot hold a focusable button. */}
+ <div
+ role="button"
+ tabIndex={-1}
+ aria-label={`Close ${title}`}
+ className="hf-dock-tab-close"
+ onPointerDown={(event) => event.stopPropagation()}
+ onClick={(event) => {
+ event.stopPropagation();
+ api.close();
+ }}
+ >
+ <X size={12} aria-hidden />
+ </div>
+ </div>
+ );
+}
diff --git a/packages/studio/src/components/dock/DockTabs.test.tsx b/packages/studio/src/components/dock/DockTabs.test.tsx
new file mode 100644
index 0000000000..58c53c86e9
--- /dev/null
+++ b/packages/studio/src/components/dock/DockTabs.test.tsx
@@ -0,0 +1,255 @@
+// @vitest-environment happy-dom
+
+import { readFileSync } from "node:fs";
+import path from "node:path";
+import { act } from "react";
+import { createRoot, type Root } from "react-dom/client";
+import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
+import { Dock } from "./Dock";
+import { useDockLayoutStore } from "./dockLayoutStore";
+import { PANEL_IDS, type PanelId } from "./panelRegistry";
+
+(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+// happy-dom never resizes anything; a test calls `resizeAll` to stand in for a real resize.
+const liveObservers = new Set<ResizeObserverStub>();
+class ResizeObserverStub {
+ readonly callback: () => void;
+ constructor(callback: () => void) {
+ this.callback = callback;
+ liveObservers.add(this);
+ }
+ observe() {}
+ unobserve() {}
+ disconnect() {
+ liveObservers.delete(this);
+ }
+}
+const resizeAll = () => {
+ for (const observer of liveObservers) observer.callback();
+};
+(globalThis as unknown as { ResizeObserver: unknown }).ResizeObserver = ResizeObserverStub;
+
+// happy-dom has no layout: a tab sits at 100px per position and is 90px wide.
+const TAB_STEP = 100;
+const TAB_WIDTH = 90;
+const tabIndex = (element: HTMLElement) =>
+ element.classList.contains("dv-tab")
+ ? [...(element.parentElement?.querySelectorAll(":scope > .dv-tab") ?? [])].indexOf(element)
+ : -1;
+const layout = {
+ offsetLeft: {
+ get(this: HTMLElement) {
+ return Math.max(tabIndex(this), 0) * TAB_STEP;
+ },
+ },
+ offsetWidth: {
+ get(this: HTMLElement) {
+ return tabIndex(this) >= 0 ? TAB_WIDTH : 0;
+ },
+ },
+};
+const original = {
+ offsetLeft: Object.getOwnPropertyDescriptor(HTMLElement.prototype, "offsetLeft"),
+ offsetWidth: Object.getOwnPropertyDescriptor(HTMLElement.prototype, "offsetWidth"),
+};
+beforeAll(() => {
+ // The shown-tab-only rule lives in dock.css; apply it so computed display is what a user sees.
+ const style = document.createElement("style");
+ style.textContent = readFileSync(path.join(import.meta.dirname, "dock.css"), "utf8").replace(
+ /@import[^;]*;/,
+ "",
+ );
+ document.head.append(style);
+ Object.defineProperties(HTMLElement.prototype, {
+ offsetLeft: { ...layout.offsetLeft, configurable: true },
+ offsetWidth: { ...layout.offsetWidth, configurable: true },
+ });
+});
+afterAll(() => {
+ for (const [key, descriptor] of Object.entries(original)) {
+ if (descriptor) Object.defineProperty(HTMLElement.prototype, key, descriptor);
+ }
+});
+
+let root: Root | null = null;
+let host: HTMLElement;
+
+beforeEach(() => {
+ localStorage.clear();
+ vi.useFakeTimers();
+ host = document.createElement("div");
+ document.body.append(host);
+ root = createRoot(host);
+ act(() => {
+ root?.render(
+ <Dock.Root projectId="p1">
+ {PANEL_IDS.map((id) => (
+ <Dock.Panel key={id} id={id}>
+ <div>{id}</div>
+ </Dock.Panel>
+ ))}
+ </Dock.Root>,
+ );
+ });
+});
+
+afterEach(() => {
+ act(() => root?.unmount());
+ root = null;
+ document.body.innerHTML = "";
+ vi.useRealTimers();
+});
+
+const tab = (id: PanelId) => host.querySelector<HTMLElement>(`[data-tab-panel-id="${id}"]`);
+const stripOf = (id: PanelId) => tab(id)?.closest<HTMLElement>(".dv-tabs-container");
+const groupOf = (id: PanelId) => tab(id)?.closest<HTMLElement>(".dv-groupview");
+const shows = (id: PanelId, part: "icon" | "close") => {
+ const element = tab(id)?.querySelector(`.hf-dock-tab-${part}`);
+ return element ? getComputedStyle(element).display !== "none" : false;
+};
+
+async function activate(id: PanelId) {
+ // dockview settles the active panel on a microtask; `act(async)` waits for it.
+ await act(async () => useDockLayoutStore.getState().activatePanel(id));
+}
+
+describe("dock tabs", () => {
+ it("draw the type icon and close glyph on the shown tab only", () => {
+ for (const id of ["design", "compositions"] as const) {
+ expect(shows(id, "icon")).toBe(true);
+ expect(shows(id, "close")).toBe(true);
+ }
+ for (const id of ["layers", "renders", "variables", "assets", "code", "catalog"] as const) {
+ expect(shows(id, "icon")).toBe(false);
+ expect(shows(id, "close")).toBe(false);
+ }
+ });
+
+ it("move the icon to the newly shown tab and drop it from the old one", async () => {
+ await activate("layers");
+ expect(shows("layers", "icon")).toBe(true);
+ expect(shows("design", "icon")).toBe(false);
+ expect(shows("design", "close")).toBe(false);
+ });
+
+ it("name the close control after the panel, and close only that panel", async () => {
+ const close = tab("design")?.querySelector<HTMLElement>(".hf-dock-tab-close");
+ expect(close?.getAttribute("aria-label")).toBe("Close Design");
+ await act(async () => close?.click());
+ expect(useDockLayoutStore.getState().openPanels.has("design")).toBe(false);
+ expect(useDockLayoutStore.getState().openPanels.has("layers")).toBe(true);
+ });
+});
+
+describe("dock strip actions", () => {
+ const groupsWithActions = () =>
+ [...host.querySelectorAll(".hf-dock-strip-actions")].map((actions) =>
+ actions.closest(".dv-groupview"),
+ );
+
+ it("sit on the active group's strip only, and follow the active group", async () => {
+ await activate("design");
+ expect(groupsWithActions()).toEqual([groupOf("design")]);
+ const labels = [...host.querySelectorAll(".hf-dock-strip-actions button")].map((button) =>
+ button.getAttribute("aria-label"),
+ );
+ expect(labels).toEqual(["Panel menu", "Maximize panel", "Close group"]);
+ await activate("assets");
+ expect(groupsWithActions()).toEqual([groupOf("assets")]);
+ });
+});
+
+describe("dock tab fill", () => {
+ it("is one element per strip, under the shown tab, and follows a switch", async () => {
+ for (const strip of host.querySelectorAll(".dv-tabs-container")) {
+ expect(strip.querySelectorAll(".hf-dock-tab-fill")).toHaveLength(1);
+ }
+ const fill = () => stripOf("design")?.querySelector<HTMLElement>(".hf-dock-tab-fill");
+ expect(fill()?.style.transform).toBe("translateX(0px)");
+ expect(fill()?.style.width).toBe(`${TAB_WIDTH}px`);
+ await activate("renders");
+ expect(stripOf("design")?.querySelectorAll(".hf-dock-tab-fill")).toHaveLength(1);
+ expect(fill()?.style.transform).toBe(`translateX(${2 * TAB_STEP}px)`);
+ });
+
+ it("keeps the shown tab whole when its strip narrows, as when the strip's actions appear", async () => {
+ const strip = stripOf("design");
+ if (!strip) throw new Error("no design strip");
+ await activate("variables");
+ // The four tabs fit, so the strip is unscrolled; then it narrows to two and a half tabs.
+ strip.scrollLeft = 0;
+ Object.defineProperty(strip, "clientWidth", { value: 1000, configurable: true });
+ act(() => resizeAll());
+ Object.defineProperty(strip, "clientWidth", { value: 250, configurable: true });
+ act(() => resizeAll());
+ expect(strip.scrollLeft).toBe(3 * TAB_STEP + TAB_WIDTH + 1 - 250);
+ });
+
+ it("leaves a strip the user scrolled alone when something else in the dock changes", async () => {
+ const strip = stripOf("design");
+ if (!strip) throw new Error("no design strip");
+ await activate("variables");
+ Object.defineProperty(strip, "clientWidth", { value: 250, configurable: true });
+ act(() => resizeAll());
+ // Scrolled back by hand to look at the first tabs, then another group takes focus.
+ strip.scrollLeft = 0;
+ await activate("assets");
+ act(() => resizeAll());
+ expect(strip.scrollLeft).toBe(0);
+ });
+
+ it("keeps a hand scroll through another group being maximised and restored", async () => {
+ const strip = stripOf("design");
+ if (!strip) throw new Error("no design strip");
+ await activate("variables");
+ Object.defineProperty(strip, "clientWidth", { value: 250, configurable: true });
+ act(() => resizeAll());
+ strip.scrollLeft = 0;
+ // Hidden while another group is maximised; the browser keeps a hidden strip's scroll.
+ Object.defineProperty(strip, "clientWidth", { value: 0, configurable: true });
+ act(() => resizeAll());
+ Object.defineProperty(strip, "clientWidth", { value: 250, configurable: true });
+ act(() => resizeAll());
+ expect(strip.scrollLeft).toBe(0);
+ });
+
+ it("leaves a hand scroll alone when its strip widens", async () => {
+ const strip = stripOf("design");
+ if (!strip) throw new Error("no design strip");
+ await activate("variables");
+ Object.defineProperty(strip, "clientWidth", { value: 150, configurable: true });
+ act(() => resizeAll());
+ strip.scrollLeft = 0;
+ // Wider, but the shown tab is still out of view where the user left the strip.
+ Object.defineProperty(strip, "clientWidth", { value: 200, configurable: true });
+ act(() => resizeAll());
+ expect(strip.scrollLeft).toBe(0);
+ });
+
+ it("reveals the shown tab when its strip comes back narrower than it left", async () => {
+ const strip = stripOf("design");
+ if (!strip) throw new Error("no design strip");
+ await activate("variables");
+ strip.scrollLeft = 0;
+ Object.defineProperty(strip, "clientWidth", { value: 1000, configurable: true });
+ act(() => resizeAll());
+ Object.defineProperty(strip, "clientWidth", { value: 0, configurable: true });
+ act(() => resizeAll());
+ Object.defineProperty(strip, "clientWidth", { value: 250, configurable: true });
+ act(() => resizeAll());
+ expect(strip.scrollLeft).toBe(3 * TAB_STEP + TAB_WIDTH + 1 - 250);
+ });
+
+ it("reveals the shown tab when a panel beside it closes and it moves", async () => {
+ const strip = stripOf("design");
+ if (!strip) throw new Error("no design strip");
+ await activate("variables");
+ Object.defineProperty(strip, "clientWidth", { value: 150, configurable: true });
+ act(() => resizeAll());
+ strip.scrollLeft = 0;
+ await act(async () => useDockLayoutStore.getState().togglePanel("design"));
+ // Variables moved from the fourth place to the third; its right edge is at 290.
+ expect(strip.scrollLeft).toBe(2 * TAB_STEP + TAB_WIDTH + 1 - 150);
+ });
+});
diff --git a/packages/studio/src/components/dock/dock.css b/packages/studio/src/components/dock/dock.css
index 82c64404e8..23a7f940b2 100644
--- a/packages/studio/src/components/dock/dock.css
+++ b/packages/studio/src/components/dock/dock.css
@@ -1,28 +1,197 @@
@import "dockview-react/dist/styles/dockview.css";
.hf-dock {
- --dv-group-view-background-color: var(--color-panel-bg);
- --dv-tabs-and-actions-container-background-color: var(--color-panel-surface);
- --dv-activegroup-visiblepanel-tab-background-color: var(--color-panel-bg);
- --dv-activegroup-hiddenpanel-tab-background-color: var(--color-panel-surface);
- --dv-inactivegroup-visiblepanel-tab-background-color: var(--color-panel-bg);
- --dv-inactivegroup-hiddenpanel-tab-background-color: var(--color-panel-surface);
- --dv-activegroup-visiblepanel-tab-color: var(--color-panel-text-1);
- --dv-activegroup-hiddenpanel-tab-color: var(--color-panel-text-3);
- --dv-inactivegroup-visiblepanel-tab-color: var(--color-panel-text-2);
- --dv-inactivegroup-hiddenpanel-tab-color: var(--color-panel-text-4);
- --dv-tab-divider-color: var(--color-panel-border);
- --dv-separator-border: var(--color-panel-border);
- --dv-paneview-header-border-color: var(--color-panel-border);
- --dv-sash-color: var(--color-panel-hover);
+ --dv-group-view-background-color: var(--panel-card-bg);
+ --dv-tabs-and-actions-container-background-color: var(--panel-strip-bg);
+ --dv-tabs-and-actions-container-height: 36px;
+ /* The fill paints the shown tab, so every tab state is transparent. */
+ --dv-activegroup-visiblepanel-tab-background-color: transparent;
+ --dv-activegroup-hiddenpanel-tab-background-color: transparent;
+ --dv-inactivegroup-visiblepanel-tab-background-color: transparent;
+ --dv-inactivegroup-hiddenpanel-tab-background-color: transparent;
+ --dv-activegroup-visiblepanel-tab-color: var(--color-text-1);
+ --dv-activegroup-hiddenpanel-tab-color: var(--color-text-2);
+ --dv-inactivegroup-visiblepanel-tab-color: var(--color-text-1);
+ --dv-inactivegroup-hiddenpanel-tab-color: var(--color-text-2);
+ --dv-tab-divider-color: transparent;
+ --dv-tab-margin: 0;
+ --dv-separator-border: transparent;
+ --dv-paneview-header-border-color: transparent;
+ --dv-sash-color: transparent;
--dv-active-sash-color: var(--color-panel-accent);
--dv-drag-over-background-color: color-mix(in srgb, var(--color-panel-accent) 12%, transparent);
--dv-drag-over-border-color: var(--color-panel-accent);
- --dv-tab-font-size: 11px;
- --dv-tabs-and-actions-container-font-size: 11px;
+ --dv-tab-font-size: 12.5px;
+ --dv-tabs-and-actions-container-font-size: 12.5px;
+ background-color: var(--panel-shell-bg);
}
.hf-dock .dv-sash:focus-visible {
background-color: var(--dv-active-sash-color);
outline: none;
}
+
+.hf-dock .dv-dockview {
+ background-color: var(--panel-shell-bg);
+}
+
+/* Cards on the shell: 3px around each group's view makes a 6px gutter. The card owns the only border. */
+.hf-dock .dv-view:has(> .dv-groupview) {
+ box-sizing: border-box;
+ padding: 3px;
+}
+
+.hf-dock .dv-groupview {
+ border: 1px solid var(--panel-card-border);
+ border-radius: 10px;
+}
+
+.hf-dock .dv-tabs-and-actions-container {
+ align-items: flex-end;
+ padding: 6px 0 0 4px;
+}
+
+.hf-dock .dv-scrollable {
+ height: 30px;
+ min-width: 0;
+}
+
+/* dockview's own scrollbar lane; the strip scrolls by wheel and keeps the shown tab in view. */
+.hf-dock .dv-scrollbar {
+ display: none;
+}
+
+.hf-dock .dv-tabs-container {
+ --hf-fade-start: 0px;
+ --hf-fade-end: 0px;
+}
+
+/* A mask adds a compositor render pass; only a strip that is actually clipped needs one. */
+.hf-dock .dv-tabs-container[data-clipped] {
+ mask-image: linear-gradient(
+ to right,
+ transparent,
+ black var(--hf-fade-start),
+ black calc(100% - var(--hf-fade-end)),
+ transparent
+ );
+}
+
+.hf-dock .dv-tabs-container[data-clipped~="start"] {
+ --hf-fade-start: 12px;
+}
+
+.hf-dock .dv-tabs-container[data-clipped~="end"] {
+ --hf-fade-end: 12px;
+}
+
+.hf-dock .dv-tab {
+ z-index: 1;
+ display: flex;
+ align-items: center;
+ height: 30px;
+ padding: 0 6px;
+ border-radius: 6px 6px 0 0;
+ white-space: nowrap;
+}
+
+/* dockview's own state rule paints tabs from these variables, so hover sets them. */
+.hf-dock .dv-tab.dv-inactive-tab:hover {
+ --dv-activegroup-hiddenpanel-tab-background-color: var(--panel-tab-bg-hover);
+ --dv-inactivegroup-hiddenpanel-tab-background-color: var(--panel-tab-bg-hover);
+ --dv-activegroup-hiddenpanel-tab-color: var(--color-text-1);
+ --dv-inactivegroup-hiddenpanel-tab-color: var(--color-text-1);
+}
+
+.hf-dock .dv-tab:focus-visible {
+ outline: 1.5px solid var(--color-accent);
+ outline-offset: -1.5px;
+}
+
+.hf-dock .dv-tab:focus-visible::after,
+.hf-dock .dv-tab:has(:focus-visible)::after {
+ outline: none !important;
+}
+
+.hf-dock-tab-fill {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ height: 30px;
+ border-radius: 6px 6px 0 0;
+ background-color: var(--panel-card-bg);
+ pointer-events: none;
+}
+
+.hf-dock-tab-fill[data-ready] {
+ transition:
+ transform 140ms ease-out,
+ width 140ms ease-out;
+}
+
+/* Fills dockview's tab part, so the label and icon centre in the tab's full height. */
+.hf-dock-tab {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ height: 100%;
+}
+
+.hf-dock .dv-inactive-tab .hf-dock-tab-icon,
+.hf-dock .dv-inactive-tab .hf-dock-tab-close {
+ display: none;
+}
+
+.hf-dock-tab-icon {
+ flex: none;
+ animation: hf-dock-tab-icon-in 80ms ease-out;
+}
+
+@keyframes hf-dock-tab-icon-in {
+ from {
+ opacity: 0;
+ transform: translateX(-2px);
+ }
+}
+
+/* Takes its space whenever the tab is shown, so hover never moves the label. */
+.hf-dock-tab-close {
+ display: flex;
+ opacity: 0;
+}
+
+.dv-tab:hover .hf-dock-tab-close,
+.dv-tab:focus-visible .hf-dock-tab-close {
+ opacity: 1;
+}
+
+/* Sized by the actions it draws, so a strip without them gives its tabs the whole width. */
+.hf-dock .dv-right-actions-container {
+ flex: none;
+ align-self: flex-start;
+}
+
+.hf-dock-strip-actions {
+ display: flex;
+ margin-right: 4px;
+ opacity: 0;
+}
+
+.dv-groupview:hover .hf-dock-strip-actions {
+ opacity: 0.5;
+}
+
+.hf-dock-strip-actions:hover,
+.hf-dock-strip-actions:focus-within {
+ opacity: 1;
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .hf-dock-tab-fill[data-ready] {
+ transition: none;
+ }
+
+ .hf-dock-tab-icon {
+ animation: none;
+ }
+}
diff --git a/packages/studio/src/components/dock/dockTabFill.ts b/packages/studio/src/components/dock/dockTabFill.ts
new file mode 100644
index 0000000000..b35062b4ac
--- /dev/null
+++ b/packages/studio/src/components/dock/dockTabFill.ts
@@ -0,0 +1,124 @@
+import type { DockviewApi } from "dockview-react";
+
+const TAB_FILL_CLASS = "hf-dock-tab-fill";
+
+/** The strip's one fill, created on first use. Dockview inserts tabs before tabs, so it stays first. */
+function fillOf(list: HTMLElement): HTMLElement {
+ const existing = list.querySelector<HTMLElement>(`:scope > .${TAB_FILL_CLASS}`);
+ if (existing) return existing;
+ const fill = document.createElement("span");
+ fill.className = TAB_FILL_CLASS;
+ fill.setAttribute("aria-hidden", "true");
+ list.prepend(fill);
+ // Placed once without motion; only later moves slide.
+ requestAnimationFrame(() => fill.setAttribute("data-ready", ""));
+ return fill;
+}
+
+/** A strip's width and where its shown tab sits, as of the last pass. */
+type StripShape = { width: number; tab: HTMLElement | null; left: number; size: number };
+
+/**
+ * True when the strip narrowed or its shown tab moved or resized since it was last visible. dockview
+ * reveals a tab only when it is activated, and the user's own scrolling changes none of these.
+ */
+function reshaped(before: StripShape | undefined, now: StripShape) {
+ if (!before || now.width === 0) return false;
+ if (now.width < before.width) return true;
+ return now.tab !== before.tab || now.left !== before.left || now.size !== before.size;
+}
+
+/** The scroll that shows the whole shown tab, e.g. after the strip narrows because its actions appeared. */
+function revealedScroll(shape: StripShape, scrollLeft: number) {
+ if (shape.left < scrollLeft) return shape.left;
+ // Offset sizes are rounded while the tab's edge is fractional; a pixel over is clamped at the end.
+ return Math.max(scrollLeft, shape.left + shape.size + 1 - shape.width);
+}
+
+/** Reads where the shown tab sits; the write happens after every strip is read, so layout runs once. */
+function measureFill(list: HTMLElement, shapes: WeakMap<HTMLElement, StripShape>): () => void {
+ const fill = fillOf(list);
+ const tab = list.querySelector<HTMLElement>(":scope > .dv-active-tab");
+ const shape = {
+ width: list.clientWidth,
+ tab,
+ left: tab?.offsetLeft ?? 0,
+ size: tab?.offsetWidth ?? 0,
+ };
+ const reveal = tab !== null && reshaped(shapes.get(list), shape);
+ // A hidden strip (another group maximised) keeps its scroll, so it is compared with its last visible shape.
+ if (shape.width > 0) shapes.set(list, shape);
+ const scrollLeft = list.scrollLeft;
+ const target = reveal ? revealedScroll(shape, scrollLeft) : scrollLeft;
+ return () => {
+ fill.hidden = !tab;
+ if (!tab) return;
+ fill.style.width = `${shape.size}px`;
+ fill.style.transform = `translateX(${shape.left}px)`;
+ if (target !== scrollLeft) list.scrollLeft = target;
+ };
+}
+
+/** Marks which edges of a scrolled strip are clipped, for the CSS edge fade. */
+function markClippedEdges(list: HTMLElement) {
+ const edges = [];
+ if (list.scrollLeft > 0) edges.push("start");
+ if (list.scrollLeft + list.clientWidth < list.scrollWidth - 1) edges.push("end");
+ const value = edges.join(" ");
+ if (value) list.setAttribute("data-clipped", value);
+ else list.removeAttribute("data-clipped");
+}
+
+/**
+ * Slides one fill per tab strip under its shown tab, keeps that tab in view, and keeps the
+ * clipped-edge marks current.
+ * Returns a disposer.
+ */
+export function installTabFill(api: DockviewApi, root: HTMLElement): () => void {
+ const lists = () => root.querySelectorAll<HTMLElement>(".dv-tabs-container");
+ // Tab widths also change with no dockview event: a renamed title, a late web font.
+ const resizeObserver = new ResizeObserver(() => placeAll());
+ const observed = new Set<Element>();
+ function observe(elements: Iterable<Element>) {
+ for (const element of observed) {
+ if (element.isConnected) continue;
+ resizeObserver.unobserve(element);
+ observed.delete(element);
+ }
+ for (const element of elements) {
+ if (observed.has(element)) continue;
+ resizeObserver.observe(element);
+ observed.add(element);
+ }
+ }
+ const shapes = new WeakMap<HTMLElement, StripShape>();
+ function placeAll() {
+ const strips = [...lists()];
+ const writes = strips.map((list) => measureFill(list, shapes));
+ for (const write of writes) write();
+ for (const list of strips) markClippedEdges(list);
+ observe(strips.flatMap((list) => [list, ...list.querySelectorAll(":scope > .dv-tab")]));
+ }
+ const onScroll = (event: Event) => {
+ const list = event.target;
+ if (list instanceof HTMLElement && list.classList.contains("dv-tabs-container")) {
+ markClippedEdges(list);
+ }
+ };
+ const subscriptions = [
+ api.onDidActivePanelChange(placeAll),
+ api.onDidAddPanel(placeAll),
+ api.onDidRemovePanel(placeAll),
+ api.onDidMovePanel(placeAll),
+ api.onDidLayoutChange(placeAll),
+ api.onDidLayoutFromJSON(placeAll),
+ ];
+ // Scroll does not bubble; a capturing listener still sees every strip's.
+ root.addEventListener("scroll", onScroll, true);
+ placeAll();
+ return () => {
+ root.removeEventListener("scroll", onScroll, true);
+ for (const subscription of subscriptions) subscription.dispose();
+ resizeObserver.disconnect();
+ };
+}
diff --git a/packages/studio/src/components/dock/dockTabs.contract.test.ts b/packages/studio/src/components/dock/dockTabs.contract.test.ts
new file mode 100644
index 0000000000..4f1c866d79
--- /dev/null
+++ b/packages/studio/src/components/dock/dockTabs.contract.test.ts
@@ -0,0 +1,80 @@
+import { readFileSync } from "node:fs";
+import path from "node:path";
+import { describe, expect, it } from "vitest";
+
+const dockCss = readFileSync(path.join(import.meta.dirname, "dock.css"), "utf8").replace(
+ /@import[^;]*;/,
+ "",
+);
+
+/** Each top-level rule's selector and body, with the reduced-motion block kept whole. */
+function rules(css: string): { selector: string; body: string }[] {
+ const found: { selector: string; body: string }[] = [];
+ let depth = 0;
+ let start = 0;
+ let selector = "";
+ for (let index = 0; index < css.length; index++) {
+ if (css[index] === "{") {
+ if (depth === 0) {
+ selector = css
+ .slice(start, index)
+ .replace(/\/\*[\s\S]*?\*\//g, "")
+ .trim();
+ start = index + 1;
+ }
+ depth++;
+ } else if (css[index] === "}") {
+ depth--;
+ if (depth === 0) {
+ found.push({ selector, body: css.slice(start, index) });
+ start = index + 1;
+ }
+ }
+ }
+ return found;
+}
+
+const bodyOf = (selector: string) =>
+ rules(dockCss).find((rule) => rule.selector === selector)?.body;
+
+describe("dock panel strip contract", () => {
+ it("draws one border per surface: the card's, and no divider, separator or tab outline", () => {
+ const bordered = rules(dockCss)
+ .filter((rule) => /(^|[\s;{])border(-(top|right|bottom|left))?\s*:/.test(rule.body))
+ .map((rule) => rule.selector);
+ expect(bordered).toEqual([".hf-dock .dv-groupview"]);
+ const dock = bodyOf(".hf-dock");
+ expect(dock).toContain("--dv-tab-divider-color: transparent");
+ expect(dock).toContain("--dv-separator-border: transparent");
+ });
+
+ it("slides only transform and width, 140ms ease-out, and reveals the icon in 80ms", () => {
+ expect(bodyOf(".hf-dock-tab-fill[data-ready]")?.replace(/\s+/g, " ").trim()).toBe(
+ "transition: transform 140ms ease-out, width 140ms ease-out;",
+ );
+ expect(bodyOf(".hf-dock-tab-icon")).toContain("animation: hf-dock-tab-icon-in 80ms ease-out");
+ const animated = rules(dockCss).filter(
+ (rule) => !rule.selector.startsWith("@") && /transition|animation/.test(rule.body),
+ );
+ expect(animated.map((rule) => rule.selector)).toEqual([
+ ".hf-dock-tab-fill[data-ready]",
+ ".hf-dock-tab-icon",
+ ]);
+ });
+
+ it("turns the slide and the icon reveal off under reduced motion", () => {
+ const reduced = bodyOf("@media (prefers-reduced-motion: reduce)")?.replace(/\s+/g, " ");
+ expect(reduced).toContain(".hf-dock-tab-fill[data-ready] { transition: none; }");
+ expect(reduced).toContain(".hf-dock-tab-icon { animation: none; }");
+ });
+
+ it("centres the tab's icon and label in the tab's full height", () => {
+ const tab = bodyOf(".hf-dock-tab");
+ expect(tab).toContain("height: 100%");
+ expect(tab).toContain("align-items: center");
+ });
+
+ it("takes every colour from a token", () => {
+ expect(dockCss).not.toMatch(/#[0-9a-f]{3,8}\b|rgba?\(|hsla?\(|oklch\(/i);
+ });
+});
diff --git a/packages/studio/src/components/nle/PreviewPane.tsx b/packages/studio/src/components/nle/PreviewPane.tsx
index 6f8bd7c10b..775a508081 100644
--- a/packages/studio/src/components/nle/PreviewPane.tsx
+++ b/packages/studio/src/components/nle/PreviewPane.tsx
@@ -115,10 +115,10 @@ export function PreviewPane({
return (
<div
ref={containerRef}
- // Panel chrome (rounded border) is dropped in fullscreen so the preview
- // fills the screen edge-to-edge.
+ // A recessed well inset in its dock card; dropped in fullscreen so the
+ // preview fills the screen edge-to-edge.
className={`flex-1 min-h-0 flex flex-col overflow-hidden bg-[var(--studio-preview-bg,var(--color-neutral-950))] ${
- isFullscreen ? "" : "rounded-lg border border-neutral-800/50"
+ isFullscreen ? "" : "m-3 rounded-md border border-neutral-800/50"
}`}
data-studio-fullscreen-target=""
>
diff --git a/packages/studio/src/components/nle/TimelinePane.tsx b/packages/studio/src/components/nle/TimelinePane.tsx
index f08c29615f..196e98b837 100644
--- a/packages/studio/src/components/nle/TimelinePane.tsx
+++ b/packages/studio/src/components/nle/TimelinePane.tsx
@@ -85,7 +85,7 @@ export function TimelinePane({
aria-disabled={timelineDisabled || undefined}
>
<div
- className="flex flex-col flex-1 min-h-0 overflow-hidden rounded-lg border border-neutral-800/50 bg-neutral-950"
+ className="flex flex-col flex-1 min-h-0 overflow-hidden"
onDoubleClick={(e) => {
if ((e.target as HTMLElement).closest("[data-clip]")) return;
if (timelineDisabled) return;
diff --git a/packages/studio/src/components/ui/Menu.tsx b/packages/studio/src/components/ui/Menu.tsx
index a0b36d54b9..b4e22b6007 100644
--- a/packages/studio/src/components/ui/Menu.tsx
+++ b/packages/studio/src/components/ui/Menu.tsx
@@ -220,6 +220,22 @@ export function MenuRadioItem({ className, children, ...props }: MenuRadioItemPr
);
}
+/** An on/off row; the tick renders only while `checked`. */
+export function MenuCheckboxItem({
+ className,
+ children,
+ ...props
+}: StyledProps<typeof BaseMenu.CheckboxItem>) {
+ return (
+ <BaseMenu.CheckboxItem className={cn(itemBase, className)} {...props}>
+ <span className="truncate">{children}</span>
+ <span className="flex size-3 shrink-0 items-center justify-center text-accent">
+ <BaseMenu.CheckboxItemIndicator>✓</BaseMenu.CheckboxItemIndicator>
+ </span>
+ </BaseMenu.CheckboxItem>
+ );
+}
+
/** A hairline between two groups of items. */
export function MenuSeparator({ className, ...props }: StyledProps<typeof BaseMenu.Separator>) {
return <BaseMenu.Separator className={cn("my-1 h-px bg-hairline", className)} {...props} />;
diff --git a/packages/studio/src/components/ui/index.ts b/packages/studio/src/components/ui/index.ts
index e9f4936e8e..aac1aa360f 100644
--- a/packages/studio/src/components/ui/index.ts
+++ b/packages/studio/src/components/ui/index.ts
@@ -11,6 +11,7 @@ export { Tooltip } from "./Tooltip";
export {
ContextMenu,
Menu,
+ MenuCheckboxItem,
MenuItem,
MenuRadioGroup,
MenuRadioItem,
diff --git a/packages/studio/src/styles/theme.css b/packages/studio/src/styles/theme.css
index 102c0272fb..6c91815b4c 100644
--- a/packages/studio/src/styles/theme.css
+++ b/packages/studio/src/styles/theme.css
@@ -273,6 +273,14 @@
--color-panel-media: var(--color-media);
--color-panel-container: var(--color-container);
+ /* Dock panels are cards on the shell. The card owns the only border; its tab
+ * strip sits below the card body and the shown tab is a fill in the body colour. */
+ --panel-shell-bg: var(--color-bg-1);
+ --panel-card-bg: var(--color-surface);
+ --panel-card-border: #303034;
+ --panel-strip-bg: var(--color-bg-0);
+ --panel-tab-bg-hover: #202023;
+
/* Names Studio's markup invented that no config ever defined, so the classes
* compiled to nothing. Aliased to the token that was meant, rather than
* given values of their own, so there is still one source per decision.
diff --git a/scripts/contrast-pairs.json b/scripts/contrast-pairs.json
index c695cb7015..49d13dccc5 100644
--- a/scripts/contrast-pairs.json
+++ b/scripts/contrast-pairs.json
@@ -270,6 +270,39 @@
],
"opacity": 0.64,
"format": "rgb-channels"
+ },
+ {
+ "id": "dock-tab-label",
+ "foreground": "--color-text-2",
+ "background": ["--panel-strip-bg"],
+ "role": "text",
+ "minimum": 4.5,
+ "sources": [
+ "packages/studio/src/components/dock/dock.css:13",
+ "packages/studio/src/components/dock/dock.css:15"
+ ]
+ },
+ {
+ "id": "dock-shown-tab-label",
+ "foreground": "--color-text-1",
+ "background": ["--panel-card-bg"],
+ "role": "text",
+ "minimum": 4.5,
+ "sources": [
+ "packages/studio/src/components/dock/dock.css:12",
+ "packages/studio/src/components/dock/dock.css:14"
+ ]
+ },
+ {
+ "id": "dock-hovered-tab-label",
+ "foreground": "--color-text-1",
+ "background": ["--panel-strip-bg", "--panel-tab-bg-hover"],
+ "role": "text",
+ "minimum": 4.5,
+ "sources": [
+ "packages/studio/src/components/dock/dock.css:100",
+ "packages/studio/src/components/dock/dock.css:102"
+ ]
}
]
},
diff --git a/scripts/studio-runtime-smoke.mjs b/scripts/studio-runtime-smoke.mjs
index a30edda022..dc56bf532d 100644
--- a/scripts/studio-runtime-smoke.mjs
+++ b/scripts/studio-runtime-smoke.mjs
@@ -97,6 +97,51 @@ export function studioSmokeApiResponse(method, requestUrl) {
return pathname.startsWith("/api/") ? studioSmokeApiPathResponse(method, pathname) : undefined;
}
+// CI renders Studio's system font stack with Linux's fallback, which sets the default tab labels
+// about 10px narrower than macOS does; keep that much room so a strip that fits here fits on a Mac.
+const MAC_FONT_ALLOWANCE_PX = 10;
+
+/** Runs in the page: the active group's tabs, plus the allowance, must fit before its actions. */
+function clippedStrip(allowance) {
+ const strip = document.querySelector(".dv-groupview.dv-active-group .dv-tabs-container");
+ if (!strip) return "no active dock strip";
+ const actions = strip
+ .closest(".dv-tabs-and-actions-container")
+ ?.querySelector(".dv-right-actions-container");
+ const room =
+ (actions?.getBoundingClientRect().left ?? Infinity) - strip.getBoundingClientRect().left;
+ if (strip.scrollWidth + allowance <= room) return null;
+ const labels = [...strip.querySelectorAll(".dv-tab")].map((tab) => tab.textContent);
+ return `${labels.join(", ")}: ${strip.scrollWidth}px of tabs in ${Math.floor(room)}px`;
+}
+
+/** Every dock strip gives its tabs the whole width it can, and fits them while its group is active. */
+async function dockStripErrors(page) {
+ const found = [];
+ const reservedSlots = await page.$$eval(
+ ".dv-groupview.dv-inactive-group .dv-right-actions-container",
+ (slots) => slots.filter((slot) => slot.getBoundingClientRect().width > 0).length,
+ );
+ if (reservedSlots > 0) {
+ found.push(`${reservedSlots} inactive dock strips hold width for actions they do not draw`);
+ }
+ const shownTabs = await page.$$(".dv-tabs-container .dv-active-tab");
+ for (const tab of shownTabs) {
+ // An active group draws its strip actions, so this is the least room its tabs get.
+ await tab.click();
+ await page.evaluate(
+ () => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve))),
+ );
+ const clipped = await page.evaluate(clippedStrip, MAC_FONT_ALLOWANCE_PX);
+ if (clipped) {
+ found.push(
+ `Dock tab strip clips a label at the default layout (${MAC_FONT_ALLOWANCE_PX}px macOS allowance): ${clipped}`,
+ );
+ }
+ }
+ return found;
+}
+
export function isExpectedStudioSmokeError(message) {
return message.includes("favicon.ico");
}
@@ -113,6 +158,8 @@ export async function runStudioRuntimeSmoke(targetUrl) {
args: ["--no-sandbox", "--disable-setuid-sandbox"],
});
const page = await browser.newPage();
+ // Studio's default layout is sized for a laptop window; the tab-strip check below depends on it.
+ await page.setViewport({ width: 1440, height: 900 });
const errors = [];
const unmockedApiRequests = [];
@@ -143,6 +190,7 @@ export async function runStudioRuntimeSmoke(targetUrl) {
return textContent.includes("Something went wrong") ? textContent : null;
});
if (errorBoundary) errors.push(`React error boundary triggered: ${errorBoundary}`);
+ errors.push(...(await dockStripErrors(page)));
} finally {
await browser.close();
}