Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

Add integrated top bar on desktop (#8114)

James Brunton298b92f3e687
diff --git a/frontend/editor/src-tauri/src/commands/mod.rs b/frontend/editor/src-tauri/src/commands/mod.rs
index 5e2da45176..ad985f716e 100644
--- a/frontend/editor/src-tauri/src/commands/mod.rs
+++ b/frontend/editor/src-tauri/src/commands/mod.rs
@@ -17,6 +17,7 @@ pub use files::{
};
pub use watcher::{release_window_watches, unwatch_disk_paths, watch_disk_paths};
pub use window::{
+ build_main_window,
forward_files_to_window,
open_files_in_new_window,
open_in_new_window,
diff --git a/frontend/editor/src-tauri/src/commands/window.rs b/frontend/editor/src-tauri/src/commands/window.rs
index e1275db717..261205569d 100644
--- a/frontend/editor/src-tauri/src/commands/window.rs
+++ b/frontend/editor/src-tauri/src/commands/window.rs
@@ -27,6 +27,43 @@ fn queue_file_ids(label: &str, ids: Vec<String>) {
map.entry(label.to_string()).or_default().extend(ids);
}
+// macOS traffic-light inset, vertically centred in the frontend title-bar strip.
+// Must track the strip height in TitleBarStrip.module.css (--titlebar-h); kept in
+// Rust, not tauri.conf.json, so the value lives with the window builders.
+#[cfg(target_os = "macos")]
+const TRAFFIC_LIGHT_INSET: (f64, f64) = (13.0, 18.0);
+
+// The main window, built here rather than declared in tauri.conf.json so its
+// chrome (decorations, the macOS overlay title bar, the traffic-light inset)
+// sits beside the spawned-window chrome instead of split across a config file.
+// OS drag-drop is disabled; the frontend handles file drops itself.
+pub fn build_main_window(app: &AppHandle) -> Result<WebviewWindow, String> {
+ let builder = WebviewWindowBuilder::new(app, MAIN_WINDOW_LABEL, WebviewUrl::App("/".into()))
+ .title("Stirling PDF")
+ .inner_size(1280.0, 800.0)
+ // Below this width the file manager collapses to its mobile layout, so
+ // keep the window above the breakpoint (matches the spawned windows).
+ .min_inner_size(1030.0, 600.0)
+ .resizable(true)
+ .disable_drag_drop_handler();
+
+ #[cfg(target_os = "windows")]
+ let builder = builder
+ .additional_browser_args("--enable-features=CertVerifierBuiltinFeature")
+ .decorations(false);
+
+ #[cfg(target_os = "macos")]
+ let builder = builder
+ .title_bar_style(tauri::TitleBarStyle::Overlay)
+ .hidden_title(true)
+ .traffic_light_position(tauri::LogicalPosition::new(
+ TRAFFIC_LIGHT_INSET.0,
+ TRAFFIC_LIGHT_INSET.1,
+ ));
+
+ builder.build().map_err(|e| e.to_string())
+}
+
// Shared window builder: every Stirling window must use identical WebView2
// browser args so they can share one user-data folder (see the note below),
// so all spawn paths funnel through here.
@@ -50,10 +87,23 @@ fn build_window(app: &AppHandle, label: &str, url: &str) -> Result<WebviewWindow
#[cfg(target_os = "windows")]
let builder = builder
.additional_browser_args("--enable-features=CertVerifierBuiltinFeature")
- // Windows: no native title bar; the frontend draws its own (WindowTitleBar).
- // macOS/Linux keep native decorations.
+ // Windows: no native title bar; the frontend draws its own controls in
+ // the title-bar strip (TitleBarStrip). macOS uses the overlay style below.
.decorations(false);
+ // macOS: keep the native frame but make the title bar an overlay so the
+ // frontend strip spans under the traffic lights, positioned to sit centred in
+ // the strip (matches the main window in tauri.conf.json). Linux keeps its
+ // native decorations.
+ #[cfg(target_os = "macos")]
+ let builder = builder
+ .title_bar_style(tauri::TitleBarStyle::Overlay)
+ .hidden_title(true)
+ .traffic_light_position(tauri::LogicalPosition::new(
+ TRAFFIC_LIGHT_INSET.0,
+ TRAFFIC_LIGHT_INSET.1,
+ ));
+
builder.build().map_err(|e| e.to_string())
}
diff --git a/frontend/editor/src-tauri/src/lib.rs b/frontend/editor/src-tauri/src/lib.rs
index 8e410cc084..bdb28f5cac 100644
--- a/frontend/editor/src-tauri/src/lib.rs
+++ b/frontend/editor/src-tauri/src/lib.rs
@@ -49,6 +49,7 @@ use commands::{
get_app_version,
restart_app,
target_window_label,
+ build_main_window,
MAIN_WINDOW_LABEL,
};
use commands::connection::apply_provisioning_if_present;
@@ -152,15 +153,15 @@ pub fn run() {
.setup(|app| {
add_log("πŸš€ Tauri app setup started".to_string());
- // Windows: drop the native title bar so the in-app custom title bar
- // (window controls + drag region) takes over. Runtime toggle because the
- // main window is defined in tauri.conf.json; spawned windows set it at
- // build time in window.rs. macOS/Linux keep their native decorations.
- #[cfg(target_os = "windows")]
- {
- if let Some(window) = app.get_webview_window(MAIN_WINDOW_LABEL) {
- let _ = window.set_decorations(false);
- }
+ // The main window is built here, not in tauri.conf.json, so its chrome
+ // (decorations, macOS overlay title bar, traffic-light inset) lives with
+ // the spawned-window chrome in window.rs. Created first so the deep-link
+ // and file-open handling below can target it.
+ if let Err(err) = build_main_window(app.handle()) {
+ add_log(format!("❌ Failed to build main window: {}", err));
+ // No fallback window exists, so abort startup rather than run headless
+ // (on frameless Windows a windowless app has no way to be closed).
+ return Err(err.into());
}
// Files passed on the command line at first launch load into the main
diff --git a/frontend/editor/src-tauri/tauri.conf.json b/frontend/editor/src-tauri/tauri.conf.json
index 212b22cc0c..5999737e92 100644
--- a/frontend/editor/src-tauri/tauri.conf.json
+++ b/frontend/editor/src-tauri/tauri.conf.json
@@ -1,5 +1,5 @@
{
- "$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
+ "$schema": "../../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "Stirling PDF",
"mainBinaryName": "Stirling-PDF",
"version": "3.0.0",
@@ -11,17 +11,7 @@
"beforeBuildCommand": "npx vite build --mode desktop"
},
"app": {
- "windows": [
- {
- "title": "Stirling PDF",
- "width": 1280,
- "height": 800,
- "resizable": true,
- "fullscreen": false,
- "dragDropEnabled": false,
- "additionalBrowserArgs": "--enable-features=CertVerifierBuiltinFeature"
- }
- ]
+ "windows": []
},
"bundle": {
"active": true,
diff --git a/frontend/editor/src/core/components/AppLayout.tsx b/frontend/editor/src/core/components/AppLayout.tsx
index 881285c5a8..34f93bedd5 100644
--- a/frontend/editor/src/core/components/AppLayout.tsx
+++ b/frontend/editor/src/core/components/AppLayout.tsx
@@ -1,6 +1,7 @@
import { ReactNode } from "react";
import { useBanner } from "@app/contexts/BannerContext";
import NavigationWarningModal from "@app/components/shared/NavigationWarningModal";
+import { TitleBarSearch } from "@app/components/layout/TitleBarSearch";
interface AppLayoutProps {
children: ReactNode;
@@ -21,11 +22,18 @@ export function AppLayout({ children }: AppLayoutProps) {
}
`}</style>
<div
- style={{ height: "100dvh", display: "flex", flexDirection: "column" }}
+ style={{
+ height: "var(--titlebar-body-h, 100dvh)",
+ display: "flex",
+ flexDirection: "column",
+ }}
>
{banner}
<div style={{ flex: 1, minHeight: 0, height: 0 }}>{children}</div>
</div>
+ {/* Portals Super Search into the title-bar strip when a layer provides one;
+ otherwise renders nothing. Kept here so it stays mounted across views. */}
+ <TitleBarSearch />
<NavigationWarningModal />
</>
);
diff --git a/frontend/editor/src/core/components/layout/AppFrame.tsx b/frontend/editor/src/core/components/layout/AppFrame.tsx
index 38fa92ecba..699c024b6c 100644
--- a/frontend/editor/src/core/components/layout/AppFrame.tsx
+++ b/frontend/editor/src/core/components/layout/AppFrame.tsx
@@ -3,20 +3,23 @@ import { Outlet } from "react-router-dom";
import { LoadingFallback } from "@app/components/shared/LoadingFallback";
import { QuickNavHostProvider } from "@app/contexts/QuickNavHostContext";
import { QuickNavRailHost } from "@app/components/shared/quickNav/QuickNavRailHost";
+import { TitleBarChrome } from "@app/components/layout/TitleBarChrome";
import "@app/components/layout/AppFrame.css";
/** The rail renders once outside both apps; Suspense sits inside it, not above. */
export function AppFrame() {
return (
<QuickNavHostProvider>
- <div className="app-frame">
- <QuickNavRailHost />
- <div className="app-frame__content">
- <Suspense fallback={<LoadingFallback />}>
- <Outlet />
- </Suspense>
+ <TitleBarChrome>
+ <div className="app-frame">
+ <QuickNavRailHost />
+ <div className="app-frame__content">
+ <Suspense fallback={<LoadingFallback />}>
+ <Outlet />
+ </Suspense>
+ </div>
</div>
- </div>
+ </TitleBarChrome>
</QuickNavHostProvider>
);
}
diff --git a/frontend/editor/src/core/components/layout/TitleBarChrome.tsx b/frontend/editor/src/core/components/layout/TitleBarChrome.tsx
new file mode 100644
index 0000000000..a887872cdb
--- /dev/null
+++ b/frontend/editor/src/core/components/layout/TitleBarChrome.tsx
@@ -0,0 +1,10 @@
+import type { ReactNode } from "react";
+
+/**
+ * Extension point for an in-window title-bar strip. A layer that has one shadows
+ * this to render the strip above the app and supply its portal slots; the
+ * default renders the app body unchanged.
+ */
+export function TitleBarChrome({ children }: { children: ReactNode }) {
+ return <>{children}</>;
+}
diff --git a/frontend/editor/src/core/components/layout/TitleBarSearch.tsx b/frontend/editor/src/core/components/layout/TitleBarSearch.tsx
new file mode 100644
index 0000000000..0fd419e156
--- /dev/null
+++ b/frontend/editor/src/core/components/layout/TitleBarSearch.tsx
@@ -0,0 +1,8 @@
+/**
+ * Renders Super Search into the title-bar strip when a layer provides one; the
+ * default has no strip and renders nothing. A layer with a strip shadows this at
+ * the same @app path.
+ */
+export function TitleBarSearch() {
+ return null;
+}
diff --git a/frontend/editor/src/core/components/layout/Workbench.tsx b/frontend/editor/src/core/components/layout/Workbench.tsx
index 0686ccf6c7..df24c185cc 100644
--- a/frontend/editor/src/core/components/layout/Workbench.tsx
+++ b/frontend/editor/src/core/components/layout/Workbench.tsx
@@ -18,6 +18,7 @@ import styles from "@app/components/layout/Workbench.module.css";
import WorkbenchBar from "@app/components/shared/WorkbenchBar";
import { useWorkbenchTakeover } from "@app/components/layout/WorkbenchTakeover";
+import { useTitleBarStrip } from "@app/contexts/TitleBarStripContext";
import WorkbenchFloatingSearch from "@app/components/shared/WorkbenchFloatingSearch";
import LandingPage from "@app/components/shared/LandingPage";
import DismissAllErrorsButton from "@app/components/shared/DismissAllErrorsButton";
@@ -42,6 +43,7 @@ export default function Workbench() {
// A flow that owns the canvas outright (desktop onboarding's Downloads sweep).
// Null in every other case, which is every case in core.
const takeover = useWorkbenchTakeover();
+ const strip = useTitleBarStrip();
// Use context-based hooks to eliminate all prop drilling
const { files: activeFiles, fileIds } = useAllFiles();
@@ -97,7 +99,11 @@ export default function Workbench() {
const showWorkbenchBar =
topControlsAvailable && hasWorkbenchContent && !readerMode && !takeover;
const showFloatingSearch =
- topControlsAvailable && !hasWorkbenchContent && !readerMode && !takeover;
+ topControlsAvailable &&
+ !hasWorkbenchContent &&
+ !readerMode &&
+ !takeover &&
+ !strip.enabled;
// On the transition, so reading sets the toolbar's start state without locking it.
const prevReaderModeRef = useRef(readerMode);
diff --git a/frontend/editor/src/core/components/settings/useActiveHeading.ts b/frontend/editor/src/core/components/settings/useActiveHeading.ts
index d551a1a5ce..42fe494f3d 100644
--- a/frontend/editor/src/core/components/settings/useActiveHeading.ts
+++ b/frontend/editor/src/core/components/settings/useActiveHeading.ts
@@ -30,27 +30,45 @@ export function useActiveHeading(
// and overwrites the slug the reader just asked for.
const settleUntil = useRef(0);
- const focus = useCallback((id: string) => {
- const el = document.getElementById(id);
- if (!el) return;
- // Unfold first, or there is nothing to scroll to: the anchor is either a
- // folded card's own toggle, or a control inside its hidden panel.
- if (el.getAttribute("aria-expanded") === "false") {
- el.click();
- } else {
- el.closest(".settings-card__panel[hidden]")
- ?.parentElement?.querySelector<HTMLButtonElement>(
- ".settings-card__toggle",
- )
- ?.click();
- }
- settleUntil.current = Date.now() + SETTLE_MS;
- setActive(id);
- writeHash(id);
- el.scrollIntoView({ behavior: "smooth", block: "start" });
- el.classList.add("settings-focus-target");
- window.setTimeout(() => el.classList.remove("settings-focus-target"), 1800);
- }, []);
+ const focus = useCallback(
+ (id: string) => {
+ const el = document.getElementById(id);
+ if (!el) return;
+ // Unfold first, or there is nothing to scroll to: the anchor is either a
+ // folded card's own toggle, or a control inside its hidden panel.
+ if (el.getAttribute("aria-expanded") === "false") {
+ el.click();
+ } else {
+ el.closest(".settings-card__panel[hidden]")
+ ?.parentElement?.querySelector<HTMLButtonElement>(
+ ".settings-card__toggle",
+ )
+ ?.click();
+ }
+ settleUntil.current = Date.now() + SETTLE_MS;
+ setActive(id);
+ writeHash(id);
+ // Scroll the settings scroller itself, not scrollIntoView: that walks the
+ // whole ancestor chain and drags the app frame up under the title bar.
+ if (container) {
+ container.scrollTo({
+ top:
+ el.getBoundingClientRect().top -
+ container.getBoundingClientRect().top +
+ container.scrollTop,
+ behavior: "smooth",
+ });
+ } else {
+ el.scrollIntoView({ behavior: "smooth", block: "start" });
+ }
+ el.classList.add("settings-focus-target");
+ window.setTimeout(
+ () => el.classList.remove("settings-focus-target"),
+ 1800,
+ );
+ },
+ [container],
+ );
useEffect(() => {
if (!container || headings.length === 0) {
diff --git a/frontend/editor/src/core/components/shared/WorkbenchBar.css b/frontend/editor/src/core/components/shared/WorkbenchBar.css
index 0b23884fff..e5afb38181 100644
--- a/frontend/editor/src/core/components/shared/WorkbenchBar.css
+++ b/frontend/editor/src/core/components/shared/WorkbenchBar.css
@@ -21,6 +21,16 @@
z-index: 50;
}
+/* When the top row is portalled into a title-bar strip, only the tool row stays
+ inline. It sits directly under the strip (which carries its own bottom
+ hairline), so drop the tool row's own top hairline to avoid doubling. */
+.workbench-bar[data-portaled="true"] {
+ min-height: 0;
+}
+.workbench-bar[data-portaled="true"] .workbench-bar-center {
+ border-top: none;
+}
+
/* ---- View switcher (left) ---- */
/* Follows the view switcher, which claims order 1 in the bar's reflow. */
.workbench-bar-lead {
diff --git a/frontend/editor/src/core/components/shared/WorkbenchBar.tsx b/frontend/editor/src/core/components/shared/WorkbenchBar.tsx
index 124c1996ef..18ea1e9973 100644
--- a/frontend/editor/src/core/components/shared/WorkbenchBar.tsx
+++ b/frontend/editor/src/core/components/shared/WorkbenchBar.tsx
@@ -6,6 +6,7 @@ import React, {
useState,
useSyncExternalStore,
} from "react";
+import { createPortal } from "react-dom";
import { Button } from "@app/ui/Button";
import { ActionIcon } from "@app/ui/ActionIcon";
import { SegmentedControl } from "@app/ui/SegmentedControl";
@@ -33,6 +34,7 @@ import { ViewerContext, useViewer } from "@app/contexts/ViewerContext";
import { WorkbenchType, isBaseWorkbench } from "@app/types/workbench";
import SuperSearch from "@app/components/shared/superSearch/SuperSearch";
import { useEditorSearchScopes } from "@app/hooks/useSuperSearch";
+import { useTitleBarStrip } from "@app/contexts/TitleBarStripContext";
import ViewerShareButton from "@app/components/viewer/ViewerShareButton";
import { useSharingEnabled } from "@app/hooks/useSharingEnabled";
import { usePolicyFileBadges } from "@app/hooks/usePolicyFileBadges";
@@ -85,6 +87,7 @@ export default function WorkbenchBar({
}: WorkbenchBarProps) {
const { t } = useTranslation();
const navigate = useNavigate();
+ const strip = useTitleBarStrip();
const searchScopes = useEditorSearchScopes();
const returnRoute = useSyncExternalStore(
subscribeFilesPageReturnRoute,
@@ -458,6 +461,9 @@ export default function WorkbenchBar({
// little room for a usable search, bump the search to its own row
const barRef = useRef<HTMLDivElement>(null);
useLayoutEffect(() => {
+ // The strip lays its single row out itself; search isn't in the inline bar
+ // to measure, so there's nothing to reflow.
+ if (strip.enabled) return;
const bar = barRef.current;
if (!bar) return;
const MIN_SEARCH_WIDTH = 320;
@@ -497,164 +503,194 @@ export default function WorkbenchBar({
if (globalsEl) ro.observe(globalsEl);
measure();
return () => ro.disconnect();
- }, []);
-
- return (
- <div
- ref={barRef}
- className="workbench-bar"
- data-wrapped="false"
- data-tour="workbench-bar"
- >
- {/* Left: optional "Back to File library" + view switcher */}
- <div className="workbench-bar-views" data-tour="view-switcher">
- {returnRoute && hasFiles && (
- <>
- <Button
- variant="tertiary"
- className="workbench-bar-view-btn workbench-bar-back-btn"
- onClick={handleBackToFiles}
- aria-label={t(
- returnRoute.label
- ? "filesPage.backToFolder"
- : "filesPage.backToMyFiles",
- returnRoute.label
- ? `Back to ${returnRoute.label}`
- : "Back to File library",
- { folder: returnRoute.label ?? "" },
- )}
- leftSection={<Icon name="arrow-left" size={"1.1rem"} />}
- >
- <span className="workbench-bar-view-label">
- {returnRoute.label
- ? t("filesPage.backToFolder", "Back to {{folder}}", {
- folder: returnRoute.label,
- })
- : t("filesPage.backToMyFiles", "Back to File library")}
- </span>
- </Button>
+ }, [strip.enabled]);
+
+ // Left: optional "Back to File library" + view switcher.
+ const viewsCluster = (
+ <div className="workbench-bar-views" data-tour="view-switcher">
+ {returnRoute && hasFiles && (
+ <>
+ <Button
+ variant="tertiary"
+ className="workbench-bar-view-btn workbench-bar-back-btn"
+ onClick={handleBackToFiles}
+ aria-label={t(
+ returnRoute.label
+ ? "filesPage.backToFolder"
+ : "filesPage.backToMyFiles",
+ returnRoute.label
+ ? `Back to ${returnRoute.label}`
+ : "Back to File library",
+ { folder: returnRoute.label ?? "" },
+ )}
+ leftSection={<Icon name="arrow-left" size={"1.1rem"} />}
+ >
+ <span className="workbench-bar-view-label">
+ {returnRoute.label
+ ? t("filesPage.backToFolder", "Back to {{folder}}", {
+ folder: returnRoute.label,
+ })
+ : t("filesPage.backToMyFiles", "Back to File library")}
+ </span>
+ </Button>
+ <div className="workbench-bar-divider" />
+ </>
+ )}
+ {/* Not in the library: it browses files rather than showing one, and the
+ rail is what moves between surfaces. */}
+ {currentView !== "myFiles" && (hasFiles || isCustomView) && (
+ <SegmentedControl<WorkbenchType>
+ className="workbench-bar-views"
+ size="sm"
+ value={currentView}
+ onChange={setCurrentView}
+ variant="secondary"
+ options={viewOptions.map((opt) => ({
+ value: opt.value,
+ label: (
+ <>
+ {opt.icon}
+ <span className="workbench-bar-view-label">{opt.label}</span>
+ </>
+ ),
+ }))}
+ />
+ )}
+ {barLeadButtons.map((btn) => {
+ const content = renderButton(btn);
+ if (!content) return null;
+ return (
+ <div className="workbench-bar-lead" key={btn.id}>
<div className="workbench-bar-divider" />
- </>
- )}
- {/* Not in the library: it browses files rather than showing one, and the
- rail is what moves between surfaces. */}
- {currentView !== "myFiles" && (hasFiles || isCustomView) && (
- <SegmentedControl<WorkbenchType>
- className="workbench-bar-views"
- size="sm"
- value={currentView}
- onChange={setCurrentView}
- variant="secondary"
- options={viewOptions.map((opt) => ({
- value: opt.value,
- label: (
- <>
- {opt.icon}
- <span className="workbench-bar-view-label">{opt.label}</span>
- </>
- ),
- }))}
- />
- )}
- {barLeadButtons.map((btn) => {
- const content = renderButton(btn);
- if (!content) return null;
- return (
- <div className="workbench-bar-lead" key={btn.id}>
- <div className="workbench-bar-divider" />
- {content}
- </div>
- );
- })}
- </div>
+ {content}
+ </div>
+ );
+ })}
+ </div>
+ );
- {/* Global super search - always present, even on the homepage */}
- <div className="workbench-bar-search">
- <SuperSearch scopes={searchScopes} />
+ // Global super search - always present, even on the homepage.
+ const searchCluster = (
+ <div className="workbench-bar-search">
+ <SuperSearch scopes={searchScopes} />
+ </div>
+ );
+
+ // Tool buttons - second row, only rendered when buttons exist. In the viewer
+ // the row is retractable: a handle on its right edge hides the whole row;
+ // Workbench then shows a tab below the bar to bring it back.
+ const toolRow =
+ sectionsWithButtons.length > 0 && !(isViewer && viewerToolbarCollapsed) ? (
+ <div
+ className={`workbench-bar-center${
+ isMobile && mobileToolsExpanded
+ ? " workbench-bar-center--expanded"
+ : ""
+ }`}
+ >
+ <div className="workbench-bar-center-scroll">
+ {sectionsWithButtons.map(
+ ({ section, buttons: sectionButtons }, idx) => (
+ <React.Fragment key={section}>
+ {idx > 0 && <div className="workbench-bar-divider" />}
+ {sectionButtons.map((btn) => {
+ const content = renderButton(btn);
+ if (!content) return null;
+ return (
+ <div key={btn.id} className="workbench-bar-action-wrapper">
+ {content}
+ </div>
+ );
+ })}
+ </React.Fragment>
+ ),
+ )}
+ </div>
+ <WorkbenchBarToolbarHandle
+ isMobile={isMobile}
+ expanded={mobileToolsExpanded}
+ onToggleExpanded={toggleMobileTools}
+ onRetract={
+ isViewer && onCollapseViewerToolbar
+ ? handleRetractToolbar
+ : undefined
+ }
+ />
</div>
+ ) : null;
+
+ // Right: global buttons - export group left, close anchored right.
+ const globalsCluster = (
+ <div className="workbench-bar-globals">
+ {/* A view's own controls, ahead of the globals every view shares. */}
+ {barRowButtons.map((btn) => {
+ const content = renderButton(btn);
+ if (!content) return null;
+ return (
+ <div key={btn.id} className="workbench-bar-action-wrapper">
+ {content}
+ </div>
+ );
+ })}
+ {barRowButtons.length > 0 && (
+ <div className="workbench-bar-divider workbench-bar-globals-sep" />
+ )}
+ {/* Share (viewer only; opens the same modal as My Files "Manage sharing") */}
+ {currentView === "viewer" && sharingEnabled && (
+ <ViewerShareButton disabled={actionsDisabled} />
+ )}
+
+ {isMobile ? (
+ <WorkbenchBarMobileActions {...globalActionProps} />
+ ) : (
+ <WorkbenchBarDesktopActions
+ {...globalActionProps}
+ enforcingProgress={enforcingProgress}
+ />
+ )}
+ {isPhone && (
+ <>
+ {/* Last in the globals, so it is the rightmost control. */}
+ <div className="workbench-bar-divider workbench-bar-globals-sep" />
+ <NotificationBell />
+ </>
+ )}
+ </div>
+ );
- {/* Tool buttons - second row, only rendered when buttons exist. In the
- viewer the row is retractable: a handle on its right edge hides the
- whole row; Workbench then shows a tab below the bar to bring it back. */}
- {sectionsWithButtons.length > 0 &&
- !(isViewer && viewerToolbarCollapsed) && (
+ // With a title-bar strip, the top row lives in it: portal the view switcher and
+ // globals into its slots, keep the tool row inline, and leave search to the
+ // strip (which owns the single SuperSearch instance).
+ if (strip.enabled) {
+ return (
+ <>
+ {strip.viewsSlot && createPortal(viewsCluster, strip.viewsSlot)}
+ {strip.globalsSlot && createPortal(globalsCluster, strip.globalsSlot)}
+ {toolRow && (
<div
- className={`workbench-bar-center${
- isMobile && mobileToolsExpanded
- ? " workbench-bar-center--expanded"
- : ""
- }`}
+ ref={barRef}
+ className="workbench-bar"
+ data-wrapped="false"
+ data-portaled="true"
>
- <div className="workbench-bar-center-scroll">
- {sectionsWithButtons.map(
- ({ section, buttons: sectionButtons }, idx) => (
- <React.Fragment key={section}>
- {idx > 0 && <div className="workbench-bar-divider" />}
- {sectionButtons.map((btn) => {
- const content = renderButton(btn);
- if (!content) return null;
- return (
- <div
- key={btn.id}
- className="workbench-bar-action-wrapper"
- >
- {content}
- </div>
- );
- })}
- </React.Fragment>
- ),
- )}
- </div>
- <WorkbenchBarToolbarHandle
- isMobile={isMobile}
- expanded={mobileToolsExpanded}
- onToggleExpanded={toggleMobileTools}
- onRetract={
- isViewer && onCollapseViewerToolbar
- ? handleRetractToolbar
- : undefined
- }
- />
+ {toolRow}
</div>
)}
+ </>
+ );
+ }
- {/* Right: Global buttons - export group left, close anchored right */}
- <div className="workbench-bar-globals">
- {/* A view's own controls, ahead of the globals every view shares. */}
- {barRowButtons.map((btn) => {
- const content = renderButton(btn);
- if (!content) return null;
- return (
- <div key={btn.id} className="workbench-bar-action-wrapper">
- {content}
- </div>
- );
- })}
- {barRowButtons.length > 0 && (
- <div className="workbench-bar-divider workbench-bar-globals-sep" />
- )}
- {/* Share (viewer only; opens the same modal as My Files "Manage sharing") */}
- {currentView === "viewer" && sharingEnabled && (
- <ViewerShareButton disabled={actionsDisabled} />
- )}
-
- {isMobile ? (
- <WorkbenchBarMobileActions {...globalActionProps} />
- ) : (
- <WorkbenchBarDesktopActions
- {...globalActionProps}
- enforcingProgress={enforcingProgress}
- />
- )}
- {isPhone && (
- <>
- {/* Last in the globals, so it is the rightmost control. */}
- <div className="workbench-bar-divider workbench-bar-globals-sep" />
- <NotificationBell />
- </>
- )}
- </div>
+ return (
+ <div
+ ref={barRef}
+ className="workbench-bar"
+ data-wrapped="false"
+ data-tour="workbench-bar"
+ >
+ {viewsCluster}
+ {searchCluster}
+ {toolRow}
+ {globalsCluster}
</div>
);
}
diff --git a/frontend/editor/src/core/contexts/TitleBarStripContext.tsx b/frontend/editor/src/core/contexts/TitleBarStripContext.tsx
new file mode 100644
index 0000000000..4f5e4ad41d
--- /dev/null
+++ b/frontend/editor/src/core/contexts/TitleBarStripContext.tsx
@@ -0,0 +1,22 @@
+import { createContext, useContext } from "react";
+
+/** Optional in-window title-bar strip. */
+export interface TitleBarStripSlots {
+ enabled: boolean;
+ viewsSlot: HTMLElement | null;
+ searchSlot: HTMLElement | null;
+ globalsSlot: HTMLElement | null;
+}
+
+const DEFAULT: TitleBarStripSlots = {
+ enabled: false,
+ viewsSlot: null,
+ searchSlot: null,
+ globalsSlot: null,
+};
+
+export const TitleBarStripContext = createContext<TitleBarStripSlots>(DEFAULT);
+
+export function useTitleBarStrip(): TitleBarStripSlots {
+ return useContext(TitleBarStripContext);
+}
diff --git a/frontend/editor/src/core/pages/HomePage.tsx b/frontend/editor/src/core/pages/HomePage.tsx
index 88f1d865cd..a216640d01 100644
--- a/frontend/editor/src/core/pages/HomePage.tsx
+++ b/frontend/editor/src/core/pages/HomePage.tsx
@@ -32,6 +32,7 @@ import { Icon } from "@app/ui/Icon";
import RightSidebar from "@app/components/tools/RightSidebar";
import { ReaderRail } from "@app/components/viewer/readerRail/ReaderRail";
import { ReaderSuperSearch } from "@app/components/viewer/readerRail/ReaderSuperSearch";
+import { useTitleBarStrip } from "@app/contexts/TitleBarStripContext";
import Workbench from "@app/components/layout/Workbench";
import FileSidebar from "@app/components/shared/FileSidebar";
import FileManager from "@app/components/FileManager";
@@ -131,6 +132,9 @@ export default function HomePage() {
const navigate = useNavigate();
const { config } = useAppConfig();
+ // When a title-bar strip owns Super Search, suppress the reader-mode float so
+ // only one SuperSearch instance is ever live.
+ const strip = useTitleBarStrip();
const processingFolderCreation = useProcessingFolderCreation();
const isMobile = useIsMobile();
const isTouch = useIsTouch();
@@ -749,7 +753,7 @@ export default function HomePage() {
Both render together only while the panel is on its way out. */}
{wingsMounted && !hideToolPanel && <RightSidebar />}
{readerMode && <ReaderRail />}
- {readerMode && <ReaderSuperSearch />}
+ {readerMode && !strip.enabled && <ReaderSuperSearch />}
<FileManager selectedTool={selectedTool} />
</Group>
)}
diff --git a/frontend/editor/src/core/pages/SettingsPage.tsx b/frontend/editor/src/core/pages/SettingsPage.tsx
index e713a9f726..f523271e8e 100644
--- a/frontend/editor/src/core/pages/SettingsPage.tsx
+++ b/frontend/editor/src/core/pages/SettingsPage.tsx
@@ -19,6 +19,7 @@ import { SettingsNavChevron } from "@app/components/shared/config/SettingsNavChe
import { useSettingsNav } from "@app/components/settings/useSettingsNav";
import SuperSearch from "@app/components/shared/superSearch/SuperSearch";
import { useEditorSearchScopes } from "@app/hooks/useSuperSearch";
+import { useTitleBarStrip } from "@app/contexts/TitleBarStripContext";
import type { NavKey } from "@app/components/shared/config/types";
import { useIsMobile } from "@app/hooks/useIsMobile";
import { useLicenseAlert } from "@app/hooks/useLicenseAlert";
@@ -54,6 +55,8 @@ const SettingsPageInner: React.FC = () => {
// The same bar as the editor and the processor, so search is one thing
// everywhere; settings results deep-link straight back into this page.
const searchScopes = useEditorSearchScopes();
+ // A title-bar strip already hosts the one Super Search; don't add a second here.
+ const strip = useTitleBarStrip();
const [mobilePane, setMobilePane] = useState<"nav" | "content">(() =>
sectionFromPath(window.location.pathname) ? "content" : "nav",
);
@@ -329,13 +332,15 @@ const SettingsPageInner: React.FC = () => {
isMobile && mobilePane !== "content" ? { display: "none" } : undefined
}
>
- <div className="settings-page__search-bar">
- <SuperSearch
- inputId="settings-search-input"
- scopes={searchScopes}
- dropdownClassName="settings-search-dropdown"
- />
- </div>
+ {!strip.enabled && (
+ <div className="settings-page__search-bar">
+ <SuperSearch
+ inputId="settings-search-input"
+ scopes={searchScopes}
+ dropdownClassName="settings-search-dropdown"
+ />
+ </div>
+ )}
<div className="modal-content-scroll" ref={setContentRef}>
{isMobile && (
<div className="settings-page__mobile-bar modal-header">
diff --git a/frontend/editor/src/core/styles/index.css b/frontend/editor/src/core/styles/index.css
index 32b2f2eaad..3b0f311a8e 100644
--- a/frontend/editor/src/core/styles/index.css
+++ b/frontend/editor/src/core/styles/index.css
@@ -7,6 +7,12 @@ body {
overscroll-behavior: none;
}
+/* Give the mount node an explicit height so full-height layouts can size against
+ it with percentages. */
+#root {
+ height: 100%;
+}
+
body {
font-family:
-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",
diff --git a/frontend/editor/src/desktop/components/AppProviders.tsx b/frontend/editor/src/desktop/components/AppProviders.tsx
index 2b98af09b3..75bd425724 100644
--- a/frontend/editor/src/desktop/components/AppProviders.tsx
+++ b/frontend/editor/src/desktop/components/AppProviders.tsx
@@ -1,7 +1,6 @@
import { ReactNode, useEffect, useRef, useState } from "react";
import { AppProviders as ProprietaryAppProviders } from "@proprietary/components/AppProviders";
import { DesktopConfigSync } from "@app/components/DesktopConfigSync";
-import { WindowTitleBar } from "@app/components/WindowTitleBar";
import { DesktopQueryCacheReset } from "@app/components/DesktopQueryCacheReset";
import { DesktopBannerInitializer } from "@app/components/DesktopBannerInitializer";
import { SaveShortcutListener } from "@app/components/SaveShortcutListener";
@@ -345,8 +344,9 @@ export function AppProviders({ children }: { children: ReactNode }) {
>
{/* Also here: the auth check below switches mode pre-authChecked. */}
<DesktopQueryCacheReset />
- <WindowTitleBar />
- <div style={{ minHeight: "100vh" }} />
+ {/* The title-bar strip (window controls) comes from AppFrame, which wraps
+ this loading branch too; here we just fill the space below it. */}
+ <div style={{ height: "100%" }} />
{updatePopupModal}
</ProprietaryAppProviders>
);
@@ -372,7 +372,6 @@ export function AppProviders({ children }: { children: ReactNode }) {
}}
>
<DesktopQueryCacheReset />
- <WindowTitleBar />
<SaaSTeamProvider key={appKey}>
<DesktopConfigSync />
<DesktopBannerInitializer />
diff --git a/frontend/editor/src/desktop/components/WindowTitleBar.module.css b/frontend/editor/src/desktop/components/WindowTitleBar.module.css
deleted file mode 100644
index 660c5e2c56..0000000000
--- a/frontend/editor/src/desktop/components/WindowTitleBar.module.css
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Custom Windows window controls (see WindowTitleBar.tsx): a fixed cluster in
- the top-right corner, overlaying the app chrome β€” which reserves the corner
- via --wincontrols-w. Kept above app overlays so the controls stay usable. */
-.titleBar {
- position: fixed;
- top: 0;
- right: 0;
- z-index: 1500;
- display: flex;
- height: 2rem;
- user-select: none;
- -webkit-user-select: none;
-}
-
-.controls {
- display: flex;
- align-items: stretch;
- height: 100%;
-}
-
-.button {
- width: 46px;
- height: 100%;
- display: inline-flex;
- align-items: center;
- justify-content: center;
- padding: 0;
- border: none;
- background: transparent;
- color: var(--c-text-muted);
- font-size: 15px; /* drives the inherit-sized MUI icons */
- line-height: 1;
- cursor: default;
- transition:
- background-color 0.12s ease,
- color 0.12s ease;
-}
-
-/* Clicks (and Tauri's drag-region hit test) should always resolve to the
- button, never its SVG glyph. */
-.button svg {
- pointer-events: none;
-}
-
-.button:hover {
- background: var(--c-hover);
- color: var(--c-text);
-}
-
-.close:hover {
- background: var(--c-danger);
- color: #fff;
-}
-
-.restoreIcon {
- /* The overlapping-squares glyph reads large next to the others. */
- font-size: 13px;
-}
diff --git a/frontend/editor/src/desktop/components/WindowTitleBar.tsx b/frontend/editor/src/desktop/components/WindowTitleBar.tsx
deleted file mode 100644
index c8faf630d2..0000000000
--- a/frontend/editor/src/desktop/components/WindowTitleBar.tsx
+++ /dev/null
@@ -1,184 +0,0 @@
-import { useEffect, useState } from "react";
-import { useIsomorphicEffect } from "@mantine/hooks";
-import { getCurrentWindow } from "@tauri-apps/api/window";
-import { isTauri } from "@tauri-apps/api/core";
-import { Icon } from "@app/ui/Icon";
-import { getDesktopOs, DesktopOs } from "@app/services/platformService";
-import styles from "@app/components/WindowTitleBar.module.css";
-// Desktop-only skin that reserves the controls' corner across core layout
-// surfaces; every rule is gated by the data-window-controls flag set below.
-import "@app/components/windowChrome.css";
-
-// Seed from the UA so the bar (and its reserved height) is present on the first
-// frame on Windows, avoiding a layout shift. getDesktopOs() confirms it right
-// after via the Rust command.
-const seedIsWindows =
- typeof navigator !== "undefined" && /Windows/i.test(navigator.userAgent);
-
-/**
- * Custom window controls for the Windows desktop build. The native caption is
- * removed in Rust (decorations:false), so this draws minimize/maximize/close as
- * a fixed overlay pinned to the top-right corner β€” the rail and panels run all
- * the way to the window edge, and the app chrome reserves the corner via the
- * data-window-controls flag this sets on <html> (consumed by windowChrome.css).
- * Renders nothing on macOS/Linux (native decorations kept); not bundled in the
- * browser build. tao provides edge/corner resize for the undecorated window, so
- * no manual resize handles are needed here.
- */
-export function WindowTitleBar() {
- const [isWindows, setIsWindows] = useState(seedIsWindows);
- const [maximized, setMaximized] = useState(false);
- const active = isWindows && isTauri();
-
- // Confirm the OS authoritatively (the UA seed is only a first-frame guess).
- useEffect(() => {
- if (!isTauri()) {
- setIsWindows(false);
- return;
- }
- let mounted = true;
- void getDesktopOs().then((os) => {
- if (mounted) setIsWindows(os === DesktopOs.Windows);
- });
- return () => {
- mounted = false;
- };
- }, []);
-
- // Flag the custom chrome on <html> so windowChrome.css can reserve the
- // controls' corner across the app. Set only when active (Windows desktop);
- // absent otherwise, so the skin is inert on macOS/Linux. Layout effect so it
- // lands before paint.
- useIsomorphicEffect(() => {
- const root = document.documentElement;
- if (active) {
- root.setAttribute("data-window-controls", "custom");
- } else {
- root.removeAttribute("data-window-controls");
- }
- return () => {
- root.removeAttribute("data-window-controls");
- };
- }, [active]);
-
- // Keep the maximize/restore icon in sync with the actual window state
- // (double-click, snap, or the button itself all change it).
- useEffect(() => {
- if (!active) return;
- const appWindow = getCurrentWindow();
- let unlisten: (() => void) | undefined;
- void appWindow.isMaximized().then(setMaximized);
- void appWindow
- .onResized(() => {
- void appWindow.isMaximized().then(setMaximized);
- })
- .then((u) => {
- unlisten = u;
- });
- return () => unlisten?.();
- }, [active]);
-
- // Let the window be dragged, and double-click-maximized, from any
- // non-interactive spot in the top strip. data-tauri-drag-region only fires on
- // bare container backgrounds, leaving most of a busy toolbar undraggable, so a
- // document-level hit test covers the whole top instead.
- //
- // startDragging() must NOT run on mousedown: it enters the OS drag loop and
- // swallows the browser's dblclick. So begin the drag on the first real move,
- // and detect a double-click from the interval between mousedowns.
- useEffect(() => {
- if (!active) return;
- const TOP_STRIP_PX = 48;
- const DOUBLE_CLICK_MS = 500;
- const DRAG_THRESHOLD_PX = 4;
- const INTERACTIVE =
- "button, a[href], input, textarea, select, label, summary," +
- '[role="button"], [role="tab"], [role="menuitem"], [role="switch"],' +
- '[role="slider"], [contenteditable="true"], [data-no-window-drag]';
- const draggableAt = (e: MouseEvent) => {
- if (e.button !== 0 || e.clientY > TOP_STRIP_PX) return false;
- const el = e.target as Element | null;
- return !!el && !el.closest(INTERACTIVE);
- };
- let pending: { x: number; y: number } | null = null;
- let lastDownAt = 0;
- const onMouseDown = (e: MouseEvent) => {
- if (!draggableAt(e)) {
- pending = null;
- return;
- }
- const now = Date.now();
- if (now - lastDownAt < DOUBLE_CLICK_MS) {
- pending = null;
- lastDownAt = 0;
- void getCurrentWindow().toggleMaximize();
- return;
- }
- lastDownAt = now;
- pending = { x: e.clientX, y: e.clientY };
- };
- const onMouseMove = (e: MouseEvent) => {
- if (!pending) return;
- if (
- Math.abs(e.clientX - pending.x) > DRAG_THRESHOLD_PX ||
- Math.abs(e.clientY - pending.y) > DRAG_THRESHOLD_PX
- ) {
- pending = null;
- lastDownAt = 0; // a drag is not the first half of a double-click
- void getCurrentWindow().startDragging();
- }
- };
- const onMouseUp = () => {
- pending = null;
- };
- document.addEventListener("mousedown", onMouseDown);
- document.addEventListener("mousemove", onMouseMove);
- document.addEventListener("mouseup", onMouseUp);
- return () => {
- document.removeEventListener("mousedown", onMouseDown);
- document.removeEventListener("mousemove", onMouseMove);
- document.removeEventListener("mouseup", onMouseUp);
- };
- }, [active]);
-
- if (!active) return null;
-
- const appWindow = getCurrentWindow();
- return (
- <div className={styles.titleBar}>
- <div className={styles.controls}>
- <button
- type="button"
- className={styles.button}
- onClick={() => void appWindow.minimize()}
- aria-label="Minimize"
- tabIndex={-1}
- >
- <Icon name="minus" size="1em" />
- </button>
- <button
- type="button"
- className={styles.button}
- onClick={() => void appWindow.toggleMaximize()}
- aria-label={maximized ? "Restore" : "Maximize"}
- tabIndex={-1}
- >
- {maximized ? (
- <Icon name="copy" size="1em" className={styles.restoreIcon} />
- ) : (
- <Icon name="square" size="1em" />
- )}
- </button>
- <button
- type="button"
- className={`${styles.button} ${styles.close}`}
- onClick={() => void appWindow.close()}
- aria-label="Close"
- tabIndex={-1}
- >
- <Icon name="x" size="1em" />
- </button>
- </div>
- </div>
- );
-}
diff --git a/frontend/editor/src/desktop/components/layout/TitleBarChrome.tsx b/frontend/editor/src/desktop/components/layout/TitleBarChrome.tsx
new file mode 100644
index 0000000000..426a44e497
--- /dev/null
+++ b/frontend/editor/src/desktop/components/layout/TitleBarChrome.tsx
@@ -0,0 +1,45 @@
+import { useCallback, useMemo, useState, type ReactNode } from "react";
+import {
+ TitleBarStripContext,
+ type TitleBarStripSlots,
+} from "@app/contexts/TitleBarStripContext";
+import { TitleBarStrip } from "@app/components/layout/TitleBarStrip";
+import styles from "@app/components/layout/TitleBarStrip.module.css";
+
+/**
+ * Desktop app frame: the window title-bar strip as a full-width row above the
+ * rail + app, and the portal slots the app fills.
+ */
+export function TitleBarChrome({ children }: { children: ReactNode }) {
+ const [viewsSlot, setViewsSlot] = useState<HTMLElement | null>(null);
+ const [searchSlot, setSearchSlot] = useState<HTMLElement | null>(null);
+ const [globalsSlot, setGlobalsSlot] = useState<HTMLElement | null>(null);
+
+ const value = useMemo<TitleBarStripSlots>(
+ () => ({ enabled: true, viewsSlot, searchSlot, globalsSlot }),
+ [viewsSlot, searchSlot, globalsSlot],
+ );
+
+ const setViews = useCallback((el: HTMLDivElement | null) => {
+ setViewsSlot(el);
+ }, []);
+ const setSearch = useCallback((el: HTMLDivElement | null) => {
+ setSearchSlot(el);
+ }, []);
+ const setGlobals = useCallback((el: HTMLDivElement | null) => {
+ setGlobalsSlot(el);
+ }, []);
+
+ return (
+ <TitleBarStripContext.Provider value={value}>
+ <div className={styles.column}>
+ <TitleBarStrip>
+ <div ref={setViews} className={styles.viewsSlot} />
+ <div ref={setSearch} className={styles.searchSlot} />
+ <div ref={setGlobals} className={styles.globalsSlot} />
+ </TitleBarStrip>
+ {children}
+ </div>
+ </TitleBarStripContext.Provider>
+ );
+}
diff --git a/frontend/editor/src/desktop/components/layout/TitleBarSearch.tsx b/frontend/editor/src/desktop/components/layout/TitleBarSearch.tsx
new file mode 100644
index 0000000000..8c2765d74c
--- /dev/null
+++ b/frontend/editor/src/desktop/components/layout/TitleBarSearch.tsx
@@ -0,0 +1,22 @@
+import { createPortal } from "react-dom";
+import SuperSearch from "@app/components/shared/superSearch/SuperSearch";
+import { useEditorSearchScopes } from "@app/hooks/useSuperSearch";
+import { useTitleBarStrip } from "@app/contexts/TitleBarStripContext";
+
+/**
+ * The single desktop Super Search instance, portalled into the title-bar strip.
+ * Mounted in AppLayout so it stays across every editor view (reader, empty
+ * homepage, takeover) - which is why the inline bar search, floating search and
+ * reader search are all suppressed on desktop.
+ */
+export function TitleBarSearch() {
+ const strip = useTitleBarStrip();
+ const scopes = useEditorSearchScopes();
+ if (!strip.searchSlot) return null;
+ return createPortal(
+ <div className="workbench-bar-search">
+ <SuperSearch scopes={scopes} />
+ </div>,
+ strip.searchSlot,
+ );
+}
diff --git a/frontend/editor/src/desktop/components/layout/TitleBarStrip.module.css b/frontend/editor/src/desktop/components/layout/TitleBarStrip.module.css
new file mode 100644
index 0000000000..528033c0bf
--- /dev/null
+++ b/frontend/editor/src/desktop/components/layout/TitleBarStrip.module.css
@@ -0,0 +1,135 @@
+/* Frame column: the strip on top, then the rail + app below it. */
+.column {
+ --titlebar-h: 2.5rem;
+ /* Inherited down to AppLayout, which sizes itself to the space under the strip
+ with a real length (a percentage would collapse under WebKit; see AppLayout). */
+ --titlebar-body-h: calc(100dvh - var(--titlebar-h));
+ display: flex;
+ flex-direction: column;
+ height: 100dvh;
+ /* clip, not hidden: a hidden box is still programmatically scrollable, so a
+ scrollIntoView on a deep element (settings/docs/admin anchors) could shift
+ the whole app inside the frame. clip forbids that; inner scrollers still
+ scroll. */
+ overflow: clip;
+}
+/* Fill the space under the strip via flex, tied to the strip's real row - not a
+ fixed calc(100dvh - strip), which slides up leaving a strip-sized gap at the
+ bottom if it ever disagrees with the strip's actual height (a reflow, a stray
+ scroll). AppLayout still renders because it self-sizes with a real length, not
+ a height:100% that WebKit won't resolve against a flex-sized ancestor. */
+.column > :global(.app-frame) {
+ flex: 1 1 0;
+ min-height: 0;
+ height: auto;
+ /* Non-scrollable (see .column): the frame must never be the thing a
+ scrollIntoView drags; legitimate inner scrollers keep their own overflow. */
+ overflow: clip;
+}
+
+/* The desktop title-bar row. Normal flow (first row of the frame column), so it
+ reserves its own height for the whole app and nothing below it can reach the
+ window-controls corner.
+
+ Three columns: search sits in the fixed centre column, centred on the strip;
+ the view switcher and global actions hug it from the equal side columns, so
+ the empty space (and the OS controls) fall on the outer edges rather than
+ between the clusters. */
+.strip {
+ position: relative;
+ display: grid;
+ grid-template-columns: 1fr minmax(0, 24rem) 1fr;
+ align-items: center;
+ column-gap: 8px;
+ flex-shrink: 0;
+ height: var(--titlebar-h, 2.5rem);
+ padding-inline: 8px;
+ background: var(--c-surface);
+ border-bottom: 1px solid var(--c-border-subtle);
+ user-select: none;
+ -webkit-user-select: none;
+ z-index: 60;
+}
+
+/* The OS controls live in the reserved corners: macOS traffic lights top-left
+ (drawn by the OS over the overlay title bar), Windows controls top-right.
+ Reserve the SAME width on both sides so the centre column stays on the true
+ window midpoint whichever corner an OS actually uses. */
+.strip[data-os="macos"] {
+ padding-inline: 4.75rem;
+}
+.strip[data-os="windows"] {
+ padding-inline: 8.625rem; /* three 46px controls */
+}
+
+/* Portal targets: the view switcher hugs the search from the left column, the
+ global actions from the right; search fills the centre column. */
+.viewsSlot {
+ justify-self: end;
+ display: flex;
+ align-items: center;
+ min-width: 0;
+}
+
+.globalsSlot {
+ justify-self: start;
+ display: flex;
+ align-items: center;
+ min-width: 0;
+}
+
+.searchSlot {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ min-width: 0;
+}
+
+.controls {
+ position: absolute;
+ top: 0;
+ right: 0;
+ height: 100%;
+ display: flex;
+ align-items: stretch;
+ /* Keep minimize/maximize/close in that order regardless of app direction. */
+ direction: ltr;
+}
+
+.button {
+ width: 46px;
+ height: 100%;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ padding: 0;
+ border: none;
+ background: transparent;
+ color: var(--c-text-muted);
+ font-size: 15px;
+ line-height: 1;
+ cursor: default;
+ transition:
+ background-color 0.12s ease,
+ color 0.12s ease;
+}
+
+/* Clicks (and the drag hit test) resolve to the button, never its glyph. */
+.button svg {
+ pointer-events: none;
+}
+
+.button:hover {
+ background: var(--c-hover);
+ color: var(--c-text);
+}
+
+.close:hover {
+ background: var(--c-danger);
+ color: #fff;
+}
+
+.restoreIcon {
+ /* The overlapping-squares glyph reads large next to the others. */
+ font-size: 13px;
+}
diff --git a/frontend/editor/src/desktop/components/layout/TitleBarStrip.tsx b/frontend/editor/src/desktop/components/layout/TitleBarStrip.tsx
new file mode 100644
index 0000000000..33b3c82f59
--- /dev/null
+++ b/frontend/editor/src/desktop/components/layout/TitleBarStrip.tsx
@@ -0,0 +1,166 @@
+import { useEffect, useState, type ReactNode } from "react";
+import { getCurrentWindow } from "@tauri-apps/api/window";
+import { isTauri } from "@tauri-apps/api/core";
+import { Icon } from "@app/ui/Icon";
+import { getDesktopOs, DesktopOs } from "@app/services/platformService";
+import styles from "@app/components/layout/TitleBarStrip.module.css";
+
+// Seed the OS side from the UA so the correct reservation (macOS lights left /
+// Windows controls right) is present on the first frame; getDesktopOs() confirms
+// it authoritatively right after.
+const seedOs: DesktopOs = /Windows/i.test(navigator.userAgent)
+ ? DesktopOs.Windows
+ : /Mac/i.test(navigator.userAgent)
+ ? DesktopOs.Mac
+ : DesktopOs.Unknown;
+
+interface TitleBarStripProps {
+ /** Strip centre: the WorkbenchBar's top-row slots and Super Search. Omitted on
+ * the pre-auth loading screen, which shows only the window controls. */
+ children?: ReactNode;
+}
+
+/**
+ * The desktop window's title-bar row. Full width, first in the viewport column,
+ * so the rest of the app flows beneath it and can never overdraw the controls.
+ * macOS keeps native traffic lights (drawn by the OS over the reserved left
+ * gutter via the overlay title-bar style); Windows draws its own controls on
+ * the right, since Tauri has no native-caption-plus-content mode there.
+ */
+export function TitleBarStrip({ children }: TitleBarStripProps) {
+ const [os, setOs] = useState<DesktopOs>(seedOs);
+ const [maximized, setMaximized] = useState(false);
+ const isWindows = os === DesktopOs.Windows;
+
+ useEffect(() => {
+ let mounted = true;
+ void getDesktopOs().then((v) => {
+ if (mounted) setOs(v);
+ });
+ return () => {
+ mounted = false;
+ };
+ }, []);
+
+ // Keep the maximize/restore glyph in sync: double-click, snap, or the button
+ // itself all change the window state.
+ useEffect(() => {
+ if (!isWindows || !isTauri()) return;
+ const appWindow = getCurrentWindow();
+ let unlisten: (() => void) | undefined;
+ void appWindow.isMaximized().then(setMaximized);
+ void appWindow
+ .onResized(() => {
+ void appWindow.isMaximized().then(setMaximized);
+ })
+ .then((u) => {
+ unlisten = u;
+ });
+ return () => unlisten?.();
+ }, [isWindows]);
+
+ // Drag, and double-click-maximize, from any blank area of the strip. A
+ // document-level hit test rather than data-tauri-drag-region because the strip
+ // is full of interactive controls; startDragging() runs on the first move, not
+ // mousedown (which would swallow the browser's dblclick). macOS needs this too:
+ // the overlay title bar only lets the OS drag the native-lights region.
+ useEffect(() => {
+ if (!isTauri()) return;
+ const DOUBLE_CLICK_MS = 500;
+ const DRAG_THRESHOLD_PX = 4;
+ const INTERACTIVE =
+ "button, a[href], input, textarea, select, label, summary," +
+ '[role="button"], [role="tab"], [role="menuitem"], [role="switch"],' +
+ '[role="slider"], [contenteditable="true"], [data-no-window-drag]';
+ const draggableAt = (e: MouseEvent) => {
+ if (e.button !== 0) return false;
+ const el = e.target as Element | null;
+ if (!el || !el.closest("[data-title-bar-strip]")) return false;
+ return !el.closest(INTERACTIVE);
+ };
+ let pending: { x: number; y: number } | null = null;
+ let lastDownAt = 0;
+ const onMouseDown = (e: MouseEvent) => {
+ if (!draggableAt(e)) {
+ pending = null;
+ return;
+ }
+ const now = Date.now();
+ if (now - lastDownAt < DOUBLE_CLICK_MS) {
+ pending = null;
+ lastDownAt = 0;
+ void getCurrentWindow().toggleMaximize();
+ return;
+ }
+ lastDownAt = now;
+ pending = { x: e.clientX, y: e.clientY };
+ };
+ const onMouseMove = (e: MouseEvent) => {
+ if (!pending) return;
+ if (
+ Math.abs(e.clientX - pending.x) > DRAG_THRESHOLD_PX ||
+ Math.abs(e.clientY - pending.y) > DRAG_THRESHOLD_PX
+ ) {
+ pending = null;
+ lastDownAt = 0;
+ void getCurrentWindow().startDragging();
+ }
+ };
+ const onMouseUp = () => {
+ pending = null;
+ };
+ document.addEventListener("mousedown", onMouseDown);
+ document.addEventListener("mousemove", onMouseMove);
+ document.addEventListener("mouseup", onMouseUp);
+ return () => {
+ document.removeEventListener("mousedown", onMouseDown);
+ document.removeEventListener("mousemove", onMouseMove);
+ document.removeEventListener("mouseup", onMouseUp);
+ };
+ }, []);
+
+ // getCurrentWindow() reads Tauri internals, so call it lazily in the handlers
+ // rather than at render: this component also mounts in non-Tauri contexts
+ // (the browser dev server), where a render-time call throws and, sitting above
+ // any error boundary, would blank the whole app.
+ return (
+ <div className={styles.strip} data-title-bar-strip data-os={os}>
+ {children}
+ {isWindows && (
+ <div className={styles.controls}>
+ <button
+ type="button"
+ className={styles.button}
+ onClick={() => void getCurrentWindow().minimize()}
+ aria-label="Minimize"
+ tabIndex={-1}
+ >
+ <Icon name="minus" size="1em" />
+ </button>
+ <button
+ type="button"
+ className={styles.button}
+ onClick={() => void getCurrentWindow().toggleMaximize()}
+ aria-label={maximized ? "Restore" : "Maximize"}
+ tabIndex={-1}
+ >
+ {maximized ? (
+ <Icon name="copy" size="1em" className={styles.restoreIcon} />
+ ) : (
+ <Icon name="square" size="1em" />
+ )}
+ </button>
+ <button
+ type="button"
+ className={`${styles.button} ${styles.close}`}
+ onClick={() => void getCurrentWindow().close()}
+ aria-label="Close"
+ tabIndex={-1}
+ >
+ <Icon name="x" size="1em" />
+ </button>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/frontend/editor/src/desktop/components/windowChrome.css b/frontend/editor/src/desktop/components/windowChrome.css
deleted file mode 100644
index 7fa8f8f231..0000000000
--- a/frontend/editor/src/desktop/components/windowChrome.css
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Desktop (Windows) custom window chrome.
- *
- * The window controls are a fixed overlay in the top-right corner (see
- * WindowTitleBar). These rules keep the app's own chrome clear of that corner.
- *
- * Loaded only in the desktop build (imported by WindowTitleBar) and gated on the
- * data-window-controls flag the overlay sets on <html> only when active, so it
- * is inert on macOS/Linux (flag never set) and absent from web builds. It
- * targets core layout class names on purpose: this is the single, contained
- * coupling point between the desktop chrome and the core layout, kept here in
- * the desktop layer so the core components stay unaware of window chrome. */
-
-html[data-window-controls="custom"] {
- --wincontrols-w: 8.625rem; /* three 46px controls */
- --wincontrols-h: 2rem; /* control height */
-}
-
-/* Files-page toolbar spans the width; reflow search + actions left of the
- controls by shrinking the grid's right edge. */
-html[data-window-controls="custom"] .files-page-header {
- padding-right: calc(0.75rem + var(--wincontrols-w));
-}
-
-/* Right panel, expanded: move the header (PDF Tools, or an active tool such as
- Automate) below the controls instead of squashing its title. */
-html[data-window-controls="custom"] .tool-panel__compact-header,
-html[data-window-controls="custom"] .tool-panel .sui-panelhdr {
- margin-top: var(--wincontrols-h);
-}
-
-html[data-window-controls="custom"] .reader-rail {
- padding-top: calc(0.75rem + var(--wincontrols-h));
-}
-
-/* The tool picker draws no header to carry the offset, so the panel takes it. */
-html[data-window-controls="custom"]
- .tool-panel:not(:has(.tool-panel__compact-header)):not(:has(.sui-panelhdr)) {
- padding-top: var(--wincontrols-h);
-}
-
-/* Mobile layout: the top bar spans the full width. Keep the brand top-left
- (already clear of the top-right controls) and drop the view switcher below
- them by top-aligning the row and nudging the switcher down. */
-html[data-window-controls="custom"] .mobile-toggle {
- align-items: flex-start;
-}
-html[data-window-controls="custom"] .mobile-toggle-buttons {
- margin-top: var(--wincontrols-h);
-}