feat(panel): refine macOS overlay geometry, port discovery, font tokens, and LF bundling

Co-authored-by: Swei <sweilo@qq.com>
This commit is contained in:
fish
2026-11-17 22:30:01 +09:00
co-authored by Swei
parent 96bf0c049f
commit d4d359bc89
13 changed files with 444 additions and 25 deletions
@@ -44,6 +44,7 @@ import {
fetchTelemetry,
formatAgentBadgeText,
getAgentBadgeClass,
isMacHostPlatform,
normalizeClientHoverModules,
normalizeClientPopoverWidth,
normalizeClientPopoverWidthMode,
@@ -1777,6 +1778,8 @@ export function mountWindowOverlay() {
return true;
}
const isMac = () => isMacHostPlatform(telemetryStore.getState().telemetry);
function updateFixedFallbackPosition() {
const dockMode = capsuleHost.getAttribute('data-dock');
if (dockMode === 'flow' || dockMode === 'ide-titlebar' || dockMode === 'composer') {
@@ -1786,12 +1789,13 @@ export function mountWindowOverlay() {
}
try {
const vw = Number(window.innerWidth || 1280);
let rightOffset = 144;
const minRight = isMac() ? 12 : 144;
let rightOffset = minRight;
const anchor = findNativeTopRightAnchor();
if (anchor?.getBoundingClientRect) {
const r = anchor.getBoundingClientRect();
if (r.width > 0 && r.left > 0 && r.left < vw) {
rightOffset = Math.max(144, Math.ceil(vw - r.left + 6));
rightOffset = Math.max(minRight, Math.ceil(vw - r.left + 6));
}
}
capsuleHost.style.top = '7px';
@@ -1801,6 +1805,16 @@ export function mountWindowOverlay() {
}
}
function syncCapsuleOsAttr() {
const nextOs = isMac() ? 'mac' : 'default';
if (capsuleHost.getAttribute('data-os') !== nextOs) {
patchAttr(capsuleHost, 'data-os', nextOs);
if (capsuleHost.getAttribute('data-dock') === 'fixed') {
updateFixedFallbackPosition();
}
}
}
function measureAvailableTitlebarWidth(dockTarget) {
try {
const titlebar = dockTarget?.titlebar || null;
@@ -1870,10 +1884,19 @@ export function mountWindowOverlay() {
}
}
}
if (!hasVisibleWindowControls && navigator?.windowControlsOverlay?.visible) {
if (navigator?.windowControlsOverlay?.visible) {
const wcoRect = navigator.windowControlsOverlay.getTitlebarAreaRect?.();
if (wcoRect && wcoRect.width > 0 && tbRect.right > wcoRect.right + 4) {
rightSiblingsWidth += tbRect.right - wcoRect.right;
if (wcoRect && wcoRect.width > 0) {
if (!hasVisibleWindowControls && tbRect.right > wcoRect.right + 4) {
rightSiblingsWidth += tbRect.right - wcoRect.right;
}
const leftOverlayInset = wcoRect.left - tbRect.left;
if (leftOverlayInset > leftContentWidth) {
leftContentWidth = Math.min(
Math.round(tbRect.width * 0.45),
Math.ceil(leftOverlayInset)
);
}
}
}
@@ -1886,10 +1909,11 @@ export function mountWindowOverlay() {
if (tbRect.width > 0) {
const titleEl = titlebar.firstElementChild;
const titleInner = titleEl?.firstElementChild;
const macTrafficReserve = isMac() ? 80 : 168;
const contentStart = titleInner?.getBoundingClientRect
? Math.max(8, titleInner.getBoundingClientRect().left - tbRect.left)
: tbRect.left < 168
? 168 - tbRect.left
: tbRect.left < macTrafficReserve
? macTrafficReserve - tbRect.left
: 12;
const minTitleWidth = 180;
let siblingButtonsWidth = 64;
@@ -2167,6 +2191,7 @@ export function mountWindowOverlay() {
if (bodyOrDoc && !portalHost.isConnected) {
bodyOrDoc.appendChild(portalHost);
}
syncCapsuleOsAttr();
ensureWorkbenchThemeObserved();
const dockTarget = resolveRuntimeDockTarget();
@@ -2651,6 +2676,7 @@ export function mountWindowOverlay() {
setI18nLanguage(telemetry?.settings?.language);
syncPortalAppearance(telemetry?.settings);
syncCapsuleOsAttr();
const showMulti = telemetry?.settings?.showTopbarMultiSession !== false;
patchAttr(multiBtn, 'hidden', !showMulti);
@@ -399,6 +399,7 @@ function isEquivalentTelemetry(prev, next) {
if ((pSet?.language ?? 'zh-CN') !== (nSet?.language ?? 'zh-CN')) return false;
if ((pSet?.themeAccent ?? 'host') !== (nSet?.themeAccent ?? 'host')) return false;
if ((pSet?.fontScale ?? 'md') !== (nSet?.fontScale ?? 'md')) return false;
if ((prev.hostPlatform || '') !== (next.hostPlatform || '')) return false;
if (Boolean(pSet?.contextWindowRiskAccepted) !== Boolean(nSet?.contextWindowRiskAccepted)) {
return false;
}
@@ -1490,3 +1491,21 @@ export function resolveScopedConversation(
ctxAgent,
};
}
/**
* 判断宿主系统是否为 macOS (`darwin`):优先读取后端遥测或双栖桥接注入的 `platform`,首帧缺省时回退 UA/平台标识。
*
* @param {Record<string, any>|null|undefined} telemetry
* @returns {boolean}
*/
export function isMacHostPlatform(telemetry) {
const p = String(telemetry?.hostPlatform || readInjectedWindowBridge()?.platform || '')
.trim()
.toLowerCase();
if (p) return p === 'darwin';
if (typeof navigator !== 'undefined') {
const ua = String(navigator.platform || navigator.userAgent || '');
return /\b(?:mac|darwin)\b|macintosh|mac\s*os/i.test(ua);
}
return false;
}
+2 -1
View File
@@ -29,11 +29,12 @@ body {
overflow: hidden;
background: var(--surface-bg);
color: var(--text-primary);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
font-family: var(--font-sans);
font-size: var(--fs-body);
line-height: 1.4;
font-variant-numeric: tabular-nums;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
button,
+8 -2
View File
@@ -15,7 +15,7 @@
-webkit-app-region: no-drag;
pointer-events: auto;
user-select: none;
font-family: "Google Sans Flex", "Google Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
font-family: "Google Sans Flex", "Google Sans", system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
font-size: 12px;
font-weight: 450;
font-stretch: 100%;
@@ -24,6 +24,7 @@
letter-spacing: 0.015em;
font-variant-numeric: tabular-nums;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: var(--text-primary);
z-index: 2147482900;
}
@@ -77,6 +78,10 @@
right: 144px;
}
:host(.wm-capsule-host[data-dock="fixed"][data-os="mac"]) {
right: 12px;
}
@keyframes wm-dot-pulse {
0%, 100% {
opacity: 1;
@@ -518,11 +523,12 @@
overflow: visible;
pointer-events: none;
z-index: 2147483000;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
font-family: var(--font-sans);
font-size: var(--fs-body);
line-height: 1.4;
font-variant-numeric: tabular-nums;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: var(--text-primary);
}
+4
View File
@@ -6,6 +6,10 @@
:root,
:host {
/* Cross-Platform Typography Stacks (macOS SF Pro / SF Mono + Windows / Linux Fallbacks) */
--font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
--font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, "Cascadia Mono", Consolas, monospace;
/* Architectural Geometry: Only Top Nav uses --radius-pill */
--radius-pill: 999px;
--radius-sm: 4px;