fix(panel): drop decimals at >=100s, round segmented context bar, and suppress card title over anomaly tip

This commit is contained in:
fish
2026-11-19 23:29:56 +09:00
parent e93f1bc0ad
commit 88abdaf56e
11 changed files with 325 additions and 85 deletions
+61 -28
View File
@@ -3432,13 +3432,13 @@ const EN_MONTH_SHORT = Object.freeze([
]);
function formatMetric(value, unit = '') {
return Number.isFinite(value) ? `${value.toFixed(1)}${unit}` : '—';
if (!Number.isFinite(value)) return '—';
const numStr = Math.abs(value) >= 100 ? String(Math.round(value)) : value.toFixed(1);
return `${numStr}${unit}`;
}
function formatSpeedMetric(value, unit = ' tok/s') {
if (!Number.isFinite(value)) return '—';
const numStr = value >= 100 ? String(Math.round(value)) : value.toFixed(1);
return `${numStr}${unit}`;
return formatMetric(value, unit);
}
function formatCachePct(value) {
@@ -8118,20 +8118,21 @@ const { ContextSegmentMeter } = (() => {
const SEGMENT_DEFS = [
{ key: 'assistant', cls: 'seg-assistant', getVal: (c) => Number(c.assistantTokens || 0) },
{ key: 'toolResults', cls: 'seg-tool-results', getVal: (c) => Number(c.toolResultsTokens || 0) },
{ key: 'assistant', labelKey: 'ctx.ch.assistant', cls: 'seg-assistant', getVal: (c) => Number(c.assistantTokens || 0) },
{ key: 'toolResults', labelKey: 'ctx.ch.toolResults', cls: 'seg-tool-results', getVal: (c) => Number(c.toolResultsTokens || 0) },
{
key: 'userInput',
labelKey: 'ctx.ch.userInput',
cls: 'seg-user-input',
getVal: (c) => Number(c.userInputTokens ?? c.messagesTokens ?? 0),
},
{ key: 'subagent', cls: 'seg-subagent-msg', getVal: (c) => Number(c.subagentTokens || 0) },
{ key: 'checkpoint', cls: 'seg-checkpoint', getVal: (c) => Number(c.checkpointTokens || 0) },
{ key: 'systemPrompt', cls: 'seg-system-prompt', getVal: (c) => Number(c.systemPromptTokens || 0) },
{ key: 'systemTools', cls: 'seg-system-tools', getVal: (c) => Number(c.systemToolsTokens || 0) },
{ key: 'mcpTools', cls: 'seg-mcp-tools', getVal: (c) => Number(c.mcpToolsTokens || 0) },
{ key: 'skills', cls: 'seg-skills', getVal: (c) => Number(c.skillsTokens || 0) },
{ key: 'userRules', cls: 'seg-user-rules', getVal: (c) => Number(c.userRulesTokens || 0) },
{ key: 'subagent', labelKey: 'ctx.ch.subagent', cls: 'seg-subagent-msg', getVal: (c) => Number(c.subagentTokens || 0) },
{ key: 'checkpoint', labelKey: 'ctx.ch.checkpoint', cls: 'seg-checkpoint', getVal: (c) => Number(c.checkpointTokens || 0) },
{ key: 'systemPrompt', labelKey: 'ctx.ch.systemPrompt', cls: 'seg-system-prompt', getVal: (c) => Number(c.systemPromptTokens || 0) },
{ key: 'systemTools', labelKey: 'ctx.ch.systemTools', cls: 'seg-system-tools', getVal: (c) => Number(c.systemToolsTokens || 0) },
{ key: 'mcpTools', labelKey: 'ctx.ch.mcpTools', cls: 'seg-mcp-tools', getVal: (c) => Number(c.mcpToolsTokens || 0) },
{ key: 'skills', labelKey: 'ctx.ch.skills', cls: 'seg-skills', getVal: (c) => Number(c.skillsTokens || 0) },
{ key: 'userRules', labelKey: 'ctx.ch.userRules', cls: 'seg-user-rules', getVal: (c) => Number(c.userRulesTokens || 0) },
];
const ContextSegmentMeter = defineComponent({
@@ -8145,7 +8146,7 @@ const ContextSegmentMeter = defineComponent({
const trackEl = h(
'div',
{
className: 'progress-track',
className: 'progress-track ctx-segment-meter',
role: 'progressbar',
'aria-valuemin': '0',
'aria-valuemax': '100',
@@ -8177,11 +8178,23 @@ const ContextSegmentMeter = defineComponent({
patchClasses(trackEl, { 'is-reordering': orderChanged });
let seenActive = false;
for (let i = 0; i < slotEls.length; i++) {
const slotEl = slotEls[i];
const item = scored[i];
patchAttr(slotEl, 'class', `progress-seg ${item.def.cls}`);
patchStyleVar(slotEl, '--seg-w', `${item.pct.toFixed(2)}%`);
const isActive = item.val > 0 && item.pct > 0;
const hasSep = isActive && seenActive;
if (isActive) seenActive = true;
const cls = `progress-seg ${item.def.cls}${isActive ? ' is-active' : ''}${hasSep ? ' has-sep' : ''}`;
patchAttr(slotEl, 'class', cls);
patchStyleVar(slotEl, '--seg-w', isActive ? `${item.pct.toFixed(2)}%` : '0%');
patchAttr(
slotEl,
'title',
isActive
? `${t(item.def.labelKey)} · ${formatTokens(item.val)} (${item.pct.toFixed(1)}%)`
: null
);
}
patchAttr(trackEl, 'aria-valuenow', Math.round(ctx.compactionUsedPct ?? ctx.usedPct ?? 0));
@@ -9990,7 +10003,7 @@ function formatChartMetricValue(metric, val) {
case 'tps':
return formatSpeedMetric(val, ' tok/s');
case 'ttft':
return `${val.toFixed(1)}s`;
return formatMetric(val, 's');
case 'cache':
return `${val.toFixed(1)}%`;
case 'cost':
@@ -10009,7 +10022,7 @@ function formatChartMetricCompact(metric, val) {
case 'tps':
return formatSpeedMetric(val, ' tok/s');
case 'ttft':
return `${val.toFixed(1)}s`;
return formatMetric(val, 's');
case 'cache':
return `${val.toFixed(1)}%`;
case 'cost':
@@ -10478,7 +10491,7 @@ function createSessionLineChart() {
valid = !st.isCompactionStep && Number.isFinite(st.tokPerSec) && st.tokPerSec > 0;
value = valid ? Number(st.tokPerSec) : 0;
secondaryRight = Number.isFinite(st.ttftSec)
? t('chart.step.ttftShort', { sec: st.ttftSec.toFixed(1) })
? t('chart.step.ttftShort', { sec: formatMetric(st.ttftSec, '') })
: '';
subDetail = valid
? t('chart.step.outAndCtx', {
@@ -23859,6 +23872,7 @@ const StepsDetailView = defineComponent({
const callsPillEl = h('span', { className: 'smodel-calls-pill text-mono' });
const anomalyTagEl = h('span', {
className: 'step-anomaly-tag smodel-anomaly-tag text-mono',
title: '',
hidden: true,
});
const tokEl = h('span', { className: 'smodel-tok text-mono' });
@@ -23880,7 +23894,18 @@ const StepsDetailView = defineComponent({
return {
el: cardEl,
refs: { nameEl, callsPillEl, anomalyTagEl, tokEl, costEl, segBar, perfEl, splitEl },
refs: {
nameEl,
callsPillEl,
anomalyTagEl,
tokEl,
costEl,
segBar,
perfEl,
splitEl,
cardTitle: '',
isHoveringAnomaly: false,
},
};
},
updateRow: (refs, m, _idx, cardEl) => {
@@ -23911,11 +23936,21 @@ const StepsDetailView = defineComponent({
if (anomSum) {
patchText(refs.anomalyTagEl, anomSum.tagText);
patchClasses(refs.anomalyTagEl, { 'is-danger': anomSum.severity === 'danger' });
refs.anomalyTagEl.onmouseenter = () =>
patchAttr(refs.anomalyTagEl, 'title', '');
refs.anomalyTagEl.onmouseenter = () => {
refs.isHoveringAnomaly = true;
patchAttr(cardEl, 'title', null);
showAnomalyTip(refs.anomalyTagEl, buildModelAnomalyDiagnostic(effM));
refs.anomalyTagEl.onmouseleave = hideAnomalyTip;
};
refs.anomalyTagEl.onmouseleave = () => {
refs.isHoveringAnomaly = false;
patchAttr(cardEl, 'title', refs.cardTitle || null);
hideAnomalyTip();
};
refs.anomalyTagEl.onclick = (e) => {
e?.stopPropagation?.();
refs.isHoveringAnomaly = false;
patchAttr(cardEl, 'title', refs.cardTitle || null);
hideAnomalyTip();
selectedTableModels = hasMultipleModels ? [...cardGroupKeys] : ['__all__'];
onlyAnomalies = true;
@@ -23923,6 +23958,7 @@ const StepsDetailView = defineComponent({
uiStore.setState({ stepsSubTab: 'steps' });
};
} else {
refs.isHoveringAnomaly = false;
refs.anomalyTagEl.onmouseenter = null;
refs.anomalyTagEl.onmouseleave = null;
refs.anomalyTagEl.onclick = null;
@@ -23989,15 +24025,12 @@ const StepsDetailView = defineComponent({
const isActiveFit =
hasMultipleModels && cardGroupKeys.some((k) => fitActiveKeySet.has(k));
patchClasses(cardEl, { 'is-fit-active': isActiveFit });
patchAttr(
cardEl,
'title',
!hasMultipleModels
refs.cardTitle = !hasMultipleModels
? dispTitle
: isActiveFit
? t('steps.fitActiveCardTitle', { title: dispTitle })
: t('steps.fitInactiveCardTitle', { text: dispText })
);
: t('steps.fitInactiveCardTitle', { text: dispText });
patchAttr(cardEl, 'title', refs.isHoveringAnomaly ? null : refs.cardTitle);
cardEl.onclick = (e) => {
if (!hasMultipleModels) return;
if (e && (e.ctrlKey || e.metaKey || e.shiftKey) && !isFitPooledAll) {
+2 -2
View File
@@ -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=1795097331072">
<link rel="stylesheet" href="/styles.css?v=1795098443766">
<script src="/preload.js"></script>
</head>
<body>
<div id="app-root"></div>
<script src="/app.js?v=1795097331072"></script>
<script src="/app.js?v=1795098443766"></script>
</body>
</html>
@@ -11,6 +11,7 @@
import { h, patchAttr, patchClasses, patchStyleVar, patchText } from '../../core/domPatch.js';
import {
formatAgentBadgeText,
formatMetric,
formatSpeedMetric,
formatStepAnomalyInlineSummary,
formatTokens,
@@ -645,7 +646,7 @@ function formatChartMetricValue(metric, val) {
case 'tps':
return formatSpeedMetric(val, ' tok/s');
case 'ttft':
return `${val.toFixed(1)}s`;
return formatMetric(val, 's');
case 'cache':
return `${val.toFixed(1)}%`;
case 'cost':
@@ -664,7 +665,7 @@ function formatChartMetricCompact(metric, val) {
case 'tps':
return formatSpeedMetric(val, ' tok/s');
case 'ttft':
return `${val.toFixed(1)}s`;
return formatMetric(val, 's');
case 'cache':
return `${val.toFixed(1)}%`;
case 'cost':
@@ -1133,7 +1134,7 @@ export function createSessionLineChart() {
valid = !st.isCompactionStep && Number.isFinite(st.tokPerSec) && st.tokPerSec > 0;
value = valid ? Number(st.tokPerSec) : 0;
secondaryRight = Number.isFinite(st.ttftSec)
? t('chart.step.ttftShort', { sec: st.ttftSec.toFixed(1) })
? t('chart.step.ttftShort', { sec: formatMetric(st.ttftSec, '') })
: '';
subDetail = valid
? t('chart.step.outAndCtx', {
@@ -6,22 +6,25 @@
import { defineComponent } from '../../core/component.js';
import { h, patchAttr, patchClasses, patchStyleVar } from '../../core/domPatch.js';
import { formatTokens } from '../../core/formatters.js';
import { t } from '../../i18n/index.js';
const SEGMENT_DEFS = [
{ key: 'assistant', cls: 'seg-assistant', getVal: (c) => Number(c.assistantTokens || 0) },
{ key: 'toolResults', cls: 'seg-tool-results', getVal: (c) => Number(c.toolResultsTokens || 0) },
{ key: 'assistant', labelKey: 'ctx.ch.assistant', cls: 'seg-assistant', getVal: (c) => Number(c.assistantTokens || 0) },
{ key: 'toolResults', labelKey: 'ctx.ch.toolResults', cls: 'seg-tool-results', getVal: (c) => Number(c.toolResultsTokens || 0) },
{
key: 'userInput',
labelKey: 'ctx.ch.userInput',
cls: 'seg-user-input',
getVal: (c) => Number(c.userInputTokens ?? c.messagesTokens ?? 0),
},
{ key: 'subagent', cls: 'seg-subagent-msg', getVal: (c) => Number(c.subagentTokens || 0) },
{ key: 'checkpoint', cls: 'seg-checkpoint', getVal: (c) => Number(c.checkpointTokens || 0) },
{ key: 'systemPrompt', cls: 'seg-system-prompt', getVal: (c) => Number(c.systemPromptTokens || 0) },
{ key: 'systemTools', cls: 'seg-system-tools', getVal: (c) => Number(c.systemToolsTokens || 0) },
{ key: 'mcpTools', cls: 'seg-mcp-tools', getVal: (c) => Number(c.mcpToolsTokens || 0) },
{ key: 'skills', cls: 'seg-skills', getVal: (c) => Number(c.skillsTokens || 0) },
{ key: 'userRules', cls: 'seg-user-rules', getVal: (c) => Number(c.userRulesTokens || 0) },
{ key: 'subagent', labelKey: 'ctx.ch.subagent', cls: 'seg-subagent-msg', getVal: (c) => Number(c.subagentTokens || 0) },
{ key: 'checkpoint', labelKey: 'ctx.ch.checkpoint', cls: 'seg-checkpoint', getVal: (c) => Number(c.checkpointTokens || 0) },
{ key: 'systemPrompt', labelKey: 'ctx.ch.systemPrompt', cls: 'seg-system-prompt', getVal: (c) => Number(c.systemPromptTokens || 0) },
{ key: 'systemTools', labelKey: 'ctx.ch.systemTools', cls: 'seg-system-tools', getVal: (c) => Number(c.systemToolsTokens || 0) },
{ key: 'mcpTools', labelKey: 'ctx.ch.mcpTools', cls: 'seg-mcp-tools', getVal: (c) => Number(c.mcpToolsTokens || 0) },
{ key: 'skills', labelKey: 'ctx.ch.skills', cls: 'seg-skills', getVal: (c) => Number(c.skillsTokens || 0) },
{ key: 'userRules', labelKey: 'ctx.ch.userRules', cls: 'seg-user-rules', getVal: (c) => Number(c.userRulesTokens || 0) },
];
export const ContextSegmentMeter = defineComponent({
@@ -35,7 +38,7 @@ export const ContextSegmentMeter = defineComponent({
const trackEl = h(
'div',
{
className: 'progress-track',
className: 'progress-track ctx-segment-meter',
role: 'progressbar',
'aria-valuemin': '0',
'aria-valuemax': '100',
@@ -67,11 +70,23 @@ export const ContextSegmentMeter = defineComponent({
patchClasses(trackEl, { 'is-reordering': orderChanged });
let seenActive = false;
for (let i = 0; i < slotEls.length; i++) {
const slotEl = slotEls[i];
const item = scored[i];
patchAttr(slotEl, 'class', `progress-seg ${item.def.cls}`);
patchStyleVar(slotEl, '--seg-w', `${item.pct.toFixed(2)}%`);
const isActive = item.val > 0 && item.pct > 0;
const hasSep = isActive && seenActive;
if (isActive) seenActive = true;
const cls = `progress-seg ${item.def.cls}${isActive ? ' is-active' : ''}${hasSep ? ' has-sep' : ''}`;
patchAttr(slotEl, 'class', cls);
patchStyleVar(slotEl, '--seg-w', isActive ? `${item.pct.toFixed(2)}%` : '0%');
patchAttr(
slotEl,
'title',
isActive
? `${t(item.def.labelKey)} · ${formatTokens(item.val)} (${item.pct.toFixed(1)}%)`
: null
);
}
patchAttr(trackEl, 'aria-valuenow', Math.round(ctx.compactionUsedPct ?? ctx.usedPct ?? 0));
+4 -4
View File
@@ -22,13 +22,13 @@ const EN_MONTH_SHORT = Object.freeze([
]);
export function formatMetric(value, unit = '') {
return Number.isFinite(value) ? `${value.toFixed(1)}${unit}` : '—';
if (!Number.isFinite(value)) return '—';
const numStr = Math.abs(value) >= 100 ? String(Math.round(value)) : value.toFixed(1);
return `${numStr}${unit}`;
}
export function formatSpeedMetric(value, unit = ' tok/s') {
if (!Number.isFinite(value)) return '—';
const numStr = value >= 100 ? String(Math.round(value)) : value.toFixed(1);
return `${numStr}${unit}`;
return formatMetric(value, unit);
}
export function formatCachePct(value) {
+6
View File
@@ -411,6 +411,12 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
background: var(--modern-progress-track);
}
[data-modern-ui="true"] .progress-track.ctx-segment-meter {
height: 6px;
border-radius: 3px;
background: var(--modern-progress-track);
}
/* --- 4. 用量统计矩阵、热力格与详情卡去边框且不叠内层背景 --- */
[data-modern-ui="true"] .cons-box,
[data-modern-ui="true"] .cons-custom-range-bar {
+25 -10
View File
@@ -89,16 +89,16 @@
--metric-danger-soft: color-mix(in srgb, var(--metric-danger) 14%, transparent);
/* Context Window 10-Channel Palette */
--ctx-assistant: hsl(217 82% 54%);
--ctx-tool-results: hsl(192 82% 43%);
--ctx-user-input: hsl(245 72% 62%);
--ctx-subagent-msg: hsl(280 70% 58%);
--ctx-checkpoint: hsl(38 90% 50%);
--ctx-system-tools: hsl(22 86% 50%);
--ctx-mcp-tools: hsl(316 72% 54%);
--ctx-skills: hsl(145 64% 38%);
--ctx-system-prompt: hsl(168 72% 40%);
--ctx-user-rules: hsl(346 78% 54%);
--ctx-assistant: hsl(215 62% 52%);
--ctx-tool-results: hsl(172 68% 40%);
--ctx-user-input: hsl(256 76% 62%);
--ctx-subagent-msg: hsl(286 64% 58%);
--ctx-checkpoint: hsl(42 90% 49%);
--ctx-system-tools: hsl(24 86% 52%);
--ctx-mcp-tools: hsl(336 78% 58%);
--ctx-skills: hsl(150 60% 41%);
--ctx-system-prompt: hsl(214 26% 54%);
--ctx-user-rules: hsl(352 78% 56%);
/* Legacy 4-Channel Palette (retained for compatibility) */
--ctx-cached: hsl(217 82% 51%);
@@ -123,6 +123,21 @@
--space-5: 12px;
}
:root[data-color-scheme="dark"],
:host([data-color-scheme="dark"]),
[data-color-scheme="dark"] {
--ctx-assistant: hsl(216 30% 58%);
--ctx-tool-results: hsl(168 72% 54%);
--ctx-user-input: hsl(258 86% 73%);
--ctx-subagent-msg: hsl(288 72% 70%);
--ctx-checkpoint: hsl(43 94% 58%);
--ctx-system-tools: hsl(24 90% 62%);
--ctx-mcp-tools: hsl(338 82% 69%);
--ctx-skills: hsl(150 64% 55%);
--ctx-system-prompt: hsl(214 28% 68%);
--ctx-user-rules: hsl(354 82% 66%);
}
:root[data-font-scale="sm"],
:host([data-font-scale="sm"]),
[data-font-scale="sm"] {
@@ -458,6 +458,48 @@
width var(--dur-normal) var(--ease-fast) 0.05s;
}
/* 块状微圆角风格上下文进度条(保持 6px 紧凑高度 + 色块间 2px 轻间隙 + 每段 2px 边缘圆润处理) */
.progress-track.ctx-segment-meter {
height: 6px;
border-radius: 3px;
align-items: stretch;
}
.progress-track.ctx-segment-meter .progress-seg {
flex: 0 1 auto;
box-sizing: border-box;
width: 0%;
min-width: 0;
margin-left: 0;
border-radius: 2px;
transition:
background-color 0.08s ease,
width var(--dur-normal) var(--ease-fast),
margin-left var(--dur-fast) var(--ease-fast),
filter 120ms ease;
}
.progress-track.ctx-segment-meter.is-reordering .progress-seg {
transition:
background-color 0.05s ease,
width var(--dur-normal) var(--ease-fast) 0.05s,
margin-left var(--dur-fast) var(--ease-fast),
filter 120ms ease;
}
.progress-track.ctx-segment-meter .progress-seg.is-active {
width: var(--seg-w, 0%);
min-width: 3px;
}
.progress-track.ctx-segment-meter .progress-seg.is-active.has-sep {
margin-left: 2px;
}
.progress-track.ctx-segment-meter .progress-seg.is-active:hover {
filter: brightness(1.12);
}
.progress-seg.seg-assistant {
background-color: var(--ctx-assistant);
}
+29 -9
View File
@@ -1144,6 +1144,7 @@ export const StepsDetailView = defineComponent({
const callsPillEl = h('span', { className: 'smodel-calls-pill text-mono' });
const anomalyTagEl = h('span', {
className: 'step-anomaly-tag smodel-anomaly-tag text-mono',
title: '',
hidden: true,
});
const tokEl = h('span', { className: 'smodel-tok text-mono' });
@@ -1165,7 +1166,18 @@ export const StepsDetailView = defineComponent({
return {
el: cardEl,
refs: { nameEl, callsPillEl, anomalyTagEl, tokEl, costEl, segBar, perfEl, splitEl },
refs: {
nameEl,
callsPillEl,
anomalyTagEl,
tokEl,
costEl,
segBar,
perfEl,
splitEl,
cardTitle: '',
isHoveringAnomaly: false,
},
};
},
updateRow: (refs, m, _idx, cardEl) => {
@@ -1196,11 +1208,21 @@ export const StepsDetailView = defineComponent({
if (anomSum) {
patchText(refs.anomalyTagEl, anomSum.tagText);
patchClasses(refs.anomalyTagEl, { 'is-danger': anomSum.severity === 'danger' });
refs.anomalyTagEl.onmouseenter = () =>
patchAttr(refs.anomalyTagEl, 'title', '');
refs.anomalyTagEl.onmouseenter = () => {
refs.isHoveringAnomaly = true;
patchAttr(cardEl, 'title', null);
showAnomalyTip(refs.anomalyTagEl, buildModelAnomalyDiagnostic(effM));
refs.anomalyTagEl.onmouseleave = hideAnomalyTip;
};
refs.anomalyTagEl.onmouseleave = () => {
refs.isHoveringAnomaly = false;
patchAttr(cardEl, 'title', refs.cardTitle || null);
hideAnomalyTip();
};
refs.anomalyTagEl.onclick = (e) => {
e?.stopPropagation?.();
refs.isHoveringAnomaly = false;
patchAttr(cardEl, 'title', refs.cardTitle || null);
hideAnomalyTip();
selectedTableModels = hasMultipleModels ? [...cardGroupKeys] : ['__all__'];
onlyAnomalies = true;
@@ -1208,6 +1230,7 @@ export const StepsDetailView = defineComponent({
uiStore.setState({ stepsSubTab: 'steps' });
};
} else {
refs.isHoveringAnomaly = false;
refs.anomalyTagEl.onmouseenter = null;
refs.anomalyTagEl.onmouseleave = null;
refs.anomalyTagEl.onclick = null;
@@ -1274,15 +1297,12 @@ export const StepsDetailView = defineComponent({
const isActiveFit =
hasMultipleModels && cardGroupKeys.some((k) => fitActiveKeySet.has(k));
patchClasses(cardEl, { 'is-fit-active': isActiveFit });
patchAttr(
cardEl,
'title',
!hasMultipleModels
refs.cardTitle = !hasMultipleModels
? dispTitle
: isActiveFit
? t('steps.fitActiveCardTitle', { title: dispTitle })
: t('steps.fitInactiveCardTitle', { text: dispText })
);
: t('steps.fitInactiveCardTitle', { text: dispText });
patchAttr(cardEl, 'title', refs.isHoveringAnomaly ? null : refs.cardTitle);
cardEl.onclick = (e) => {
if (!hasMultipleModels) return;
if (e && (e.ctrlKey || e.metaKey || e.shiftKey) && !isFitPooledAll) {
+73 -10
View File
@@ -90,16 +90,16 @@
--metric-danger-soft: color-mix(in srgb, var(--metric-danger) 14%, transparent);
/* Context Window 10-Channel Palette */
--ctx-assistant: hsl(217 82% 54%);
--ctx-tool-results: hsl(192 82% 43%);
--ctx-user-input: hsl(245 72% 62%);
--ctx-subagent-msg: hsl(280 70% 58%);
--ctx-checkpoint: hsl(38 90% 50%);
--ctx-system-tools: hsl(22 86% 50%);
--ctx-mcp-tools: hsl(316 72% 54%);
--ctx-skills: hsl(145 64% 38%);
--ctx-system-prompt: hsl(168 72% 40%);
--ctx-user-rules: hsl(346 78% 54%);
--ctx-assistant: hsl(215 62% 52%);
--ctx-tool-results: hsl(172 68% 40%);
--ctx-user-input: hsl(256 76% 62%);
--ctx-subagent-msg: hsl(286 64% 58%);
--ctx-checkpoint: hsl(42 90% 49%);
--ctx-system-tools: hsl(24 86% 52%);
--ctx-mcp-tools: hsl(336 78% 58%);
--ctx-skills: hsl(150 60% 41%);
--ctx-system-prompt: hsl(214 26% 54%);
--ctx-user-rules: hsl(352 78% 56%);
/* Legacy 4-Channel Palette (retained for compatibility) */
--ctx-cached: hsl(217 82% 51%);
@@ -124,6 +124,21 @@
--space-5: 12px;
}
:root[data-color-scheme="dark"],
:host([data-color-scheme="dark"]),
[data-color-scheme="dark"] {
--ctx-assistant: hsl(216 30% 58%);
--ctx-tool-results: hsl(168 72% 54%);
--ctx-user-input: hsl(258 86% 73%);
--ctx-subagent-msg: hsl(288 72% 70%);
--ctx-checkpoint: hsl(43 94% 58%);
--ctx-system-tools: hsl(24 90% 62%);
--ctx-mcp-tools: hsl(338 82% 69%);
--ctx-skills: hsl(150 64% 55%);
--ctx-system-prompt: hsl(214 28% 68%);
--ctx-user-rules: hsl(354 82% 66%);
}
:root[data-font-scale="sm"],
:host([data-font-scale="sm"]),
[data-font-scale="sm"] {
@@ -1768,6 +1783,48 @@ html[data-standalone="true"] .app-shell {
width var(--dur-normal) var(--ease-fast) 0.05s;
}
/* 块状微圆角风格上下文进度条(保持 6px 紧凑高度 + 色块间 2px 轻间隙 + 每段 2px 边缘圆润处理) */
.progress-track.ctx-segment-meter {
height: 6px;
border-radius: 3px;
align-items: stretch;
}
.progress-track.ctx-segment-meter .progress-seg {
flex: 0 1 auto;
box-sizing: border-box;
width: 0%;
min-width: 0;
margin-left: 0;
border-radius: 2px;
transition:
background-color 0.08s ease,
width var(--dur-normal) var(--ease-fast),
margin-left var(--dur-fast) var(--ease-fast),
filter 120ms ease;
}
.progress-track.ctx-segment-meter.is-reordering .progress-seg {
transition:
background-color 0.05s ease,
width var(--dur-normal) var(--ease-fast) 0.05s,
margin-left var(--dur-fast) var(--ease-fast),
filter 120ms ease;
}
.progress-track.ctx-segment-meter .progress-seg.is-active {
width: var(--seg-w, 0%);
min-width: 3px;
}
.progress-track.ctx-segment-meter .progress-seg.is-active.has-sep {
margin-left: 2px;
}
.progress-track.ctx-segment-meter .progress-seg.is-active:hover {
filter: brightness(1.12);
}
.progress-seg.seg-assistant {
background-color: var(--ctx-assistant);
}
@@ -6254,6 +6311,12 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
background: var(--modern-progress-track);
}
[data-modern-ui="true"] .progress-track.ctx-segment-meter {
height: 6px;
border-radius: 3px;
background: var(--modern-progress-track);
}
/* --- 4. 用量统计矩阵、热力格与详情卡去边框且不叠内层背景 --- */
[data-modern-ui="true"] .cons-box,
[data-modern-ui="true"] .cons-custom-range-bar {
+46 -1
View File
@@ -12,8 +12,10 @@ import {
buildModelAnomalyDiagnostic,
buildStepAnomalyDiagnostic,
formatAnomalyTagText,
formatMetric,
formatSpeedMetric,
} from '../src/core/formatters.js';
import { ContextSegmentMeter } from '../src/components/ui/ContextSegmentMeter.js';
import { STEP_COLUMN_REGISTRY } from '../src/registries/stepColumnRegistry.js';
import { StepTableWidget } from '../src/components/widgets/StepTableWidget.js';
import {
@@ -400,6 +402,43 @@ test('formatSpeedMetric drops decimals at >= 100 tok/s and STEP_COLUMN_REGISTRY.
);
assert.equal(fastCell.refs.speedMain.textContent, '—');
assert.equal(fastCell.refs.speedReason.textContent, '调用报错');
// Seconds >= 100s also drop decimals in ttft & duration columns
assert.equal(formatMetric(100, 's'), '100s');
assert.equal(formatMetric(142.6, 's'), '143s');
assert.equal(formatMetric(99.9, 's'), '99.9s');
const ttftCell = STEP_COLUMN_REGISTRY.ttft.createCell();
STEP_COLUMN_REGISTRY.ttft.updateCell(ttftCell.refs, { ttftSec: 124.7 });
assert.equal(ttftCell.refs.valEl.textContent, '125s');
STEP_COLUMN_REGISTRY.ttft.updateCell(ttftCell.refs, { ttftSec: 14.2 });
assert.equal(ttftCell.refs.valEl.textContent, '14.2s');
const durCell = STEP_COLUMN_REGISTRY.duration.createCell();
STEP_COLUMN_REGISTRY.duration.updateCell(durCell.refs, { totalDurationSec: 108.4 });
assert.equal(durCell.refs.valEl.textContent, '108s');
STEP_COLUMN_REGISTRY.duration.updateCell(durCell.refs, { totalDurationSec: 42.3 });
assert.equal(durCell.refs.valEl.textContent, '42.3s');
// ContextSegmentMeter renders crisp separated blocks (.ctx-segment-meter + .is-active + .has-sep)
const meter = ContextSegmentMeter({
context: {
limitTokens: 200_000,
toolResultsTokens: 60_000,
assistantTokens: 20_000,
skillsTokens: 1_000,
},
});
assert.equal(meter.el.classList.contains('ctx-segment-meter'), true);
const activeSegs = meter.refs.segments.filter((s) => s.classList.contains('is-active'));
assert.equal(activeSegs.length, 3);
assert.equal(activeSegs[0].classList.contains('has-sep'), false, 'First active segment has no left cut gap');
assert.equal(activeSegs[1].classList.contains('has-sep'), true, 'Second active segment has 2px cut gap');
assert.equal(activeSegs[2].classList.contains('has-sep'), true, 'Third active segment has 2px cut gap');
assert.match(activeSegs[0].getAttribute('title') || '', /60\.0k/);
const inactiveSegs = meter.refs.segments.filter((s) => !s.classList.contains('is-active'));
assert.equal(inactiveSegs.length, 7);
assert.equal(inactiveSegs.every((s) => !s.classList.contains('has-sep') && !s.getAttribute('title')), true);
} finally {
env.restore();
}
@@ -667,13 +706,16 @@ test('StepsDetailView total summary cards, session anomaly strip, click-to-filte
assert.equal(flashBadge.hasAttribute('hidden'), true);
assert.match(cards[1].querySelector('.smodel-perf').textContent, /88\.2 tok\/s/);
// Hovering model card anomaly badge opens diagnostic popover with click hint
// Hovering model card anomaly badge opens diagnostic popover with click hint AND suppresses parent card native title tooltip
const modelDiag = buildModelAnomalyDiagnostic(modelBreakdown[0]);
assert.ok(modelDiag && modelDiag.hint);
assert.ok(cards[0].getAttribute('title'), 'Model card has native fit-chart title before hovering anomaly badge');
proBadge.onmouseenter();
assert.equal(cards[0].getAttribute('title'), null, 'Parent model card native title must be suppressed while hovering anomaly badge');
assert.equal(view.refs.anomalyTipEl.hasAttribute('hidden'), false);
assert.match(view.refs.anomalyTipEl.querySelector('.step-anomaly-tip-hint').textContent, /按步查看/);
proBadge.onmouseleave();
assert.ok(cards[0].getAttribute('title'), 'Parent model card native title restores after leaving anomaly badge');
assert.equal(view.refs.anomalyTipEl.hasAttribute('hidden'), true);
// Clicking model card anomaly badge jumps to 'steps', activates anomaly filterbar, and filters to only anomaly step #10
@@ -779,4 +821,7 @@ test('Compiled styles.css centers odometer capsule slot text and ships both clas
assert.match(builtCss, /\.sstep-anomaly-dot/);
assert.match(builtCss, /\.trend-tip-anomaly/);
assert.match(builtCss, /\[data-modern-ui="true"\]\s*\.step-anomaly-tip/);
assert.match(builtCss, /\.progress-track\.ctx-segment-meter\s*\{[\s\S]*?height:\s*6px;/);
assert.match(builtCss, /\.progress-track\.ctx-segment-meter\s+\.progress-seg\s*\{[\s\S]*?border-radius:\s*2px;/);
assert.match(builtCss, /\.progress-track\.ctx-segment-meter\s+\.progress-seg\.is-active\.has-sep\s*\{[\s\S]*?margin-left:\s*2px;/);
});