Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(desktop): derive the macOS traffic-light reserve from one source
ZeroY05eeaeef2d22
diff --git a/apps/desktop/electron/main/bootstrap/window.ts b/apps/desktop/electron/main/bootstrap/window.tsindex ba8e5daf4..a9c3e78e9 100644--- a/apps/desktop/electron/main/bootstrap/window.ts+++ b/apps/desktop/electron/main/bootstrap/window.ts@@ -2,7 +2,13 @@ import { app, BrowserWindow, nativeTheme, screen, type Tray } from "electron";import { execFileSync } from "node:child_process";import { existsSync } from "node:fs";import { join } from "node:path";-import { APP_NAME, builtinWindowBackground, IPC, type CloseBehavior } from "@pi-desktop/shared";+import {+ APP_NAME,+ builtinWindowBackground,+ IPC,+ MAC_TRAFFIC_LIGHT_POSITION,+ type CloseBehavior,+} from "@pi-desktop/shared";import type { BrowserPane } from "../browser-view";import type { HostProcess } from "../host-process";import type { Logger } from "../logger";@@ -157,10 +163,13 @@ export async function createWindow({// One frameless look everywhere: macOS keeps inset traffic lights;// Windows/Linux hide native chrome entirely — the renderer draws its// own Codex-style window controls (see WindowControls.tsx).+ // The traffic-light position comes from @pi-desktop/shared so the space+ // the renderer reserves for the buttons (styles/tokens.css) is derived+ // from the same numbers that place them....(process.platform === "darwin"? {titleBarStyle: "hiddenInset" as const,- trafficLightPosition: { x: 16, y: 16 },+ trafficLightPosition: MAC_TRAFFIC_LIGHT_POSITION,vibrancy: "sidebar" as const,visualEffectState: "followWindow" as const,transparent: true,diff --git a/apps/desktop/src/main.tsx b/apps/desktop/src/main.tsxindex ed2d90389..035eb5599 100644--- a/apps/desktop/src/main.tsx+++ b/apps/desktop/src/main.tsx@@ -3,6 +3,7 @@ import ReactDOM from "react-dom/client";import i18n from "i18next";import { initReactI18next } from "react-i18next";import { catalogs, flattenCatalog, resolveLocale } from "@pi-desktop/i18n";+import { MAC_TRAFFIC_LIGHT_EDGE_DIP } from "@pi-desktop/shared";import App from "./App";import { PluginLauncher } from "./components/PluginLauncher";import { initLanguageSync, resolveOsLocale } from "./lib/app-language";@@ -16,6 +17,16 @@ document.documentElement.dataset.theme = "dark";// controls overlay right on Windows/Linux); set before first paint.document.documentElement.dataset.platform =window.piDesktop?.platform ?? "darwin";+// The macOS traffic lights are native views with a fixed footprint; the space+// the shell leaves clear for them derives from the same shared constant the+// main process positions them with (styles/tokens.css). Only macOS has them —+// the 0px default keeps Windows/Linux on the renderer-drawn controls.+if (document.documentElement.dataset.platform === "darwin") {+ document.documentElement.style.setProperty(+ "--ds-traffic-light-edge",+ `${MAC_TRAFFIC_LIGHT_EDGE_DIP}px`,+ );+}// Scrollbars are transparent at rest (base.css); this marks the scrolling// element so the thumb shows while it moves, not only under the pointer.installScrollbarReveal(document);diff --git a/apps/desktop/src/styles/chrome.css b/apps/desktop/src/styles/chrome.cssindex 98de2cfe7..e1707c1db 100644--- a/apps/desktop/src/styles/chrome.css+++ b/apps/desktop/src/styles/chrome.css@@ -383,16 +383,10 @@display: flex;align-items: center;margin-right: auto;- padding-left: 64px; /* traffic lights (76px) minus main-titlebar padding */-}--:root[data-platform="win32"] .main-titlebar-left,-:root[data-platform="linux"] .main-titlebar-left {- padding-left: 0;-}--:root[data-platform="darwin"][data-fullscreen="true"] .main-titlebar-left {- padding-left: 0;+ /* The row already pads 12px, so the title only adds the difference between+ that and the traffic-light reserve. Platforms with no native traffic+ lights, and fullscreen, resolve to the row's own padding. */+ padding-left: max(0px, calc(var(--ds-window-lead-inset) - 12px));}.title-nav-btn {@@ -624,16 +618,28 @@);}-/* macOS traffic lights occupy the top-left ~76px; only reserve that space- * when the sidebar is collapsed and the main pane reaches the window edge.+/* The macOS traffic lights own the window's top-left corner. Everything below+ * reads `--ds-window-lead-inset`: the cluster's right edge (native geometry,+ * injected at boot from @pi-desktop/shared — see window-chrome.ts) plus the+ * breathing room kept before the first shell control. Fullscreen hides the+ * buttons, so the reserve falls back to the ordinary 8px gutter; Windows and+ * Linux keep the 0px default from tokens.css and use their renderer-drawn+ * controls instead.+ ** Only the inset moves per platform — the collapsed padding below derives the* title's offset from it, so the two can never drift apart. */-:root[data-platform="darwin"] .conversation-topbar.ct-collapsed {- --ct-lead-inset: 76px;+:root[data-platform="darwin"] {+ --ds-window-lead-inset: calc(+ var(--ds-traffic-light-edge) + var(--ds-traffic-light-gap)+ );+}++:root[data-platform="darwin"][data-fullscreen="true"] {+ --ds-window-lead-inset: 8px;}-:root[data-platform="darwin"][data-fullscreen="true"] .conversation-topbar.ct-collapsed {- --ct-lead-inset: 8px;+:root[data-platform="darwin"] .conversation-topbar.ct-collapsed {+ --ct-lead-inset: var(--ds-window-lead-inset);}/*@@ -653,9 +659,9 @@* The title's edge is `padding-left`; this button must stay exactly 36px to* its left (28px button + .ct-left's 8px gap) at EVERY frame, not just at the* two endpoints. Deriving `left` from the same inset keeps both ranges- * identical (100px on darwin, 36px elsewhere), so the pair interpolates in- * lockstep. Offsetting instead of transitioning 12px->76px matters: that range- * is only 64px against padding's 100px, and the icon drifts onto the title+ * identical (112px on darwin, 36px elsewhere), so the pair interpolates in+ * lockstep. Offsetting instead of transitioning 12px->88px matters: that range+ * is only 76px against padding's 112px, and the icon drifts onto the title* mid-flight. Expanded it lands off the pane's left edge, where it is* invisible anyway, and slides in rather than materialising over the title.*/@@ -666,7 +672,7 @@align-items: center;/** Out of flow, so .ct-left's no-drag box no longer covers it: .ct-left starts- * at the padding edge (x=112 collapsed) while this sits at x=76. Without its+ * at the padding edge (x=124 collapsed) while this sits at x=88. Without its* own carve-out the button falls inside the top bar's drag region, which on* macOS swallows the click and keeps the arrow cursor instead of the pointer.*/@@ -1052,17 +1058,13 @@}:root[data-platform="darwin"] .sidebar-header {- padding-left: 76px;+ padding-left: var(--ds-window-lead-inset);}:root[data-platform="darwin"] .sidebar-header > .brand {display: none;}-:root[data-platform="darwin"][data-fullscreen="true"] .sidebar-header {- padding-left: 8px;-}-.sidebar-header-actions {display: flex;flex: 0 0 auto;@@ -1138,15 +1140,10 @@left: var(--ds-sidebar-width);}-/* Native macOS traffic lights occupy the top-left ~76px of the window. Keep- * preview actions outside that hit area while the sidebar is collapsed. */+/* Keep preview actions outside the native traffic-light footprint while the+ * sidebar is collapsed and this row reaches the window's left edge. */:root[data-platform="darwin"] .window-chrome-row:not(.sidebar-expanded) {- padding-left: 76px;-}--:root[data-platform="darwin"][data-fullscreen="true"]- .window-chrome-row:not(.sidebar-expanded) {- padding-left: 8px;+ padding-left: var(--ds-window-lead-inset);}.window-chrome-row button {diff --git a/apps/desktop/src/styles/tokens.css b/apps/desktop/src/styles/tokens.cssindex 3ba5afcd8..f03f4523d 100644--- a/apps/desktop/src/styles/tokens.css+++ b/apps/desktop/src/styles/tokens.css@@ -166,6 +166,18 @@--ds-preview-action-lane-width: 56px;/* Keep an 8px visual buffer between work-panel actions and window chrome. */--ds-window-controls-width: 120px;+ /* macOS traffic lights sit at the window's top-left. Their footprint is+ native geometry, injected at boot from @pi-desktop/shared (window-chrome.ts)+ so it cannot drift from the position electron/main/bootstrap/window.ts+ gives the buttons; frames without native traffic lights keep the 0px+ default. The gap is the breathing room the cluster's right edge keeps+ before the first shell control. */+ --ds-traffic-light-edge: 0px;+ --ds-traffic-light-gap: 12px;+ /* Left inset a window-level chrome row must leave clear for the traffic+ lights. The platform policy that turns the two values above into this+ reserve lives with the consumers in chrome.css. */+ --ds-window-lead-inset: 0px;--ds-composer-radius: var(--radius-xl);--ds-composer-radius-lg: var(--radius-xl);diff --git a/apps/desktop/src/styles/work-panel.css b/apps/desktop/src/styles/work-panel.cssindex 9d8bdd741..c35ea2e10 100644--- a/apps/desktop/src/styles/work-panel.css+++ b/apps/desktop/src/styles/work-panel.css@@ -140,18 +140,15 @@}/* In preview mode the panel can move to the window's left edge when the sidebar- is collapsed. Keep its first tab clear of both macOS's hiddenInset traffic- lights and the preview row's sidebar/new-task action group. */-:root[data-platform="darwin"]:not([data-fullscreen="true"])+ is collapsed. Keep its first tab clear of both the macOS traffic lights (the+ shared lead inset, which already drops to the 8px fullscreen gutter when the+ buttons are hidden) and the preview row's sidebar/new-task action group. */+:root[data-platform="darwin"].app-shell.work-panel-maximized.sidebar-collapsed.work-panel-header {- padding-left: calc(76px + var(--ds-preview-action-lane-width));-}--:root[data-platform="darwin"][data-fullscreen="true"]- .app-shell.work-panel-maximized.sidebar-collapsed- .work-panel-header {- padding-left: calc(8px + var(--ds-preview-action-lane-width));+ padding-left: calc(+ var(--ds-window-lead-inset) + var(--ds-preview-action-lane-width)+ );}:root[data-platform="win32"] .work-panel-header,diff --git a/apps/desktop/test/macos-sidebar-vibrancy.test.mjs b/apps/desktop/test/macos-sidebar-vibrancy.test.mjsindex 53a85ebe5..957775f6e 100644--- a/apps/desktop/test/macos-sidebar-vibrancy.test.mjs+++ b/apps/desktop/test/macos-sidebar-vibrancy.test.mjs@@ -30,7 +30,9 @@ function functionSource(source, name) {test("macOS main window enables native sidebar vibrancy only in its platform branch", () => {assert.match(macOptions, /titleBarStyle:\s*"hiddenInset"/);- assert.match(macOptions, /trafficLightPosition:\s*\{ x: 16, y: 16 \}/);+ // The position itself lives in @pi-desktop/shared so the renderer's reserve+ // for it (styles/tokens.css) is derived from the same numbers.+ assert.match(macOptions, /trafficLightPosition:\s*MAC_TRAFFIC_LIGHT_POSITION/);assert.match(macOptions, /vibrancy:\s*"sidebar"/);assert.match(macOptions, /visualEffectState:\s*"followWindow"/);assert.match(macOptions, /transparent:\s*true/);diff --git a/apps/desktop/test/sidebar-collapse-animation.test.mjs b/apps/desktop/test/sidebar-collapse-animation.test.mjsindex 699b18318..9e4f679ca 100644--- a/apps/desktop/test/sidebar-collapse-animation.test.mjs+++ b/apps/desktop/test/sidebar-collapse-animation.test.mjs@@ -186,13 +186,12 @@ test("the top bar's collapsed lead-in tracks the dock instead of snapping", () =const topbarBaseBlock =globalStyles.match(/\.conversation-topbar\s*\{[\s\S]*?\}/)?.[0] ?? "";assert.match(topbarBaseBlock, /--ct-lead-inset:\s*12px/);+ // The collapsed inset is the shared traffic-light reserve; its darwin value+ // (native footprint + gap, 8px in fullscreen) lives in one place, asserted by+ // test/traffic-light-reserve.test.mjs.assert.match(globalStyles,- /:root\[data-platform="darwin"\] \.conversation-topbar\.ct-collapsed\s*\{[^}]*--ct-lead-inset:\s*76px/,- );- assert.match(- globalStyles,- /:root\[data-platform="darwin"\]\[data-fullscreen="true"\] \.conversation-topbar\.ct-collapsed\s*\{[^}]*--ct-lead-inset:\s*8px/,+ /:root\[data-platform="darwin"\] \.conversation-topbar\.ct-collapsed\s*\{[^}]*--ct-lead-inset:\s*var\(--ds-window-lead-inset\)/,);// The button stays mounted so it can cross-fade with the dock's own toggle;diff --git a/apps/desktop/test/sidebar-navigation.test.mjs b/apps/desktop/test/sidebar-navigation.test.mjsindex 5a5fd00b4..8d7922bf8 100644--- a/apps/desktop/test/sidebar-navigation.test.mjs+++ b/apps/desktop/test/sidebar-navigation.test.mjs@@ -86,16 +86,12 @@ test("macOS hides sidebar branding and keeps header actions beside traffic lightassert.doesNotMatch(sidebarSource, /sidebar-macos-drag-row/);assert.match(globalStyles,- /:root\[data-platform="darwin"\] \.sidebar-header\s*\{[^}]*padding-left:\s*76px;/s,+ /:root\[data-platform="darwin"\] \.sidebar-header\s*\{[^}]*padding-left:\s*var\(--ds-window-lead-inset\);/s,);assert.match(globalStyles,/:root\[data-platform="darwin"\] \.sidebar-header > \.brand\s*\{[^}]*display:\s*none;/s,);- assert.match(- globalStyles,- /:root\[data-platform="darwin"\]\[data-fullscreen="true"\] \.sidebar-header\s*\{[^}]*padding-left:\s*8px;/s,- );assert.match(globalStyles,/\.sidebar-header-actions\s*\{[^}]*margin-left:\s*auto;/s,diff --git a/apps/desktop/test/traffic-light-reserve.test.mjs b/apps/desktop/test/traffic-light-reserve.test.mjsnew file mode 100644index 000000000..f23cb4cc6--- /dev/null+++ b/apps/desktop/test/traffic-light-reserve.test.mjs@@ -0,0 +1,128 @@+import assert from "node:assert/strict";+import { readFile } from "node:fs/promises";+import test from "node:test";+import { loadStyles } from "./helpers/styles.mjs";++const read = (relative) => readFile(new URL(relative, import.meta.url), "utf8");++const sharedSource = await read("../../../packages/shared/src/window-chrome.ts");+const windowSource = await read("../electron/main/bootstrap/window.ts");+const entrySource = await read("../src/main.tsx");+const tokensSource = await read("../src/styles/tokens.css");+const chromeSource = await read("../src/styles/chrome.css");+const workPanelSource = await read("../src/styles/work-panel.css");+const globalStyles = await loadStyles();++test("the macOS traffic lights have one geometry owner across processes", () => {+ // The renderer reserves space for these buttons, so a second literal for+ // where they sit is exactly the drift the shared constant exists to prevent.+ assert.match(+ windowSource,+ /trafficLightPosition:\s*MAC_TRAFFIC_LIGHT_POSITION/,+ );+ assert.doesNotMatch(windowSource, /trafficLightPosition:\s*\{\s*x:/);+ assert.match(+ sharedSource,+ /export const MAC_TRAFFIC_LIGHT_POSITION = \{ x: 16, y: 16 \}/,+ );+ // The footprint the renderer reserves is derived from the position the main+ // process applies, so moving the buttons moves the reserve with them.+ assert.match(+ sharedSource,+ /export const MAC_TRAFFIC_LIGHT_EDGE_DIP =\s*MAC_TRAFFIC_LIGHT_POSITION\.x \+ MAC_TRAFFIC_LIGHT_CLUSTER_WIDTH_DIP;/,+ );+});++test("the renderer publishes the native footprint before first paint", () => {+ assert.match(+ entrySource,+ /import \{ MAC_TRAFFIC_LIGHT_EDGE_DIP \} from "@pi-desktop\/shared";/,+ );+ const bootstrap = entrySource.slice(+ 0,+ entrySource.indexOf("installScrollbarReveal(document)"),+ );+ const platform = bootstrap.indexOf("dataset.platform");+ const publish = bootstrap.indexOf('"--ds-traffic-light-edge"');+ assert.ok(+ platform !== -1 && publish > platform,+ "the inset is published after the platform attribute that gates it",+ );+ assert.match(+ bootstrap,+ /if \(document\.documentElement\.dataset\.platform === "darwin"\) \{\s*document\.documentElement\.style\.setProperty\(\s*"--ds-traffic-light-edge",\s*`\$\{MAC_TRAFFIC_LIGHT_EDGE_DIP\}px`,\s*\);\s*\}/,+ );+});++test("every shell surface reserves the shared lead inset", () => {+ // Comments may quote the old footprint while explaining the geometry; only+ // declarations can drift.+ const declarationsOnly = (css) => css.replace(/\/\*[\s\S]*?\*\//g, "");+ for (const [name, source] of [+ ["chrome.css", chromeSource],+ ["work-panel.css", workPanelSource],+ ["tokens.css", tokensSource],+ ]) {+ assert.doesNotMatch(+ declarationsOnly(source),+ /76px/,+ `${name} must not restate the traffic-light footprint`,+ );+ }+ // One composition, on the platform that has the buttons.+ assert.match(+ chromeSource,+ /:root\[data-platform="darwin"\] \{\s*--ds-window-lead-inset: calc\(\s*var\(--ds-traffic-light-edge\) \+ var\(--ds-traffic-light-gap\)\s*\);/,+ );+ assert.equal(+ [...globalStyles.matchAll(/--ds-window-lead-inset:\s*calc\(/g)].length,+ 1,+ "the reserve is composed in exactly one place",+ );+ // The four surfaces that reach the window's left edge consume it.+ assert.match(+ chromeSource,+ /:root\[data-platform="darwin"\] \.sidebar-header \{[\s\S]*?padding-left:\s*var\(--ds-window-lead-inset\);/,+ );+ assert.match(+ chromeSource,+ /:root\[data-platform="darwin"\] \.window-chrome-row:not\(\.sidebar-expanded\) \{[\s\S]*?padding-left:\s*var\(--ds-window-lead-inset\);/,+ );+ assert.match(+ chromeSource,+ /:root\[data-platform="darwin"\] \.conversation-topbar\.ct-collapsed \{[\s\S]*?--ct-lead-inset:\s*var\(--ds-window-lead-inset\)/,+ );+ assert.match(+ workPanelSource,+ /\.work-panel-header \{[\s\S]*?padding-left: calc\(\s*var\(--ds-window-lead-inset\) \+ var\(--ds-preview-action-lane-width\)\s*\);/,+ );+});++test("the reserve collapses where there are no native traffic lights", () => {+ assert.match(tokensSource, /--ds-traffic-light-edge: 0px/);+ assert.match(tokensSource, /--ds-traffic-light-gap: 12px/);+ assert.match(tokensSource, /--ds-window-lead-inset: 0px/);+ // Fullscreen hides the buttons: the reserve becomes the ordinary gutter.+ assert.match(+ chromeSource,+ /:root\[data-platform="darwin"\]\[data-fullscreen="true"\] \{\s*--ds-window-lead-inset: 8px;/,+ );+ // The titlebar row already pads 12px, so its title adds only the difference —+ // clamped, because a platform without native lights (or fullscreen) resolves+ // the reserve to 0 or 8px and the difference must not go negative.+ assert.match(+ chromeSource,+ /\.main-titlebar-left \{[\s\S]*?padding-left:\s*max\(0px, calc\(var\(--ds-window-lead-inset\) - 12px\)\);/,+ );+ // Windows/Linux draw their own controls on the right and reserve nothing on+ // the left.+ for (const rule of globalStyles.matchAll(+ /:root\[data-platform="(?:win32|linux)"\][^{]*\{([^}]*)\}/g,+ )) {+ assert.doesNotMatch(+ rule[1],+ /--ds-window-lead-inset/,+ "only macOS reserves space for native traffic lights",+ );+ }+});diff --git a/apps/desktop/test/work-panel.test.mjs b/apps/desktop/test/work-panel.test.mjsindex 94f8da501..6f4c7bd62 100644--- a/apps/desktop/test/work-panel.test.mjs+++ b/apps/desktop/test/work-panel.test.mjs@@ -586,18 +586,10 @@ test("preview mode keeps shell actions and restores routes before navigation", ();assert.match(globalStyles,- /:root\[data-platform="darwin"\] \.window-chrome-row:not\(\.sidebar-expanded\) \{[\s\S]*?padding-left:\s*76px;/,+ /:root\[data-platform="darwin"\] \.window-chrome-row:not\(\.sidebar-expanded\) \{[\s\S]*?padding-left:\s*var\(--ds-window-lead-inset\);/,);assert.match(globalStyles,- /:root\[data-platform="darwin"\]\[data-fullscreen="true"\][\s\S]*?\.window-chrome-row:not\(\.sidebar-expanded\) \{[\s\S]*?padding-left:\s*8px;/,- );- assert.match(- globalStyles,- /:root\[data-platform="darwin"\]:not\(\[data-fullscreen="true"\]\)[\s\S]*?\.app-shell\.work-panel-maximized\.sidebar-collapsed\s+\.work-panel-header\s*\{[^}]*padding-left:\s*calc\(76px \+ var\(--ds-preview-action-lane-width\)\);/,- );- assert.match(- globalStyles,- /:root\[data-platform="darwin"\]\[data-fullscreen="true"\][\s\S]*?\.app-shell\.work-panel-maximized\.sidebar-collapsed\s+\.work-panel-header\s*\{[^}]*padding-left:\s*calc\(8px \+ var\(--ds-preview-action-lane-width\)\);/,+ /:root\[data-platform="darwin"\][\s\S]*?\.app-shell\.work-panel-maximized\.sidebar-collapsed\s+\.work-panel-header\s*\{[^}]*padding-left:\s*calc\(\s*var\(--ds-window-lead-inset\) \+ var\(--ds-preview-action-lane-width\)\s*\);/,);});diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.tsindex 5153616d6..00916d22b 100644--- a/packages/shared/src/index.ts+++ b/packages/shared/src/index.ts@@ -52,3 +52,4 @@ export * from "./trusted-extensions.js";export * from "./provider-retry.js";export * from "./message-stream.js";export * from "./session-collaboration.js";+export * from "./window-chrome.js";diff --git a/packages/shared/src/window-chrome.test.ts b/packages/shared/src/window-chrome.test.tsnew file mode 100644index 000000000..cc188f713--- /dev/null+++ b/packages/shared/src/window-chrome.test.ts@@ -0,0 +1,21 @@+import { describe, expect, it } from "vitest";+import {+ MAC_TRAFFIC_LIGHT_CLUSTER_WIDTH_DIP,+ MAC_TRAFFIC_LIGHT_EDGE_DIP,+ MAC_TRAFFIC_LIGHT_POSITION,+} from "./window-chrome.js";++describe("macOS traffic-light geometry", () => {+ it("derives the cluster edge from the position the main process applies", () => {+ expect(MAC_TRAFFIC_LIGHT_EDGE_DIP).toBe(+ MAC_TRAFFIC_LIGHT_POSITION.x + MAC_TRAFFIC_LIGHT_CLUSTER_WIDTH_DIP,+ );+ });++ it("pins the measured native geometry the renderer reserve is built on", () => {+ // Native geometry measured on macOS 26, not a design choice: moving either+ // value moves the space the shell reserves in front of the buttons.+ expect(MAC_TRAFFIC_LIGHT_POSITION).toEqual({ x: 16, y: 16 });+ expect(MAC_TRAFFIC_LIGHT_CLUSTER_WIDTH_DIP).toBe(60);+ });+});diff --git a/packages/shared/src/window-chrome.ts b/packages/shared/src/window-chrome.tsnew file mode 100644index 000000000..b8399b536--- /dev/null+++ b/packages/shared/src/window-chrome.ts@@ -0,0 +1,32 @@+/**+ * Native window-chrome geometry that more than one process has to agree on.+ *+ * The main process positions the macOS traffic lights with these values, and+ * the renderer derives the space it leaves clear for them from the same+ * numbers (`--ds-traffic-light-edge` in styles/tokens.css). Sharing one+ * constant is what keeps the reserved space and the buttons it exists for+ * from drifting apart.+ *+ * Distances are DIP — the native coordinate space. The buttons are native+ * views: the renderer's zoom factor does not scale them.+ */++/**+ * Position handed to Electron's `trafficLightPosition`. The first button's+ * left edge lands on `x`; `y` is measured from the window's top edge.+ */+export const MAC_TRAFFIC_LIGHT_POSITION = { x: 16, y: 16 } as const;++/**+ * Width of the three-button cluster: first button's left edge to last+ * button's right edge.+ *+ * Measured on macOS 26 at a 2x display — the buttons run at a ~23 DIP pitch+ * with ~14 DIP of visible diameter, spanning ~60 DIP. macOS owns these+ * metrics, so re-measure if a release changes the traffic-light buttons.+ */+export const MAC_TRAFFIC_LIGHT_CLUSTER_WIDTH_DIP = 60;++/** Right edge of the cluster, measured from the window's left edge. */+export const MAC_TRAFFIC_LIGHT_EDGE_DIP =+ MAC_TRAFFIC_LIGHT_POSITION.x + MAC_TRAFFIC_LIGHT_CLUSTER_WIDTH_DIP;diff --git a/scripts/e2e-three-column-layout.mjs b/scripts/e2e-three-column-layout.mjsindex 5d76bc82d..e8adfbac1 100644--- a/scripts/e2e-three-column-layout.mjs+++ b/scripts/e2e-three-column-layout.mjs@@ -507,6 +507,7 @@ async function main() {JSON.stringify(openedTabPreview),);const previewActions = await cdp.evaluate(`(() => {+ const row = document.querySelector(".window-chrome-row");const firstAction =document.querySelector('.window-chrome-row [data-nav="toggle-sidebar"]') ??document.querySelector('.window-chrome-row [data-nav="new-task"]');@@ -515,6 +516,13 @@ async function main() {platform: window.piDesktop?.platform ?? "unknown",fullscreen: document.documentElement.dataset.fullscreen === "true",firstActionLeft: firstActionBox ? Math.round(firstActionBox.left) : null,+ // Read the reserve as the layout resolved it instead of restating the+ // number: preview mode runs with the sidebar collapsed, so this row owns+ // the macOS traffic-light reserve.+ leadInset:+ row && !row.classList.contains("sidebar-expanded")+ ? Math.round(parseFloat(getComputedStyle(row).paddingLeft))+ : null,newTask: !!document.querySelector('.window-chrome-row [data-nav="new-task"]'),sidebarToggle:!!document.querySelector('.window-chrome-row [data-nav="toggle-sidebar"]') ||@@ -528,8 +536,11 @@ async function main() {(previewActions.controls || previewActions.platform === "darwin") &&(previewActions.platform !== "darwin" ||previewActions.fullscreen ||+ // 88 = the native cluster's right edge (76) plus the shell's 12px gap.(previewActions.firstActionLeft !== null &&- previewActions.firstActionLeft >= 76)),+ previewActions.leadInset !== null &&+ previewActions.leadInset >= 88 &&+ previewActions.firstActionLeft >= previewActions.leadInset)),"preview mode keeps new-task, sidebar, and window controls available",JSON.stringify(previewActions),);@@ -722,6 +733,13 @@ async function main() {document.querySelector('.window-chrome-row [data-nav="toggle-sidebar"]') ??document.querySelector('.window-chrome-row [data-nav="new-task"]');const firstActionBox = firstAction?.getBoundingClientRect();+ // Read the reserve as the layout resolved it instead of restating the+ // number: preview mode runs with the sidebar collapsed, so this row owns+ // the macOS traffic-light reserve.+ const bandInset =+ band && !band.classList.contains("sidebar-expanded")+ ? Math.round(parseFloat(getComputedStyle(band).paddingLeft))+ : null;const previewActionGroup = document.querySelector(".window-chrome-row .titlebar-nav",);@@ -733,6 +751,7 @@ async function main() {platform: window.piDesktop?.platform ?? "unknown",fullscreen: document.documentElement.dataset.fullscreen === "true",firstActionLeft: firstActionBox ? Math.round(firstActionBox.left) : null,+ bandInset,controlsPosition: controls ? getComputedStyle(controls).position : null,controlsOnScreen: controlsBox? controlsBox.width > 0 && controlsBox.right <= window.innerWidth + 1@@ -802,8 +821,11 @@ async function main() {check(e2eChromePreview.platform !== "darwin" ||e2eChromePreview.fullscreen ||+ // 88 = the native cluster's right edge (76) plus the shell's 12px gap.(e2eChromePreview.firstActionLeft !== null &&- e2eChromePreview.firstActionLeft >= 76),+ e2eChromePreview.bandInset !== null &&+ e2eChromePreview.bandInset >= 88 &&+ e2eChromePreview.firstActionLeft >= e2eChromePreview.bandInset),"preview actions clear the macOS traffic-light hit area",JSON.stringify(e2eChromePreview),);