diff --git a/sidecars/panel/app.js b/sidecars/panel/app.js index 87c4279..a512d4d 100644 --- a/sidecars/panel/app.js +++ b/sidecars/panel/app.js @@ -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 - ? dispTitle - : isActiveFit - ? t('steps.fitActiveCardTitle', { title: dispTitle }) - : t('steps.fitInactiveCardTitle', { text: dispText }) - ); + refs.cardTitle = !hasMultipleModels + ? dispTitle + : isActiveFit + ? t('steps.fitActiveCardTitle', { title: dispTitle }) + : 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) { diff --git a/sidecars/panel/index.html b/sidecars/panel/index.html index 265e406..416579f 100644 --- a/sidecars/panel/index.html +++ b/sidecars/panel/index.html @@ -4,11 +4,11 @@