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): integrate chat controls into the native window header (#2294)

Max559a6d29ec74
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 5fcd52269..a221be163 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -88,7 +88,7 @@ jobs:
npm run test:project-order
npm run test:inbox-return
npm run test:badge-triggers
- npm run test:workbench-general -- sidebar-floating.spec.ts
+ npm run test:workbench-general -- sidebar-floating.spec.ts desktop-window-chrome.spec.ts
npm run test:voice-shortcut
show-router-integration:
diff --git a/desktop/README.md b/desktop/README.md
index 51f48f6b6..4966a1e48 100644
--- a/desktop/README.md
+++ b/desktop/README.md
@@ -248,26 +248,33 @@ 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 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.
+traffic lights are centered in the 48px top row. The complete chat toolbar sits
+beside them, with the same 1080px content width and responsive gutters as the web
+toolbar, transcript and composer. Back, title editing, agent/model/effort selection,
+Visualize and sharing keep their existing handlers and state. There is no extra
+empty title strip above the toolbar. Home and chat use the same sidebar divider
+and clearance, with matching 16px top and left insets around the logo.
+
+Tauri's built-in `data-tauri-drag-region` handler owns window gestures. The
+toolbar's outer padding and inner blank space are direct-target drag regions;
+child controls, menus and popups keep their normal mouse input. Native window
+background dragging is disabled, so the transcript cannot move the window.
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.
+DOM regions cover traffic-light clearance on the sidebar, Setup, Settings,
+ordinary Workbench pages and bootstrap. Settings hides the retained chat toolbar.
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.
+`__AVIBE_DESKTOP_DRAG__` before page scripts run. The native sidebar and chat
+override that clearance to 48px for the window toolbar. The native frame stays
+transparent even when an adopted Runtime serves older UI without drag metadata;
+pages that predate drag regions need a Runtime UI update to provide those gestures.
+The metadata declarations remain for older shells, but the current Workbench
+activates native drag attributes from the shell capability marker alone.
+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/src-tauri/src/lib.rs b/desktop/src-tauri/src/lib.rs
index ce54087f5..6e1b02845 100644
--- a/desktop/src-tauri/src/lib.rs
+++ b/desktop/src-tauri/src/lib.rs
@@ -1197,7 +1197,7 @@ fn ensure_main_window(app: &AppHandle) -> Option<WebviewWindow> {
serde_json::to_string(&app.package_info().version.to_string()).expect("version JSON")
))
.on_new_window(|url, _features| handle_new_window_request(url));
- // macOS draws the page under an overlay title bar (`tauri.conf.json`).
+ // macOS draws the page under a transparent native title bar (`tauri.conf.json`).
#[cfg(target_os = "macos")]
let builder = builder.initialization_script(macos_title_bar::inset_script());
let window = builder.build().ok()?;
@@ -1728,8 +1728,8 @@ pub fn run() {
PluginBuilder::<_, ()>::new("shell-run-events")
.on_page_load(|webview, payload| {
if webview.label() == MAIN_WINDOW && payload.event() == tauri::webview::PageLoadEvent::Finished {
- // Each loaded page decides whether it sits under the overlay
- // title bar; an older adopted Workbench gets the standard one.
+ // The native frame is independent of the Runtime UI version;
+ // older adopted Workbench pages must not restore a title bar.
#[cfg(target_os = "macos")]
macos_title_bar::sync(webview);
apply_pending_deep_link(webview.app_handle());
diff --git a/desktop/src-tauri/src/macos_title_bar.rs b/desktop/src-tauri/src/macos_title_bar.rs
index 2d9557453..c0337f218 100644
--- a/desktop/src-tauri/src/macos_title_bar.rs
+++ b/desktop/src-tauri/src/macos_title_bar.rs
@@ -1,19 +1,17 @@
-//! macOS overlay layout negotiation. Tauri owns drag gestures and window
+//! macOS transparent title-bar setup. 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.
+//! Every page uses the same transparent native frame, including older Runtime
+//! pages that predate the drag-region metadata.
-use block2::RcBlock;
use objc2::rc::Retained;
-use objc2::runtime::AnyObject;
use objc2::MainThreadMarker;
use objc2_app_kit::{NSWindow, NSWindowStyleMask, NSWindowTitleVisibility};
-use objc2_foundation::{NSError, NSString};
-use objc2_web_kit::WKWebView;
use tauri::Webview;
/// 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;
+#[cfg(test)]
const SUPPORT_META: &str = "avibe-shell-drag-regions";
/// Advertise the built-in drag capability only on macOS, before React renders.
@@ -27,59 +25,33 @@ pub fn inset_script() -> String {
)
}
-/// Answers whether the loaded top-level page declares [`SUPPORT_META`] for this
-/// shell's Tauri drag support, and makes the published inset agree.
-fn support_probe() -> String {
- format!(
- "(function () {{ \
- 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'; }})()"
- )
-}
-
-/// 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.
+/// Applies the transparent native frame to every loaded page. The frame is a
+/// shell property, so it must not depend on a metadata marker served by the
+/// Runtime's UI version.
pub fn sync(webview: &Webview) {
let _ = webview.with_webview(|platform| {
let Some(mtm) = MainThreadMarker::new() else {
return;
};
// SAFETY: Tauri hands out the live WKWebView and its NSWindow, on the
- // main thread, for the duration of this closure; retaining them keeps
- // both alive until the completion handler has run.
- let (Some(web_view), Some(window)) = (
- unsafe { Retained::retain(platform.inner().cast::<WKWebView>()) },
- unsafe { Retained::retain(platform.ns_window().cast::<NSWindow>()) },
- ) else {
+ // main thread, for the duration of this closure.
+ let Some(window) = (unsafe { Retained::retain(platform.ns_window().cast::<NSWindow>()) }) else {
return;
};
- let handler = RcBlock::new(move |result: *mut AnyObject, _error: *mut NSError| {
- // SAFETY: WebKit passes the script's result, or null, as a live object.
- let supported = unsafe { result.as_ref() }
- .and_then(|result| result.downcast_ref::<NSString>())
- .is_some_and(|answer| answer.to_string() == "supported");
- set_overlay(&window, supported, mtm);
- });
- // SAFETY: called on the main thread with a live WKWebView; WebKit calls
- // the handler once, on the main thread.
- unsafe { web_view.evaluateJavaScript_completionHandler(&NSString::from_str(&support_probe()), Some(&handler)) };
+ set_overlay(&window, mtm);
});
}
-/// 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) {
+/// Keeps the content view under a transparent native title bar while retaining
+/// AppKit's traffic-light buttons and native window behavior.
+fn set_overlay(window: &NSWindow, _mtm: MainThreadMarker) {
let mut mask = window.styleMask();
- mask.set(NSWindowStyleMask::FullSizeContentView, overlay);
+ mask.set(NSWindowStyleMask::FullSizeContentView, true);
window.setStyleMask(mask);
- window.setTitlebarAppearsTransparent(overlay);
- window.setTitleVisibility(if overlay {
- NSWindowTitleVisibility::Hidden
- } else {
- NSWindowTitleVisibility::Visible
- });
+ // Only Tauri drag regions may move the window; transcript backgrounds cannot.
+ window.setMovableByWindowBackground(false);
+ window.setTitlebarAppearsTransparent(true);
+ window.setTitleVisibility(NSWindowTitleVisibility::Hidden);
}
#[cfg(test)]
diff --git a/desktop/src-tauri/tauri.conf.json b/desktop/src-tauri/tauri.conf.json
index 6cc6bc475..8634c0504 100644
--- a/desktop/src-tauri/tauri.conf.json
+++ b/desktop/src-tauri/tauri.conf.json
@@ -23,6 +23,7 @@
"center": true,
"resizable": true,
"titleBarStyle": "Overlay",
+ "trafficLightPosition": { "x": 12, "y": 24 },
"hiddenTitle": true
}
],
diff --git a/docs/plans/2026-09-29-desktop-window-chrome-preview.md b/docs/plans/2026-09-29-desktop-window-chrome-preview.md
new file mode 100644
index 000000000..ee7bd22db
--- /dev/null
+++ b/docs/plans/2026-09-29-desktop-window-chrome-preview.md
@@ -0,0 +1,152 @@
+# Desktop chat chrome preview
+
+## Contract
+
+Reuse the complete ChatHeaderBar in a macOS window-level slot: title editing,
+Back, agent/model/effort selection, Visualize and its menus keep their existing
+state and handlers. The web toolbar remains inline. The window row occupies the
+existing chat-header height; there is no additional empty title strip above it.
+Only direct hits on blank top-row regions drag or double-click maximize/restore.
+Controls, popovers and the transcript retain ordinary input. Settings hides the
+retained chat's portal along with its background surface.
+
+The native window uses Overlay with a hidden title and a transparent title bar.
+Window-background movement is disabled. Tauri owns drag/double-click behavior;
+only start-dragging and internal-toggle-maximize are granted to the loopback
+Workbench. Same-origin pages share this accepted window-control boundary;
+Runtime lifecycle management stays local-only.
+
+## Scope and delivery
+
+The owner accepted the installed preview, including the complete chat toolbar,
+sidebar consistency and equal logo insets, and requested a PR and review on
+2026-09-30. Continue the existing isolated branch, integrate current master,
+and require an exact-head Codex pass, zero unresolved review threads and all
+expected CI checks. Merging, releasing and restarting the Runtime remain outside
+this delivery authorization.
+
+The preview began at f1e20d49f. Both the native shell and Runtime-served UI were
+installed for acceptance; previous app and package artifacts remain available.
+Native physical drag and double-click acceptance stays distinct from DOM/IPC
+and build evidence: the owner accepted the preview's appearance, while the
+recorded automated gesture evidence is limited to Tauri's browser IPC handler.
+
+## Validation
+
+- Render the real chat in a hermetic browser with web and native-shell markers.
+- Verify one complete toolbar, control interaction, geometry and Settings retention.
+- Exercise the locked Tauri drag script against the rendered page locally.
+- Run affected complete UI tests, UI/bootstrap builds, Rust shell tests and lint.
+- Read back installed app bytes and HTTP-served UI assets; preserve service PIDs.
+
+## Local preview evidence
+
+- UI production build, bootstrap build and macOS app bundle passed.
+- 100 tests across the complete AppShell, desktopShell, archived-chat and
+ ShowPageLaunchControl files passed; all 35 Rust shell boundary tests passed.
+- UI lint baseline, browser-test TypeScript, Cargo formatting and Clippy passed.
+- Both web/native-marked browser cases passed: toolbar controls, one header,
+ 48px chrome bounds, title editing, model popup and Settings hide/return.
+- A temporary hermetic probe executed locked Tauri 2.11.5 drag.js against the
+ actual chat: four top blanks dispatched start_dragging, double-click dispatched
+ internal_toggle_maximize, and transcript/title input/model popup dispatched
+ neither. The temporary registry-dependent probe was removed after it passed.
+- Repacked the installed 3.1.2rc3 wheel with only the built Workbench assets and
+ wheel metadata changed. All 390 original Python files matched; old hashed UI
+ assets remain available to already-open clients. Installed with uv pip through
+ the existing tool interpreter, without dependencies or an editable checkout.
+- Replaced /Applications/Avibe.app and verified its executable/Info.plist against
+ the bundle. HTTP index and entry assets on port 5123 match this UI build.
+- Runtime PIDs 61799 and 61802 stayed running; /health remained ok.
+- Reopened the app and the existing chat. Native accessibility and screenshot
+ show Back, the editable title, model/effort picker and Visualize in the top row.
+ Computer-use coordinate gestures did not establish reliable physical-drag or
+ double-click evidence; leave that acceptance to the owner, rather than count
+ the browser IPC probe or the native Zoom button as a passing double-click test.
+
+Rollback artifacts: /tmp/Avibe.app.before-window-chrome-20260929 and the original
+/tmp/avibe_os-3.1.2rc3-py3-none-any.whl. The preview wheel is retained under
+.runtime/desktop-chrome-preview/ with build tag 1desktopchrome.
+
+The evidence above records local preview validation before PR review and CI.
+
+## Alignment follow-up
+
+Owner acceptance requires the web layout inside the relocated toolbar: the same
+1080px content maximum and responsive horizontal gutters as the transcript and
+composer. The surrounding empty chrome remains a full-width drag region. Native
+traffic lights use Tauri's trafficLightPosition configuration (12, 24), centering
+the controls within the 48px row without custom AppKit positioning code.
+Validate web and native content bounds at 880, 1200 and 2000px viewport widths,
+then replace the local shell and UI preview again.
+
+Alignment follow-up installed: both real-browser cases passed at all three widths;
+UI/bootstrap/macOS builds and all 35 Rust shell boundary tests passed. The installed
+app binary and HTTP-served UI entry assets matched the rebuilt artifacts. Backend
+package files were preserved and Runtime PIDs stayed unchanged. The app reopened
+and the previous chat was selected; final native screenshot capture was blocked
+because the Mac locked. Native traffic-light visual acceptance remains unverified.
+Previous preview app: /tmp/Avibe.app.before-chrome-alignment-20260929.
+Current UI preview wheel: .runtime/desktop-chrome-alignment/ with build tag
+2desktopchrome; original and first-preview wheels remain available for rollback.
+
+## Sidebar consistency follow-up
+
+The native sidebar reserves the same 48px traffic-light row and bottom divider
+on the home and chat routes. Its logo and navigation must retain their positions
+when switching routes. Scope the clearance to the sidebar so the home page's
+content and top controls retain their existing layout. Web sidebar spacing is
+unchanged. Validate real home/chat navigation in the existing hermetic browser
+cases, rebuild the UI, and replace the local preview UI without restarting the
+Runtime or rebuilding the unchanged native shell.
+
+Installed sidebar follow-up evidence:
+
+- The complete web/native browser file passed both cases, including brand-link
+ navigation to home and history return to chat. Logo, Inbox and capability-nav
+ bounding boxes stay identical; the native sidebar retains its 48px row and
+ divider, including the top-right edge. Web retains its original 10px brand inset.
+- All 53 AppShell/desktopShell tests, browser-test TypeScript, UI lint baseline,
+ production build and diff whitespace checks passed.
+- Built and installed the 3desktopchrome preview wheel under
+ .runtime/desktop-sidebar-consistency/. All 446 original non-UI package files
+ remain byte-identical. All 191 built UI files match the wheel and all 223
+ previous hashed assets remain available. The served index and entry assets
+ match the new production build.
+- Reopened the unchanged installed desktop shell and inspected the real home
+ and chat screenshots: the sidebar divider, logo and navigation align. Returned
+ to home for owner acceptance. Runtime PIDs 61799 and 61802 stayed unchanged and
+ /health remained ok. No Runtime restart or native-shell rebuild was needed.
+
+## Sidebar logo inset follow-up
+
+The native sidebar's brand mark uses the same 16px top and left content inset
+after the 48px traffic-light row. The web sidebar keeps its existing spacing.
+The hermetic browser geometry assertion covers this invariant. Rebuild and
+install a new UI-only preview wheel, then leave the existing desktop shell open
+on the home route.
+
+Installed logo inset follow-up evidence:
+
+- Desktop-only sidebar spacing is now 16px after the 48px native row, matching
+ the existing 16px horizontal inset. Web remains at its original 10px top inset.
+- The complete web/native browser file passed both cases, including the native
+ logo geometry assertion; 53 focused UI tests, browser-test TypeScript, UI lint,
+ production build and diff whitespace checks passed.
+- Repacked and installed the 4desktopchrome UI preview wheel under
+ .runtime/desktop-sidebar-logo-inset/. The 446 non-UI package files remain
+ byte-identical and the 242 previous UI assets remain available. Served index
+ and entry assets match the build. The desktop window was reopened on the home
+ route for owner acceptance; Runtime PIDs 61799 and 61802 and /health stayed
+ unchanged.
+
+## PR preparation
+
+Integrated master 99db88055 with a normal merge and preserved its Runtime,
+updater and Vault changes. The resulting candidate passed both production UI
+and bootstrap builds, 102 focused UI tests, all 12 browser cases in the chrome
+and sidebar/Dock files, and all 84 desktop Rust tests (including 35 shell boundary
+tests). UI lint baseline, browser-test TypeScript, Rust formatting, Clippy and
+diff checks passed. The chrome browser file now runs in the existing CI job.
+The accepted installed preview remains in place; these master changes have not
+been installed into the owner's local Runtime.
diff --git a/ui/e2e/workbench-general/desktop-window-chrome.spec.ts b/ui/e2e/workbench-general/desktop-window-chrome.spec.ts
new file mode 100644
index 000000000..5fb8fd014
--- /dev/null
+++ b/ui/e2e/workbench-general/desktop-window-chrome.spec.ts
@@ -0,0 +1,150 @@
+import { expect, test, type Page } from '@playwright/test';
+import { open, serveProduct } from './support';
+
+async function serveChat(page: Page) {
+ const denied = await serveProduct(page);
+ const session = {
+ id: 'chrome-fixture', scope_id: 'fixture', project_id: 'proj-1', title: '中文窗口会话',
+ agent_id: null, agent_name: 'codex', agent_backend: 'codex', model: 'gpt-fixture',
+ reasoning_effort: 'high', status: 'active', agent_status: 'idle', pinned: false,
+ workdir: '/fixture/work', native_session_id: null, metadata: {},
+ created_at: '2026-09-29T00:00:00Z', updated_at: '2026-09-29T00:00:00Z',
+ };
+ const turnState = { in_flight: false, foreground: 'idle', native_turn_started: false,
+ pending_input_count: 0, background_activities: [], pending_activity_output_count: 0, connection: 'connected' };
+ await page.route('**/api/sessions/chrome-fixture/bootstrap', route => route.fulfill({ json: {
+ session, capabilities: { can_chat: true }, agents: [{ id: 'codex', name: 'codex', backend: 'codex', enabled: true }],
+ default_agent_name: 'codex', config: { ui: {} }, messages: [], queued: [],
+ next_after_id: null, next_before_id: null, draft: { text: '', updated_at: null }, turn_state: turnState,
+ } }));
+ await page.route('**/api/sessions/chrome-fixture', route => route.fulfill({ json: session }));
+ await page.route('**/api/sessions/chrome-fixture/queue', route => route.fulfill({ json: [] }));
+ await page.route('**/api/sessions/chrome-fixture/turn-state', route => route.fulfill({ json: turnState }));
+ await page.route('**/api/sessions/chrome-fixture/activity**', route => route.fulfill({ json: { groups: [] } }));
+ // The unread acknowledgement belongs to this fixture only.
+ await page.route('**/api/inbox/chrome-fixture/read', route => route.fulfill({ json: { ok: true } }));
+ return denied;
+}
+
+for (const desktop of [false, true]) {
+ test(`${desktop ? 'native' : 'web'} chat retains the complete toolbar and confines native drag targets to the top`, async ({ page }) => {
+ const denied = await serveChat(page);
+ if (desktop) {
+ await page.addInitScript(() => {
+ Object.defineProperty(window, '__AVIBE_DESKTOP_SHELL__', { value: true });
+ Object.defineProperty(window, '__AVIBE_DESKTOP_DRAG__', { value: true });
+ document.addEventListener('DOMContentLoaded', () => document.documentElement.style.setProperty('--shell-titlebar-inset', '28px'));
+ });
+ }
+ await page.setViewportSize({ width: 1200, height: 800 });
+ await open(page, '/chat/chrome-fixture');
+ const header = page.locator('[data-chat-header]');
+ await expect(header).toBeVisible();
+ await expect(header.getByRole('button', { name: '中文窗口会话' })).toBeVisible();
+ await expect(header.getByRole('button', { name: /gpt-fixture/ })).toBeVisible();
+ await expect(header.getByRole('button', { name: 'Visualize', exact: true })).toBeVisible();
+ await expect(header.getByRole('button', { name: 'Back', exact: true })).toBeVisible();
+ await expect(header).toHaveCount(1);
+
+ if (desktop) {
+ await expect(page.locator('[data-desktop-window-chrome] [data-chat-header]')).toHaveCount(1);
+ await expect(page.locator('main [data-chat-header]')).toHaveCount(0);
+ const bounds = await page.locator('[data-desktop-window-chrome]').boundingBox();
+ expect(bounds).toEqual({ x: 0, y: 0, width: 1200, height: 48 });
+ // Every rendered drag surface is confined to the same top row, including
+ // the sidebar clearance. The transcript and composer never join it.
+ for (const region of await page.locator('[data-tauri-drag-region]').all()) {
+ const rect = await region.boundingBox();
+ if (rect) {
+ expect(rect.y).toBeGreaterThanOrEqual(0);
+ expect(rect.y + rect.height).toBeLessThanOrEqual(48);
+ }
+ await expect(region).toHaveAttribute('data-tauri-drag-region', '');
+ }
+ } else {
+ await expect(page.locator('[data-desktop-window-chrome]')).toHaveCount(0);
+ await expect(page.locator('main [data-chat-header]')).toHaveCount(1);
+ await expect(page.locator('[data-tauri-drag-region]')).toHaveCount(0);
+ }
+ // Native relocation keeps the web toolbar's content bounds, including at
+ // widths where both the transcript and composer stop growing.
+ for (const width of [880, 2000, 1200]) {
+ await page.setViewportSize({ width, height: 800 });
+ const toolbar = await header.locator(':scope > div').boundingBox();
+ const composer = await page.locator('main div.mx-auto').filter({ has: page.getByRole('textbox') }).last().boundingBox();
+ expect(toolbar).not.toBeNull();
+ expect(composer).not.toBeNull();
+ expect(toolbar!.x).toBeCloseTo(composer!.x, 0);
+ expect(toolbar!.width).toBeCloseTo(composer!.width, 0);
+ await expect(header.getByRole('button', { name: /gpt-fixture/ })).toBeVisible();
+ await expect(header.getByRole('button', { name: 'Visualize', exact: true })).toBeVisible();
+ if (width === 2000) {
+ await page.screenshot({ path: `e2e/.artifacts/workbench-general/shots/chat-chrome-${desktop ? 'native' : 'web'}-wide.png` });
+ }
+ }
+ // Relocation must preserve live title editing and the real route picker.
+ await header.getByRole('button', { name: '中文窗口会话' }).click();
+ await expect(header.locator('input')).toBeFocused();
+ await header.locator('input').press('Escape');
+ await header.getByRole('button', { name: /gpt-fixture/ }).click();
+ await expect(page.getByRole('dialog')).toBeVisible();
+ await page.keyboard.press('Escape');
+ await expect(page.getByRole('dialog')).toBeHidden();
+ await page.mouse.move(1000, 400);
+ await page.screenshot({ path: `e2e/.artifacts/workbench-general/shots/chat-chrome-${desktop ? 'native' : 'web'}.png` });
+
+ // The retained ChatPage behind Settings must not leak a live portaled header.
+ await page.locator('[data-settings-toggle]').click();
+ await expect(page.locator('nav[aria-label="Settings sections"]')).toBeVisible();
+ if (desktop) await expect(page.locator('[data-desktop-window-chrome]')).toBeHidden();
+ await page.keyboard.press('Escape');
+ await expect(header).toBeVisible();
+
+ // The shell owns sidebar clearance independently of the route's toolbar.
+ // Navigate through the actual brand link and browser history: the logo and
+ // navigation must stay in place when the chat portal unmounts and returns.
+ const sidebar = page.locator('aside').filter({ has: page.locator('#workbench-capability-nav') });
+ const brand = sidebar.locator('a[href="/"]');
+ const inbox = sidebar.getByRole('link', { name: 'Inbox', exact: true });
+ const nav = sidebar.locator('#workbench-capability-nav');
+ const chatSidebar = {
+ brand: await brand.boundingBox(),
+ inbox: await inbox.boundingBox(),
+ nav: await nav.boundingBox(),
+ };
+ expect(chatSidebar.brand).not.toBeNull();
+ expect(chatSidebar.inbox).not.toBeNull();
+ expect(chatSidebar.nav).not.toBeNull();
+ await brand.click();
+ await expect(page).toHaveURL(/\/$/);
+ await expect(header).toHaveCount(0);
+ expect(await brand.boundingBox()).toEqual(chatSidebar.brand);
+ expect(await inbox.boundingBox()).toEqual(chatSidebar.inbox);
+ expect(await nav.boundingBox()).toEqual(chatSidebar.nav);
+ if (desktop) {
+ const topRow = sidebar.locator(':scope > [data-tauri-drag-region]');
+ const topBounds = await topRow.boundingBox();
+ expect(topBounds?.y).toBe(0);
+ expect(topBounds?.height).toBe(48);
+ expect(topBounds?.width).toBe((await sidebar.boundingBox())?.width);
+ await expect(topRow).toHaveCSS('border-bottom-width', '1px');
+ const brandMark = brand.locator('img');
+ const brandMarkBounds = await brandMark.boundingBox();
+ expect(brandMarkBounds?.x).toBeCloseTo((await sidebar.boundingBox())!.x + 16, 0);
+ expect(brandMarkBounds?.y).toBeCloseTo(topBounds!.y + topBounds!.height + 16, 0);
+ // There is no whole-window empty chrome added to the home page.
+ await expect(page.locator('[data-desktop-window-chrome]')).toHaveCount(0);
+ } else {
+ await expect(sidebar.locator('[data-tauri-drag-region]')).toHaveCount(0);
+ expect(chatSidebar.brand!.y).toBe(10);
+ }
+ await page.mouse.move(1000, 400);
+ await page.screenshot({ path: `e2e/.artifacts/workbench-general/shots/home-chrome-${desktop ? 'native' : 'web'}.png` });
+ await page.goBack();
+ await expect(header).toBeVisible();
+ expect(await brand.boundingBox()).toEqual(chatSidebar.brand);
+ expect(await inbox.boundingBox()).toEqual(chatSidebar.inbox);
+ expect(await nav.boundingBox()).toEqual(chatSidebar.nav);
+ expect(denied).toEqual([]);
+ });
+}
diff --git a/ui/src/components/AppShell.tsx b/ui/src/components/AppShell.tsx
index 518eb6407..927265d9a 100644
--- a/ui/src/components/AppShell.tsx
+++ b/ui/src/components/AppShell.tsx
@@ -1,4 +1,6 @@
import { DesktopDragRegion } from './DesktopDragRegion';
+import { DesktopWindowChrome } from './DesktopWindowChrome';
+import { desktopDragRegion } from '../lib/desktopShell';
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';
@@ -412,6 +414,7 @@ export const AppShell: React.FC = () => {
// These mobile surfaces render their own top chrome, so the shell's mobile
// brand header AND the bottom tab bar are hidden on them.
const isChat = surfaceLocation.pathname.startsWith('/chat/');
+ const windowChrome = isDesktop && isChat && !chromeless && desktopDragRegion() !== undefined;
const isSearch = surfaceLocation.pathname === '/search';
const isSettings = settingsOpen;
const isShowPageApp = surfaceLocation.pathname.startsWith('/apps/show/');
@@ -441,9 +444,11 @@ export const AppShell: React.FC = () => {
<StandaloneAppTabContext.Provider value={standaloneAppTab}>
<DockProvider enabled={canUseApps}>
<ShowPageDragProvider>
+ <DesktopWindowChrome enabled={windowChrome} hidden={settingsOpen}>
{/* Chromeless (single-app tab): the locked full-viewport column applies on DESKTOP too —
the app fills the browser area exactly, with nothing to scroll around it. */}
<div
+ style={windowChrome && !settingsOpen ? { '--shell-titlebar-inset': '48px' } as React.CSSProperties : undefined}
className={clsx(
'flex h-[var(--app-shell-h)] flex-col overflow-hidden bg-background text-foreground',
!chromeless && 'md:block md:h-auto md:min-h-screen md:overflow-visible'
@@ -452,8 +457,8 @@ export const AppShell: React.FC = () => {
<ConfigRecoveryNotice config={config} />
{/* Windows cover the sidebar (z-10 < z-20). AppsLauncher portals its button and Dock
above the window layer so app switching remains reachable even when maximized. */}
- {/* Sidebar Y1TiVV — 248 wide by default, 16px horizontal/bottom padding and
- the original 10px brand top inset. The top group and bottom
+ {/* Sidebar Y1TiVV — 248 wide by default, 16px horizontal/bottom padding,
+ a 16px native brand inset and the original 10px web inset. The top group and bottom
cluster pushed apart. The brand row, navigation and projects are one unit
inside WorkbenchSidebar; this frame owns only the column and the bottom.
The width is SidebarResizer's --app-sidebar-w, shared with Workbench
@@ -464,12 +469,18 @@ export const AppShell: React.FC = () => {
<aside
aria-hidden={settingsCoversSidebar || undefined}
inert={settingsCoversSidebar || undefined}
+ // Keep the native sidebar at the chat toolbar's height on every route.
+ // Scope the clearance here so home-page controls keep their own layout.
+ style={desktopDragRegion() !== undefined ? { '--shell-titlebar-inset': '48px' } as React.CSSProperties : undefined}
className={clsx(
- 'fixed inset-y-0 left-0 z-10 hidden w-[var(--app-sidebar-w)] flex-col justify-between gap-6 border-r border-border bg-[var(--sidebar-background)] px-4 pt-[calc(0.625rem+var(--shell-titlebar-inset))] pb-4 md:flex',
+ 'fixed inset-y-0 left-0 z-10 hidden w-[var(--app-sidebar-w)] flex-col justify-between gap-6 border-r border-border bg-[var(--sidebar-background)] px-4 pb-4 md:flex',
+ desktopDragRegion() !== undefined
+ ? 'pt-[calc(1rem+var(--shell-titlebar-inset))]'
+ : 'pt-[calc(0.625rem+var(--shell-titlebar-inset))]',
settingsCoversSidebar && 'invisible pointer-events-none',
)}
>
- <DesktopDragRegion className="absolute inset-x-0 top-0" />
+ <DesktopDragRegion className="absolute left-0 -right-px top-0 border-b border-border bg-[var(--sidebar-background)]" />
<div className="flex min-h-0 flex-1 flex-col">
{isDesktop && (
<RouteSurfaceActivityBoundary active={!settingsCoversSidebar}>
@@ -687,6 +698,7 @@ export const AppShell: React.FC = () => {
</div>
)}
</div>
+ </DesktopWindowChrome>
</ShowPageDragProvider>
</DockProvider>
</StandaloneAppTabContext.Provider>
diff --git a/ui/src/components/DesktopWindowChrome.tsx b/ui/src/components/DesktopWindowChrome.tsx
new file mode 100644
index 000000000..726234da3
--- /dev/null
+++ b/ui/src/components/DesktopWindowChrome.tsx
@@ -0,0 +1,38 @@
+import { useState, type ReactNode } from 'react';
+import { DesktopWindowChromeContext } from '../context/DesktopWindowChromeContext';
+import { desktopDragRegion } from '../lib/desktopShell';
+
+/** A window-level home for the existing chat toolbar, beside native traffic lights. */
+export function DesktopWindowChrome({ enabled, hidden, children }: {
+ enabled: boolean;
+ hidden: boolean;
+ children: ReactNode;
+}) {
+ const [slot, setSlot] = useState<HTMLDivElement | null>(null);
+ return (
+ <DesktopWindowChromeContext.Provider value={enabled ? slot : null}>
+ {enabled && (
+ <div
+ data-desktop-window-chrome=""
+ hidden={hidden}
+ inert={hidden || undefined}
+ className="fixed inset-x-0 top-0 z-30 h-12 border-b border-border bg-background"
+ >
+ {/* Native traffic lights occupy the left of the sidebar; its remaining
+ width is a drag target. No transparent overlay covers controls. */}
+ <div
+ aria-hidden="true"
+ data-tauri-drag-region={desktopDragRegion()}
+ className="absolute inset-y-0 left-0 w-[var(--app-sidebar-w)] select-none bg-[var(--sidebar-background)]"
+ />
+ <div
+ ref={setSlot}
+ data-tauri-drag-region={desktopDragRegion()}
+ className="ml-[var(--app-sidebar-w)] h-full"
+ />
+ </div>
+ )}
+ {children}
+ </DesktopWindowChromeContext.Provider>
+ );
+}
diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsx
index 7ba6676df..ca1cd9efa 100644
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@ -1,4 +1,6 @@
import { desktopDragRegion } from '../../lib/desktopShell';
+import { createPortal } from 'react-dom';
+import { useDesktopWindowChrome } from '../../context/DesktopWindowChromeContext';
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';
@@ -282,6 +284,7 @@ export const ChatPage: React.FC = () => {
const { focusedId: foregroundAppWindowId, focusCanvas } = useWindowManager();
const isDesktop = useIsDesktop();
const routeSurfaceActive = useRouteSurfaceActive();
+ const windowChrome = useDesktopWindowChrome();
const pageActive = usePageActive();
// The mobile chat surface is a fixed full-screen flex column; this keeps the
// composer glued to the iOS keyboard (settle-then-correct; see the hook).
@@ -2888,6 +2891,7 @@ export const ChatPage: React.FC = () => {
there). */}
<div
ref={chatSurfaceRef}
+ style={windowChrome ? { paddingTop: '48px' } : undefined}
className="fixed inset-0 z-40 flex flex-col bg-background pt-[env(safe-area-inset-top)] md:relative md:inset-auto md:z-auto md:-mx-10 md:-my-8 md:h-[var(--app-vvh)] md:bg-transparent md:pt-0"
onKeyDown={annotation.handleShortcutKeyDown}
onPointerDownCapture={focusCanvas}
@@ -3642,6 +3646,7 @@ interface ChatHeaderBarProps {
// read-only rendering is reachable without an ApiProvider.
export const ChatHeaderBar: React.FC<ChatHeaderBarProps> = ({ session, agents, defaultAgentName, onPatch, patchSaving, onBack, working, showPageMode, showPageBusy, onToggleShowPage, onPrepareShowPageLaunch, onShowPageVisibilityChange, onShareOpenChange, annotation, onAnnotateOpenChange, readOnlyReason, writable = readOnlyReason === null, showPageAccess = null, canOpenShowPage = true, canManageShowPage = true, canManageInstance = false, canPinToDock = false, sessionActions, titleFieldRef }) => {
const { t } = useTranslation();
+ const windowChrome = useDesktopWindowChrome();
const readOnly = !writable;
const sessionReadOnly = readOnlyReason !== null;
const showPageActions = showPageControlActions(sessionReadOnly, showPageMode);
@@ -3690,15 +3695,21 @@ export const ChatHeaderBar: React.FC<ChatHeaderBarProps> = ({ session, agents, d
}
: undefined;
const inheritsDefault = !session.agent_name && !session.agent_backend;
- return (
+ const header = (
// A single compact row (design.pen IDQ5n): back button + click-to-edit
// title on the left, the agent/model/effort picker on the right. The bar
// runs edge-to-edge (the page root cancels the shell padding) with a
// 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 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">
+ <div data-chat-header="" data-tauri-drag-region={desktopDragRegion()} className={clsx(
+ 'shrink-0 px-4 md:px-8',
+ windowChrome ? 'h-full' : 'border-b border-border bg-surface/70 py-2.5 backdrop-blur',
+ )}>
+ <div data-tauri-drag-region={desktopDragRegion()} className={clsx(
+ 'mx-auto flex w-full max-w-[1080px] items-center gap-3',
+ windowChrome && 'h-full',
+ )}>
<Button
type="button"
variant="outline"
@@ -3813,6 +3824,7 @@ export const ChatHeaderBar: React.FC<ChatHeaderBarProps> = ({ session, agents, d
</div>
</div>
);
+ return windowChrome ? createPortal(header, windowChrome) : header;
};
interface TitleFieldProps {
diff --git a/ui/src/context/DesktopWindowChromeContext.ts b/ui/src/context/DesktopWindowChromeContext.ts
new file mode 100644
index 000000000..eca4a3f34
--- /dev/null
+++ b/ui/src/context/DesktopWindowChromeContext.ts
@@ -0,0 +1,5 @@
+import { createContext, useContext } from 'react';
+
+// The route still owns its header and state; the shell supplies only a DOM slot.
+export const DesktopWindowChromeContext = createContext<HTMLDivElement | null>(null);
+export const useDesktopWindowChrome = () => useContext(DesktopWindowChromeContext);
diff --git a/ui/src/lib/desktopShell.test.tsx b/ui/src/lib/desktopShell.test.tsx
index 8879d1c37..5305faf4f 100644
--- a/ui/src/lib/desktopShell.test.tsx
+++ b/ui/src/lib/desktopShell.test.tsx
@@ -80,12 +80,17 @@ describe('native desktop drag surfaces', () => {
}
});
- 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 });
+ it.each(['browser', 'older-shell', 'without-metadata'] as const)(
+ 'keeps Setup language switching and derives dragging from shell capability: %s',
+ (mode) => {
+ if (mode !== 'browser') inShell({ native: mode !== 'older-shell', supported: mode !== 'without-metadata' });
renderHeaders();
expect(document.querySelector('button[aria-haspopup="listbox"]')).not.toBeNull();
- expect(document.querySelector('[data-tauri-drag-region]')).toBeNull();
- }
- });
+ if (mode === 'without-metadata') {
+ expect(document.querySelector('[data-tauri-drag-region]')).not.toBeNull();
+ } else {
+ expect(document.querySelector('[data-tauri-drag-region]')).toBeNull();
+ }
+ },
+ );
});
diff --git a/ui/src/lib/desktopShell.ts b/ui/src/lib/desktopShell.ts
index 0dcfbe278..ebc3dcc37 100644
--- a/ui/src/lib/desktopShell.ts
+++ b/ui/src/lib/desktopShell.ts
@@ -29,7 +29,8 @@ 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;
+ // Dragging is granted by the native shell marker. It must not depend on the
+ // Runtime UI version: a desktop shell can load an older loopback Workbench
+ // whose HTML predates the optional metadata tag.
+ return isDesktopShell() && window.__AVIBE_DESKTOP_DRAG__ === true ? '' : undefined;
}