mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user