Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(desktop): use native Tauri header dragging and restore setup language switcher (#2262)

Max0f773d1a7970
diff --git a/desktop/README.md b/desktop/README.md
index 08c64b6bc..900df9995 100644
--- a/desktop/README.md
+++ b/desktop/README.md
@@ -38,7 +38,7 @@ product logic.
The Runtime outlives the shell. Closing the window never stops a Runtime,
whether the shell adopted it or started it.
-### Why the Workbench stays unprivileged
+### Native command boundaries
The three bootstrap commands are declared in `src-tauri/build.rs`, which makes
`tauri-build` generate `allow-bootstrap-status` / `allow-bootstrap-retry`
@@ -57,8 +57,16 @@ as a Runtime origin outright — in release builds too, where the dev server doe
not exist — so no `AVIBE_DESKTOP_ORIGIN` value can produce a Workbench page that
Tauri would classify as the shell's own.
-All three properties are asserted, in `src-tauri/tests/shell_boundaries.rs` and
-`runtime-host/src/origin.rs`. Widening any of them fails a test.
+These Runtime-management boundaries are asserted in
+`src-tauri/tests/shell_boundaries.rs` and `runtime-host/src/origin.rs`.
+
+On macOS, a separate `window-drag` capability grants only Tauri's
+`start_dragging` and `internal_toggle_maximize` commands to the main window's
+bootstrap and literal-loopback Workbench pages. The existing navigation policy
+still admits only the active Runtime origin. Same-origin Show Pages can access
+these two window commands through their parent; they are intentionally inside
+this window-control boundary. No remote bootstrap, notification, updater, file,
+or Runtime lifecycle permission is granted.
## Product packages
@@ -239,26 +247,27 @@ far enough onto the display it overlaps most, or the nearest. Fullscreen, Spaces
visibility, and routes are not restored. An absent or corrupt store uses the
centered 1200×800 default.
-On macOS the main window uses an overlay title bar with a hidden title: the
-traffic lights float over the page and there is no separate title strip.
-WKWebView has no `app-region` CSS, and Tauri's drag-region attribute needs an IPC
-grant the Workbench origin must not have, so the shell lays one transparent
-native view (`src/macos_title_bar.rs`) over the sidebar's top — a 248x28pt
-strip at the top-left corner, above the WebView, where the traffic lights float.
-A drag there moves the window; a double-click follows the system "double-click a
-window's title bar" setting. No capability or command is added. Everything right
-of the sidebar keeps its full height, so the main pane's chat and search headers
-reach the window's top edge. The shell also sets `--shell-titlebar-inset: 28px`
-on the top-level document before any page script runs; `ui/src/index.css`
-defaults it to `0px`, and left-edge and full-window Workbench surfaces add it so
-no control sits under the strip or the traffic lights. Because the shell can
-adopt an already-running Runtime whose Workbench was built against different
-strip geometry (or none), the overlay is opt-in per page: after every
-main-window page load the shell natively asks whether the page declares
-`<meta name="avibe-shell-title-strip" content="248x28">` (both `index.html`
-files do). A page that does not, or cannot answer, gets the standard title bar
-with the window title, the strip hidden, and the inset reset to `0px`. Windows
-and Linux keep the native title bar and a zero inset.
+On macOS the main window uses an overlay title bar with a hidden title. The
+traffic lights float over the existing layout, without an additional horizontal
+bar. Tauri's built-in `data-tauri-drag-region` handler owns window gestures. The
+chat header's full-width outer padding and inner blank space are direct-target
+drag regions; child controls, menus and popups keep their normal mouse input.
+Setup retains its language switcher and marks its existing header's empty space.
+Transparent DOM regions cover existing traffic-light clearance on the sidebar,
+Setup, Settings, ordinary Workbench pages and bootstrap, without adding height.
+No native hit-test overlay, WebKit message handler or custom mouse listener is
+installed. Double-click follows the bundled Tauri implementation (toggle maximize),
+not a locally emulated macOS double-click preference.
+
+The shell publishes `--shell-titlebar-inset: 28px` and
+`__AVIBE_DESKTOP_DRAG__` before page scripts run. The inset only preserves the
+existing traffic-light clearance; chat and search headers still reach the top
+edge. Pages declare `<meta name="avibe-shell-drag-regions" content="tauri">`.
+An older page without that declaration gets a standard title bar and a zero
+inset, so it remains draggable. The legacy `avibe-shell-title-strip` declaration
+is retained for older shells; pages under those shells do not activate the new
+drag attributes. Windows, Linux and ordinary browsers retain their existing
+layout and do not activate the macOS drag regions.
Links that ask for a new browsing context (`target="_blank"` or
`window.open`) open in the system browser when they are `http(s)`; anything
diff --git a/desktop/index.html b/desktop/index.html
index c92352eb3..c108c97f4 100644
--- a/desktop/index.html
+++ b/desktop/index.html
@@ -8,8 +8,10 @@
drag strip free of controls (--shell-titlebar-inset); without an exact
match the shell keeps the standard title bar. -->
<meta name="avibe-shell-title-strip" content="248x28" />
+ <meta name="avibe-shell-drag-regions" content="tauri" />
</head>
<body>
+ <div class="window-drag-region" data-tauri-drag-region></div>
<main class="stage" role="main">
<section class="card" aria-labelledby="title">
<!--
diff --git a/desktop/runtime-host/src/window_frame.rs b/desktop/runtime-host/src/window_frame.rs
index 5bdc5cb9c..8ff0c14bd 100644
--- a/desktop/runtime-host/src/window_frame.rs
+++ b/desktop/runtime-host/src/window_frame.rs
@@ -18,10 +18,10 @@ pub struct WindowFrame {
/// The grab handle: the part of the title bar that drags the window on every
/// frame the shell draws, in logical px from the window's top-left corner.
///
-/// The macOS overlay title bar moves the window only through its native drag
-/// strip, `TITLE_BAR_STRIP_WIDTH` × `TITLE_BAR_INSET` (248 × 28 pt) in
-/// `src-tauri/src/macos_title_bar.rs`, so the handle ends with that strip and
-/// must shrink if the strip does. It starts past the traffic lights, which end
+/// The macOS sidebar reserves at least 248 × 28 pt of draggable clearance
+/// (`DesktopDragRegion` in the Workbench). Other header areas can contain
+/// controls, so recovery conservatively keeps this guaranteed area reachable.
+/// It starts past the traffic lights, which end
/// about 60 pt from the left edge, and past the Windows window icon. The
/// standard macOS title bar and the Windows caption drag across all of it.
const HANDLE_LEFT: f64 = 72.0;
diff --git a/desktop/src-tauri/capabilities/window-drag.json b/desktop/src-tauri/capabilities/window-drag.json
new file mode 100644
index 000000000..7d0eec0fb
--- /dev/null
+++ b/desktop/src-tauri/capabilities/window-drag.json
@@ -0,0 +1,22 @@
+{
+ "$schema": "../gen/schemas/desktop-schema.json",
+ "identifier": "window-drag",
+ "description": "Allow only built-in window drag gestures on macOS, in bootstrap and the loopback Workbench. Same-origin Show Pages share this window-control boundary; Runtime management remains local-only.",
+ "platforms": [
+ "macOS"
+ ],
+ "local": true,
+ "windows": [
+ "main"
+ ],
+ "remote": {
+ "urls": [
+ "http://127.0.0.1:*/*",
+ "http://[\\:\\:1]:*/*"
+ ]
+ },
+ "permissions": [
+ "core:window:allow-start-dragging",
+ "core:window:allow-internal-toggle-maximize"
+ ]
+}
diff --git a/desktop/src-tauri/src/lib.rs b/desktop/src-tauri/src/lib.rs
index 8f230a0fd..a822c7959 100644
--- a/desktop/src-tauri/src/lib.rs
+++ b/desktop/src-tauri/src/lib.rs
@@ -9,10 +9,11 @@
//! * **Normal lifecycle does not stop the Runtime.** Closing or recreating a
//! window leaves it running. Only confirmed lifecycle actions invoke
//! the Runtime's own graceful stop command.
-//! * **The Workbench is not privileged.** `capabilities/bootstrap.json` grants
+//! * **Runtime management stays local.** `capabilities/bootstrap.json` grants
//! the two bootstrap commands to the shell's own local page only. Once the
//! window navigates to the Workbench origin the capability no longer matches,
-//! and [`ensure_shell_ui`] rejects the call a second time regardless.
+//! and [`ensure_shell_ui`] rejects the call a second time regardless. Only
+//! the two built-in window drag commands are granted to the Workbench.
use std::sync::atomic::{AtomicBool, AtomicU64, AtomicU8, Ordering};
use std::sync::{Arc, Mutex};
@@ -1211,7 +1212,6 @@ fn ensure_main_window(app: &AppHandle) -> Option<WebviewWindow> {
let window = builder.build().ok()?;
#[cfg(target_os = "macos")]
{
- macos_title_bar::install(&window);
macos_new_context::install(&window);
}
Some(window)
diff --git a/desktop/src-tauri/src/macos_title_bar.rs b/desktop/src-tauri/src/macos_title_bar.rs
index b2ee980bf..2d9557453 100644
--- a/desktop/src-tauri/src/macos_title_bar.rs
+++ b/desktop/src-tauri/src/macos_title_bar.rs
@@ -1,183 +1,43 @@
-//! The macOS window draws the Workbench under its title bar.
-//!
-//! `tauri.conf.json` gives the main window an overlay title bar with a hidden
-//! title, so the traffic lights float over the page instead of sitting on a
-//! separate grey strip. Two things then have to hold:
-//!
-//! - The page must keep the strip's region free of its own controls. The strip
-//! covers only the sidebar's top — the traffic lights float there — so the
-//! main pane's chat and search headers reach the window's top edge with their
-//! ordinary padding. Left-edge and full-window surfaces learn the strip's
-//! height from `--shell-titlebar-inset`, which [`inset_script`] sets on the
-//! root element before any Workbench script runs.
-//! - The strip must move the window. WKWebView honours no `app-region` CSS and
-//! swallows the mouse-down that would start a native drag, and Tauri's
-//! drag-region attribute needs an IPC grant the remote Workbench origin
-//! deliberately does not have. So the shell lays one transparent native view
-//! over the strip, above the WebView: a drag there moves the window and a
-//! double-click does what the system title bar would, with no page script
-//! involved and no capability widened.
-//!
-//! Both only hold for a page built against this exact geometry. The shell can
-//! adopt a Runtime it did not ship, whose Workbench keeps a different region
-//! free — or none at all — so every loaded page is asked, natively and without
-//! IPC, whether it declares [`SUPPORT_META`] with the geometry this shell
-//! draws. A page that does keeps the overlay; any other page, or a page that
-//! cannot answer, gets the standard title bar back with the strip hidden and
-//! the inset reset to zero.
+//! macOS overlay layout negotiation. Tauri owns drag gestures and window
+//! commands; no native hit-test overlay or custom WebKit IPC is installed.
+//! Older pages without explicit Tauri drag support get a standard title bar.
use block2::RcBlock;
use objc2::rc::Retained;
use objc2::runtime::AnyObject;
-use objc2::{define_class, msg_send, ClassType, MainThreadMarker, MainThreadOnly};
-use objc2_app_kit::{
- NSAutoresizingMaskOptions, NSEvent, NSResponder, NSView, NSWindow, NSWindowOrderingMode, NSWindowStyleMask,
- NSWindowTitleVisibility,
-};
-use objc2_foundation::{
- ns_string, NSError, NSObject, NSObjectProtocol, NSPoint, NSRect, NSSize, NSString, NSUserDefaults,
-};
+use objc2::MainThreadMarker;
+use objc2_app_kit::{NSWindow, NSWindowStyleMask, NSWindowTitleVisibility};
+use objc2_foundation::{NSError, NSString};
use objc2_web_kit::WKWebView;
-use tauri::{Webview, WebviewWindow};
+use tauri::Webview;
-/// Height, in points, of the strip the overlay title bar occupies: the standard
-/// macOS title bar of a window without a toolbar, where the traffic lights sit.
+/// Existing clearance under the traffic lights; this does not add a bar over
+/// the chat header, which continues to reach the top edge.
pub const TITLE_BAR_INSET: f64 = 28.0;
+const SUPPORT_META: &str = "avibe-shell-drag-regions";
-/// Width, in points, of the strip: the Workbench sidebar's minimum width
-/// (`MIN_SIDEBAR_WIDTH` in `ui/src/lib/sidebarWidth.ts`). The sidebar can only
-/// grow from there and keeps its whole top edge free, so the strip never
-/// reaches the main pane, whose headers therefore keep the window's full
-/// height. The traffic lights float over the sidebar, above the strip.
-/// Restoring the window keeps a grab handle inside this strip on screen
-/// (`window_frame` in the runtime-host crate); a narrower strip narrows it too.
-pub const TITLE_BAR_STRIP_WIDTH: f64 = 248.0;
-
-/// Publishes [`TITLE_BAR_INSET`] to the Workbench and the bootstrap page. User
-/// scripts run after the document element exists and before any page script.
-/// Top-level document only: Show Page content in subframes is laid out by the
-/// Workbench window that hosts it.
+/// Advertise the built-in drag capability only on macOS, before React renders.
+/// Window restore still keeps a grab handle inside the sidebar's existing
+/// clearance; replacing its native overlay with a DOM region preserves that area.
pub fn inset_script() -> String {
format!(
- "if (window.self === window.top) \
- document.documentElement.style.setProperty('--shell-titlebar-inset', '{TITLE_BAR_INSET}px');"
+ "if (window.self === window.top) {{ \
+ Object.defineProperty(window, '__AVIBE_DESKTOP_DRAG__', {{ value: true }}); \
+ document.documentElement.style.setProperty('--shell-titlebar-inset', '{TITLE_BAR_INSET}px'); }}"
)
}
-/// The `<meta name>` a page carries when it keeps the strip's region free, with
-/// the geometry it was built against as the content (`240x28`). The Workbench
-/// (`ui/index.html`) and the bootstrap page (`index.html`) both declare it. A
-/// page from another release that kept a different region free carries a
-/// different name or content, so skew in either direction falls back to the
-/// standard title bar instead of covering that page's controls.
-const SUPPORT_META: &str = "avibe-shell-title-strip";
-
-/// The geometry half of the [`SUPPORT_META`] contract, `<width>x<height>` in
-/// points, derived from the constants the strip is drawn with.
-fn support_geometry() -> String {
- format!("{TITLE_BAR_STRIP_WIDTH}x{TITLE_BAR_INSET}")
-}
-
/// Answers whether the loaded top-level page declares [`SUPPORT_META`] for this
-/// shell's exact strip geometry, and makes the published inset agree.
+/// shell's Tauri drag support, and makes the published inset agree.
fn support_probe() -> String {
- let geometry = support_geometry();
format!(
"(function () {{ \
- var supported = document.querySelector('meta[name=\"{SUPPORT_META}\"][content=\"{geometry}\"]') !== null; \
+ var supported = document.querySelector('meta[name=\"{SUPPORT_META}\"][content=\"tauri\"]') !== null; \
document.documentElement.style.setProperty('--shell-titlebar-inset', supported ? '{TITLE_BAR_INSET}px' : '0px'); \
return supported ? 'supported' : 'unsupported'; }})()"
)
}
-define_class!(
- #[unsafe(super(NSView, NSResponder, NSObject))]
- #[thread_kind = MainThreadOnly]
- #[name = "AvibeTitleBarDragStrip"]
- struct TitleBarDragStrip;
-
- unsafe impl NSObjectProtocol for TitleBarDragStrip {}
-
- impl TitleBarDragStrip {
- #[unsafe(method(mouseDown:))]
- fn mouse_down(&self, event: &NSEvent) {
- let Some(window) = self.window() else {
- return;
- };
- if event.clickCount() == 2 {
- perform_title_bar_double_click(&window);
- } else {
- window.performWindowDragWithEvent(event);
- }
- }
-
- /// A click on an inactive window drags it at once, as the system title
- /// bar does, instead of being spent on activation.
- #[unsafe(method(acceptsFirstMouse:))]
- fn accepts_first_mouse(&self, _event: Option<&NSEvent>) -> bool {
- true
- }
- }
-);
-
-impl TitleBarDragStrip {
- fn new(mtm: MainThreadMarker, frame: NSRect) -> Retained<Self> {
- let this = Self::alloc(mtm).set_ivars(());
- unsafe { msg_send![super(this), initWithFrame: frame] }
- }
-}
-
-/// The user's System Settings choice for double-clicking a title bar
-/// (Desktop & Dock > "Double-click a window's title bar to"). An unset value is
-/// the system default, zoom.
-fn perform_title_bar_double_click(window: &NSWindow) {
- let action = NSUserDefaults::standardUserDefaults().stringForKey(ns_string!("AppleActionOnDoubleClick"));
- match action.map(|action| action.to_string()).as_deref() {
- Some("Minimize") => window.performMiniaturize(None),
- Some("None") => {}
- _ => window.performZoom(None),
- }
-}
-
-/// Lays the drag strip over the top of the window's content, above the WebView.
-/// The window's content view holds the WebView for the window's whole life, and
-/// navigation replaces only the page inside it, so one strip per window suffices.
-pub fn install(window: &WebviewWindow) {
- let _ = window.with_webview(|webview| {
- let Some(mtm) = MainThreadMarker::new() else {
- return;
- };
- // SAFETY: Tauri hands out the live NSWindow of this webview's window, on
- // the main thread, for the duration of this closure.
- let window: &NSWindow = unsafe { &*webview.ns_window().cast() };
- let Some(content) = window.contentView() else {
- return;
- };
- let bounds = content.bounds();
- let flipped = content.isFlipped();
- let y = if flipped {
- 0.0
- } else {
- bounds.size.height - TITLE_BAR_INSET
- };
- let strip = TitleBarDragStrip::new(
- mtm,
- NSRect::new(
- NSPoint::new(0.0, y),
- NSSize::new(TITLE_BAR_STRIP_WIDTH, TITLE_BAR_INSET),
- ),
- );
- // Pinned to the top-left corner, fixed size, on every resize.
- let pin_top = if flipped {
- NSAutoresizingMaskOptions::ViewMaxYMargin
- } else {
- NSAutoresizingMaskOptions::ViewMinYMargin
- };
- strip.setAutoresizingMask(NSAutoresizingMaskOptions::ViewMaxXMargin | pin_top);
- content.addSubview_positioned_relativeTo(&strip, NSWindowOrderingMode::Above, None);
- });
-}
-
/// Keeps the overlay title bar only while the loaded page declares
/// [`SUPPORT_META`]. Called for every finished main-window page load; a later
/// load re-decides, so a stale answer never outlives the page that gave it.
@@ -208,7 +68,7 @@ pub fn sync(webview: &Webview) {
});
}
-/// Switches between the overlay title bar with the drag strip and the standard
+/// Switches between the overlay title bar and the standard
/// title bar with the window title, the only two frames the shell draws.
fn set_overlay(window: &NSWindow, overlay: bool, _mtm: MainThreadMarker) {
let mut mask = window.styleMask();
@@ -220,50 +80,18 @@ fn set_overlay(window: &NSWindow, overlay: bool, _mtm: MainThreadMarker) {
} else {
NSWindowTitleVisibility::Visible
});
- let Some(content) = window.contentView() else {
- return;
- };
- for view in content.subviews().iter() {
- if view.isKindOfClass(TitleBarDragStrip::class()) {
- view.setHidden(!overlay);
- }
- }
}
#[cfg(test)]
mod tests {
use super::*;
- /// A page that keeps the strip's region free must say so for this exact
- /// geometry, or the shell falls back to the standard title bar for it. Both
- /// pages the shell can show at the current release declare it.
#[test]
- fn every_page_this_release_serves_declares_this_strip_geometry() {
- let crate_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- for page in ["../index.html", "../../ui/index.html"] {
- let html = std::fs::read_to_string(crate_dir.join(page)).expect("page is readable");
- assert!(
- html.contains(&format!(
- "<meta name=\"{SUPPORT_META}\" content=\"{}\"",
- support_geometry()
- )),
- "{page} must declare {SUPPORT_META} for {}",
- support_geometry()
- );
+ fn shipping_pages_declare_native_drag_support() {
+ let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
+ for path in ["../index.html", "../../ui/index.html"] {
+ let html = std::fs::read_to_string(root.join(path)).unwrap();
+ assert!(html.contains(&format!("<meta name=\"{SUPPORT_META}\" content=\"tauri\"")));
}
}
-
- /// The strip must never reach the main pane, whose headers use the full
- /// window height. The sidebar guarantees that by never shrinking below the
- /// strip's width; if its minimum changes, the strip and the geometry
- /// contract must change with it.
- #[test]
- fn the_strip_never_outgrows_the_workbench_sidebar() {
- let widths = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../ui/src/lib/sidebarWidth.ts");
- let widths = std::fs::read_to_string(widths).expect("sidebarWidth.ts is readable");
- assert!(
- widths.contains(&format!("MIN_SIDEBAR_WIDTH = {TITLE_BAR_STRIP_WIDTH};")),
- "the sidebar's minimum width must equal the native drag strip's width ({TITLE_BAR_STRIP_WIDTH}px)"
- );
- }
}
diff --git a/desktop/src-tauri/tauri.conf.json b/desktop/src-tauri/tauri.conf.json
index b4c8750d6..1a2dba7bf 100644
--- a/desktop/src-tauri/tauri.conf.json
+++ b/desktop/src-tauri/tauri.conf.json
@@ -28,7 +28,8 @@
],
"security": {
"capabilities": [
- "bootstrap"
+ "bootstrap",
+ "window-drag"
],
"csp": "default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; connect-src 'self' ipc: http://ipc.localhost"
}
diff --git a/desktop/src-tauri/tests/shell_boundaries.rs b/desktop/src-tauri/tests/shell_boundaries.rs
index 37480a6c4..aa59d90f5 100644
--- a/desktop/src-tauri/tests/shell_boundaries.rs
+++ b/desktop/src-tauri/tests/shell_boundaries.rs
@@ -100,15 +100,15 @@ fn the_bootstrap_capability_grants_only_the_three_shell_commands() {
}
#[test]
-fn the_shell_enables_no_capability_beyond_bootstrap() {
+fn the_shell_enables_only_bootstrap_and_window_drag() {
assert_eq!(
config()["app"]["security"]["capabilities"],
- serde_json::json!(["bootstrap"])
+ serde_json::json!(["bootstrap", "window-drag"])
);
}
#[test]
-fn notifications_are_native_only_without_remote_capabilities_or_workbench_callable_commands() {
+fn notifications_are_native_only_without_workbench_callable_commands() {
let source = shipping_source("src/lib.rs");
let native = shipping_source("src/notifications.rs");
let build = shipping_source("build.rs");
@@ -135,7 +135,6 @@ fn notifications_are_native_only_without_remote_capabilities_or_workbench_callab
let path = entry.unwrap().path();
if path.extension().is_some_and(|extension| extension == "json") {
let capability = read_json(path);
- assert!(capability.get("remote").is_none());
assert!(!capability["permissions"].to_string().contains("notification:"));
}
}
@@ -664,11 +663,11 @@ fn the_workbench_learns_it_runs_in_the_shell_from_one_top_level_marker() {
}
#[test]
-fn the_macos_overlay_title_bar_needs_no_page_permission_and_defaults_to_no_inset() {
+fn the_macos_overlay_title_bar_keeps_its_layout_and_defaults_to_no_inset() {
let window = &config()["app"]["windows"][0];
assert_eq!(window["titleBarStyle"], "Overlay");
assert_eq!(window["hiddenTitle"], true);
- // The strip drags natively; the page is granted no window permission for it.
+ // Bootstrap management and window gestures have separate capability grants.
assert!(!read_to_string(&crate_dir().join("capabilities/bootstrap.json")).contains("start-dragging"));
let css = read_to_string(&crate_dir().join("../../ui/src/index.css"));
assert!(
@@ -962,3 +961,45 @@ fn updates_have_one_native_owner_and_no_remote_install_permission() {
assert!(!include_str!("../capabilities/bootstrap.json").contains("updater:"));
assert!(!include_str!("../build.rs").contains("update_install"));
}
+
+#[test]
+fn workbench_window_permissions_are_narrow_and_match_literal_loopback_origins() {
+ use tauri::utils::acl::RemoteUrlPattern;
+ let grant = read_json(crate_dir().join("capabilities/window-drag.json"));
+ assert_eq!(grant["windows"], serde_json::json!(["main"]));
+ assert_eq!(grant["platforms"], serde_json::json!(["macOS"]));
+ assert_eq!(grant["local"], true);
+ assert_eq!(
+ grant["permissions"],
+ serde_json::json!([
+ "core:window:allow-start-dragging",
+ "core:window:allow-internal-toggle-maximize"
+ ])
+ );
+ let patterns: Vec<RemoteUrlPattern> = grant["remote"]["urls"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .map(|pattern| pattern.as_str().unwrap().parse().unwrap())
+ .collect();
+ for origin in [
+ "http://127.0.0.1:5123",
+ "http://[::1]:5123",
+ "http://127.0.0.1",
+ "http://[::1]:6174",
+ ] {
+ for path in ["/", "/setup", "/chat/abc", "/show/abc/"] {
+ let url = url::Url::parse(&format!("{origin}{path}")).unwrap();
+ assert!(patterns.iter().any(|pattern| pattern.test(&url)), "{url}");
+ }
+ }
+ for rejected in [
+ "https://example.com/setup",
+ "http://127.0.0.1.example.com/",
+ "http://192.168.1.2:5123/",
+ "http://localhost:5123/",
+ ] {
+ let url = url::Url::parse(rejected).unwrap();
+ assert!(!patterns.iter().any(|pattern| pattern.test(&url)), "{url}");
+ }
+}
diff --git a/desktop/src/styles.css b/desktop/src/styles.css
index 18f86cb27..938997809 100644
--- a/desktop/src/styles.css
+++ b/desktop/src/styles.css
@@ -247,3 +247,10 @@ body {
transform: none;
}
}
+
+/* Occupies existing overlay clearance, without adding layout height. */
+.window-drag-region {
+ position: fixed;
+ inset: 0 0 auto;
+ height: var(--shell-titlebar-inset, 0px);
+}
diff --git a/docs/plans/2026-09-29-desktop-native-drag.md b/docs/plans/2026-09-29-desktop-native-drag.md
new file mode 100644
index 000000000..8b24780df
--- /dev/null
+++ b/docs/plans/2026-09-29-desktop-native-drag.md
@@ -0,0 +1,86 @@
+# Desktop title bar: Tauri drag regions
+
+## Contract
+
+Keep the macOS overlay title bar and hidden title. The existing top header's
+empty space is draggable across the window; no extra horizontal bar or layout
+height is added. Setup keeps its language switcher. Interactive controls and
+popup surfaces retain their current actions.
+
+Use Tauri's built-in `data-tauri-drag-region` handling and window commands.
+Grant only start-dragging and internal-toggle-maximize to the main macOS window,
+including its loopback Workbench. Same-origin Show Pages can reach these window
+commands through their parent; this is an explicitly accepted window-control
+boundary, not isolation. Bootstrap, notifications, updater and Runtime lifecycle
+commands remain outside the remote grant.
+
+Remove the custom WebKit message handler, native drag overlay and page mouse
+listeners. Mark concrete blank layout containers with the direct-target drag
+attribute, rather than inferring controls from global events. Retain the existing
+traffic-light clearance without growing the chat header. New shells use the
+standard title bar for older pages that do not declare Tauri drag support.
+
+## Review inventory and decision
+
+Before this revision: head 9d3d659c4 had three findings (overlay-state gating,
+popup hit testing, double-click tolerance); head 1c4e3d9be had one finding
+(same-origin subframes bypassing the claimed main-frame bridge boundary).
+The owner now permits Workbench window IPC. Replace the custom interaction
+protocol with Tauri, and document the actual same-origin boundary. Double-click
+behavior follows the bundled Tauri implementation rather than a local emulation
+of macOS preferences. No new dependencies, merge, release or deployment.
+
+The previous lane's last Watch follow-up failed and no run was active. Its Watch
+3658eb938494 was paused before taking over the existing clean PR worktree.
+
+## Validation
+
+- Exercise the bundled Tauri drag script against real rendered header/Setup
+ controls and popups; ensure blank header targets invoke dragging and controls do not.
+- Check the remote capability URL matching and exact permission allowlist.
+- Run the relevant complete UI test files, UI and bootstrap builds, Rust tests,
+ formatting and Clippy.
+- Packaged macOS dragging remains a separate acceptance boundary; do not claim
+ browser or unit evidence proves actual native window movement.
+- Update PR #2262, read its body back and follow exact-head review/CI gates.
+
+## Local results
+
+- UI build and bootstrap build passed. Six affected UI test files passed
+ (199 assertions total).
+- `cargo test -p avibe-desktop`: 73 passed, including real Tauri URLPattern
+ matching for IPv4/IPv6, alternate ports and rejected non-loopback hosts.
+- Clippy with warnings denied passed.
+- A temporary local probe loaded the exact locked Tauri 2.11.5 `drag.js`,
+ executed it against rendered Setup and chat headers, and verified every marked
+ blank invokes start-dragging, buttons and their nested icons invoke nothing,
+ a still double-click invokes internal-toggle-maximize, and the real open
+ LanguageSwitcher listbox/options invoke nothing. All three probe tests passed;
+ the local registry-dependent probe was removed after verification.
+- `vibe watch add` cannot bind this Codex desktop chat: `missing_session_policy`.
+ The original lane's Watch remains paused to prevent concurrent stale edits.
+ Review/CI observation in this chat uses the bundled waiter and a pre-push
+ baseline; no unrelated Avibe session is created or messaged.
+
+- Repository UI lint baseline passed with no drift. Direct ESLint reports the
+ existing baselined findings; no unrelated lint changes were made.
+- Hermetic Chromium probe of the real `/chat/drag-fixture` route passed. With
+ the exact Tauri script injected and native invocation captured, real pointer
+ clicks at x=100,258,700,1355 along the top all invoked dragging. Title editing
+ remained clickable without invoking dragging. Measured header y=0, x=248,
+ height under 60px at 1366x800; no extra bar. All application requests were
+ intercepted by the existing fixture and the denied-request ledger was empty.
+ The temporary test/server were cleaned up. Native OS movement is still deferred.
+
+## Base synchronization
+
+Merged origin/master fb18756aa after GitHub reported a conflict. The sole conflict
+was the restored-window grab-area comment on the removed native drag strip.
+Preserved master window restoration, update architecture checks, backend install
+outcomes and other changes unchanged; the sidebar DOM region still covers the
+same grab area the restoration algorithm protects. Revalidate the merged tree.
+
+Merged-tree revalidation: UI/bootstrap builds, 199 UI tests, 75 desktop Rust
+tests, all 8 window-frame tests and Clippy passed. The first revised head
+55a600141 is under Codex review; wait for its terminal verdict before pushing
+the base synchronization, so review evidence cannot be attributed across heads.
diff --git a/ui/index.html b/ui/index.html
index eb49d1bd1..0353d7554 100644
--- a/ui/index.html
+++ b/ui/index.html
@@ -15,6 +15,7 @@
drag strip free of controls (--shell-titlebar-inset); without an exact
match the shell keeps the standard title bar. -->
<meta name="avibe-shell-title-strip" content="248x28" />
+ <meta name="avibe-shell-drag-regions" content="tauri" />
<!-- PWA / iOS standalone: "Add to Home Screen" launches a full-screen app
(no Safari chrome), which sidesteps the iOS keyboard whitespace/accessory
diff --git a/ui/src/components/AppShell.tsx b/ui/src/components/AppShell.tsx
index c0bd281ed..518eb6407 100644
--- a/ui/src/components/AppShell.tsx
+++ b/ui/src/components/AppShell.tsx
@@ -1,3 +1,4 @@
+import { DesktopDragRegion } from './DesktopDragRegion';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { Link, Navigate, NavLink, Outlet, useLocation, useNavigate } from 'react-router-dom';
import { AlertTriangle, FolderTree, Grid2x2, Inbox, LayoutGrid, Plus, Settings } from 'lucide-react';
@@ -468,6 +469,7 @@ export const AppShell: React.FC = () => {
settingsCoversSidebar && 'invisible pointer-events-none',
)}
>
+ <DesktopDragRegion className="absolute inset-x-0 top-0" />
<div className="flex min-h-0 flex-1 flex-col">
{isDesktop && (
<RouteSurfaceActivityBoundary active={!settingsCoversSidebar}>
@@ -573,6 +575,9 @@ export const AppShell: React.FC = () => {
</header>
)}
+ {!chromeless && !isFullScreenMobile && !isSettings && (
+ <DesktopDragRegion className="fixed left-[var(--app-sidebar-w)] right-0 top-0 z-10" />
+ )}
<main
id={APP_SHELL_SCROLL_ID}
className={clsx(
diff --git a/ui/src/components/DesktopDragRegion.tsx b/ui/src/components/DesktopDragRegion.tsx
new file mode 100644
index 000000000..a43e2c7e8
--- /dev/null
+++ b/ui/src/components/DesktopDragRegion.tsx
@@ -0,0 +1,9 @@
+import clsx from 'clsx';
+import { desktopDragRegion } from '../lib/desktopShell';
+
+/** Makes existing traffic-light clearance draggable without adding layout height. */
+export function DesktopDragRegion({ className }: { className: string }) {
+ const region = desktopDragRegion();
+ if (region === undefined) return null;
+ return <div aria-hidden="true" data-tauri-drag-region={region} className={clsx('h-[var(--shell-titlebar-inset)] select-none', className)} />;
+}
diff --git a/ui/src/components/Wizard.tsx b/ui/src/components/Wizard.tsx
index 2a2c74b4b..e414b1b85 100644
--- a/ui/src/components/Wizard.tsx
+++ b/ui/src/components/Wizard.tsx
@@ -1,3 +1,5 @@
+import { desktopDragRegion } from '../lib/desktopShell';
+import { DesktopDragRegion } from './DesktopDragRegion';
import { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactElement, type Ref } from 'react';
import { ArrowLeft, ArrowRight, LoaderCircle, RefreshCw } from 'lucide-react';
import { Button } from './ui/button';
@@ -25,7 +27,6 @@ import {
} from './onboarding/providers/gatewayBootstrap';
import logoImg from '@/assets/logo.png';
import { LanguageSwitcher } from './LanguageSwitcher';
-import { isDesktopShell } from '../lib/desktopShell';
import { useApi } from '../context/ApiContext';
import { useStatus } from '../context/StatusContext';
import { setConfigField } from '../lib/configMutations';
@@ -39,14 +40,15 @@ import { admitEntry, chooseEntryDefault, readEntryEvidence, type EntryGateDeps,
* at the window's own gutter, and the shared language switcher wearing its round
* trigger opposite it.
*
- * The desktop shell leaves it out, and its height with it: the window's title bar
- * names the app, and language lives in General Settings behind the native menu.
+ * The desktop shell keeps it too — its overlay title bar shows no title — and lets the
+ * row move the window wherever the brand and the language button leave it free.
*/
-function SetupHeader() {
+export function SetupHeader() {
const { t } = useTranslation();
- if (isDesktopShell()) return null;
return (
- <header>
+ <>
+ <DesktopDragRegion className="fixed inset-x-0 top-0 z-10" />
+ <header data-tauri-drag-region={desktopDragRegion()}>
<div className="onboarding-brand">
<span className="onboarding-brand-mark"><img src={logoImg} alt="" /></span>
<span className="onboarding-brand-wordmark">
@@ -56,6 +58,7 @@ function SetupHeader() {
</div>
<LanguageSwitcher variant="icon-round" />
</header>
+ </>
);
}
diff --git a/ui/src/components/settings/SettingsLayout.tsx b/ui/src/components/settings/SettingsLayout.tsx
index 8b5073f30..78cc7d0dd 100644
--- a/ui/src/components/settings/SettingsLayout.tsx
+++ b/ui/src/components/settings/SettingsLayout.tsx
@@ -1,3 +1,4 @@
+import { DesktopDragRegion } from '../DesktopDragRegion';
import type { TranslationKey } from '@/i18n/types';
import React, { useEffect, useMemo, useState } from 'react';
import { NavLink, Outlet, useLocation, useNavigate } from 'react-router-dom';
@@ -366,7 +367,8 @@ export const SettingsLayout: React.FC = () => {
}, [atRoot, capabilities.can_manage_instance, isDesktop, navigate]);
return (
- <div className="flex h-full min-h-0 flex-col overflow-hidden bg-background md:h-[var(--app-shell-h)]">
+ <div className="relative flex h-full min-h-0 flex-col overflow-hidden bg-background md:h-[var(--app-shell-h)]">
+ <DesktopDragRegion className="absolute inset-x-0 top-0 z-10" />
{/* The desktop shell's title bar stands in for this one. Its window never
gets narrower than the rail breakpoint, so the rail's own Back to Avibe
row is always on screen to leave by. */}
diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsx
index d08fde3b0..b32c2d785 100644
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@ -1,3 +1,4 @@
+import { desktopDragRegion } from '../../lib/desktopShell';
import { Fragment, forwardRef, memo, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Link, useLocation, useNavigate, useParams, useSearchParams } from 'react-router-dom';
@@ -3687,8 +3688,8 @@ export const ChatHeaderBar: React.FC<ChatHeaderBarProps> = ({ session, agents, d
// hairline bottom border separating it from the scrolling transcript.
// No project-id pill and no override banner — both were noise the user
// flagged (regression feedback #1/#3).
- <div className="shrink-0 border-b border-border bg-surface/70 px-4 py-2.5 backdrop-blur md:px-8">
- <div className="mx-auto flex w-full max-w-[1080px] items-center gap-3">
+ <div data-tauri-drag-region={desktopDragRegion()} className="shrink-0 border-b border-border bg-surface/70 px-4 py-2.5 backdrop-blur md:px-8">
+ <div data-tauri-drag-region={desktopDragRegion()} className="mx-auto flex w-full max-w-[1080px] items-center gap-3">
<Button
type="button"
variant="outline"
diff --git a/ui/src/components/workbench/SearchPage.tsx b/ui/src/components/workbench/SearchPage.tsx
index 23eea5854..f8781b96f 100644
--- a/ui/src/components/workbench/SearchPage.tsx
+++ b/ui/src/components/workbench/SearchPage.tsx
@@ -1,3 +1,4 @@
+import { desktopDragRegion } from '../../lib/desktopShell';
import { useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom';
@@ -102,7 +103,7 @@ export const SearchPage: React.FC = () => {
// routes here (sidebar field + ⌘K own search), but keep it sane if hit.
<div className="fixed inset-0 z-40 flex flex-col bg-background pt-[env(safe-area-inset-top)] md:absolute">
{/* Header — back chevron + active search field (design.pen P6Nsz/KmsNV). */}
- <header className="flex shrink-0 items-center gap-2.5 border-b border-border bg-background/92 px-4 py-3 backdrop-blur">
+ <header data-tauri-drag-region={desktopDragRegion()} className="flex shrink-0 items-center gap-2.5 border-b border-border bg-background/92 px-4 py-3 backdrop-blur">
<Button
type="button"
variant="ghost"
diff --git a/ui/src/lib/desktopShell.test.tsx b/ui/src/lib/desktopShell.test.tsx
new file mode 100644
index 000000000..8879d1c37
--- /dev/null
+++ b/ui/src/lib/desktopShell.test.tsx
@@ -0,0 +1,91 @@
+// @vitest-environment jsdom
+import { createInstance } from 'i18next';
+import { renderToStaticMarkup } from 'react-dom/server';
+import { I18nextProvider, initReactI18next } from 'react-i18next';
+import { MemoryRouter } from 'react-router-dom';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { SetupHeader } from '../components/Wizard';
+import { ChatHeaderBar } from '../components/workbench/ChatPage';
+import { DesktopDragRegion } from '../components/DesktopDragRegion';
+import { ToastProvider } from '../context/ToastProvider';
+import type { WorkbenchSession } from '../context/ApiContext';
+import en from '../i18n/en.json';
+import zh from '../i18n/zh.json';
+
+vi.mock('../context/InstanceAuthorizationContext', async (original) => ({
+ ...await original<typeof import('../context/InstanceAuthorizationContext')>(),
+ useInstanceAuthorization: () => ({ capabilities: { can_manage_instance: false } }),
+}));
+vi.mock('../context/ApiContext', async (original) => ({
+ ...await original<typeof import('../context/ApiContext')>(),
+ useApi: () => ({}),
+}));
+
+vi.hoisted(() => {
+ window.matchMedia = vi.fn().mockReturnValue({ matches: false, addEventListener: vi.fn(), removeEventListener: vi.fn() });
+});
+
+const i18n = createInstance();
+void i18n.use(initReactI18next).init({
+ lng: 'en', fallbackLng: 'en', resources: { en: { translation: en }, zh: { translation: zh } },
+ interpolation: { escapeValue: false },
+});
+
+function inShell({ native = true, supported = true } = {}) {
+ Object.defineProperty(window, '__AVIBE_DESKTOP_SHELL__', { configurable: true, value: true });
+ if (native) Object.defineProperty(window, '__AVIBE_DESKTOP_DRAG__', { configurable: true, value: true });
+ if (supported) document.head.innerHTML = '<meta name="avibe-shell-drag-regions" content="tauri">';
+}
+
+function renderHeaders() {
+ document.body.innerHTML = renderToStaticMarkup(
+ <I18nextProvider i18n={i18n}><ToastProvider><MemoryRouter>
+ <SetupHeader />
+ <DesktopDragRegion className="absolute inset-x-0 top-0" />
+ <ChatHeaderBar
+ session={{ id: 'test', title: 'Header title', status: 'archived' } as WorkbenchSession}
+ agents={[]} defaultAgentName={null} onPatch={async () => undefined}
+ onBack={() => undefined} working={false} showPageMode={false}
+ showPageBusy={false} onToggleShowPage={() => undefined}
+ onPrepareShowPageLaunch={async () => false}
+ annotation={{ state: null, iframeRef: { current: null }, handleIframeLoad: () => undefined,
+ handleShortcutKeyDown: () => undefined, enable: () => undefined, disable: () => undefined, setMode: () => undefined }}
+ readOnlyReason="archived"
+ />
+ </MemoryRouter></ToastProvider></I18nextProvider>,
+ );
+}
+
+afterEach(() => {
+ document.head.innerHTML = '';
+ document.body.innerHTML = '';
+ delete (window as { __AVIBE_DESKTOP_SHELL__?: true }).__AVIBE_DESKTOP_SHELL__;
+ delete (window as { __AVIBE_DESKTOP_DRAG__?: true }).__AVIBE_DESKTOP_DRAG__;
+});
+
+describe('native desktop drag surfaces', () => {
+ it('marks existing header blanks and clearance without marking controls or their descendants', () => {
+ inShell();
+ renderHeaders();
+ const regions = [...document.querySelectorAll('[data-tauri-drag-region]')];
+ expect(regions).toHaveLength(5); // Setup header + clearance, sidebar clearance, chat outer + inner.
+ expect(regions.every((region) => region.getAttribute('data-tauri-drag-region') === '')).toBe(true);
+ expect(document.querySelector('header')?.hasAttribute('data-tauri-drag-region')).toBe(true);
+ const controls = [...document.querySelectorAll('button')];
+ expect(controls.length).toBeGreaterThanOrEqual(2); // Real language trigger and Back.
+ for (const control of controls) {
+ expect(control.closest('[data-tauri-drag-region]')).not.toBeNull();
+ expect(control.hasAttribute('data-tauri-drag-region')).toBe(false);
+ expect(control.querySelector('[data-tauri-drag-region]')).toBeNull();
+ }
+ });
+
+ it('keeps the setup language switcher in browsers and older shells without enabling native dragging', () => {
+ for (const mode of ['browser', 'older-shell', 'unsupported-layout'] as const) {
+ if (mode !== 'browser') inShell({ native: mode !== 'older-shell', supported: false });
+ renderHeaders();
+ expect(document.querySelector('button[aria-haspopup="listbox"]')).not.toBeNull();
+ expect(document.querySelector('[data-tauri-drag-region]')).toBeNull();
+ }
+ });
+});
diff --git a/ui/src/lib/desktopShell.ts b/ui/src/lib/desktopShell.ts
index b83a7a7ce..0dcfbe278 100644
--- a/ui/src/lib/desktopShell.ts
+++ b/ui/src/lib/desktopShell.ts
@@ -3,6 +3,8 @@ declare global {
/** Defined by the Avibe desktop shell before any page script runs, top-level document only. */
readonly __AVIBE_DESKTOP_SHELL__?: true;
readonly __AVIBE_DESKTOP_VERSION__?: string;
+ /** The macOS shell grants Tauri window dragging to this page. */
+ readonly __AVIBE_DESKTOP_DRAG__?: true;
}
}
@@ -24,3 +26,10 @@ export function isDesktopShell(): boolean {
* shell loads Settings as a page instead.
*/
export const DESKTOP_OPEN_SETTINGS_EVENT = 'avibe:desktop-open-settings';
+
+/** Only a direct press on this layout element drags; descendants keep their input. */
+export function desktopDragRegion(): '' | undefined {
+ return isDesktopShell() && window.__AVIBE_DESKTOP_DRAG__ === true
+ && document.querySelector('meta[name="avibe-shell-drag-regions"][content="tauri"]')
+ ? '' : undefined;
+}