feat(panel): polish compaction row popover, pill selects, steps header, scrollbar, and chart tooltips

# Conflicts:
#	sidecars/panel/index.html
This commit is contained in:
fish
2026-11-20 16:35:18 +09:00
parent e1c3134e72
commit 481f383763
23 changed files with 1062 additions and 321 deletions
@@ -782,11 +782,23 @@ export function createSessionLineChart() {
const tipHeadRight = h('span', { className: 'trend-tip-calls text-mono' });
const tipMainLeft = h('strong', { className: 'trend-tip-tokens text-mono' });
const tipMainRight = h('span', { className: 'trend-tip-cost text-mono' });
const tipInLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legInput') });
const tipInValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipCacheLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legCache') });
const tipCacheValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipOutLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legOutput') });
const tipOutValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipIoGrid = h('div', { className: 'trend-tip-sub is-grid', hidden: true }, [
h('div', { className: 'trend-tip-stat' }, [tipInLabelEl, tipInValEl]),
h('div', { className: 'trend-tip-stat' }, [tipCacheLabelEl, tipCacheValEl]),
h('div', { className: 'trend-tip-stat' }, [tipOutLabelEl, tipOutValEl]),
]);
const tipSub = h('div', { className: 'trend-tip-sub text-mono', hidden: true });
const tipAnomaly = h('div', { className: 'trend-tip-anomaly text-mono', hidden: true });
const tooltipEl = h('div', { className: 'trend-tooltip', hidden: true }, [
h('div', { className: 'trend-tip-head' }, [tipHeadLeft, tipHeadRight]),
h('div', { className: 'trend-tip-main' }, [tipMainLeft, tipMainRight]),
tipIoGrid,
tipSub,
tipAnomaly,
]);
@@ -863,8 +875,18 @@ export function createSessionLineChart() {
pt.valid ? formatChartMetricValue(currentMetric, pt.value) : t('chart.step.excluded')
);
patchText(tipMainRight, pt.secondaryRight || '');
patchAttr(tipSub, 'hidden', !pt.subDetail);
if (pt.subDetail) {
const hasIoParts = Boolean(pt.ioParts);
patchAttr(tipIoGrid, 'hidden', !hasIoParts);
if (hasIoParts) {
patchText(tipInLabelEl, t('cons.legInput'));
patchText(tipCacheLabelEl, t('cons.legCache'));
patchText(tipOutLabelEl, t('cons.legOutput'));
patchText(tipInValEl, pt.ioParts.inTok);
patchText(tipCacheValEl, pt.ioParts.cacheTok);
patchText(tipOutValEl, pt.ioParts.outTok);
}
patchAttr(tipSub, 'hidden', hasIoParts || !pt.subDetail);
if (!hasIoParts && pt.subDetail) {
patchText(tipSub, pt.subDetail);
}
patchAttr(tipAnomaly, 'hidden', !pt.anomalySummary);
@@ -1107,15 +1129,17 @@ export function createSessionLineChart() {
let value = 0;
let secondaryRight = '';
let subDetail = '';
let ioParts = null;
if (metric === 'totalTokens') {
value = isMultiCompare ? modelCumTok : runningTokens;
secondaryRight = t('chart.step.stepAdd', { tokens: formatTokens(stepTotalTok) });
subDetail = t('chart.step.ioSplit', {
ioParts = {
inTok: formatTokens(inTok),
cacheTok: formatTokens(cacheTok),
outTok: formatTokens(outTok),
});
};
subDetail = t('chart.step.ioSplit', ioParts);
} else if (metric === 'context') {
value = ctxTok;
if (hasPrevCtx) {
@@ -1198,6 +1222,7 @@ export function createSessionLineChart() {
value,
secondaryRight,
subDetail,
ioParts,
anomalySummary,
anomalySeverity: st.anomaly?.severity || '',
};
@@ -324,7 +324,17 @@ export function createTrendAreaChart() {
const tipCallsEl = h('span', { className: 'trend-tip-calls text-mono' });
const tipTokensEl = h('strong', { className: 'trend-tip-tokens text-mono' });
const tipCostEl = h('span', { className: 'trend-tip-cost text-mono' });
const tipSubEl = h('div', { className: 'trend-tip-sub text-mono', hidden: true });
const tipInLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legInput') });
const tipInValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipCacheLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legCache') });
const tipCacheValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipOutLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legOutput') });
const tipOutValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipSubEl = h('div', { className: 'trend-tip-sub is-grid', hidden: true }, [
h('div', { className: 'trend-tip-stat' }, [tipInLabelEl, tipInValEl]),
h('div', { className: 'trend-tip-stat' }, [tipCacheLabelEl, tipCacheValEl]),
h('div', { className: 'trend-tip-stat' }, [tipOutLabelEl, tipOutValEl]),
]);
const tipModelsEl = h('div', { className: 'cons-pop-models', hidden: true });
const tooltipEl = h(
@@ -455,14 +465,12 @@ export function createTrendAreaChart() {
slot.outputTokens !== undefined);
patchAttr(tipSubEl, 'hidden', !hasSubBreakdown);
if (hasSubBreakdown) {
patchText(
tipSubEl,
t('chart.step.ioSplit', {
inTok: formatTokensPrecise(safeSlotTokens(slot.inputTokens)),
cacheTok: formatTokensPrecise(safeSlotTokens(slot.cacheReadTokens)),
outTok: formatTokensPrecise(safeSlotTokens(slot.outputTokens)),
})
);
patchText(tipInLabelEl, t('cons.legInput'));
patchText(tipCacheLabelEl, t('cons.legCache'));
patchText(tipOutLabelEl, t('cons.legOutput'));
patchText(tipInValEl, formatTokensPrecise(safeSlotTokens(slot.inputTokens)));
patchText(tipCacheValEl, formatTokensPrecise(safeSlotTokens(slot.cacheReadTokens)));
patchText(tipOutValEl, formatTokensPrecise(safeSlotTokens(slot.outputTokens)));
}
const modelSegs = Array.isArray(slot.modelSegments) ? slot.modelSegments : [];
@@ -56,6 +56,7 @@ export const CustomSelect = defineComponent({
setup({ getProps, setProps, emit, onCleanup }) {
let isOpen = false;
let focusedIndex = -1;
let lastOpenMenuLayoutSig = '';
const initialIcon = getProps().icon;
const leadIcon = createSvgIcon(initialIcon || 'bolt', { size: 13 });
@@ -134,6 +135,15 @@ export const CustomSelect = defineComponent({
}
}
function buildMenuLayoutSig(options = [], labelText = '') {
let sig = `${labelText}|${options.length}`;
for (let i = 0; i < options.length; i++) {
const o = options[i];
sig += `|${o?.value ?? ''}:${o?.label ?? ''}:${o?.meta ?? ''}`;
}
return sig;
}
function toggleOpen(nextOpen) {
isOpen = Boolean(nextOpen);
if (isOpen) {
@@ -144,6 +154,9 @@ export const CustomSelect = defineComponent({
opts.findIndex((o) => selSet.has(o.value))
);
renderMenuOptions();
lastOpenMenuLayoutSig = buildMenuLayoutSig(opts, triggerLabel.textContent || '');
} else {
lastOpenMenuLayoutSig = '';
}
patchClasses(rootEl, { 'is-open': isOpen });
patchAttr(triggerBtn, 'aria-expanded', isOpen ? 'true' : 'false');
@@ -343,7 +356,11 @@ export const CustomSelect = defineComponent({
patchAttr(triggerBtn, 'title', titleText);
if (isOpen) {
renderMenuOptions();
positionMenu();
const nextLayoutSig = buildMenuLayoutSig(options, labelText);
if (nextLayoutSig !== lastOpenMenuLayoutSig) {
lastOpenMenuLayoutSig = nextLayoutSig;
positionMenu();
}
}
}
@@ -15,6 +15,7 @@ import {
} from '../../core/domPatch.js';
import {
buildStepAnomalyDiagnostic,
buildStepCompactionDiagnostic,
resolveModelDisplayInfo,
speedReasonText,
} from '../../core/formatters.js';
@@ -22,6 +23,7 @@ import { getEffectiveLocale, t } from '../../i18n/index.js';
import {
DEFAULT_STEP_COLUMN_KEYS,
STEP_COLUMN_REGISTRY,
isCompactionStepItem,
} from '../../registries/stepColumnRegistry.js';
import {
formatAgentBadgeText,
@@ -329,7 +331,7 @@ function buildColumnSizerSpec(tableSteps, colKeys, wantedSet, cellCtx) {
let bestModelObj = firstStep;
for (const cand of modelCandidates.values()) {
const disp = resolveModelDisplayInfo(cand, cellCtx?.displaySettings, { fallback: '—' });
const len = (disp.baseText?.length || 0) + (disp.compactionSuffix?.length || 0);
const len = disp.baseText?.length || 0;
if (len > bestModelLen) {
bestModelLen = len;
bestModelObj = cand;
@@ -509,7 +511,10 @@ export const StepTableWidget = defineComponent({
return;
}
hideTurnTip();
patchClasses(anomalyTipEl, { 'is-danger': diag.severity === 'danger' });
patchClasses(anomalyTipEl, {
'is-danger': diag.severity === 'danger',
'is-compaction': diag.severity === 'compaction',
});
patchText(anomalyTipTitleEl, diag.title);
patchAttr(anomalyTipSubEl, 'hidden', !diag.sub);
if (diag.sub) patchText(anomalyTipSubEl, diag.sub);
@@ -527,7 +532,10 @@ export const StepTableWidget = defineComponent({
if (row.detail) {
itemChildren.push(
h('div', {
className: 'step-anomaly-tip-detail text-mono',
className:
row.mono === false
? 'step-anomaly-tip-detail'
: 'step-anomaly-tip-detail text-mono',
text: row.detail,
})
);
@@ -679,16 +687,35 @@ export const StepTableWidget = defineComponent({
if (event?.target === badge) hideTurnTip();
}
function buildStepRowDiagnostic(st, displaySettings, hasStepAnomaly, isCompactionRow) {
if (hasStepAnomaly) {
const diag = buildStepAnomalyDiagnostic(st);
if (diag && isCompactionRow) {
return {
...diag,
hint: diag.hint
? `${diag.hint} · ${t('steps.compactionAnomalyHint')}`
: t('steps.compactionAnomalyHint'),
};
}
return diag;
}
if (isCompactionRow) {
return buildStepCompactionDiagnostic(st, displaySettings);
}
return null;
}
function moveAlongTurnRail(event) {
const { badge, prompt, anomalyStep } = hoverRows.get(this);
const { badge, prompt, rowDiagGetter } = hoverRows.get(this);
const rect = this.getBoundingClientRect?.();
const relX = rect ? (event?.clientX ?? 0) - rect.left : 0;
if (event?.target !== badge && relX <= 18) {
showTurnTip(this, prompt);
} else {
hideTurnTip();
if (anomalyStep) {
showAnomalyTip(this, buildStepAnomalyDiagnostic(anomalyStep));
if (rowDiagGetter) {
showAnomalyTip(this, rowDiagGetter());
}
}
}
@@ -696,8 +723,8 @@ export const StepTableWidget = defineComponent({
function leaveStepCell(event) {
const entry = hoverRows.get(this);
hideTurnTip();
if (entry?.anomalyStep && entry.tr && event?.relatedTarget && entry.tr.contains?.(event.relatedTarget)) {
showAnomalyTip(this, buildStepAnomalyDiagnostic(entry.anomalyStep));
if (entry?.rowDiagGetter && entry.tr && event?.relatedTarget && entry.tr.contains?.(event.relatedTarget)) {
showAnomalyTip(this, entry.rowDiagGetter());
}
}
@@ -991,7 +1018,8 @@ export const StepTableWidget = defineComponent({
: '';
const stripeSig = isVirtualized ? (item.isStripeEven ? 'E' : 'O') : 'N';
const anomalySig = st.anomalySig || '';
return `${locale}:${colOrderSig}:${stripeSig}:${badgeSig}:${anomalySig}:${railActive}:${item.hasTurn}:${item.hasUp}:${item.hasDown}:${item.isStart}:${item.isLatest}:${item.prompt}:${parts}`;
const compactSig = isCompactionStepItem(st) ? 'C' : '';
return `${locale}:${colOrderSig}:${stripeSig}:${badgeSig}:${anomalySig}:${compactSig}:${railActive}:${item.hasTurn}:${item.hasUp}:${item.hasDown}:${item.isStart}:${item.isLatest}:${item.prompt}:${parts}`;
},
createRow: (item) => {
if (item.isSizer) {
@@ -1236,14 +1264,20 @@ export const StepTableWidget = defineComponent({
const hasStepAnomaly = Boolean(st?.anomaly && Number(st.anomaly.count) > 0);
const isAnomalyDanger = Boolean(hasStepAnomaly && st.anomaly.severity === 'danger');
const isAnomalyWarn = Boolean(hasStepAnomaly && !isAnomalyDanger);
const isCompactionRow = isCompactionStepItem(st);
const hasRowTip = hasStepAnomaly || isCompactionRow;
const rowDiagGetter = hasRowTip
? () => buildStepRowDiagnostic(st, cellCtx.displaySettings, hasStepAnomaly, isCompactionRow)
: null;
patchClasses(tr, {
'is-compaction': isCompactionRow,
'is-anomaly-warn': isAnomalyWarn,
'is-anomaly-danger': isAnomalyDanger,
});
if (hasStepAnomaly) {
if (hasRowTip) {
const anchorEl = firstTd || tr;
tr.onmouseenter = () => {
showAnomalyTip(anchorEl, buildStepAnomalyDiagnostic(st));
showAnomalyTip(anchorEl, rowDiagGetter());
};
tr.onmouseleave = hideAnomalyTip;
} else {
@@ -1268,10 +1302,10 @@ export const StepTableWidget = defineComponent({
hoverRows.set(hoverTd, {
badge: refs.agentBadgeEl,
prompt,
anomalyStep: hasStepAnomaly ? st : null,
rowDiagGetter,
tr,
});
const useWholeCellTurnTip = firstColKey === 'step' && !hasStepAnomaly;
const useWholeCellTurnTip = firstColKey === 'step' && !hasRowTip;
hoverTd.onmouseenter = useWholeCellTurnTip ? enterStepCell : null;
hoverTd.onmousemove = useWholeCellTurnTip ? moveInStepCell : moveAlongTurnRail;
hoverTd.onmouseleave = leaveStepCell;
@@ -1299,6 +1333,7 @@ export const StepTableWidget = defineComponent({
patchClasses(tr, {
'is-stripe-even': false,
'is-step-entering': false,
'is-compaction': false,
'is-anomaly-warn': false,
'is-anomaly-danger': false,
});