From 5565133710bb569880de81d276084cc6e9b1970e Mon Sep 17 00:00:00 2001 From: fish <1770968958@qq.com> Date: Wed, 25 Nov 2026 13:18:21 +0900 Subject: [PATCH] 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 --- sidecars/panel/app.js | 51 ++++++++++++ sidecars/panel/index.html | 4 +- .../components/layout/WindowOverlayShell.js | 51 ++++++++++++ sidecars/panel/src/styles/base.css | 5 ++ sidecars/panel/src/styles/modern-ui.css | 18 ++++- sidecars/panel/src/styles/overlay.css | 34 ++++---- sidecars/panel/src/styles/tokens.css | 1 + sidecars/panel/src/styles/views-overview.css | 4 +- sidecars/panel/styles.css | 62 +++++++++----- sidecars/panel/test/modern-ui.test.mjs | 15 ++++ sidecars/panel/test/window-bridge.test.mjs | 81 +++++++++++++++++++ 11 files changed, 284 insertions(+), 42 deletions(-) diff --git a/sidecars/panel/app.js b/sidecars/panel/app.js index c6a471b..fc45599 100644 --- a/sidecars/panel/app.js +++ b/sidecars/panel/app.js @@ -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') || diff --git a/sidecars/panel/index.html b/sidecars/panel/index.html index b84e6b1..7f78bbb 100644 --- a/sidecars/panel/index.html +++ b/sidecars/panel/index.html @@ -4,11 +4,11 @@