mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
fix(panel): align floating task panel font and spacing with sidebar
- Mirror host --font-sans/--font-mono onto portalHost before native theme early-return so Shadow DOM overlays inherit host fonts instead of falling back to narrower system defaults - Reset font-weight, font-stretch, font-variation-settings, font-feature-settings, and letter-spacing on portalHost and panel root, and enable :host([data-font-scale]) token scaling - Align multi-session floating panel width (522px), card row gap (7px), header baseline, Modern UI last-child bottom padding, and right-side elapsed spacing with the sidebar task card
This commit is contained in:
@@ -41654,6 +41654,55 @@ function mountWindowOverlay() {
|
||||
let observedWorkbench = null;
|
||||
let themeObserver = null;
|
||||
const mirroredThemeVars = new Map();
|
||||
const mirroredTypographyVars = new Map();
|
||||
|
||||
function isUsableHostFontStack(raw) {
|
||||
const val = String(raw || '').trim();
|
||||
if (!val) return false;
|
||||
const bare = val.replace(/["']/g, '').trim();
|
||||
return !/^(?:initial|inherit|unset|revert|serif|sans-serif|monospace|times new roman|arial)$/i.test(
|
||||
bare
|
||||
);
|
||||
}
|
||||
|
||||
function syncHostTypographyVars(rootCs, bodyCs, wbCs) {
|
||||
const readProp = (cs, prop, fallbackKey = '') => {
|
||||
if (!cs) return '';
|
||||
const v = String(cs.getPropertyValue?.(prop) || (fallbackKey ? cs[fallbackKey] : '') || '').trim();
|
||||
return isUsableHostFontStack(v) ? v : '';
|
||||
};
|
||||
const hostFontSans =
|
||||
readProp(rootCs, '--font-sans') ||
|
||||
readProp(bodyCs, '--font-sans') ||
|
||||
readProp(wbCs, '--vscode-font-family') ||
|
||||
readProp(bodyCs, 'font-family', 'fontFamily') ||
|
||||
readProp(rootCs, 'font-family', 'fontFamily');
|
||||
const hostFontMono =
|
||||
readProp(rootCs, '--font-mono') ||
|
||||
readProp(bodyCs, '--font-mono') ||
|
||||
readProp(wbCs, '--vscode-editor-font-family') ||
|
||||
readProp(rootCs, '--font-code');
|
||||
|
||||
for (const [cssVar, val] of [
|
||||
['--font-sans', hostFontSans],
|
||||
['--font-mono', hostFontMono],
|
||||
]) {
|
||||
const prevVal = mirroredTypographyVars.get(cssVar) || '';
|
||||
if (val) {
|
||||
if (prevVal !== val) {
|
||||
portalHost.style.setProperty?.(cssVar, val);
|
||||
mirroredTypographyVars.set(cssVar, val);
|
||||
}
|
||||
} else if (prevVal) {
|
||||
if (typeof portalHost.style.removeProperty === 'function') {
|
||||
portalHost.style.removeProperty(cssVar);
|
||||
} else {
|
||||
portalHost.style.setProperty?.(cssVar, '');
|
||||
}
|
||||
mirroredTypographyVars.delete(cssVar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function restorePatchedActionToolbar() {
|
||||
if (!patchedActionToolbar) return;
|
||||
@@ -41683,6 +41732,8 @@ function mountWindowOverlay() {
|
||||
? window.getComputedStyle(document.documentElement)
|
||||
: null;
|
||||
const bodyCs = document.body ? window.getComputedStyle(document.body) : null;
|
||||
const wbOnlyCs = workbenchEl ? window.getComputedStyle(workbenchEl) : null;
|
||||
syncHostTypographyVars(rootCs, bodyCs, wbOnlyCs);
|
||||
const nativeRootBg = String(
|
||||
rootCs?.getPropertyValue?.('--background') ||
|
||||
bodyCs?.getPropertyValue?.('--background') ||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>用量监控</title>
|
||||
<link rel="stylesheet" href="/styles.css?v=1795544315678">
|
||||
<link rel="stylesheet" href="/styles.css?v=1795580198302">
|
||||
<script src="/preload.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app-root"></div>
|
||||
<script src="/app.js?v=1795544315678"></script>
|
||||
<script src="/app.js?v=1795580198302"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -665,6 +665,55 @@ export function mountWindowOverlay() {
|
||||
let observedWorkbench = null;
|
||||
let themeObserver = null;
|
||||
const mirroredThemeVars = new Map();
|
||||
const mirroredTypographyVars = new Map();
|
||||
|
||||
function isUsableHostFontStack(raw) {
|
||||
const val = String(raw || '').trim();
|
||||
if (!val) return false;
|
||||
const bare = val.replace(/["']/g, '').trim();
|
||||
return !/^(?:initial|inherit|unset|revert|serif|sans-serif|monospace|times new roman|arial)$/i.test(
|
||||
bare
|
||||
);
|
||||
}
|
||||
|
||||
function syncHostTypographyVars(rootCs, bodyCs, wbCs) {
|
||||
const readProp = (cs, prop, fallbackKey = '') => {
|
||||
if (!cs) return '';
|
||||
const v = String(cs.getPropertyValue?.(prop) || (fallbackKey ? cs[fallbackKey] : '') || '').trim();
|
||||
return isUsableHostFontStack(v) ? v : '';
|
||||
};
|
||||
const hostFontSans =
|
||||
readProp(rootCs, '--font-sans') ||
|
||||
readProp(bodyCs, '--font-sans') ||
|
||||
readProp(wbCs, '--vscode-font-family') ||
|
||||
readProp(bodyCs, 'font-family', 'fontFamily') ||
|
||||
readProp(rootCs, 'font-family', 'fontFamily');
|
||||
const hostFontMono =
|
||||
readProp(rootCs, '--font-mono') ||
|
||||
readProp(bodyCs, '--font-mono') ||
|
||||
readProp(wbCs, '--vscode-editor-font-family') ||
|
||||
readProp(rootCs, '--font-code');
|
||||
|
||||
for (const [cssVar, val] of [
|
||||
['--font-sans', hostFontSans],
|
||||
['--font-mono', hostFontMono],
|
||||
]) {
|
||||
const prevVal = mirroredTypographyVars.get(cssVar) || '';
|
||||
if (val) {
|
||||
if (prevVal !== val) {
|
||||
portalHost.style.setProperty?.(cssVar, val);
|
||||
mirroredTypographyVars.set(cssVar, val);
|
||||
}
|
||||
} else if (prevVal) {
|
||||
if (typeof portalHost.style.removeProperty === 'function') {
|
||||
portalHost.style.removeProperty(cssVar);
|
||||
} else {
|
||||
portalHost.style.setProperty?.(cssVar, '');
|
||||
}
|
||||
mirroredTypographyVars.delete(cssVar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function restorePatchedActionToolbar() {
|
||||
if (!patchedActionToolbar) return;
|
||||
@@ -694,6 +743,8 @@ export function mountWindowOverlay() {
|
||||
? window.getComputedStyle(document.documentElement)
|
||||
: null;
|
||||
const bodyCs = document.body ? window.getComputedStyle(document.body) : null;
|
||||
const wbOnlyCs = workbenchEl ? window.getComputedStyle(workbenchEl) : null;
|
||||
syncHostTypographyVars(rootCs, bodyCs, wbOnlyCs);
|
||||
const nativeRootBg = String(
|
||||
rootCs?.getPropertyValue?.('--background') ||
|
||||
bodyCs?.getPropertyValue?.('--background') ||
|
||||
|
||||
@@ -31,6 +31,11 @@ body {
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-sans);
|
||||
font-size: var(--fs-body);
|
||||
font-weight: 400;
|
||||
font-stretch: 100%;
|
||||
font-variation-settings: normal;
|
||||
font-feature-settings: normal;
|
||||
letter-spacing: normal;
|
||||
line-height: 1.4;
|
||||
font-variant-numeric: tabular-nums;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
|
||||
@@ -934,7 +934,11 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
|
||||
}
|
||||
|
||||
[data-modern-ui="true"] .wm-multi-header,
|
||||
:host([data-modern-ui="true"]) .wm-multi-header,
|
||||
:host([data-modern-ui="true"]) .wm-multi-header {
|
||||
border: none;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
|
||||
[data-modern-ui="true"].wm-multi-panel .live-task-card + .live-task-card,
|
||||
:host([data-modern-ui="true"]) .wm-multi-panel .live-task-card + .live-task-card {
|
||||
border: none;
|
||||
@@ -952,12 +956,22 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
|
||||
|
||||
[data-modern-ui="true"].wm-multi-panel .live-task-card,
|
||||
:host([data-modern-ui="true"]) .wm-multi-panel .live-task-card {
|
||||
padding: 10px 2px;
|
||||
padding: 8px 0;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
[data-modern-ui="true"].wm-multi-panel .live-task-card:first-child,
|
||||
:host([data-modern-ui="true"]) .wm-multi-panel .live-task-card:first-child {
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
[data-modern-ui="true"].wm-multi-panel .live-task-card:last-child,
|
||||
:host([data-modern-ui="true"]) .wm-multi-panel .live-task-card:last-child {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
/* --- 8. 顶栏胶囊老虎机滚动数字 (0.15s) 与语义色平滑渐变 (0.1s),严格限定实验性新 UI --- */
|
||||
:host([data-modern-ui="true"]) .wm-cap-slot,
|
||||
:host([data-modern-ui="true"]) .wm-cap-slot .wm-slot-text,
|
||||
|
||||
@@ -561,6 +561,11 @@
|
||||
z-index: 2147483000;
|
||||
font-family: var(--font-sans);
|
||||
font-size: var(--fs-body);
|
||||
font-weight: 400;
|
||||
font-stretch: 100%;
|
||||
font-variation-settings: normal;
|
||||
font-feature-settings: normal;
|
||||
letter-spacing: normal;
|
||||
line-height: 1.4;
|
||||
font-variant-numeric: tabular-nums;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
@@ -642,14 +647,14 @@
|
||||
animation: wm-popover-in var(--dur-instant) var(--ease-fast);
|
||||
}
|
||||
|
||||
/* 左侧在线多会话实时看板浮层(单层无套娃细线卡片,仅显示在线运行会话,留足呼吸感) */
|
||||
/* 左侧在线多会话实时看板浮层(单层无套娃细线卡片,宽度与排版密度与侧边栏保持一致) */
|
||||
.wm-multi-panel {
|
||||
position: fixed;
|
||||
top: 42px;
|
||||
left: 12px;
|
||||
width: min(calc(464px * var(--ui-panel-scale, 1)), calc(100vw - 24px));
|
||||
width: min(calc(522px * var(--ui-panel-scale, 1)), calc(100vw - 24px));
|
||||
max-height: calc(100vh - 54px);
|
||||
padding: 14px 16px;
|
||||
padding: 12px 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
@@ -783,53 +788,50 @@
|
||||
}
|
||||
|
||||
.wm-task-metrics {
|
||||
font-size: var(--fs-md);
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--fs-sm);
|
||||
font-weight: 500;
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.wm-multi-header {
|
||||
padding-bottom: 10px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid var(--border-hairline);
|
||||
}
|
||||
|
||||
/* 多会话单层面板内去除重复边框与底色,留足行距与段落呼吸感,仅靠左侧圆点闪烁表达状态 */
|
||||
/* 多会话单层面板内去除重复边框与底色,对齐侧边栏任务卡片间距与左侧基线 */
|
||||
.wm-multi-panel .live-activity-list {
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.wm-multi-panel .live-task-card {
|
||||
gap: 8px;
|
||||
padding: 12px 2px;
|
||||
gap: 7px;
|
||||
padding: 10px 0;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.wm-multi-panel .live-task-card:first-child {
|
||||
padding-top: 11px;
|
||||
padding-top: 9px;
|
||||
}
|
||||
|
||||
.wm-multi-panel .live-task-card:last-child {
|
||||
padding-bottom: 2px;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.wm-multi-panel .live-task-card + .live-task-card {
|
||||
border-top: 1px solid var(--border-hairline);
|
||||
}
|
||||
|
||||
.wm-multi-panel .live-task-title {
|
||||
font-size: var(--fs-body);
|
||||
}
|
||||
|
||||
.wm-multi-empty {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-3);
|
||||
min-height: 36px;
|
||||
padding: 12px 2px 4px;
|
||||
padding: 10px 0 2px;
|
||||
font-size: var(--fs-base);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
@@ -171,6 +171,7 @@
|
||||
--ui-panel-scale: 1.18;
|
||||
}
|
||||
|
||||
:host([data-font-scale]),
|
||||
[data-font-scale] {
|
||||
--fs-2xs: calc(10.5px * var(--ui-font-scale, 1));
|
||||
--fs-xs: calc(11px * var(--ui-font-scale, 1));
|
||||
|
||||
@@ -175,7 +175,7 @@
|
||||
.live-task-header-right {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@
|
||||
font-weight: 500;
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
min-width: 28px;
|
||||
min-width: 22px;
|
||||
text-align: right;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
+42
-20
@@ -172,6 +172,7 @@
|
||||
--ui-panel-scale: 1.18;
|
||||
}
|
||||
|
||||
:host([data-font-scale]),
|
||||
[data-font-scale] {
|
||||
--fs-2xs: calc(10.5px * var(--ui-font-scale, 1));
|
||||
--fs-xs: calc(11px * var(--ui-font-scale, 1));
|
||||
@@ -230,6 +231,11 @@ body {
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-sans);
|
||||
font-size: var(--fs-body);
|
||||
font-weight: 400;
|
||||
font-stretch: 100%;
|
||||
font-variation-settings: normal;
|
||||
font-feature-settings: normal;
|
||||
letter-spacing: normal;
|
||||
line-height: 1.4;
|
||||
font-variant-numeric: tabular-nums;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
@@ -1962,7 +1968,7 @@ html[data-standalone="true"] .app-shell {
|
||||
.live-task-header-right {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@@ -2071,7 +2077,7 @@ html[data-standalone="true"] .app-shell {
|
||||
font-weight: 500;
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
min-width: 28px;
|
||||
min-width: 22px;
|
||||
text-align: right;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
@@ -8104,6 +8110,11 @@ html[data-standalone="true"] .app-shell {
|
||||
z-index: 2147483000;
|
||||
font-family: var(--font-sans);
|
||||
font-size: var(--fs-body);
|
||||
font-weight: 400;
|
||||
font-stretch: 100%;
|
||||
font-variation-settings: normal;
|
||||
font-feature-settings: normal;
|
||||
letter-spacing: normal;
|
||||
line-height: 1.4;
|
||||
font-variant-numeric: tabular-nums;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
@@ -8185,14 +8196,14 @@ html[data-standalone="true"] .app-shell {
|
||||
animation: wm-popover-in var(--dur-instant) var(--ease-fast);
|
||||
}
|
||||
|
||||
/* 左侧在线多会话实时看板浮层(单层无套娃细线卡片,仅显示在线运行会话,留足呼吸感) */
|
||||
/* 左侧在线多会话实时看板浮层(单层无套娃细线卡片,宽度与排版密度与侧边栏保持一致) */
|
||||
.wm-multi-panel {
|
||||
position: fixed;
|
||||
top: 42px;
|
||||
left: 12px;
|
||||
width: min(calc(464px * var(--ui-panel-scale, 1)), calc(100vw - 24px));
|
||||
width: min(calc(522px * var(--ui-panel-scale, 1)), calc(100vw - 24px));
|
||||
max-height: calc(100vh - 54px);
|
||||
padding: 14px 16px;
|
||||
padding: 12px 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
@@ -8326,53 +8337,50 @@ html[data-standalone="true"] .app-shell {
|
||||
}
|
||||
|
||||
.wm-task-metrics {
|
||||
font-size: var(--fs-md);
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--fs-sm);
|
||||
font-weight: 500;
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.wm-multi-header {
|
||||
padding-bottom: 10px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid var(--border-hairline);
|
||||
}
|
||||
|
||||
/* 多会话单层面板内去除重复边框与底色,留足行距与段落呼吸感,仅靠左侧圆点闪烁表达状态 */
|
||||
/* 多会话单层面板内去除重复边框与底色,对齐侧边栏任务卡片间距与左侧基线 */
|
||||
.wm-multi-panel .live-activity-list {
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.wm-multi-panel .live-task-card {
|
||||
gap: 8px;
|
||||
padding: 12px 2px;
|
||||
gap: 7px;
|
||||
padding: 10px 0;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.wm-multi-panel .live-task-card:first-child {
|
||||
padding-top: 11px;
|
||||
padding-top: 9px;
|
||||
}
|
||||
|
||||
.wm-multi-panel .live-task-card:last-child {
|
||||
padding-bottom: 2px;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.wm-multi-panel .live-task-card + .live-task-card {
|
||||
border-top: 1px solid var(--border-hairline);
|
||||
}
|
||||
|
||||
.wm-multi-panel .live-task-title {
|
||||
font-size: var(--fs-body);
|
||||
}
|
||||
|
||||
.wm-multi-empty {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-3);
|
||||
min-height: 36px;
|
||||
padding: 12px 2px 4px;
|
||||
padding: 10px 0 2px;
|
||||
font-size: var(--fs-base);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
@@ -9329,7 +9337,11 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
|
||||
}
|
||||
|
||||
[data-modern-ui="true"] .wm-multi-header,
|
||||
:host([data-modern-ui="true"]) .wm-multi-header,
|
||||
:host([data-modern-ui="true"]) .wm-multi-header {
|
||||
border: none;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
|
||||
[data-modern-ui="true"].wm-multi-panel .live-task-card + .live-task-card,
|
||||
:host([data-modern-ui="true"]) .wm-multi-panel .live-task-card + .live-task-card {
|
||||
border: none;
|
||||
@@ -9347,12 +9359,22 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
|
||||
|
||||
[data-modern-ui="true"].wm-multi-panel .live-task-card,
|
||||
:host([data-modern-ui="true"]) .wm-multi-panel .live-task-card {
|
||||
padding: 10px 2px;
|
||||
padding: 8px 0;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
[data-modern-ui="true"].wm-multi-panel .live-task-card:first-child,
|
||||
:host([data-modern-ui="true"]) .wm-multi-panel .live-task-card:first-child {
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
[data-modern-ui="true"].wm-multi-panel .live-task-card:last-child,
|
||||
:host([data-modern-ui="true"]) .wm-multi-panel .live-task-card:last-child {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
/* --- 8. 顶栏胶囊老虎机滚动数字 (0.15s) 与语义色平滑渐变 (0.1s),严格限定实验性新 UI --- */
|
||||
:host([data-modern-ui="true"]) .wm-cap-slot,
|
||||
:host([data-modern-ui="true"]) .wm-cap-slot .wm-slot-text,
|
||||
|
||||
@@ -303,6 +303,21 @@ test('applyAppearanceToRoot and SettingsGeneralTab toggle data-modern-ui + data-
|
||||
builtStyles,
|
||||
/\[data-modern-ui="true"\]\.wm-multi-panel\s+\.live-task-card[\s\S]*?background:\s*transparent;/
|
||||
);
|
||||
assert.match(
|
||||
builtStyles,
|
||||
/:host\(\.wm-portal-host\)\s*\{[^}]*font-stretch:\s*100%;[^}]*font-variation-settings:\s*normal;[^}]*letter-spacing:\s*normal;/s,
|
||||
'Portal Shadow host must reset inherited host font-stretch/variation/letter-spacing to match sidebar typography'
|
||||
);
|
||||
assert.match(
|
||||
builtStyles,
|
||||
/\.wm-multi-panel\s+\.live-task-card\s*\{[^}]*gap:\s*7px;[^}]*padding:\s*10px\s+0;/s,
|
||||
'Floating multi-session task cards must match sidebar 7px row gap and 0px horizontal inset alignment'
|
||||
);
|
||||
assert.match(
|
||||
builtStyles,
|
||||
/\[data-modern-ui="true"\]\.wm-multi-panel\s+\.live-task-card:last-child[\s\S]*?padding-bottom:\s*0;/,
|
||||
'Modern UI multi-session panel must preserve symmetric bottom padding on last task card'
|
||||
);
|
||||
assert.match(
|
||||
builtStyles,
|
||||
/\.ctx-inspector-bar\s*\{[^}]*align-items:\s*flex-start;/,
|
||||
|
||||
@@ -6977,3 +6977,84 @@ test('IDE chat iframe route probe disambiguates multi-view DOM, aborts hanging s
|
||||
fs.rmSync(tmpDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('WindowOverlayShell mirrors host --font-sans and --font-mono onto portalHost even on native Antigravity 2.0 theme', async () => {
|
||||
const { mountWindowOverlay } = await import('../src/components/layout/WindowOverlayShell.js');
|
||||
const { createMockDom } = await import('./mock-dom.mjs');
|
||||
const { WINDOW_BRIDGE_KEY } = await import('../shared/window-bridge-protocol.mjs');
|
||||
const prevDoc = globalThis.document;
|
||||
const prevWin = globalThis.window;
|
||||
const prevRo = globalThis.ResizeObserver;
|
||||
const prevMo = globalThis.MutationObserver;
|
||||
const prevFetch = globalThis.fetch;
|
||||
|
||||
const { document } = createMockDom();
|
||||
const hostSans = '"Google Sans Flex", "PingFang SC", sans-serif';
|
||||
const hostMono = '"Cascadia Mono", monospace';
|
||||
globalThis.document = document;
|
||||
globalThis.ResizeObserver = class {
|
||||
observe() {}
|
||||
disconnect() {}
|
||||
};
|
||||
globalThis.MutationObserver = class {
|
||||
observe() {}
|
||||
disconnect() {}
|
||||
};
|
||||
globalThis.fetch = async () => ({
|
||||
ok: true,
|
||||
status: 200,
|
||||
json: async () => ({ settings: { modernUi: true, fontScale: 'md' } }),
|
||||
text: async () => JSON.stringify({ settings: { modernUi: true, fontScale: 'md' } }),
|
||||
});
|
||||
globalThis.window = {
|
||||
innerWidth: 1440,
|
||||
innerHeight: 900,
|
||||
location: { pathname: '/', href: 'http://127.0.0.1:41234/' },
|
||||
[WINDOW_BRIDGE_KEY]: {
|
||||
port: 0,
|
||||
token: 't',
|
||||
bundleVersion: 'v-font-sync',
|
||||
stylesCss: ':host{}',
|
||||
initialTelemetry: { settings: { modernUi: true, fontScale: 'md' } },
|
||||
},
|
||||
getComputedStyle: (el) => {
|
||||
if (el === document.documentElement) {
|
||||
return {
|
||||
getPropertyValue: (prop) => {
|
||||
if (prop === '--background') return 'hsl(222 18% 10%)';
|
||||
if (prop === '--font-sans') return hostSans;
|
||||
if (prop === '--font-mono') return hostMono;
|
||||
return '';
|
||||
},
|
||||
};
|
||||
}
|
||||
return { getPropertyValue: () => '' };
|
||||
},
|
||||
addEventListener() {},
|
||||
removeEventListener() {},
|
||||
requestAnimationFrame: (cb) => setTimeout(cb, 0),
|
||||
cancelAnimationFrame: (id) => clearTimeout(id),
|
||||
};
|
||||
|
||||
let ov = null;
|
||||
try {
|
||||
ov = mountWindowOverlay();
|
||||
const portalHost = document.getElementById('ag-usage-monitor-portal');
|
||||
const capsuleHost = document.getElementById('ag-usage-monitor-capsule');
|
||||
assert.ok(portalHost, 'portalHost mounted');
|
||||
assert.equal(portalHost.style.getPropertyValue('--font-sans'), hostSans);
|
||||
assert.equal(portalHost.style.getPropertyValue('--font-mono'), hostMono);
|
||||
assert.equal(
|
||||
capsuleHost?.style?.getPropertyValue?.('--font-sans') || '',
|
||||
'',
|
||||
'capsuleHost retains its own titlebar typography isolation'
|
||||
);
|
||||
} finally {
|
||||
ov?.dispose?.();
|
||||
globalThis.document = prevDoc;
|
||||
globalThis.window = prevWin;
|
||||
globalThis.ResizeObserver = prevRo;
|
||||
globalThis.MutationObserver = prevMo;
|
||||
globalThis.fetch = prevFetch;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user