From c948126c9674a2d0d7ad1340f2a4c9cd3e5f78fb Mon Sep 17 00:00:00 2001 From: fish <1770968958@qq.com> Date: Wed, 18 Nov 2026 12:56:51 +0900 Subject: [PATCH] fix(panel): prevent top pill nav overflow in narrow sidebar via minmax(0, 1fr) and @container stages --- sidecars/panel/app.js | 4 +- sidecars/panel/index.html | 4 +- .../panel/src/components/ui/TopLongPillNav.js | 4 +- sidecars/panel/src/styles/controls.css | 58 ++++++++++++++--- .../panel/src/styles/views-consumption.css | 2 +- sidecars/panel/src/styles/views-overview.css | 3 +- sidecars/panel/styles.css | 63 ++++++++++++++++--- .../test/cross-module-regressions.test.mjs | 5 +- 8 files changed, 120 insertions(+), 23 deletions(-) diff --git a/sidecars/panel/app.js b/sidecars/panel/app.js index 201db31..a9710d4 100644 --- a/sidecars/panel/app.js +++ b/sidecars/panel/app.js @@ -4285,12 +4285,14 @@ const TopLongPillNav = defineComponent({ } patchText(entry.labelEl, item.label); - if (item.badge !== undefined && item.badge !== null && item.badge !== '') { + const hasBadge = item.badge !== undefined && item.badge !== null && item.badge !== ''; + if (hasBadge) { patchAttr(entry.badgeEl, 'hidden', false); patchText(entry.badgeEl, `(${item.badge})`); } else { patchAttr(entry.badgeEl, 'hidden', true); } + patchAttr(entry.btn, 'title', hasBadge ? `${item.label} (${item.badge})` : item.label); const isActive = item.value === modelValue; patchClasses(entry.btn, { 'is-active': isActive }); diff --git a/sidecars/panel/index.html b/sidecars/panel/index.html index 3403778..cf6a7a3 100644 --- a/sidecars/panel/index.html +++ b/sidecars/panel/index.html @@ -4,11 +4,11 @@ 用量监控 - +
- + diff --git a/sidecars/panel/src/components/ui/TopLongPillNav.js b/sidecars/panel/src/components/ui/TopLongPillNav.js index 5eb93d7..4360afd 100644 --- a/sidecars/panel/src/components/ui/TopLongPillNav.js +++ b/sidecars/panel/src/components/ui/TopLongPillNav.js @@ -90,12 +90,14 @@ export const TopLongPillNav = defineComponent({ } patchText(entry.labelEl, item.label); - if (item.badge !== undefined && item.badge !== null && item.badge !== '') { + const hasBadge = item.badge !== undefined && item.badge !== null && item.badge !== ''; + if (hasBadge) { patchAttr(entry.badgeEl, 'hidden', false); patchText(entry.badgeEl, `(${item.badge})`); } else { patchAttr(entry.badgeEl, 'hidden', true); } + patchAttr(entry.btn, 'title', hasBadge ? `${item.label} (${item.badge})` : item.label); const isActive = item.value === modelValue; patchClasses(entry.btn, { 'is-active': isActive }); diff --git a/sidecars/panel/src/styles/controls.css b/sidecars/panel/src/styles/controls.css index c4ae4a8..96c2b09 100644 --- a/sidecars/panel/src/styles/controls.css +++ b/sidecars/panel/src/styles/controls.css @@ -117,13 +117,15 @@ /* --- 2. 顶部药丸导航栏 (Top Long-Pill Navigation Bar) --- */ .long-pill-nav { position: relative; + container-type: inline-size; display: grid; - grid-template-columns: repeat(var(--pill-count, 4), 1fr); + grid-template-columns: repeat(var(--pill-count, 4), minmax(0, 1fr)); align-items: center; padding: 3px; background: var(--surface-panel); border: 1px solid var(--border-hairline); border-radius: var(--radius-pill); + overflow: hidden; user-select: none; } @@ -149,6 +151,7 @@ align-items: center; justify-content: center; gap: 5px; + min-width: 0; min-height: calc(26px * var(--ui-font-scale, 1)); padding: 2px var(--space-2); border: none; @@ -158,6 +161,7 @@ font-weight: 500; line-height: 1.15; border-radius: var(--radius-pill); + overflow: hidden; cursor: pointer; white-space: nowrap; transition: color var(--dur-instant) var(--ease-fast); @@ -171,20 +175,60 @@ flex-shrink: 0; } -.pill-tab-label, -.pill-tab-badge { - display: inline-flex; - align-items: center; - min-height: 14px; - line-height: 1.15; +.pill-tab-label { + display: block; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + line-height: 1.2; } .pill-tab-badge { + display: inline-flex; + align-items: center; + flex-shrink: 0; + min-height: 14px; + line-height: 1.15; margin-left: -2px; font-size: var(--fs-base-sm); opacity: 0.85; } +@container (max-width: 30em) { + .pill-tab { + gap: 3.5px; + padding: 2px 4px; + font-size: var(--fs-md); + } + .pill-tab .svg-icon { + width: 13px; + height: 13px; + } + .pill-tab-badge { + display: none !important; + } +} + +@container (max-width: 23em) { + .pill-tab { + gap: 0; + padding: 2px 3px; + } + .pill-tab .svg-icon { + display: none; + } +} + +@container (max-width: 17.5em) { + .pill-tab .svg-icon { + display: block; + } + .pill-tab-label { + display: none; + } +} + .pill-tab:hover { color: var(--text-primary); } diff --git a/sidecars/panel/src/styles/views-consumption.css b/sidecars/panel/src/styles/views-consumption.css index 792bb9b..cb49807 100644 --- a/sidecars/panel/src/styles/views-consumption.css +++ b/sidecars/panel/src/styles/views-consumption.css @@ -45,7 +45,7 @@ .cons-split-3 { display: grid; - grid-template-columns: repeat(3, 1fr); + grid-template-columns: repeat(3, minmax(0, 1fr)); } .cons-matrix-bottom { diff --git a/sidecars/panel/src/styles/views-overview.css b/sidecars/panel/src/styles/views-overview.css index a720501..bebec4a 100644 --- a/sidecars/panel/src/styles/views-overview.css +++ b/sidecars/panel/src/styles/views-overview.css @@ -477,7 +477,7 @@ /* --- 4. 上下文双列图例网格 (Context 10-Channel Legend Grid) --- */ .ctx-legend-grid { display: grid; - grid-template-columns: repeat(2, 1fr); + grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px var(--space-4); padding: 2px 0 0 0; background: transparent; @@ -490,6 +490,7 @@ align-items: center; justify-content: space-between; gap: var(--space-2); + min-width: 0; } .legend-left { diff --git a/sidecars/panel/styles.css b/sidecars/panel/styles.css index 75c1188..6305365 100644 --- a/sidecars/panel/styles.css +++ b/sidecars/panel/styles.css @@ -488,13 +488,15 @@ html[data-standalone="true"] .app-shell { /* --- 2. 顶部药丸导航栏 (Top Long-Pill Navigation Bar) --- */ .long-pill-nav { position: relative; + container-type: inline-size; display: grid; - grid-template-columns: repeat(var(--pill-count, 4), 1fr); + grid-template-columns: repeat(var(--pill-count, 4), minmax(0, 1fr)); align-items: center; padding: 3px; background: var(--surface-panel); border: 1px solid var(--border-hairline); border-radius: var(--radius-pill); + overflow: hidden; user-select: none; } @@ -520,6 +522,7 @@ html[data-standalone="true"] .app-shell { align-items: center; justify-content: center; gap: 5px; + min-width: 0; min-height: calc(26px * var(--ui-font-scale, 1)); padding: 2px var(--space-2); border: none; @@ -529,6 +532,7 @@ html[data-standalone="true"] .app-shell { font-weight: 500; line-height: 1.15; border-radius: var(--radius-pill); + overflow: hidden; cursor: pointer; white-space: nowrap; transition: color var(--dur-instant) var(--ease-fast); @@ -542,20 +546,60 @@ html[data-standalone="true"] .app-shell { flex-shrink: 0; } -.pill-tab-label, -.pill-tab-badge { - display: inline-flex; - align-items: center; - min-height: 14px; - line-height: 1.15; +.pill-tab-label { + display: block; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + line-height: 1.2; } .pill-tab-badge { + display: inline-flex; + align-items: center; + flex-shrink: 0; + min-height: 14px; + line-height: 1.15; margin-left: -2px; font-size: var(--fs-base-sm); opacity: 0.85; } +@container (max-width: 30em) { + .pill-tab { + gap: 3.5px; + padding: 2px 4px; + font-size: var(--fs-md); + } + .pill-tab .svg-icon { + width: 13px; + height: 13px; + } + .pill-tab-badge { + display: none !important; + } +} + +@container (max-width: 23em) { + .pill-tab { + gap: 0; + padding: 2px 3px; + } + .pill-tab .svg-icon { + display: none; + } +} + +@container (max-width: 17.5em) { + .pill-tab .svg-icon { + display: block; + } + .pill-tab-label { + display: none; + } +} + .pill-tab:hover { color: var(--text-primary); } @@ -1680,7 +1724,7 @@ html[data-standalone="true"] .app-shell { /* --- 4. 上下文双列图例网格 (Context 10-Channel Legend Grid) --- */ .ctx-legend-grid { display: grid; - grid-template-columns: repeat(2, 1fr); + grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px var(--space-4); padding: 2px 0 0 0; background: transparent; @@ -1693,6 +1737,7 @@ html[data-standalone="true"] .app-shell { align-items: center; justify-content: space-between; gap: var(--space-2); + min-width: 0; } .legend-left { @@ -1900,7 +1945,7 @@ html[data-standalone="true"] .app-shell { .cons-split-3 { display: grid; - grid-template-columns: repeat(3, 1fr); + grid-template-columns: repeat(3, minmax(0, 1fr)); } .cons-matrix-bottom { diff --git a/sidecars/panel/test/cross-module-regressions.test.mjs b/sidecars/panel/test/cross-module-regressions.test.mjs index 11871c9..f22372d 100644 --- a/sidecars/panel/test/cross-module-regressions.test.mjs +++ b/sidecars/panel/test/cross-module-regressions.test.mjs @@ -809,10 +809,13 @@ test('post-compaction context preserves static channels + checkpoint summary, ca assert.equal(ctx2.assistantTokens, 600); assert.equal(ctx2.totalTokens, 31_100); - // Verify capsule 100% slot CSS and non-hardcoded compaction suffix color + // Verify capsule 100% slot CSS, non-hardcoded compaction suffix color, and narrow-width top pill nav containment const stylesCss = fs.readFileSync(new URL('../styles.css', import.meta.url), 'utf8'); assert.match(stylesCss, /\.wm-ctx-seg\s*\{[^}]*width:\s*58px;/); assert.match(stylesCss, /\.wm-ctx-pct\s*\{[^}]*max-width:\s*none;[^}]*overflow:\s*visible;[^}]*text-overflow:\s*clip;/s); assert.match(stylesCss, /\.step-model-compact\s*\{[^}]*color:\s*var\(--accent-primary\);/); assert.doesNotMatch(stylesCss, /\.step-model-compact\s*\{[^}]*--metric-info/); + assert.match(stylesCss, /\.long-pill-nav\s*\{[^}]*container-type:\s*inline-size;[^}]*minmax\(0,\s*1fr\)[^}]*overflow:\s*hidden;/s); + assert.match(stylesCss, /\.pill-tab\s*\{[^}]*min-width:\s*0;/s); + assert.match(stylesCss, /@container\s*\(max-width:\s*30em\)\s*\{[\s\S]*?\.pill-tab-badge\s*\{\s*display:\s*none\s*!important;/); });