Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-8776 fix(desktop): align title-bar actions with the page column, merge the issue window header into the traffic-light row (#10128)

Jiayuan Zhang98bd2628b660
diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts
index 9a1d4efb8f..ccedabf32a 100644
--- a/apps/desktop/src/main/index.ts
+++ b/apps/desktop/src/main/index.ts
@@ -604,6 +604,8 @@ function createIssueWindow(context: IssueWindowContext): void {
minHeight: 520,
title: context.title,
titleBarStyle: "hiddenInset",
+ // Center the native controls in the issue page's 48px header, which is
+ // this window's title bar.
trafficLightPosition: { x: 16, y: 17 },
show: false,
autoHideMenuBar: true,
diff --git a/apps/desktop/src/renderer/src/components/desktop-layout.tsx b/apps/desktop/src/renderer/src/components/desktop-layout.tsx
index 64b123fafe..c725778e30 100644
--- a/apps/desktop/src/renderer/src/components/desktop-layout.tsx
+++ b/apps/desktop/src/renderer/src/components/desktop-layout.tsx
@@ -101,10 +101,13 @@ function MainTopBar({ railMounted }: { railMounted: boolean }) {
>
<TabBar />
</div>
+ {/* pr-6 is the canvas's mr-2 plus the page header's PAGE_GUTTER (px-4),
+ and gap-1 is the page header's action gap, so each icon here stands
+ on the same column as a trailing icon of the page header below. */}
{railMounted && (
<div
data-slot="title-bar-actions"
- className="relative z-10 ml-auto flex shrink-0 items-center gap-2 pr-3"
+ className="relative z-10 ml-auto flex shrink-0 items-center gap-1 pr-6"
style={{ WebkitAppRegion: "no-drag" } as React.CSSProperties}
>
<NewIssueButton className={TITLE_BAR_ACTION_CLASS} tooltipSide="bottom" />
diff --git a/apps/desktop/src/renderer/src/components/issue-window.test.tsx b/apps/desktop/src/renderer/src/components/issue-window.test.tsx
index 25bba32450..3e878850e0 100644
--- a/apps/desktop/src/renderer/src/components/issue-window.test.tsx
+++ b/apps/desktop/src/renderer/src/components/issue-window.test.tsx
@@ -47,7 +47,18 @@ vi.mock("@multica/views/layout", () => ({
}));
vi.mock("@multica/views/platform", () => ({
- DragStrip: () => null,
+ DragStrip: () => <div data-testid="drag-strip" />,
+ WindowTitleBarProvider: ({
+ value,
+ children,
+ }: {
+ value: { leadingInset: number } | null;
+ children: React.ReactNode;
+ }) => (
+ <div data-testid="title-bar-scope" data-leading-inset={value?.leadingInset ?? ""}>
+ {children}
+ </div>
+ ),
}));
vi.mock("../pages/issue-detail-page", () => ({
@@ -121,4 +132,23 @@ describe("IssueWindow", () => {
expect(state.refetch).toHaveBeenCalledOnce();
expect(screen.queryByTestId("workspace-loading")).toBeNull();
});
+
+ it("lets the issue header be the title bar instead of stacking a drag strip over it", async () => {
+ state.ready = true;
+ state.workspaces = [{ id: "ws-1", slug: "acme" }];
+
+ render(<IssueWindow context={context} />);
+
+ expect(await screen.findByTestId("issue-detail")).toBeInTheDocument();
+ expect(screen.queryByTestId("drag-strip")).toBeNull();
+ expect(screen.getByTestId("title-bar-scope")).toHaveAttribute("data-leading-inset", "88");
+ });
+
+ it("keeps the drag strip for states that have no page header", async () => {
+ render(<IssueWindow context={context} />);
+
+ expect(await screen.findByTestId("workspace-loading")).toBeInTheDocument();
+ expect(screen.getByTestId("drag-strip")).toBeInTheDocument();
+ expect(screen.getByTestId("title-bar-scope")).toHaveAttribute("data-leading-inset", "");
+ });
});
diff --git a/apps/desktop/src/renderer/src/components/issue-window.tsx b/apps/desktop/src/renderer/src/components/issue-window.tsx
index 567c393a9e..a1872f1db9 100644
--- a/apps/desktop/src/renderer/src/components/issue-window.tsx
+++ b/apps/desktop/src/renderer/src/components/issue-window.tsx
@@ -14,11 +14,12 @@ import { Button } from "@multica/ui/components/ui/button";
import { MulticaIcon } from "@multica/ui/components/common/multica-icon";
import { ModalRegistry } from "@multica/views/modals/registry";
import { WorkspacePresencePrefetch } from "@multica/views/layout";
-import { DragStrip } from "@multica/views/platform";
+import { DragStrip, WindowTitleBarProvider } from "@multica/views/platform";
import type { IssueWindowContext } from "../../../shared/issue-window";
import { DesktopAuthRecoveryPage } from "../pages/auth-recovery";
import { IssueDetailPage } from "../pages/issue-detail-page";
import { IssueWindowNavigationProvider } from "../platform/issue-window-navigation";
+import { TRAFFIC_LIGHT_CLEARANCE } from "./window-toolbar";
export function IssueWindow({ context }: { context: IssueWindowContext }) {
const router = useMemo(
@@ -81,7 +82,7 @@ function IssueWindowRoute() {
<WorkspaceSlugProvider slug={workspaceSlug}>
<IssueWindowNavigationProvider>
<WorkspacePresencePrefetch />
- <IssueWindowFrame>
+ <IssueWindowFrame pageOwnsTitleBar>
<IssueDetailPage onDelete={() => window.desktopAPI.closeWindow()} />
</IssueWindowFrame>
<ModalRegistry />
@@ -90,14 +91,27 @@ function IssueWindowRoute() {
);
}
-function IssueWindowFrame({ children }: { children: React.ReactNode }) {
+const ISSUE_WINDOW_TITLE_BAR = { leadingInset: TRAFFIC_LIGHT_CLEARANCE };
+
+// The issue page's 48px header is the title bar: trafficLightPosition centres
+// the lights on it, so stacking a separate drag strip above it would leave
+// the lights alone in an empty row. States with no page header keep the strip.
+function IssueWindowFrame({
+ children,
+ pageOwnsTitleBar = false,
+}: {
+ children: React.ReactNode;
+ pageOwnsTitleBar?: boolean;
+}) {
return (
<div
data-dedicated-issue-window="true"
className="flex h-screen min-h-0 flex-col bg-page-canvas text-foreground"
>
- <DragStrip />
- <div className="flex min-h-0 flex-1 overflow-hidden">{children}</div>
+ {!pageOwnsTitleBar && <DragStrip />}
+ <WindowTitleBarProvider value={pageOwnsTitleBar ? ISSUE_WINDOW_TITLE_BAR : null}>
+ <div className="flex min-h-0 flex-1 overflow-hidden">{children}</div>
+ </WindowTitleBarProvider>
</div>
);
}
diff --git a/apps/desktop/src/renderer/src/components/window-toolbar.tsx b/apps/desktop/src/renderer/src/components/window-toolbar.tsx
index e1c47b2970..1df0127c46 100644
--- a/apps/desktop/src/renderer/src/components/window-toolbar.tsx
+++ b/apps/desktop/src/renderer/src/components/window-toolbar.tsx
@@ -36,7 +36,7 @@ import { browsingHistoryKeyForUrl } from "@/stores/tab-store";
// inset plus Back, Forward and the panel toggle (3 × 28px, 2 × 8px gaps) and
// a 12px trailing pad. It spans the rail and the start of the tab bar, which
// pads itself past it.
-const TRAFFIC_LIGHT_CLEARANCE = 88;
+export const TRAFFIC_LIGHT_CLEARANCE = 88;
export const WINDOW_TOOLBAR_CLEARANCE = 200;
const LONG_PRESS_DURATION_MS = 500;
const LONG_PRESS_MOVE_TOLERANCE_PX = 8;
diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsx
index 79a3b90f01..24c037df46 100644
--- a/packages/views/issues/components/issue-detail.tsx
+++ b/packages/views/issues/components/issue-detail.tsx
@@ -182,7 +182,7 @@ import {
import { cn } from "@multica/ui/lib/utils";
import { TruncatedTooltip } from "@multica/ui/components/common/truncated-tooltip";
import { CollectionPageState } from "../../layout/collection-page";
-import { PAGE_GUTTER } from "../../layout/page-header";
+import { PAGE_GUTTER, usePageHeaderTitleBar } from "../../layout/page-header";
import { useShowInSidebar } from "../../layout/panels/show-in-sidebar";
import { ProgressRing } from "./progress-ring";
@@ -1203,6 +1203,23 @@ interface IssueDetailProps {
skipInitialRefetch?: boolean;
}
+/**
+ * The header row a loading or failed detail shows where the breadcrumb goes,
+ * at the same height, so the page does not jump when the issue lands.
+ */
+function DetailStateBar({ children, trailing }: { children?: ReactNode; trailing?: ReactNode }) {
+ const titleBar = usePageHeaderTitleBar();
+ return (
+ <div
+ className={cn("flex h-12 shrink-0 items-center gap-2 border-b", PAGE_GUTTER, titleBar.className)}
+ style={titleBar.style}
+ >
+ {children}
+ {trailing && <div className="ml-auto flex shrink-0 items-center gap-1">{trailing}</div>}
+ </div>
+ );
+}
+
// Not found
/**
@@ -1230,14 +1247,12 @@ export function IssueNotFound({
const { t } = useT("issues");
const backOrReplace = useBackOrReplace();
const paths = useWorkspacePaths();
+ const titleBar = usePageHeaderTitleBar();
return (
<div className="flex flex-1 min-h-0 flex-col">
- {(leading || trailing) && (
- <div className={cn("flex h-12 shrink-0 items-center gap-2 border-b", PAGE_GUTTER)}>
- {leading}
- {trailing && <div className="ml-auto flex shrink-0 items-center gap-1">{trailing}</div>}
- </div>
+ {(leading || trailing || titleBar.active) && (
+ <DetailStateBar trailing={trailing}>{leading}</DetailStateBar>
)}
<CollectionPageState
icon={FileQuestion}
@@ -1273,14 +1288,12 @@ export function IssueLoadError({
const { t } = useT("issues");
const backOrReplace = useBackOrReplace();
const paths = useWorkspacePaths();
+ const titleBar = usePageHeaderTitleBar();
return (
<div className="flex flex-1 min-h-0 flex-col">
- {(leading || trailing) && (
- <div className={cn("flex h-12 shrink-0 items-center gap-2 border-b", PAGE_GUTTER)}>
- {leading}
- {trailing && <div className="ml-auto flex shrink-0 items-center gap-1">{trailing}</div>}
- </div>
+ {(leading || trailing || titleBar.active) && (
+ <DetailStateBar trailing={trailing}>{leading}</DetailStateBar>
)}
<CollectionPageState
icon={AlertTriangle}
@@ -1321,7 +1334,7 @@ export function IssueDetailSkeleton({
{/* The way back is real from the first frame, not once the issue lands:
a host that gave up its own bar for `leadingAction` has nothing else
to offer while this skeleton owns the screen. */}
- <div className={cn("flex h-12 shrink-0 items-center gap-2 border-b", PAGE_GUTTER)}>
+ <DetailStateBar trailing={trailing}>
{leading ?? (
<>
<Skeleton className="h-4 w-16" />
@@ -1329,8 +1342,7 @@ export function IssueDetailSkeleton({
<Skeleton className="h-4 w-24" />
</>
)}
- {trailing && <div className="ml-auto flex shrink-0 items-center gap-1">{trailing}</div>}
- </div>
+ </DetailStateBar>
<div className="flex flex-1 min-h-0">
{/* Same scrollbar-gutter as the loaded scroller below, so the skeleton
column doesn't shift sideways when real content mounts. */}
@@ -4167,8 +4179,9 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
onResize={handleDesktopSidebarResize}
>
{/* Sections inset their own bodies and rows, so the panel itself only
- needs a narrow gutter. */}
- <AnimatedRightSidebar open={desktopSidebarVisualOpen} motionEnabled={desktopSidebarMotionEnabled} contentClassName="px-2 py-4">
+ needs a narrow gutter. pt-2.5 centres the first 28px section
+ header on the 48px page header beside it. */}
+ <AnimatedRightSidebar open={desktopSidebarVisualOpen} motionEnabled={desktopSidebarMotionEnabled} contentClassName="px-2 pt-2.5 pb-4">
{sidebarContent}
</AnimatedRightSidebar>
</ResizablePanel>
diff --git a/packages/views/issues/components/issue-peek.tsx b/packages/views/issues/components/issue-peek.tsx
index 73fbf54071..af801ce844 100644
--- a/packages/views/issues/components/issue-peek.tsx
+++ b/packages/views/issues/components/issue-peek.tsx
@@ -22,6 +22,7 @@ import {
import { isImeComposing } from "@multica/core/utils";
import { AppLink } from "../../navigation";
import { PAGE_GUTTER } from "../../layout/page-header";
+import { WindowTitleBarProvider } from "../../platform/window-title-bar";
import { ShortcutKeycaps } from "../../common/shortcut-keycaps";
import { useT } from "../../i18n";
import { IssueDetail } from "./issue-detail";
@@ -153,6 +154,10 @@ const IssuePeekPanel = memo(function IssuePeekPanel({ issueId }: { issueId: stri
// Stops above the chat launcher, which owns the dashboard's
// bottom-right corner — the panel's composer would sit under it.
"above-chat-launcher",
+ // Floats over the top of the page, which may be the window's drag
+ // region (the Desktop issue window); without this, its header's
+ // controls would move the window instead of taking the click.
+ "[-webkit-app-region:no-drag]",
!isPresent && "pointer-events-none",
)}
// Slides in from the edge it is anchored to; the exit is shorter and
@@ -170,31 +175,33 @@ const IssuePeekPanel = memo(function IssuePeekPanel({ issueId }: { issueId: stri
}}
>
{isPresent && <IssuePeekFollow issueId={issueId} panelRef={panelRef} />}
- <ErrorBoundary
- resetKeys={[issueId]}
- // The default fallback is a bare message card; here it would be a
- // panel with no way to close it but Esc.
- fallback={({ error }) => (
- <div className="flex flex-1 min-h-0 flex-col">
- <div className={cn("flex h-12 shrink-0 items-center justify-end gap-1 border-b", PAGE_GUTTER)}>
- <IssuePeekTrailingActions issueId={issueId} />
+ <WindowTitleBarProvider value={null}>
+ <ErrorBoundary
+ resetKeys={[issueId]}
+ // The default fallback is a bare message card; here it would be a
+ // panel with no way to close it but Esc.
+ fallback={({ error }) => (
+ <div className="flex flex-1 min-h-0 flex-col">
+ <div className={cn("flex h-12 shrink-0 items-center justify-end gap-1 border-b", PAGE_GUTTER)}>
+ <IssuePeekTrailingActions issueId={issueId} />
+ </div>
+ <div className="flex flex-1 min-h-0 items-center justify-center px-4 text-center text-body text-muted-foreground">
+ {error.message}
+ </div>
</div>
- <div className="flex flex-1 min-h-0 items-center justify-center px-4 text-center text-body text-muted-foreground">
- {error.message}
- </div>
- </div>
- )}
- >
- <IssueDetail
- key={issueId}
- issueId={issueId}
- variant="peek"
- defaultSidebarOpen={false}
- leadingAction={<IssuePeekNav />}
- trailingActions={<IssuePeekTrailingActions issueId={issueId} />}
- onDelete={actions.close}
- />
- </ErrorBoundary>
+ )}
+ >
+ <IssueDetail
+ key={issueId}
+ issueId={issueId}
+ variant="peek"
+ defaultSidebarOpen={false}
+ leadingAction={<IssuePeekNav />}
+ trailingActions={<IssuePeekTrailingActions issueId={issueId} />}
+ onDelete={actions.close}
+ />
+ </ErrorBoundary>
+ </WindowTitleBarProvider>
</motion.aside>
);
});
diff --git a/packages/views/issues/components/issue-sidebar-section.tsx b/packages/views/issues/components/issue-sidebar-section.tsx
index 9bb1e01c86..4bad1eebfb 100644
--- a/packages/views/issues/components/issue-sidebar-section.tsx
+++ b/packages/views/issues/components/issue-sidebar-section.tsx
@@ -5,7 +5,13 @@ import { ChevronRight } from "@multica/ui/icons";
import { Button, buttonVariants } from "@multica/ui/components/ui/button";
import { cn } from "@multica/ui/lib/utils";
-/** Shared disclosure header; actions stay outside the disclosure button. */
+/**
+ * Shared disclosure header; actions stay outside the disclosure button.
+ *
+ * Inset like a `PropRow` (`px-2` around an 8px hit-area padding) so the title
+ * starts on the same edge as the labels and rows of every section body under
+ * it. The padding is 7px because `Button` adds a 1px transparent border.
+ */
export function IssueSidebarSectionHeader({
title, open, onOpenChange, count, actions, status, id, collapsible = true,
}: {
@@ -19,7 +25,7 @@ export function IssueSidebarSectionHeader({
id?: string;
}) {
return (
- <div className="mb-1 flex min-w-0 items-center gap-1">
+ <div className="mb-1 flex min-w-0 items-center gap-1 px-2">
{collapsible ? <Button
id={id}
type="button"
@@ -27,7 +33,7 @@ export function IssueSidebarSectionHeader({
size="sm"
aria-expanded={open}
onClick={() => onOpenChange(!open)}
- className={cn("min-w-0 flex-1 shrink justify-start font-medium aria-expanded:bg-transparent active:not-aria-[haspopup]:translate-y-0", !open && "text-muted-foreground")}
+ className={cn("min-w-0 flex-1 shrink justify-start px-[7px] font-medium aria-expanded:bg-transparent active:not-aria-[haspopup]:translate-y-0", !open && "text-muted-foreground")}
>
<span className="truncate">{title}</span>
<ChevronRight aria-hidden="true" className={cn("!size-3 shrink-0 text-faint-foreground transition-transform motion-reduce:transition-none", open && "rotate-90")} />
@@ -38,7 +44,7 @@ export function IssueSidebarSectionHeader({
</>
)}
</Button> : (
- <div id={id} className={cn(buttonVariants({ variant: "ghost", size: "sm" }), "min-w-0 flex-1 shrink justify-start font-medium hover:bg-transparent dark:hover:bg-transparent")}>
+ <div id={id} className={cn(buttonVariants({ variant: "ghost", size: "sm" }), "min-w-0 flex-1 shrink justify-start px-[7px] font-medium hover:bg-transparent dark:hover:bg-transparent")}>
<span className="truncate">{title}</span>
</div>
)}
diff --git a/packages/views/layout/page-header.test.tsx b/packages/views/layout/page-header.test.tsx
index a7bc94bcc7..741d27bf6a 100644
--- a/packages/views/layout/page-header.test.tsx
+++ b/packages/views/layout/page-header.test.tsx
@@ -10,6 +10,10 @@ import {
CollectionPageHeader,
} from "./collection-page";
import { CollapsedNavTrigger, PAGE_GUTTER, PageHeader } from "./page-header";
+import {
+ WINDOW_TITLE_BAR_CLASS,
+ WindowTitleBarProvider,
+} from "../platform/window-title-bar";
const navigation = vi.hoisted(() => ({ pathname: "/acme/issues" }));
vi.mock("../navigation", async (importOriginal) => ({
@@ -110,6 +114,35 @@ describe("PageHeader base chrome", () => {
expect(container.querySelector("[data-slot='sidebar-trigger']")).toBeNull();
});
+ // A frameless window (the Desktop issue window) hands its title bar to the
+ // page header, which then has to clear the native window controls and
+ // carve its controls out of the drag region.
+ it("becomes the window's title bar under a WindowTitleBarProvider", () => {
+ const header = renderHeader(
+ <WindowTitleBarProvider value={{ leadingInset: 88 }}>
+ <PageHeader>
+ <h1>MUL-1</h1>
+ </PageHeader>
+ </WindowTitleBarProvider>,
+ );
+
+ expect(header.style.paddingLeft).toBe("88px");
+ expect(header).toHaveClass(WINDOW_TITLE_BAR_CLASS);
+ });
+
+ it("stays a plain header where the window has its own title bar", () => {
+ const header = renderHeader(
+ <WindowTitleBarProvider value={null}>
+ <PageHeader>
+ <h1>MUL-1</h1>
+ </PageHeader>
+ </WindowTitleBarProvider>,
+ );
+
+ expect(header.style.paddingLeft).toBe("");
+ expect(header).not.toHaveClass(WINDOW_TITLE_BAR_CLASS);
+ });
+
// Outside a `SidebarProvider` there is no nav to reopen at all.
it("renders nothing when no sidebar is mounted", () => {
const { container } = renderWithI18n(<CollapsedNavTrigger />);
diff --git a/packages/views/layout/page-header.tsx b/packages/views/layout/page-header.tsx
index 14302f9459..8f0e5c0ca7 100644
--- a/packages/views/layout/page-header.tsx
+++ b/packages/views/layout/page-header.tsx
@@ -1,8 +1,14 @@
"use client";
+import type { CSSProperties } from "react";
import { cn } from "@multica/ui/lib/utils";
import { SidebarTrigger, useSidebarSafe } from "@multica/ui/components/ui/sidebar";
import { ActionShortcutKeycaps } from "../common/shortcut-keycaps";
+import {
+ useWindowTitleBar,
+ WINDOW_TITLE_BAR_CLASS,
+ windowTitleBarStyle,
+} from "../platform/window-title-bar";
import { useAppShell } from "./app-shell-context";
/**
@@ -94,6 +100,30 @@ export function CollapsedNavTrigger() {
);
}
+/**
+ * What a page's top row needs when the window has no title bar of its own
+ * (see `WindowTitleBarProvider`): the drag region, and a leading inset past
+ * the native window controls. Empty everywhere else.
+ *
+ * `PageHeader` applies it itself. A surface that draws its own header-shaped
+ * row in that slot (a loading or error state standing in for the page) spreads
+ * it too, and renders the row even when it has nothing to put in it, so the
+ * window stays draggable whichever state is on screen.
+ */
+export function usePageHeaderTitleBar(): {
+ active: boolean;
+ className?: string;
+ style?: CSSProperties;
+} {
+ const titleBar = useWindowTitleBar();
+ if (!titleBar) return { active: false };
+ return {
+ active: true,
+ className: WINDOW_TITLE_BAR_CLASS,
+ style: windowTitleBarStyle(titleBar),
+ };
+}
+
interface PageHeaderProps {
children: React.ReactNode;
/**
@@ -128,13 +158,16 @@ interface PageHeaderProps {
* every page, and the toolbar beneath the header reads the same constant.
*/
export function PageHeader({ children, leading, className }: PageHeaderProps) {
+ const titleBar = usePageHeaderTitleBar();
return (
<header
className={cn(
"flex h-12 shrink-0 items-center gap-2 border-b",
className,
PAGE_GUTTER,
+ titleBar.className,
)}
+ style={titleBar.style}
>
{leading ?? <CollapsedNavTrigger />}
{children}
diff --git a/packages/views/platform/index.ts b/packages/views/platform/index.ts
index d113fdfb96..5b3cb29c6c 100644
--- a/packages/views/platform/index.ts
+++ b/packages/views/platform/index.ts
@@ -1,6 +1,13 @@
export { useImmersiveMode } from "./use-immersive-mode";
export { useDesktopUnreadBadge } from "./use-desktop-unread-badge";
export { DragStrip } from "./drag-strip";
+export {
+ WindowTitleBarProvider,
+ useWindowTitleBar,
+ WINDOW_TITLE_BAR_CLASS,
+ windowTitleBarStyle,
+ type WindowTitleBar,
+} from "./window-title-bar";
export { openExternal } from "./open-external";
export {
isDesktopShell,
diff --git a/packages/views/platform/window-title-bar.tsx b/packages/views/platform/window-title-bar.tsx
new file mode 100644
index 0000000000..6663de4064
--- /dev/null
+++ b/packages/views/platform/window-title-bar.tsx
@@ -0,0 +1,50 @@
+"use client";
+
+import { createContext, useContext, type CSSProperties, type ReactNode } from "react";
+
+/**
+ * Set by a frameless window whose page header is its title bar: the Desktop
+ * issue window, where a separate empty strip above the header would spend a
+ * second 48px row on chrome and never line up with the traffic lights.
+ *
+ * `leadingInset` is the room the native window controls take at the start of
+ * the row. Anything that floats over the top of the page instead of starting
+ * it (the side peek) resets this to `null`, so its own header stays a header.
+ */
+export interface WindowTitleBar {
+ leadingInset: number;
+}
+
+const WindowTitleBarContext = createContext<WindowTitleBar | null>(null);
+
+export function WindowTitleBarProvider({
+ value,
+ children,
+}: {
+ value: WindowTitleBar | null;
+ children: ReactNode;
+}) {
+ return (
+ <WindowTitleBarContext.Provider value={value}>
+ {children}
+ </WindowTitleBarContext.Provider>
+ );
+}
+
+export function useWindowTitleBar(): WindowTitleBar | null {
+ return useContext(WindowTitleBarContext);
+}
+
+/**
+ * Turns a header row into the window's drag region. Every control inside has
+ * to opt back out, or a click on it moves the window instead.
+ */
+export const WINDOW_TITLE_BAR_CLASS =
+ "[&_:is(a,button,input,textarea,select,[role=button],[contenteditable=true])]:[-webkit-app-region:no-drag]";
+
+export function windowTitleBarStyle(titleBar: WindowTitleBar): CSSProperties {
+ return {
+ WebkitAppRegion: "drag",
+ paddingLeft: titleBar.leadingInset,
+ } as CSSProperties;
+}