mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(panel): add live step search, danger-tier diagnostic chips, and click-to-inspect step drawer
This commit is contained in:
+860
-10
File diff suppressed because it is too large
Load Diff
@@ -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=1795315385405">
|
||||
<link rel="stylesheet" href="/styles.css?v=1795315495603">
|
||||
<script src="/preload.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app-root"></div>
|
||||
<script src="/app.js?v=1795315385405"></script>
|
||||
<script src="/app.js?v=1795315495603"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -529,6 +529,7 @@ export function buildBundle(panelDir = PANEL_DIR) {
|
||||
'src/core/domPatch.js',
|
||||
'src/core/component.js',
|
||||
'src/core/formatters.js',
|
||||
'src/core/stepInspector.js',
|
||||
'src/core/settingsBackup.js',
|
||||
'src/core/httpClient.js',
|
||||
'src/store/uiStore.js',
|
||||
|
||||
@@ -394,6 +394,8 @@ export const StepTableWidget = defineComponent({
|
||||
typeof props.onVirtualHeightChange === 'function' ? props.onVirtualHeightChange : null;
|
||||
const onSortChange =
|
||||
typeof props.onSortChange === 'function' ? props.onSortChange : null;
|
||||
const onSelectStep =
|
||||
typeof props.onSelectStep === 'function' ? props.onSelectStep : null;
|
||||
|
||||
const stepsTheadRow = h('tr');
|
||||
const stepsThead = h('thead', {}, [stepsTheadRow]);
|
||||
@@ -1137,7 +1139,8 @@ export const StepTableWidget = defineComponent({
|
||||
const stripeSig = isVirtualized ? (item.isStripeEven ? 'E' : 'O') : 'N';
|
||||
const anomalySig = st.anomalySig || '';
|
||||
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}`;
|
||||
const selSig = ds.selectedStepKey && ds.selectedStepKey === item.rowKey ? 'S' : '';
|
||||
return `${locale}:${colOrderSig}:${stripeSig}:${badgeSig}:${anomalySig}:${compactSig}:${selSig}:${railActive}:${item.hasTurn}:${item.hasUp}:${item.hasDown}:${item.isStart}:${item.isLatest}:${item.prompt}:${parts}`;
|
||||
},
|
||||
createRow: (item) => {
|
||||
if (item.isSizer) {
|
||||
@@ -1364,6 +1367,7 @@ export const StepTableWidget = defineComponent({
|
||||
: t('steps.badgeFilterAgent', { agent: agentName })
|
||||
);
|
||||
refs.agentBadgeEl.onclick = (e) => {
|
||||
e?.stopPropagation?.();
|
||||
if (e && (e.ctrlKey || e.metaKey || e.shiftKey) && effectiveScopes[0] !== 'all') {
|
||||
const next = effectiveScopes.includes(targetScope)
|
||||
? effectiveScopes.filter((id) => id !== targetScope)
|
||||
@@ -1389,11 +1393,21 @@ export const StepTableWidget = defineComponent({
|
||||
const rowDiagGetter = hasRowTip
|
||||
? () => buildStepRowDiagnostic(st, cellCtx.displaySettings, hasStepAnomaly, isCompactionRow)
|
||||
: null;
|
||||
const isSelectedRow = Boolean(ds.selectedStepKey && ds.selectedStepKey === item.rowKey);
|
||||
patchClasses(tr, {
|
||||
'is-compaction': isCompactionRow,
|
||||
'is-anomaly-warn': isAnomalyWarn,
|
||||
'is-anomaly-danger': isAnomalyDanger,
|
||||
'is-selectable': Boolean(onSelectStep),
|
||||
'is-selected': isSelectedRow,
|
||||
});
|
||||
if (onSelectStep) {
|
||||
tr.onclick = () => {
|
||||
onSelectStep(st, item.rowKey);
|
||||
};
|
||||
} else {
|
||||
tr.onclick = null;
|
||||
}
|
||||
if (hasRowTip) {
|
||||
const anchorEl = firstTd || tr;
|
||||
tr.onmouseenter = () => {
|
||||
@@ -1567,6 +1581,7 @@ export const StepTableWidget = defineComponent({
|
||||
allowNewRowFade = false,
|
||||
sortKey = '',
|
||||
sortDir = '',
|
||||
selectedStepKey = '',
|
||||
} = {}
|
||||
) {
|
||||
const normCascadeId = String(cascadeId || '');
|
||||
@@ -1637,7 +1652,7 @@ export const StepTableWidget = defineComponent({
|
||||
cascadeId, locale, colOrderSig, effectiveScopes, hasSubagents, isMergedMultiAgents,
|
||||
effectiveTurnRail, showStepAgentBadge, showStepSpeedColor, normTokenFmt,
|
||||
displaySettings.modelDisplayMode, displaySettings.showUpstreamModel,
|
||||
displaySettings.orchestratorIdMode, normSortKey, normSortDir,
|
||||
displaySettings.orchestratorIdMode, normSortKey, normSortDir, String(selectedStepKey || ''),
|
||||
]);
|
||||
if (
|
||||
lastRenderOptions === renderOptions &&
|
||||
@@ -1736,6 +1751,7 @@ export const StepTableWidget = defineComponent({
|
||||
totalBodyH,
|
||||
sizerSpec,
|
||||
effectiveScopes,
|
||||
selectedStepKey: String(selectedStepKey || ''),
|
||||
formattedPrompts: new Map(),
|
||||
};
|
||||
renderedSliceStart = -1;
|
||||
|
||||
@@ -0,0 +1,336 @@
|
||||
/**
|
||||
* @fileoverview 步骤搜索筛选、快捷诊断统计、耗时瀑布计算及单步诊断 Markdown 导出纯函数模块 (`stepInspector.js`)。
|
||||
* 保持零 DOM 耦合和单遍 O(N) 高性能,供 `StepsDetailView` 及单元测试直接复用。
|
||||
*/
|
||||
|
||||
import { classifyTtftTier } from '../../shared/telemetry-display-rules.mjs';
|
||||
import {
|
||||
formatAnomalyKindLabel,
|
||||
formatCompactDateTime,
|
||||
formatMetric,
|
||||
formatSpeedMetric,
|
||||
formatTimingDetailSec,
|
||||
formatTokensPrecise,
|
||||
formatUsd,
|
||||
resolveModelDisplayInfo,
|
||||
speedReasonText,
|
||||
} from './formatters.js';
|
||||
|
||||
export const STEP_LOW_CACHE_MIN_PROMPT_TOKENS = 2000;
|
||||
export const STEP_LOW_CACHE_MAX_PCT = 50;
|
||||
export const STEP_SLOW_TTFT_MIN_SEC = 30;
|
||||
|
||||
/**
|
||||
* 同 `StepTableWidget` 保持一致的单步稳定选择键。
|
||||
*
|
||||
* @param {object|null|undefined} st
|
||||
* @param {string} [fallbackCascadeId='']
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getStepSelectionKey(st, fallbackCascadeId = '') {
|
||||
if (!st || typeof st !== 'object') return '';
|
||||
const agentKey = st.agentId || st.cascadeId || fallbackCascadeId || 'main';
|
||||
return `${agentKey}-${st.stepIndex}`;
|
||||
}
|
||||
|
||||
export function isLowCacheStep(st) {
|
||||
if (!st || st.isCompactionStep) return false;
|
||||
const promptTok = Number(st.inputTokens || 0) + Number(st.cacheReadTokens || 0);
|
||||
if (promptTok < STEP_LOW_CACHE_MIN_PROMPT_TOKENS) return false;
|
||||
const pct =
|
||||
st.cacheHitPct != null && Number.isFinite(Number(st.cacheHitPct))
|
||||
? Number(st.cacheHitPct)
|
||||
: promptTok > 0
|
||||
? (Number(st.cacheReadTokens || 0) / promptTok) * 100
|
||||
: 0;
|
||||
return pct < STEP_LOW_CACHE_MAX_PCT;
|
||||
}
|
||||
|
||||
export function isSlowTtftStep(st) {
|
||||
if (!st || st.isCompactionStep) return false;
|
||||
return classifyTtftTier(st.ttftSec) === 'danger';
|
||||
}
|
||||
|
||||
/**
|
||||
* 单遍 O(N) 统计当前步骤集中各诊断快捷筛选芯片的命中数量。
|
||||
*
|
||||
* @param {Array<object>} steps
|
||||
* @returns {{ anomaly: number, compaction: number, low_cache: number, slow_ttft: number }}
|
||||
*/
|
||||
export function computeStepQuickChipCounts(steps) {
|
||||
let anomaly = 0;
|
||||
let compaction = 0;
|
||||
let lowCache = 0;
|
||||
let slowTtft = 0;
|
||||
if (Array.isArray(steps)) {
|
||||
for (let i = 0; i < steps.length; i += 1) {
|
||||
const st = steps[i];
|
||||
if (!st) continue;
|
||||
if (st.anomaly && Number(st.anomaly.count) > 0) anomaly += 1;
|
||||
if (st.isCompactionStep) compaction += 1;
|
||||
if (isLowCacheStep(st)) lowCache += 1;
|
||||
if (isSlowTtftStep(st)) slowTtft += 1;
|
||||
}
|
||||
}
|
||||
return {
|
||||
anomaly,
|
||||
compaction,
|
||||
low_cache: lowCache,
|
||||
slow_ttft: slowTtft,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 按快捷诊断芯片、异常类型及多词关键字过滤步骤列表(纯函数 O(N))。
|
||||
*
|
||||
* @param {Array<object>} steps
|
||||
* @param {{ query?: string, quickChip?: string, anomalyKindFilter?: string, displaySettings?: object }} [opts]
|
||||
* @returns {Array<object>}
|
||||
*/
|
||||
export function filterStepsBySearchAndChip(
|
||||
steps,
|
||||
{ query = '', quickChip = '', anomalyKindFilter = '', displaySettings = {} } = {}
|
||||
) {
|
||||
if (!Array.isArray(steps) || steps.length === 0) return [];
|
||||
const rawTerms = String(query || '')
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.split(/\s+/)
|
||||
.filter(Boolean);
|
||||
const chip = String(quickChip || '').trim();
|
||||
const kind = String(anomalyKindFilter || '').trim();
|
||||
|
||||
if (!chip && !kind && rawTerms.length === 0) {
|
||||
return steps;
|
||||
}
|
||||
|
||||
const out = [];
|
||||
for (let i = 0; i < steps.length; i += 1) {
|
||||
const st = steps[i];
|
||||
if (!st) continue;
|
||||
|
||||
if (chip === 'anomaly' || kind) {
|
||||
const a = st.anomaly;
|
||||
if (!a || !(Number(a.count) > 0)) continue;
|
||||
if (kind && !(Number(a.kinds?.[kind] || 0) > 0)) continue;
|
||||
} else if (chip === 'compaction') {
|
||||
if (!st.isCompactionStep) continue;
|
||||
} else if (chip === 'low_cache') {
|
||||
if (!isLowCacheStep(st)) continue;
|
||||
} else if (chip === 'slow_ttft') {
|
||||
if (!isSlowTtftStep(st)) continue;
|
||||
}
|
||||
|
||||
if (rawTerms.length > 0) {
|
||||
const modelInfo = resolveModelDisplayInfo(st, displaySettings);
|
||||
const anomalyKinds = st.anomaly?.kinds ? Object.keys(st.anomaly.kinds).join(' ') : '';
|
||||
const anomalyItemsText = Array.isArray(st.anomaly?.items)
|
||||
? st.anomaly.items
|
||||
.map((it) => `${it?.kind || ''} ${it?.httpStatus || ''} ${it?.detail || ''}`)
|
||||
.join(' ')
|
||||
: '';
|
||||
const haystack = [
|
||||
`#${st.stepIndex ?? ''}`,
|
||||
String(st.stepIndex ?? ''),
|
||||
modelInfo.text,
|
||||
modelInfo.title,
|
||||
st.modelLabel || '',
|
||||
st.modelShort || '',
|
||||
st.rawModelId || '',
|
||||
st.upstreamName || '',
|
||||
st.turnPrompt || '',
|
||||
st.rootTurnPrompt || '',
|
||||
st.agentLabel || '',
|
||||
st.agentRole || '',
|
||||
st.agentBadge || '',
|
||||
st.isCompactionStep ? 'compaction 压缩' : '',
|
||||
anomalyKinds,
|
||||
anomalyItemsText,
|
||||
]
|
||||
.join(' ')
|
||||
.toLowerCase();
|
||||
|
||||
let matchedAll = true;
|
||||
for (let tIdx = 0; tIdx < rawTerms.length; tIdx += 1) {
|
||||
if (!haystack.includes(rawTerms[tIdx])) {
|
||||
matchedAll = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!matchedAll) continue;
|
||||
}
|
||||
|
||||
out.push(st);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在同代理步骤集合中定位目标步骤之前最近一步的上下文 Token 数,用于展示单步上下文增量。
|
||||
*
|
||||
* @param {Array<object>} allSteps
|
||||
* @param {object|null|undefined} targetStep
|
||||
* @returns {number|null}
|
||||
*/
|
||||
export function findPrevAgentContextTokens(allSteps, targetStep) {
|
||||
if (!Array.isArray(allSteps) || !targetStep || targetStep.stepIndex == null) return null;
|
||||
const targetIdx = Number(targetStep.stepIndex);
|
||||
const targetAgent = targetStep.agentId || 'main';
|
||||
if (!Number.isFinite(targetIdx)) return null;
|
||||
|
||||
let bestIdx = -Infinity;
|
||||
let bestCtx = null;
|
||||
for (let i = 0; i < allSteps.length; i += 1) {
|
||||
const st = allSteps[i];
|
||||
if (!st) continue;
|
||||
if ((st.agentId || 'main') !== targetAgent) continue;
|
||||
const idx = Number(st.stepIndex);
|
||||
if (Number.isFinite(idx) && idx < targetIdx && idx > bestIdx) {
|
||||
const ctxVal = Number(
|
||||
st.contextTokens ||
|
||||
Number(st.inputTokens || 0) +
|
||||
Number(st.cacheReadTokens || 0) +
|
||||
Number(st.outputTokens || 0)
|
||||
);
|
||||
if (ctxVal > 0) {
|
||||
bestIdx = idx;
|
||||
bestCtx = ctxVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bestCtx;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算单步耗时瀑布分段比例(TTFT 首字等待 / 流式输出 / 工具及尾部阶段)。
|
||||
*
|
||||
* @param {object|null|undefined} st
|
||||
* @returns {{ totalSec: number, ttftSec: number, streamSec: number, otherSec: number, thinkingSec: number, ttftPct: number, streamPct: number, otherPct: number }|null}
|
||||
*/
|
||||
export function computeStepTimingWaterfall(st) {
|
||||
if (!st || typeof st !== 'object') return null;
|
||||
const ttft =
|
||||
st.ttftSec != null && Number.isFinite(Number(st.ttftSec)) && Number(st.ttftSec) >= 0
|
||||
? Number(st.ttftSec)
|
||||
: 0;
|
||||
const stream =
|
||||
st.streamDurationSec != null &&
|
||||
Number.isFinite(Number(st.streamDurationSec)) &&
|
||||
Number(st.streamDurationSec) >= 0
|
||||
? Number(st.streamDurationSec)
|
||||
: 0;
|
||||
const thinking =
|
||||
st.thinkingDurationSec != null &&
|
||||
Number.isFinite(Number(st.thinkingDurationSec)) &&
|
||||
Number(st.thinkingDurationSec) >= 0
|
||||
? Number(st.thinkingDurationSec)
|
||||
: 0;
|
||||
const rawTotal =
|
||||
st.durationSec != null && Number.isFinite(Number(st.durationSec)) && Number(st.durationSec) > 0
|
||||
? Number(st.durationSec)
|
||||
: ttft + stream;
|
||||
const totalSec = Math.max(rawTotal, ttft + stream);
|
||||
if (!(totalSec > 0)) return null;
|
||||
|
||||
const effStream = Math.min(stream, Math.max(0, totalSec - ttft));
|
||||
const otherSec = Math.max(0, +(totalSec - ttft - effStream).toFixed(3));
|
||||
const ttftPct = +((ttft / totalSec) * 100).toFixed(2);
|
||||
const streamPct = +((effStream / totalSec) * 100).toFixed(2);
|
||||
const otherPct = Math.max(0, +(100 - ttftPct - streamPct).toFixed(2));
|
||||
|
||||
return {
|
||||
totalSec: +totalSec.toFixed(3),
|
||||
ttftSec: +ttft.toFixed(3),
|
||||
streamSec: +effStream.toFixed(3),
|
||||
otherSec,
|
||||
thinkingSec: +thinking.toFixed(3),
|
||||
ttftPct,
|
||||
streamPct,
|
||||
otherPct,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成结构化的单步诊断 Markdown 文本,便于直接复制到工单、讨论或性能复盘中。
|
||||
*
|
||||
* @param {object} st
|
||||
* @param {{ prevContextTokens?: number|null, displaySettings?: object }} [opts]
|
||||
* @returns {string}
|
||||
*/
|
||||
export function buildStepDiagnosticMarkdown(
|
||||
st,
|
||||
{ prevContextTokens = null, displaySettings = {} } = {}
|
||||
) {
|
||||
if (!st || typeof st !== 'object') return '';
|
||||
const modelInfo = resolveModelDisplayInfo(st, displaySettings);
|
||||
const timeStr = st.createdAtMs ? formatCompactDateTime(st.createdAtMs) : '—';
|
||||
const promptTok = Number(st.inputTokens || 0) + Number(st.cacheReadTokens || 0);
|
||||
const cachePct =
|
||||
st.cacheHitPct != null && Number.isFinite(Number(st.cacheHitPct))
|
||||
? `${Number(st.cacheHitPct).toFixed(1)}%`
|
||||
: promptTok > 0
|
||||
? `${((Number(st.cacheReadTokens || 0) / promptTok) * 100).toFixed(1)}%`
|
||||
: '0.0%';
|
||||
const ctxTok = Number(st.contextTokens || promptTok + Number(st.outputTokens || 0));
|
||||
const ctxDelta =
|
||||
prevContextTokens != null && ctxTok > 0
|
||||
? ` (${ctxTok >= prevContextTokens ? '+' : '-'}${formatTokensPrecise(Math.abs(ctxTok - prevContextTokens))})`
|
||||
: '';
|
||||
const wf = computeStepTimingWaterfall(st);
|
||||
const lines = [
|
||||
`### Step #${st.stepIndex ?? '—'} · ${modelInfo.text}${st.isCompactionStep ? ' [Compaction]' : ''}`,
|
||||
`- **Time**: ${timeStr}`,
|
||||
...(modelInfo.title && modelInfo.title !== modelInfo.text
|
||||
? [`- **Model ID**: \`${modelInfo.title}\``]
|
||||
: []),
|
||||
`- **Speed / Timing**: ${formatSpeedMetric(st.tokPerSec, ' tok/s')} | TTFT ${formatMetric(st.ttftSec, 's')} | Total ${wf ? formatTimingDetailSec(wf.totalSec) : '—'}${st.selectedSpeedReason ? ` (${speedReasonText(st.selectedSpeedReason) || st.selectedSpeedReason})` : ''}`,
|
||||
`- **Tokens**: Input ${formatTokensPrecise(st.inputTokens || 0)} | Cache ${formatTokensPrecise(st.cacheReadTokens || 0)} (${cachePct}) | Output ${formatTokensPrecise(st.outputTokens || 0)} (Think ${formatTokensPrecise(st.thinkingTokens || 0)} / Reply ${formatTokensPrecise(st.responseTokens || 0)})`,
|
||||
`- **Context / Cost**: ${formatTokensPrecise(ctxTok)}${ctxDelta} | ${formatUsd(st.costUsd, { precise: true })}`,
|
||||
];
|
||||
if (st.anomaly && Number(st.anomaly.count) > 0) {
|
||||
const kinds = Object.entries(st.anomaly.kinds || {})
|
||||
.map(([k, v]) => `${formatAnomalyKindLabel(k)}×${v}`)
|
||||
.join(', ');
|
||||
lines.push(`- **Anomalies (${st.anomaly.count})**: ${kinds || st.anomaly.primaryKind || 'error'}`);
|
||||
}
|
||||
const promptText = String(st.turnPrompt || st.rootTurnPrompt || '').trim();
|
||||
if (promptText) {
|
||||
lines.push('', '> ' + promptText.replace(/\r?\n/g, '\n> '));
|
||||
}
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* 轻量剪贴板复制工具(优先 Clipboard API,降级至隐藏 textarea execCommand)。
|
||||
*
|
||||
* @param {string} text
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
export async function copyPlainTextToClipboard(text) {
|
||||
const str = String(text ?? '');
|
||||
try {
|
||||
if (typeof navigator !== 'undefined' && navigator.clipboard?.writeText) {
|
||||
await navigator.clipboard.writeText(str);
|
||||
return true;
|
||||
}
|
||||
} catch {
|
||||
// 降级到 DOM 复制
|
||||
}
|
||||
try {
|
||||
if (typeof document !== 'undefined' && document.body && typeof document.execCommand === 'function') {
|
||||
const ta = document.createElement('textarea');
|
||||
ta.value = str;
|
||||
ta.setAttribute('readonly', '');
|
||||
ta.style.position = 'fixed';
|
||||
ta.style.opacity = '0';
|
||||
document.body.appendChild(ta);
|
||||
ta.select?.();
|
||||
const ok = document.execCommand('copy');
|
||||
ta.remove?.();
|
||||
return Boolean(ok);
|
||||
}
|
||||
} catch {
|
||||
// 忽略非浏览器环境异常
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -378,6 +378,30 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
|
||||
'steps.anomalyFilterLabel': 'Anomalies Only ({count})',
|
||||
'steps.anomalyFilterAll': 'Show All Steps',
|
||||
'steps.sortClickTip': 'Click to sort by {col}',
|
||||
'steps.searchPlaceholder': 'Filter #step, model, prompt, or anomaly...',
|
||||
'steps.searchClearAria': 'Clear step filter',
|
||||
'steps.chipAnomaly': 'Anomaly {count}',
|
||||
'steps.chipCompaction': 'Compact {count}',
|
||||
'steps.chipLowCache': 'Low Cache {count}',
|
||||
'steps.chipLowCacheTip': 'Filter steps with cache hit rate below 50%',
|
||||
'steps.chipSlowTtft': 'Slow TTFT {count}',
|
||||
'steps.chipSlowTtftTip': 'Filter severely delayed steps with TTFT >= 30s',
|
||||
'steps.inspPrevAria': 'Previous step',
|
||||
'steps.inspNextAria': 'Next step',
|
||||
'steps.inspCopy': 'Copy',
|
||||
'steps.inspCopied': 'Copied',
|
||||
'steps.inspCloseAria': 'Close step inspector',
|
||||
'steps.inspWaterfallTtft': 'TTFT {sec}',
|
||||
'steps.inspWaterfallStream': 'Stream {sec}',
|
||||
'steps.inspWaterfallOther': 'Tool/Wait {sec}',
|
||||
'steps.inspWaterfallThink': 'Think {sec}',
|
||||
'steps.inspInputLabel': 'Fresh Input',
|
||||
'steps.inspCacheLabel': 'Cache Read',
|
||||
'steps.inspOutputLabel': 'Output',
|
||||
'steps.inspOutputSplit': 'Think {think} / Reply {reply}',
|
||||
'steps.inspContextCostLabel': 'Context / Cost',
|
||||
'steps.inspPromptTitle': 'Turn Prompt',
|
||||
'steps.inspRowClickTip': 'Click row to inspect step details',
|
||||
|
||||
// Step Table Columns (Headers & Option Labels)
|
||||
'stepCol.step.th': 'Step',
|
||||
|
||||
@@ -378,6 +378,30 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
|
||||
'steps.anomalyFilterLabel': '仅看异常 ({count})',
|
||||
'steps.anomalyFilterAll': '返回全部步骤',
|
||||
'steps.sortClickTip': '点击按「{col}」排序',
|
||||
'steps.searchPlaceholder': '搜索 #步号、模型、提问或异常...',
|
||||
'steps.searchClearAria': '清空步骤搜索',
|
||||
'steps.chipAnomaly': '异常 {count}',
|
||||
'steps.chipCompaction': '压缩 {count}',
|
||||
'steps.chipLowCache': '低缓存 {count}',
|
||||
'steps.chipLowCacheTip': '筛选缓存命中率低于 50% 的步骤',
|
||||
'steps.chipSlowTtft': '慢首字 {count}',
|
||||
'steps.chipSlowTtftTip': '筛选首字延迟 >= 30s 的严重卡顿步骤',
|
||||
'steps.inspPrevAria': '查看上一步',
|
||||
'steps.inspNextAria': '查看下一步',
|
||||
'steps.inspCopy': '复制诊断',
|
||||
'steps.inspCopied': '已复制',
|
||||
'steps.inspCloseAria': '关闭单步详情',
|
||||
'steps.inspWaterfallTtft': '首字 {sec}',
|
||||
'steps.inspWaterfallStream': '流式 {sec}',
|
||||
'steps.inspWaterfallOther': '工具/等待 {sec}',
|
||||
'steps.inspWaterfallThink': '思考 {sec}',
|
||||
'steps.inspInputLabel': '新输入',
|
||||
'steps.inspCacheLabel': '缓存读取',
|
||||
'steps.inspOutputLabel': '输出',
|
||||
'steps.inspOutputSplit': '思 {think} / 回 {reply}',
|
||||
'steps.inspContextCostLabel': '上下文 / 费用',
|
||||
'steps.inspPromptTitle': '本轮提问',
|
||||
'steps.inspRowClickTip': '点击查看单步详情',
|
||||
|
||||
// Step Table Columns (Headers & Option Labels)
|
||||
'stepCol.step.th': '步序',
|
||||
|
||||
@@ -692,12 +692,14 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
|
||||
[data-modern-ui="true"] .number-input:focus-within,
|
||||
[data-modern-ui="true"] .settings-text-input:focus,
|
||||
[data-modern-ui="true"] .settings-account-form input:focus,
|
||||
[data-modern-ui="true"] .smig-search-wrap:focus-within {
|
||||
[data-modern-ui="true"] .smig-search-wrap:focus-within,
|
||||
[data-modern-ui="true"] .steps-search-wrap:focus-within {
|
||||
border: none;
|
||||
box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--accent-primary) 55%, transparent);
|
||||
}
|
||||
|
||||
[data-modern-ui="true"] .smig-search-wrap {
|
||||
[data-modern-ui="true"] .smig-search-wrap,
|
||||
[data-modern-ui="true"] .steps-search-wrap {
|
||||
border: none;
|
||||
background: var(--modern-surface-subtle);
|
||||
}
|
||||
|
||||
@@ -1202,3 +1202,422 @@
|
||||
.smodel-unit-cost[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* --- 步骤搜索栏、快捷诊断筛选芯片及单步透视抽屉 --- */
|
||||
.steps-filter-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
padding: 5px 0 6px;
|
||||
}
|
||||
|
||||
.steps-filter-toolbar[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.steps-search-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
flex: 1 1 160px;
|
||||
min-width: 120px;
|
||||
min-height: calc(28px * var(--ui-font-scale, 1));
|
||||
padding: 2px 8px;
|
||||
border-radius: var(--radius-xs);
|
||||
border: 1px solid var(--border-hairline);
|
||||
background: var(--surface-subtle);
|
||||
transition:
|
||||
border-color var(--dur-instant) var(--ease-fast),
|
||||
background-color var(--dur-instant) var(--ease-fast),
|
||||
box-shadow var(--dur-instant) var(--ease-fast);
|
||||
}
|
||||
|
||||
.steps-search-wrap:focus-within {
|
||||
border-color: var(--accent-primary);
|
||||
}
|
||||
|
||||
.steps-search-icon {
|
||||
color: var(--text-muted);
|
||||
flex-shrink: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.steps-search-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-sans);
|
||||
font-size: var(--fs-md);
|
||||
line-height: 1.3;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.steps-search-input::placeholder {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.steps-search-clear {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: var(--radius-pill);
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition:
|
||||
color var(--dur-instant) var(--ease-fast),
|
||||
background-color var(--dur-instant) var(--ease-fast);
|
||||
}
|
||||
|
||||
.steps-search-clear:hover {
|
||||
color: var(--text-primary);
|
||||
background: var(--surface-hover);
|
||||
}
|
||||
|
||||
.steps-search-clear[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.steps-quick-chips {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
flex: 0 1 auto;
|
||||
}
|
||||
|
||||
.steps-quick-chips[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.steps-export-menu {
|
||||
margin-left: auto;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.steps-chip-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: 24px;
|
||||
padding: 0 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
border: 1px solid var(--border-hairline);
|
||||
background: var(--surface-subtle);
|
||||
color: var(--text-secondary);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-xs);
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
transition:
|
||||
background var(--dur-instant) var(--ease-fast),
|
||||
color var(--dur-instant) var(--ease-fast),
|
||||
border-color var(--dur-instant) var(--ease-fast);
|
||||
}
|
||||
|
||||
.steps-chip-btn[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.steps-chip-btn:hover {
|
||||
background: var(--surface-hover);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.steps-chip-btn.is-active {
|
||||
background: var(--accent-primary-soft);
|
||||
border-color: var(--accent-primary-border);
|
||||
color: var(--accent-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.steps-chip-btn.is-warn.is-active {
|
||||
background: var(--metric-warn-soft);
|
||||
border-color: color-mix(in srgb, var(--metric-warn) 42%, var(--border-hairline));
|
||||
color: var(--metric-warn);
|
||||
}
|
||||
|
||||
.steps-chip-btn.is-danger.is-active {
|
||||
background: var(--metric-danger-soft);
|
||||
border-color: color-mix(in srgb, var(--metric-danger) 42%, var(--border-hairline));
|
||||
color: var(--metric-danger);
|
||||
}
|
||||
|
||||
.steps-chip-btn.is-info.is-active {
|
||||
background: var(--metric-info-soft);
|
||||
border-color: color-mix(in srgb, var(--metric-info) 42%, var(--border-hairline));
|
||||
color: var(--metric-info);
|
||||
}
|
||||
|
||||
.data-table tbody tr.is-selectable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.data-table tbody tr.is-selected {
|
||||
background: var(--surface-active) !important;
|
||||
}
|
||||
|
||||
.step-inspector-drawer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 9px 10px;
|
||||
margin-top: 4px;
|
||||
border-top: 1px solid var(--border-strong);
|
||||
background: var(--surface-subtle);
|
||||
border-radius: 0 0 var(--radius-sm) var(--radius-sm);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.step-inspector-drawer[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.step-insp-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.step-insp-head-left {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.step-insp-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 1px 6px;
|
||||
border-radius: var(--radius-xs);
|
||||
background: var(--accent-primary-soft);
|
||||
color: var(--accent-primary);
|
||||
font-size: var(--fs-xs);
|
||||
font-weight: 600;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.step-insp-model {
|
||||
font-size: var(--fs-base-sm);
|
||||
color: var(--text-primary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.step-insp-time {
|
||||
font-size: var(--fs-xs);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.step-insp-head-actions {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.step-insp-icon-btn,
|
||||
.step-insp-copy-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
height: 22px;
|
||||
padding: 0 6px;
|
||||
border-radius: var(--radius-xs);
|
||||
border: 1px solid var(--border-hairline);
|
||||
background: var(--surface-panel);
|
||||
color: var(--text-secondary);
|
||||
font-family: var(--font-sans);
|
||||
font-size: var(--fs-xs);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.step-insp-icon-btn {
|
||||
width: 22px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.step-insp-icon-btn:hover:not(:disabled),
|
||||
.step-insp-copy-btn:hover {
|
||||
background: var(--surface-hover);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.step-insp-icon-btn:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.step-insp-copy-btn.is-copied {
|
||||
color: var(--metric-ok);
|
||||
border-color: color-mix(in srgb, var(--metric-ok) 40%, var(--border-hairline));
|
||||
}
|
||||
|
||||
.step-insp-waterfall {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.step-insp-waterfall[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.step-insp-wf-track {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 5px;
|
||||
border-radius: var(--radius-pill);
|
||||
overflow: hidden;
|
||||
background: var(--surface-track);
|
||||
}
|
||||
|
||||
.step-insp-wf-seg {
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.step-insp-wf-seg.is-ttft {
|
||||
background: var(--metric-warn);
|
||||
}
|
||||
|
||||
.step-insp-wf-seg.is-stream {
|
||||
background: var(--metric-ok);
|
||||
}
|
||||
|
||||
.step-insp-wf-seg.is-other {
|
||||
background: color-mix(in srgb, var(--text-muted) 48%, transparent);
|
||||
}
|
||||
|
||||
.step-insp-wf-legend {
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.step-insp-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.step-insp-kpi {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
padding: 5px 7px;
|
||||
border-radius: var(--radius-sm);
|
||||
border: 1px solid var(--border-hairline);
|
||||
background: var(--surface-panel);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.step-insp-kpi-lbl {
|
||||
font-size: var(--fs-2xs);
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.step-insp-kpi-val {
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--text-primary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.step-insp-kpi-sub {
|
||||
font-size: var(--fs-2xs);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.step-insp-prompt {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
padding: 5px 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--surface-panel);
|
||||
border: 1px solid var(--border-hairline);
|
||||
}
|
||||
|
||||
.step-insp-prompt[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.step-insp-prompt-lbl {
|
||||
font-size: var(--fs-2xs);
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.step-insp-prompt-text {
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--text-primary);
|
||||
line-height: 1.4;
|
||||
max-height: 54px;
|
||||
overflow-y: auto;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.step-insp-prompt-text::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.step-insp-anomalies {
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--metric-danger);
|
||||
padding: 4px 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--metric-danger-soft);
|
||||
}
|
||||
|
||||
.step-insp-anomalies[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
[data-modern-ui="true"] .steps-chip-btn {
|
||||
border: none;
|
||||
border-radius: var(--radius-pill);
|
||||
background: var(--modern-surface-subtle);
|
||||
}
|
||||
|
||||
[data-modern-ui="true"] .step-inspector-drawer {
|
||||
border-top: none;
|
||||
border-radius: 10px;
|
||||
background: var(--modern-surface-subtle);
|
||||
}
|
||||
|
||||
[data-modern-ui="true"] .step-insp-kpi,
|
||||
[data-modern-ui="true"] .step-insp-prompt,
|
||||
[data-modern-ui="true"] .step-insp-icon-btn,
|
||||
[data-modern-ui="true"] .step-insp-copy-btn {
|
||||
border: none;
|
||||
background: var(--modern-surface-card);
|
||||
}
|
||||
|
||||
@media (max-width: 440px) {
|
||||
.step-insp-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,10 @@ import {
|
||||
buildModelAnomalyDiagnostic,
|
||||
formatAnomalyKindLabel,
|
||||
formatAnomalyTagText,
|
||||
formatCompactDateTime,
|
||||
formatMetric,
|
||||
formatSpeedMetric,
|
||||
formatTimingDetailSec,
|
||||
formatTokens,
|
||||
formatTokensPrecise,
|
||||
formatUsd,
|
||||
@@ -28,7 +30,18 @@ import {
|
||||
normalizeOrchestratorIdDisplayMode,
|
||||
resolveModelAnomalySummary,
|
||||
resolveModelDisplayInfo,
|
||||
speedReasonText,
|
||||
} from '../core/formatters.js';
|
||||
import {
|
||||
buildStepDiagnosticMarkdown,
|
||||
computeStepQuickChipCounts,
|
||||
computeStepTimingWaterfall,
|
||||
copyPlainTextToClipboard,
|
||||
filterStepsBySearchAndChip,
|
||||
findPrevAgentContextTokens,
|
||||
getStepSelectionKey,
|
||||
} from '../core/stepInspector.js';
|
||||
import { createSvgIcon, patchSvgIcon } from '../icons/SvgIcon.js';
|
||||
import { getEffectiveLocale, i18nStore, t } from '../i18n/index.js';
|
||||
import {
|
||||
formatAgentLabel,
|
||||
@@ -230,6 +243,13 @@ export const StepsDetailView = defineComponent({
|
||||
let selectedLineModels = ['__all__'];
|
||||
let onlyAnomalies = false;
|
||||
let anomalyKindFilter = '';
|
||||
let stepSearchQuery = '';
|
||||
let stepQuickChip = '';
|
||||
let selectedStepKey = '';
|
||||
let currentTableSteps = [];
|
||||
let currentAllConvSteps = [];
|
||||
let currentDisplaySettings = {};
|
||||
let inspCopyTimer = null;
|
||||
let sortKey = '';
|
||||
let sortDir = '';
|
||||
let cachedSortSrc = null;
|
||||
@@ -307,6 +327,10 @@ export const StepsDetailView = defineComponent({
|
||||
sortDir = nextDir || '';
|
||||
if (latestSlice) renderStepsData(latestSlice);
|
||||
},
|
||||
onSelectStep: (_st, rowKey) => {
|
||||
selectedStepKey = selectedStepKey === rowKey ? '' : rowKey;
|
||||
if (latestSlice) renderStepsData(latestSlice);
|
||||
},
|
||||
});
|
||||
const {
|
||||
stepsTablePane,
|
||||
@@ -335,6 +359,7 @@ export const StepsDetailView = defineComponent({
|
||||
onclick: () => {
|
||||
onlyAnomalies = false;
|
||||
anomalyKindFilter = '';
|
||||
if (stepQuickChip === 'anomaly') stepQuickChip = '';
|
||||
if (latestSlice) renderStepsData(latestSlice);
|
||||
},
|
||||
});
|
||||
@@ -344,6 +369,378 @@ export const StepsDetailView = defineComponent({
|
||||
[anomalyFilterLabelEl, anomalyFilterClearBtn]
|
||||
);
|
||||
|
||||
// --- 步骤搜索栏及快捷诊断芯片 ---
|
||||
const stepSearchClearBtn = h(
|
||||
'button',
|
||||
{
|
||||
type: 'button',
|
||||
className: 'steps-search-clear',
|
||||
hidden: true,
|
||||
'aria-label': t('steps.searchClearAria'),
|
||||
onclick: () => {
|
||||
stepSearchQuery = '';
|
||||
stepSearchInput.value = '';
|
||||
patchAttr(stepSearchClearBtn, 'hidden', true);
|
||||
if (latestSlice) renderStepsData(latestSlice);
|
||||
stepSearchInput.focus?.();
|
||||
},
|
||||
},
|
||||
[createSvgIcon('close', { size: 11 })]
|
||||
);
|
||||
const stepSearchInput = h('input', {
|
||||
type: 'text',
|
||||
className: 'steps-search-input',
|
||||
placeholder: t('steps.searchPlaceholder'),
|
||||
'aria-label': t('steps.searchPlaceholder'),
|
||||
onInput: (e) => {
|
||||
stepSearchQuery = String(e?.target?.value ?? '');
|
||||
patchAttr(stepSearchClearBtn, 'hidden', !stepSearchQuery.trim());
|
||||
if (latestSlice) renderStepsData(latestSlice);
|
||||
},
|
||||
onKeydown: (e) => {
|
||||
if (e?.key === 'Escape') {
|
||||
e.stopPropagation?.();
|
||||
if (stepSearchQuery) {
|
||||
stepSearchQuery = '';
|
||||
stepSearchInput.value = '';
|
||||
patchAttr(stepSearchClearBtn, 'hidden', true);
|
||||
if (latestSlice) renderStepsData(latestSlice);
|
||||
} else {
|
||||
stepSearchInput.blur?.();
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
const stepSearchWrapEl = h('div', { className: 'steps-search-wrap' }, [
|
||||
createSvgIcon('search', { size: 12, className: 'steps-search-icon' }),
|
||||
stepSearchInput,
|
||||
stepSearchClearBtn,
|
||||
]);
|
||||
|
||||
const QUICK_CHIP_DEFS = [
|
||||
{ key: 'anomaly', i18nKey: 'steps.chipAnomaly', tone: 'is-warn' },
|
||||
{ key: 'compaction', i18nKey: 'steps.chipCompaction', tone: 'is-info' },
|
||||
{ key: 'low_cache', i18nKey: 'steps.chipLowCache', tipKey: 'steps.chipLowCacheTip', tone: 'is-warn' },
|
||||
{ key: 'slow_ttft', i18nKey: 'steps.chipSlowTtft', tipKey: 'steps.chipSlowTtftTip', tone: 'is-danger' },
|
||||
];
|
||||
const quickChipBtns = QUICK_CHIP_DEFS.map((def) => {
|
||||
const btn = h('button', {
|
||||
type: 'button',
|
||||
className: `steps-chip-btn ${def.tone}`,
|
||||
'data-chip': def.key,
|
||||
hidden: true,
|
||||
onclick: () => {
|
||||
if (def.key === 'anomaly') {
|
||||
const nextOn = !(onlyAnomalies || stepQuickChip === 'anomaly');
|
||||
onlyAnomalies = nextOn;
|
||||
anomalyKindFilter = '';
|
||||
stepQuickChip = nextOn ? 'anomaly' : '';
|
||||
} else {
|
||||
const nextKey = stepQuickChip === def.key ? '' : def.key;
|
||||
stepQuickChip = nextKey;
|
||||
if (nextKey) {
|
||||
onlyAnomalies = false;
|
||||
anomalyKindFilter = '';
|
||||
}
|
||||
}
|
||||
if (latestSlice) renderStepsData(latestSlice);
|
||||
},
|
||||
});
|
||||
return { def, btn };
|
||||
});
|
||||
const stepQuickChipsEl = h(
|
||||
'div',
|
||||
{ className: 'steps-quick-chips', hidden: true },
|
||||
quickChipBtns.map((c) => c.btn)
|
||||
);
|
||||
const stepsFilterToolbarEl = h(
|
||||
'div',
|
||||
{ className: 'steps-filter-toolbar', hidden: true },
|
||||
[stepSearchWrapEl, stepQuickChipsEl]
|
||||
);
|
||||
|
||||
// --- 点击行展开的单步透视诊断抽屉 ---
|
||||
const inspStepBadgeEl = h('span', { className: 'step-insp-badge text-mono' });
|
||||
const inspModelEl = h('strong', { className: 'step-insp-model' });
|
||||
const inspTimeEl = h('span', { className: 'step-insp-time text-mono text-muted' });
|
||||
const inspPrevBtn = h(
|
||||
'button',
|
||||
{
|
||||
type: 'button',
|
||||
className: 'step-insp-icon-btn',
|
||||
'aria-label': t('steps.inspPrevAria'),
|
||||
title: t('steps.inspPrevAria'),
|
||||
onclick: () => navigateInspectorStep(-1),
|
||||
},
|
||||
[createSvgIcon('chevron-up', { size: 12 })]
|
||||
);
|
||||
const inspNextBtn = h(
|
||||
'button',
|
||||
{
|
||||
type: 'button',
|
||||
className: 'step-insp-icon-btn',
|
||||
'aria-label': t('steps.inspNextAria'),
|
||||
title: t('steps.inspNextAria'),
|
||||
onclick: () => navigateInspectorStep(1),
|
||||
},
|
||||
[createSvgIcon('chevron-down', { size: 12 })]
|
||||
);
|
||||
const inspCopyIcon = createSvgIcon('copy', { size: 11 });
|
||||
const inspCopyLabel = h('span', { text: t('steps.inspCopy') });
|
||||
let currentInspectedStep = null;
|
||||
let currentInspectedPrevCtx = null;
|
||||
const inspCopyBtn = h(
|
||||
'button',
|
||||
{
|
||||
type: 'button',
|
||||
className: 'step-insp-copy-btn',
|
||||
onclick: async () => {
|
||||
if (!currentInspectedStep) return;
|
||||
const md = buildStepDiagnosticMarkdown(currentInspectedStep, {
|
||||
prevContextTokens: currentInspectedPrevCtx,
|
||||
displaySettings: currentDisplaySettings,
|
||||
});
|
||||
await copyPlainTextToClipboard(md);
|
||||
patchSvgIcon(inspCopyIcon, 'check');
|
||||
patchText(inspCopyLabel, t('steps.inspCopied'));
|
||||
patchClasses(inspCopyBtn, { 'is-copied': true });
|
||||
if (inspCopyTimer) clearTimeout(inspCopyTimer);
|
||||
inspCopyTimer = setTimeout(() => {
|
||||
inspCopyTimer = null;
|
||||
patchSvgIcon(inspCopyIcon, 'copy');
|
||||
patchText(inspCopyLabel, t('steps.inspCopy'));
|
||||
patchClasses(inspCopyBtn, { 'is-copied': false });
|
||||
}, 1600);
|
||||
},
|
||||
},
|
||||
[inspCopyIcon, inspCopyLabel]
|
||||
);
|
||||
const inspCloseBtn = h(
|
||||
'button',
|
||||
{
|
||||
type: 'button',
|
||||
className: 'step-insp-icon-btn',
|
||||
'aria-label': t('steps.inspCloseAria'),
|
||||
title: t('steps.inspCloseAria'),
|
||||
onclick: () => {
|
||||
selectedStepKey = '';
|
||||
if (latestSlice) renderStepsData(latestSlice);
|
||||
},
|
||||
},
|
||||
[createSvgIcon('close', { size: 12 })]
|
||||
);
|
||||
|
||||
const inspWfTtftSeg = h('div', { className: 'step-insp-wf-seg is-ttft' });
|
||||
const inspWfStreamSeg = h('div', { className: 'step-insp-wf-seg is-stream' });
|
||||
const inspWfOtherSeg = h('div', { className: 'step-insp-wf-seg is-other' });
|
||||
const inspWfTrackEl = h('div', { className: 'step-insp-wf-track' }, [
|
||||
inspWfTtftSeg,
|
||||
inspWfStreamSeg,
|
||||
inspWfOtherSeg,
|
||||
]);
|
||||
const inspWfLegendEl = h('div', { className: 'step-insp-wf-legend text-mono' });
|
||||
const inspWaterfallEl = h('div', { className: 'step-insp-waterfall', hidden: true }, [
|
||||
inspWfTrackEl,
|
||||
inspWfLegendEl,
|
||||
]);
|
||||
|
||||
function createInspKpiCell(labelText) {
|
||||
const lbl = h('span', { className: 'step-insp-kpi-lbl', text: labelText });
|
||||
const val = h('strong', { className: 'step-insp-kpi-val text-mono', text: '—' });
|
||||
const sub = h('span', { className: 'step-insp-kpi-sub text-mono text-muted', text: '' });
|
||||
return {
|
||||
el: h('div', { className: 'step-insp-kpi' }, [lbl, val, sub]),
|
||||
lbl,
|
||||
val,
|
||||
sub,
|
||||
};
|
||||
}
|
||||
const inspKpiInput = createInspKpiCell(t('steps.inspInputLabel'));
|
||||
const inspKpiCache = createInspKpiCell(t('steps.inspCacheLabel'));
|
||||
const inspKpiOutput = createInspKpiCell(t('steps.inspOutputLabel'));
|
||||
const inspKpiCtxCost = createInspKpiCell(t('steps.inspContextCostLabel'));
|
||||
const inspGridEl = h('div', { className: 'step-insp-grid' }, [
|
||||
inspKpiInput.el,
|
||||
inspKpiCache.el,
|
||||
inspKpiOutput.el,
|
||||
inspKpiCtxCost.el,
|
||||
]);
|
||||
|
||||
const inspPromptLabelEl = h('span', {
|
||||
className: 'step-insp-prompt-lbl',
|
||||
text: t('steps.inspPromptTitle'),
|
||||
});
|
||||
const inspPromptTextEl = h('div', { className: 'step-insp-prompt-text' });
|
||||
const inspPromptWrapEl = h('div', { className: 'step-insp-prompt', hidden: true }, [
|
||||
inspPromptLabelEl,
|
||||
inspPromptTextEl,
|
||||
]);
|
||||
const inspAnomaliesEl = h('div', { className: 'step-insp-anomalies text-mono', hidden: true });
|
||||
|
||||
const stepInspectorDrawerEl = h(
|
||||
'div',
|
||||
{ className: 'step-inspector-drawer', hidden: true },
|
||||
[
|
||||
h('div', { className: 'step-insp-head' }, [
|
||||
h('div', { className: 'step-insp-head-left' }, [
|
||||
inspStepBadgeEl,
|
||||
inspModelEl,
|
||||
inspTimeEl,
|
||||
]),
|
||||
h('div', { className: 'step-insp-head-actions' }, [
|
||||
inspPrevBtn,
|
||||
inspNextBtn,
|
||||
inspCopyBtn,
|
||||
inspCloseBtn,
|
||||
]),
|
||||
]),
|
||||
inspWaterfallEl,
|
||||
inspGridEl,
|
||||
inspPromptWrapEl,
|
||||
inspAnomaliesEl,
|
||||
]
|
||||
);
|
||||
|
||||
function navigateInspectorStep(delta) {
|
||||
if (!selectedStepKey || currentTableSteps.length === 0) return;
|
||||
const cid = String(latestSlice?.cascadeId || latestSlice?.activeConversation?.cascadeId || '');
|
||||
const curIdx = currentTableSteps.findIndex(
|
||||
(st) => getStepSelectionKey(st, cid) === selectedStepKey
|
||||
);
|
||||
if (curIdx < 0) return;
|
||||
const nextIdx = curIdx + delta;
|
||||
if (nextIdx < 0 || nextIdx >= currentTableSteps.length) return;
|
||||
selectedStepKey = getStepSelectionKey(currentTableSteps[nextIdx], cid);
|
||||
if (latestSlice) renderStepsData(latestSlice);
|
||||
}
|
||||
|
||||
function syncStepInspectorDrawer(tableSteps, allConvSteps, cascadeId, displaySettings, showModels) {
|
||||
if (showModels || !selectedStepKey || !Array.isArray(tableSteps) || tableSteps.length === 0) {
|
||||
currentInspectedStep = null;
|
||||
currentInspectedPrevCtx = null;
|
||||
patchAttr(stepInspectorDrawerEl, 'hidden', true);
|
||||
return;
|
||||
}
|
||||
const idx = tableSteps.findIndex(
|
||||
(st) => getStepSelectionKey(st, cascadeId) === selectedStepKey
|
||||
);
|
||||
if (idx < 0) {
|
||||
selectedStepKey = '';
|
||||
currentInspectedStep = null;
|
||||
currentInspectedPrevCtx = null;
|
||||
patchAttr(stepInspectorDrawerEl, 'hidden', true);
|
||||
return;
|
||||
}
|
||||
const st = tableSteps[idx];
|
||||
currentInspectedStep = st;
|
||||
const prevCtx = findPrevAgentContextTokens(allConvSteps, st);
|
||||
currentInspectedPrevCtx = prevCtx;
|
||||
|
||||
patchAttr(stepInspectorDrawerEl, 'hidden', false);
|
||||
patchText(inspStepBadgeEl, `#${st.stepIndex ?? '—'}`);
|
||||
const mInfo = resolveModelDisplayInfo(st, displaySettings);
|
||||
patchText(inspModelEl, mInfo.text);
|
||||
patchAttr(inspModelEl, 'title', mInfo.title || mInfo.text);
|
||||
patchText(inspTimeEl, st.createdAtMs ? formatCompactDateTime(st.createdAtMs) : '');
|
||||
patchAttr(inspPrevBtn, 'disabled', idx <= 0);
|
||||
patchAttr(inspNextBtn, 'disabled', idx >= tableSteps.length - 1);
|
||||
|
||||
const wf = computeStepTimingWaterfall(st);
|
||||
patchAttr(inspWaterfallEl, 'hidden', !wf);
|
||||
if (wf) {
|
||||
inspWfTtftSeg.style.width = `${wf.ttftPct}%`;
|
||||
inspWfStreamSeg.style.width = `${wf.streamPct}%`;
|
||||
inspWfOtherSeg.style.width = `${wf.otherPct}%`;
|
||||
const parts = [formatSpeedMetric(st.tokPerSec, ' tok/s')];
|
||||
if (wf.ttftSec > 0) {
|
||||
parts.push(t('steps.inspWaterfallTtft', { sec: formatTimingDetailSec(wf.ttftSec) }));
|
||||
}
|
||||
if (wf.streamSec > 0) {
|
||||
parts.push(t('steps.inspWaterfallStream', { sec: formatTimingDetailSec(wf.streamSec) }));
|
||||
}
|
||||
if (wf.otherSec > 0.05) {
|
||||
parts.push(t('steps.inspWaterfallOther', { sec: formatTimingDetailSec(wf.otherSec) }));
|
||||
}
|
||||
if (wf.thinkingSec > 0) {
|
||||
parts.push(t('steps.inspWaterfallThink', { sec: formatTimingDetailSec(wf.thinkingSec) }));
|
||||
}
|
||||
const reason = st.selectedSpeedReason ? speedReasonText(st.selectedSpeedReason) : '';
|
||||
if (reason) parts.push(reason);
|
||||
patchText(inspWfLegendEl, parts.join(' · '));
|
||||
}
|
||||
|
||||
const inTok = Number(st.inputTokens || 0);
|
||||
const cacheTok = Number(st.cacheReadTokens || 0);
|
||||
const outTok = Number(st.outputTokens || 0);
|
||||
const thinkTok = Number(st.thinkingTokens || 0);
|
||||
const replyTok =
|
||||
st.responseTokens != null ? Number(st.responseTokens) : Math.max(0, outTok - thinkTok);
|
||||
const promptTok = inTok + cacheTok;
|
||||
const cachePct =
|
||||
st.cacheHitPct != null && Number.isFinite(Number(st.cacheHitPct))
|
||||
? Number(st.cacheHitPct)
|
||||
: promptTok > 0
|
||||
? (cacheTok / promptTok) * 100
|
||||
: 0;
|
||||
const ctxTok = Number(st.contextTokens || promptTok + outTok);
|
||||
|
||||
patchText(inspKpiInput.lbl, t('steps.inspInputLabel'));
|
||||
patchText(inspKpiInput.val, formatTokensPrecise(inTok));
|
||||
patchText(inspKpiInput.sub, st.inputCostUsd != null ? formatUsd(st.inputCostUsd, { precise: true }) : '');
|
||||
|
||||
patchText(inspKpiCache.lbl, t('steps.inspCacheLabel'));
|
||||
patchText(inspKpiCache.val, formatTokensPrecise(cacheTok));
|
||||
patchText(inspKpiCache.sub, `${cachePct.toFixed(1)}%`);
|
||||
|
||||
patchText(inspKpiOutput.lbl, t('steps.inspOutputLabel'));
|
||||
patchText(inspKpiOutput.val, formatTokensPrecise(outTok));
|
||||
patchText(
|
||||
inspKpiOutput.sub,
|
||||
thinkTok > 0
|
||||
? t('steps.inspOutputSplit', {
|
||||
think: formatTokens(thinkTok),
|
||||
reply: formatTokens(replyTok),
|
||||
})
|
||||
: st.outCostUsd != null
|
||||
? formatUsd(st.outCostUsd, { precise: true })
|
||||
: ''
|
||||
);
|
||||
|
||||
patchText(inspKpiCtxCost.lbl, t('steps.inspContextCostLabel'));
|
||||
const deltaStr =
|
||||
prevCtx != null && ctxTok > 0
|
||||
? ` (${ctxTok >= prevCtx ? '+' : '-'}${formatTokens(Math.abs(ctxTok - prevCtx))})`
|
||||
: '';
|
||||
patchText(inspKpiCtxCost.val, `${formatTokens(ctxTok)}${deltaStr}`);
|
||||
patchText(inspKpiCtxCost.sub, formatUsd(st.costUsd, { precise: true }));
|
||||
|
||||
const promptText = String(st.turnPrompt || st.rootTurnPrompt || '').trim();
|
||||
patchAttr(inspPromptWrapEl, 'hidden', !promptText);
|
||||
if (promptText) {
|
||||
patchText(inspPromptLabelEl, t('steps.inspPromptTitle'));
|
||||
patchText(inspPromptTextEl, promptText);
|
||||
}
|
||||
|
||||
const anom = st.anomaly;
|
||||
const hasAnom = Boolean(anom && Number(anom.count) > 0);
|
||||
patchAttr(inspAnomaliesEl, 'hidden', !hasAnom);
|
||||
if (hasAnom) {
|
||||
const itemsText = Array.isArray(anom.items) && anom.items.length > 0
|
||||
? anom.items
|
||||
.map((it) => {
|
||||
const lbl = formatAnomalyKindLabel(it.kind || anom.primaryKind);
|
||||
const code = it.httpStatus ? ` HTTP ${it.httpStatus}` : '';
|
||||
const delay = Number(it.delaySec) > 0 ? ` (${Number(it.delaySec).toFixed(1)}s)` : '';
|
||||
return `${lbl}${code}${delay}`;
|
||||
})
|
||||
.join(' · ')
|
||||
: Object.entries(anom.kinds || {})
|
||||
.map(([k, v]) => `${formatAnomalyKindLabel(k)} ×${v}`)
|
||||
.join(' · ');
|
||||
patchText(inspAnomaliesEl, itemsText);
|
||||
}
|
||||
}
|
||||
|
||||
// --- 子视图 2:总汇总分析面板 ---
|
||||
let selectedLineMetric = 'totalTokens';
|
||||
let selectedFitMetric = 'tps';
|
||||
@@ -507,8 +904,10 @@ export const StepsDetailView = defineComponent({
|
||||
headerFiltersEl,
|
||||
]),
|
||||
]),
|
||||
stepsFilterToolbarEl,
|
||||
anomalyFilterBarEl,
|
||||
stepsScroll.el,
|
||||
stepInspectorDrawerEl,
|
||||
modelsScroll.el,
|
||||
turnTipEl,
|
||||
anomalyTipEl,
|
||||
@@ -582,6 +981,16 @@ export const StepsDetailView = defineComponent({
|
||||
patchText(modelsSectionTitleEl, t('steps.modelsTitle'));
|
||||
patchText(modelsEmptyEl, t('steps.modelsEmpty'));
|
||||
patchText(anomalyFilterClearBtn, t('steps.anomalyFilterAll'));
|
||||
patchAttr(stepSearchInput, 'placeholder', t('steps.searchPlaceholder'));
|
||||
patchAttr(stepSearchInput, 'aria-label', t('steps.searchPlaceholder'));
|
||||
patchAttr(stepSearchClearBtn, 'aria-label', t('steps.searchClearAria'));
|
||||
patchAttr(inspPrevBtn, 'aria-label', t('steps.inspPrevAria'));
|
||||
patchAttr(inspPrevBtn, 'title', t('steps.inspPrevAria'));
|
||||
patchAttr(inspNextBtn, 'aria-label', t('steps.inspNextAria'));
|
||||
patchAttr(inspNextBtn, 'title', t('steps.inspNextAria'));
|
||||
patchAttr(inspCloseBtn, 'aria-label', t('steps.inspCloseAria'));
|
||||
patchAttr(inspCloseBtn, 'title', t('steps.inspCloseAria'));
|
||||
if (!inspCopyTimer) patchText(inspCopyLabel, t('steps.inspCopy'));
|
||||
lastAnomalyStripSig = '';
|
||||
lineMetricSwitch.setProps({
|
||||
modelValue: selectedLineMetric,
|
||||
@@ -618,6 +1027,11 @@ export const StepsDetailView = defineComponent({
|
||||
selectedLineModels = ['__all__'];
|
||||
onlyAnomalies = false;
|
||||
anomalyKindFilter = '';
|
||||
stepSearchQuery = '';
|
||||
stepSearchInput.value = '';
|
||||
patchAttr(stepSearchClearBtn, 'hidden', true);
|
||||
stepQuickChip = '';
|
||||
selectedStepKey = '';
|
||||
sortKey = '';
|
||||
sortDir = '';
|
||||
}
|
||||
@@ -818,16 +1232,35 @@ export const StepsDetailView = defineComponent({
|
||||
? steps.filter((st) => tableModelFilterSet.has(getStepModelGroupKey(st)))
|
||||
: steps;
|
||||
|
||||
let filteredTableSteps = modelFilteredSteps;
|
||||
if (onlyAnomalies) {
|
||||
filteredTableSteps = modelFilteredSteps.filter((st) => {
|
||||
const a = st?.anomaly;
|
||||
if (!a || !(Number(a.count) > 0)) return false;
|
||||
if (anomalyKindFilter && !(Number(a.kinds?.[anomalyKindFilter] || 0) > 0)) return false;
|
||||
return true;
|
||||
});
|
||||
const chipCounts = computeStepQuickChipCounts(modelFilteredSteps);
|
||||
const effectiveQuickChip = onlyAnomalies ? 'anomaly' : stepQuickChip;
|
||||
const showFilterToolbar = !showModels && steps.length > 0;
|
||||
patchAttr(stepsFilterToolbarEl, 'hidden', !showFilterToolbar);
|
||||
if (showFilterToolbar) {
|
||||
let visibleChipsCount = 0;
|
||||
for (const { def, btn } of quickChipBtns) {
|
||||
const cnt = chipCounts[def.key] || 0;
|
||||
const isActive = effectiveQuickChip === def.key;
|
||||
const showChip = cnt > 0 || isActive;
|
||||
patchAttr(btn, 'hidden', !showChip);
|
||||
if (showChip) {
|
||||
visibleChipsCount += 1;
|
||||
patchText(btn, t(def.i18nKey, { count: cnt }));
|
||||
if (def.tipKey) patchAttr(btn, 'title', t(def.tipKey));
|
||||
patchClasses(btn, { 'is-active': isActive });
|
||||
patchAttr(btn, 'aria-pressed', isActive ? 'true' : 'false');
|
||||
}
|
||||
}
|
||||
patchAttr(stepQuickChipsEl, 'hidden', visibleChipsCount === 0);
|
||||
}
|
||||
|
||||
const filteredTableSteps = filterStepsBySearchAndChip(modelFilteredSteps, {
|
||||
query: stepSearchQuery,
|
||||
quickChip: effectiveQuickChip,
|
||||
anomalyKindFilter: onlyAnomalies ? anomalyKindFilter : '',
|
||||
displaySettings,
|
||||
});
|
||||
|
||||
const normTokenFmt = normalizeClientStepTokenComboFormat(slice.stepTokenComboFormat);
|
||||
const sortSig = `${sortKey}:${sortDir}:${normTokenFmt}:${displaySettings.modelDisplayMode}:${displaySettings.showUpstreamModel ? 1 : 0}:${displaySettings.orchestratorIdMode}`;
|
||||
let tableSteps = filteredTableSteps;
|
||||
@@ -877,6 +1310,9 @@ export const StepsDetailView = defineComponent({
|
||||
const allConversationSteps = hasSubagents
|
||||
? aggregated?.recentSteps || []
|
||||
: slice.recentSteps || [];
|
||||
currentTableSteps = tableSteps;
|
||||
currentAllConvSteps = allConversationSteps;
|
||||
currentDisplaySettings = displaySettings;
|
||||
const shouldAnimateNewRows = Boolean(
|
||||
allowNewRowFade && slice.experimentalModernUi && !showModels
|
||||
);
|
||||
@@ -895,11 +1331,14 @@ export const StepsDetailView = defineComponent({
|
||||
allowNewRowFade: shouldAnimateNewRows,
|
||||
sortKey,
|
||||
sortDir,
|
||||
selectedStepKey,
|
||||
});
|
||||
syncStepInspectorDrawer(tableSteps, allConversationSteps, currentCid, displaySettings, false);
|
||||
stepsScroll.refresh();
|
||||
fitPinnedWhileVisible = false;
|
||||
return;
|
||||
}
|
||||
syncStepInspectorDrawer(tableSteps, allConversationSteps, currentCid, displaySettings, true);
|
||||
|
||||
const chronoSteps = getMemoizedChronoSteps(steps, isMergedMultiAgents);
|
||||
const stepTtftFallbackMap = new Map();
|
||||
@@ -1436,6 +1875,8 @@ export const StepsDetailView = defineComponent({
|
||||
hideAnomalyTip();
|
||||
subTabSwitch.setValue(tab);
|
||||
patchAttr(anomalyFilterBarEl, 'hidden', tab !== 'steps' || !onlyAnomalies);
|
||||
patchAttr(stepsFilterToolbarEl, 'hidden', tab !== 'steps' || currentTableSteps.length === 0 && !stepSearchQuery && !stepQuickChip);
|
||||
patchAttr(stepInspectorDrawerEl, 'hidden', tab !== 'steps' || !selectedStepKey);
|
||||
patchAttr(stepsScroll.el, 'hidden', tab !== 'steps');
|
||||
patchAttr(modelsScroll.el, 'hidden', tab !== 'models');
|
||||
if (getVisibleMonitorView() === 'steps' && latestSlice) {
|
||||
@@ -1531,7 +1972,32 @@ export const StepsDetailView = defineComponent({
|
||||
}
|
||||
);
|
||||
|
||||
const onPanelKeydown = (e) => {
|
||||
if (!selectedStepKey || uiStore.getState().stepsSubTab !== 'steps') return;
|
||||
const tag = String(e?.target?.tagName || '').toUpperCase();
|
||||
if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || e?.target?.isContentEditable) {
|
||||
return;
|
||||
}
|
||||
if (e?.key === 'Escape') {
|
||||
e.preventDefault?.();
|
||||
selectedStepKey = '';
|
||||
if (latestSlice) renderStepsData(latestSlice);
|
||||
} else if (e?.key === 'ArrowUp') {
|
||||
e.preventDefault?.();
|
||||
navigateInspectorStep(-1);
|
||||
} else if (e?.key === 'ArrowDown') {
|
||||
e.preventDefault?.();
|
||||
navigateInspectorStep(1);
|
||||
}
|
||||
};
|
||||
panelEl.addEventListener?.('keydown', onPanelKeydown);
|
||||
|
||||
onCleanup(() => {
|
||||
if (inspCopyTimer) {
|
||||
clearTimeout(inspCopyTimer);
|
||||
inspCopyTimer = null;
|
||||
}
|
||||
panelEl.removeEventListener?.('keydown', onPanelKeydown);
|
||||
modelsAnalyticsPane.removeEventListener('scroll', onModelsPaneScroll);
|
||||
unsubUi();
|
||||
unsubTelemetry();
|
||||
@@ -1560,6 +2026,10 @@ export const StepsDetailView = defineComponent({
|
||||
turnTipEl,
|
||||
anomalyTipEl,
|
||||
anomalyFilterBarEl,
|
||||
stepsFilterToolbarEl,
|
||||
stepSearchInput,
|
||||
stepQuickChipsEl,
|
||||
stepInspectorDrawerEl,
|
||||
modelsAnomalyStripEl,
|
||||
modelsListEl,
|
||||
inlineScopeSelect,
|
||||
|
||||
+423
-2
@@ -4732,6 +4732,425 @@ html[data-standalone="true"] .app-shell {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* --- 步骤搜索栏、快捷诊断筛选芯片及单步透视抽屉 --- */
|
||||
.steps-filter-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
padding: 5px 0 6px;
|
||||
}
|
||||
|
||||
.steps-filter-toolbar[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.steps-search-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
flex: 1 1 160px;
|
||||
min-width: 120px;
|
||||
min-height: calc(28px * var(--ui-font-scale, 1));
|
||||
padding: 2px 8px;
|
||||
border-radius: var(--radius-xs);
|
||||
border: 1px solid var(--border-hairline);
|
||||
background: var(--surface-subtle);
|
||||
transition:
|
||||
border-color var(--dur-instant) var(--ease-fast),
|
||||
background-color var(--dur-instant) var(--ease-fast),
|
||||
box-shadow var(--dur-instant) var(--ease-fast);
|
||||
}
|
||||
|
||||
.steps-search-wrap:focus-within {
|
||||
border-color: var(--accent-primary);
|
||||
}
|
||||
|
||||
.steps-search-icon {
|
||||
color: var(--text-muted);
|
||||
flex-shrink: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.steps-search-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-sans);
|
||||
font-size: var(--fs-md);
|
||||
line-height: 1.3;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.steps-search-input::placeholder {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.steps-search-clear {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: var(--radius-pill);
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition:
|
||||
color var(--dur-instant) var(--ease-fast),
|
||||
background-color var(--dur-instant) var(--ease-fast);
|
||||
}
|
||||
|
||||
.steps-search-clear:hover {
|
||||
color: var(--text-primary);
|
||||
background: var(--surface-hover);
|
||||
}
|
||||
|
||||
.steps-search-clear[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.steps-quick-chips {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
flex: 0 1 auto;
|
||||
}
|
||||
|
||||
.steps-quick-chips[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.steps-export-menu {
|
||||
margin-left: auto;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.steps-chip-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: 24px;
|
||||
padding: 0 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
border: 1px solid var(--border-hairline);
|
||||
background: var(--surface-subtle);
|
||||
color: var(--text-secondary);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-xs);
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
transition:
|
||||
background var(--dur-instant) var(--ease-fast),
|
||||
color var(--dur-instant) var(--ease-fast),
|
||||
border-color var(--dur-instant) var(--ease-fast);
|
||||
}
|
||||
|
||||
.steps-chip-btn[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.steps-chip-btn:hover {
|
||||
background: var(--surface-hover);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.steps-chip-btn.is-active {
|
||||
background: var(--accent-primary-soft);
|
||||
border-color: var(--accent-primary-border);
|
||||
color: var(--accent-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.steps-chip-btn.is-warn.is-active {
|
||||
background: var(--metric-warn-soft);
|
||||
border-color: color-mix(in srgb, var(--metric-warn) 42%, var(--border-hairline));
|
||||
color: var(--metric-warn);
|
||||
}
|
||||
|
||||
.steps-chip-btn.is-danger.is-active {
|
||||
background: var(--metric-danger-soft);
|
||||
border-color: color-mix(in srgb, var(--metric-danger) 42%, var(--border-hairline));
|
||||
color: var(--metric-danger);
|
||||
}
|
||||
|
||||
.steps-chip-btn.is-info.is-active {
|
||||
background: var(--metric-info-soft);
|
||||
border-color: color-mix(in srgb, var(--metric-info) 42%, var(--border-hairline));
|
||||
color: var(--metric-info);
|
||||
}
|
||||
|
||||
.data-table tbody tr.is-selectable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.data-table tbody tr.is-selected {
|
||||
background: var(--surface-active) !important;
|
||||
}
|
||||
|
||||
.step-inspector-drawer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 9px 10px;
|
||||
margin-top: 4px;
|
||||
border-top: 1px solid var(--border-strong);
|
||||
background: var(--surface-subtle);
|
||||
border-radius: 0 0 var(--radius-sm) var(--radius-sm);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.step-inspector-drawer[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.step-insp-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.step-insp-head-left {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.step-insp-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 1px 6px;
|
||||
border-radius: var(--radius-xs);
|
||||
background: var(--accent-primary-soft);
|
||||
color: var(--accent-primary);
|
||||
font-size: var(--fs-xs);
|
||||
font-weight: 600;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.step-insp-model {
|
||||
font-size: var(--fs-base-sm);
|
||||
color: var(--text-primary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.step-insp-time {
|
||||
font-size: var(--fs-xs);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.step-insp-head-actions {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.step-insp-icon-btn,
|
||||
.step-insp-copy-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
height: 22px;
|
||||
padding: 0 6px;
|
||||
border-radius: var(--radius-xs);
|
||||
border: 1px solid var(--border-hairline);
|
||||
background: var(--surface-panel);
|
||||
color: var(--text-secondary);
|
||||
font-family: var(--font-sans);
|
||||
font-size: var(--fs-xs);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.step-insp-icon-btn {
|
||||
width: 22px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.step-insp-icon-btn:hover:not(:disabled),
|
||||
.step-insp-copy-btn:hover {
|
||||
background: var(--surface-hover);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.step-insp-icon-btn:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.step-insp-copy-btn.is-copied {
|
||||
color: var(--metric-ok);
|
||||
border-color: color-mix(in srgb, var(--metric-ok) 40%, var(--border-hairline));
|
||||
}
|
||||
|
||||
.step-insp-waterfall {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.step-insp-waterfall[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.step-insp-wf-track {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 5px;
|
||||
border-radius: var(--radius-pill);
|
||||
overflow: hidden;
|
||||
background: var(--surface-track);
|
||||
}
|
||||
|
||||
.step-insp-wf-seg {
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.step-insp-wf-seg.is-ttft {
|
||||
background: var(--metric-warn);
|
||||
}
|
||||
|
||||
.step-insp-wf-seg.is-stream {
|
||||
background: var(--metric-ok);
|
||||
}
|
||||
|
||||
.step-insp-wf-seg.is-other {
|
||||
background: color-mix(in srgb, var(--text-muted) 48%, transparent);
|
||||
}
|
||||
|
||||
.step-insp-wf-legend {
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.step-insp-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.step-insp-kpi {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
padding: 5px 7px;
|
||||
border-radius: var(--radius-sm);
|
||||
border: 1px solid var(--border-hairline);
|
||||
background: var(--surface-panel);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.step-insp-kpi-lbl {
|
||||
font-size: var(--fs-2xs);
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.step-insp-kpi-val {
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--text-primary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.step-insp-kpi-sub {
|
||||
font-size: var(--fs-2xs);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.step-insp-prompt {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
padding: 5px 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--surface-panel);
|
||||
border: 1px solid var(--border-hairline);
|
||||
}
|
||||
|
||||
.step-insp-prompt[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.step-insp-prompt-lbl {
|
||||
font-size: var(--fs-2xs);
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.step-insp-prompt-text {
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--text-primary);
|
||||
line-height: 1.4;
|
||||
max-height: 54px;
|
||||
overflow-y: auto;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.step-insp-prompt-text::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.step-insp-anomalies {
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--metric-danger);
|
||||
padding: 4px 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--metric-danger-soft);
|
||||
}
|
||||
|
||||
.step-insp-anomalies[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
[data-modern-ui="true"] .steps-chip-btn {
|
||||
border: none;
|
||||
border-radius: var(--radius-pill);
|
||||
background: var(--modern-surface-subtle);
|
||||
}
|
||||
|
||||
[data-modern-ui="true"] .step-inspector-drawer {
|
||||
border-top: none;
|
||||
border-radius: 10px;
|
||||
background: var(--modern-surface-subtle);
|
||||
}
|
||||
|
||||
[data-modern-ui="true"] .step-insp-kpi,
|
||||
[data-modern-ui="true"] .step-insp-prompt,
|
||||
[data-modern-ui="true"] .step-insp-icon-btn,
|
||||
[data-modern-ui="true"] .step-insp-copy-btn {
|
||||
border: none;
|
||||
background: var(--modern-surface-card);
|
||||
}
|
||||
|
||||
@media (max-width: 440px) {
|
||||
.step-insp-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
/* --- src/styles/views-settings.css --- */
|
||||
/*
|
||||
* 模块化偏好设置样式表 (views-settings.css).
|
||||
@@ -7807,12 +8226,14 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
|
||||
[data-modern-ui="true"] .number-input:focus-within,
|
||||
[data-modern-ui="true"] .settings-text-input:focus,
|
||||
[data-modern-ui="true"] .settings-account-form input:focus,
|
||||
[data-modern-ui="true"] .smig-search-wrap:focus-within {
|
||||
[data-modern-ui="true"] .smig-search-wrap:focus-within,
|
||||
[data-modern-ui="true"] .steps-search-wrap:focus-within {
|
||||
border: none;
|
||||
box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--accent-primary) 55%, transparent);
|
||||
}
|
||||
|
||||
[data-modern-ui="true"] .smig-search-wrap {
|
||||
[data-modern-ui="true"] .smig-search-wrap,
|
||||
[data-modern-ui="true"] .steps-search-wrap {
|
||||
border: none;
|
||||
background: var(--modern-surface-subtle);
|
||||
}
|
||||
|
||||
@@ -1314,3 +1314,197 @@ test('Feature 13: TopSessionHeader exposes project/workspace tags on sessions an
|
||||
assert.equal(visibleOpts.length, 1);
|
||||
assert.match(visibleOpts[0].textContent, /web-dashboard/);
|
||||
});
|
||||
|
||||
test('Feature 10: StepsDetailView live search, dynamic diagnostic chips, and click-to-inspect step drawer', async (t) => {
|
||||
const {
|
||||
computeStepQuickChipCounts,
|
||||
computeStepTimingWaterfall,
|
||||
filterStepsBySearchAndChip,
|
||||
buildStepDiagnosticMarkdown,
|
||||
} = await import('../src/core/stepInspector.js');
|
||||
|
||||
const steps = [
|
||||
{
|
||||
stepIndex: 4,
|
||||
createdAtMs: Date.UTC(2026, 10, 22, 10, 4, 0),
|
||||
modelShort: '4-neon',
|
||||
modelLabel: 'Gemini 4 Neon',
|
||||
tokPerSec: 42.5,
|
||||
ttftSec: 32.4,
|
||||
streamDurationSec: 4.6,
|
||||
durationSec: 38.0,
|
||||
inputTokens: 12_000,
|
||||
cacheReadTokens: 8_000,
|
||||
outputTokens: 600,
|
||||
thinkingTokens: 400,
|
||||
responseTokens: 200,
|
||||
contextTokens: 120_600,
|
||||
cacheHitPct: 40.0,
|
||||
costUsd: 0.24,
|
||||
turnPrompt: 'Debug SQLite migrator lock contention',
|
||||
anomaly: { count: 1, severity: 'danger', primaryKind: 'rate_limit', kinds: { rate_limit: 1 } },
|
||||
anomalySig: 'rate_limit:1',
|
||||
},
|
||||
{
|
||||
stepIndex: 3,
|
||||
createdAtMs: Date.UTC(2026, 10, 22, 10, 3, 0),
|
||||
modelShort: '4-carbon',
|
||||
modelLabel: 'Gemini 4 Carbon',
|
||||
tokPerSec: null,
|
||||
ttftSec: null,
|
||||
isCompactionStep: true,
|
||||
inputTokens: 40_000,
|
||||
cacheReadTokens: 0,
|
||||
outputTokens: 1_500,
|
||||
contextTokens: 41_500,
|
||||
cacheHitPct: 0,
|
||||
costUsd: 0.08,
|
||||
},
|
||||
{
|
||||
stepIndex: 2,
|
||||
createdAtMs: Date.UTC(2026, 10, 22, 10, 2, 0),
|
||||
modelShort: '4-carbon',
|
||||
modelLabel: 'Gemini 4 Carbon',
|
||||
tokPerSec: 68.0,
|
||||
ttftSec: 1.8,
|
||||
streamDurationSec: 3.2,
|
||||
durationSec: 5.0,
|
||||
inputTokens: 4_000,
|
||||
cacheReadTokens: 96_000,
|
||||
outputTokens: 800,
|
||||
thinkingTokens: 200,
|
||||
responseTokens: 600,
|
||||
contextTokens: 100_800,
|
||||
cacheHitPct: 96.0,
|
||||
costUsd: 0.05,
|
||||
turnPrompt: 'Polish quota widget styling',
|
||||
},
|
||||
];
|
||||
|
||||
// 1. Pure O(N) chip counts, filtering, waterfall math, and diagnostic Markdown
|
||||
const counts = computeStepQuickChipCounts(steps);
|
||||
assert.deepEqual(counts, { anomaly: 1, compaction: 1, low_cache: 1, slow_ttft: 1 });
|
||||
assert.deepEqual(
|
||||
filterStepsBySearchAndChip(steps, { query: 'sqlite neon' }).map((s) => s.stepIndex),
|
||||
[4]
|
||||
);
|
||||
assert.deepEqual(
|
||||
filterStepsBySearchAndChip(steps, { quickChip: 'compaction' }).map((s) => s.stepIndex),
|
||||
[3]
|
||||
);
|
||||
assert.deepEqual(
|
||||
filterStepsBySearchAndChip(steps, { quickChip: 'low_cache' }).map((s) => s.stepIndex),
|
||||
[4]
|
||||
);
|
||||
assert.deepEqual(
|
||||
filterStepsBySearchAndChip(steps, { quickChip: 'slow_ttft' }).map((s) => s.stepIndex),
|
||||
[4]
|
||||
);
|
||||
|
||||
const wf = computeStepTimingWaterfall(steps[0]);
|
||||
assert.equal(wf.totalSec, 38);
|
||||
assert.equal(wf.ttftSec, 32.4);
|
||||
assert.equal(wf.streamSec, 4.6);
|
||||
assert.equal(wf.otherSec, 1);
|
||||
|
||||
// Aligns slow_ttft strictly with danger TTFT tier (>= 30s), avoiding false positives on 10-29.9s steps
|
||||
assert.deepEqual(
|
||||
computeStepQuickChipCounts([
|
||||
{ stepIndex: 10, ttftSec: 12.4 },
|
||||
{ stepIndex: 11, ttftSec: 29.9 },
|
||||
{ stepIndex: 12, ttftSec: 30.0 },
|
||||
]).slow_ttft,
|
||||
1
|
||||
);
|
||||
|
||||
const md = buildStepDiagnosticMarkdown(steps[0], { prevContextTokens: 41_500 });
|
||||
assert.match(md, /Step #4/);
|
||||
assert.match(md, /Debug SQLite migrator/);
|
||||
assert.match(md, /\+79\.1k/);
|
||||
|
||||
// 2. Full StepsDetailView DOM integration: search input, diagnostic chips, row click -> drawer, keyboard Escape
|
||||
const prevDoc = globalThis.document;
|
||||
const prevWin = globalThis.window;
|
||||
const prevUi = { ...uiStore.getState() };
|
||||
const prevTel = { ...telemetryStore.getState() };
|
||||
const prevLocale = i18nStore.getState().locale;
|
||||
|
||||
const { document } = createMockDom();
|
||||
globalThis.document = document;
|
||||
globalThis.window = {
|
||||
innerWidth: 960,
|
||||
innerHeight: 720,
|
||||
addEventListener() {},
|
||||
removeEventListener() {},
|
||||
};
|
||||
setI18nLanguage('zh-CN');
|
||||
|
||||
let view = null;
|
||||
t.after(() => {
|
||||
view?.destroy?.();
|
||||
uiStore.setState(prevUi, { sync: true });
|
||||
telemetryStore.setState(prevTel, { sync: true });
|
||||
setI18nLanguage(prevLocale);
|
||||
globalThis.document = prevDoc;
|
||||
globalThis.window = prevWin;
|
||||
});
|
||||
|
||||
uiStore.setState({ activeView: 'steps', stepsSubTab: 'steps', monitorVisible: true }, { sync: true });
|
||||
telemetryStore.setState(
|
||||
{
|
||||
telemetry: {
|
||||
settings: { stepTableColumns: ['step', 'model', 'tps', 'cost'] },
|
||||
activeConversation: {
|
||||
cascadeId: 'cid-insp-1',
|
||||
stepCount: 3,
|
||||
recentSteps: steps,
|
||||
modelBreakdown: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
{ sync: true }
|
||||
);
|
||||
|
||||
view = StepsDetailView();
|
||||
document.body.appendChild(view.el);
|
||||
|
||||
// Filter toolbar visible with all 4 diagnostic chips
|
||||
assert.equal(view.refs.stepsFilterToolbarEl.hasAttribute('hidden'), false);
|
||||
const chipBtns = view.refs.stepQuickChipsEl.querySelectorAll('.steps-chip-btn');
|
||||
assert.equal(chipBtns.length, 4);
|
||||
assert.equal(chipBtns.every((b) => !b.hasAttribute('hidden')), true);
|
||||
|
||||
// Click Low Cache chip -> narrows table to step #4
|
||||
chipBtns[2].dispatchEvent({ type: 'click' });
|
||||
let rows = view.el.querySelectorAll('tbody tr');
|
||||
assert.equal(rows.length, 1);
|
||||
assert.equal(rows[0].children[0].textContent, '#4');
|
||||
|
||||
// Toggle chip off -> restores all 3 rows
|
||||
chipBtns[2].dispatchEvent({ type: 'click' });
|
||||
rows = view.el.querySelectorAll('tbody tr');
|
||||
assert.equal(rows.length, 3);
|
||||
|
||||
// Type search query "quota" -> narrows to step #2
|
||||
view.refs.stepSearchInput.value = 'quota';
|
||||
view.refs.stepSearchInput.dispatchEvent({ type: 'input', target: view.refs.stepSearchInput });
|
||||
rows = view.el.querySelectorAll('tbody tr');
|
||||
assert.equal(rows.length, 1);
|
||||
assert.equal(rows[0].children[0].textContent, '#2');
|
||||
|
||||
// Clear search -> click row #4 -> opens inspector drawer with prompt, waterfall, and delta
|
||||
view.refs.stepSearchInput.value = '';
|
||||
view.refs.stepSearchInput.dispatchEvent({ type: 'input', target: view.refs.stepSearchInput });
|
||||
rows = view.el.querySelectorAll('tbody tr');
|
||||
assert.equal(view.refs.stepInspectorDrawerEl.hasAttribute('hidden'), true);
|
||||
|
||||
rows[0].onclick();
|
||||
assert.equal(view.refs.stepInspectorDrawerEl.hasAttribute('hidden'), false);
|
||||
assert.equal(rows[0].classList.contains('is-selected'), true);
|
||||
assert.match(view.refs.stepInspectorDrawerEl.textContent, /Debug SQLite migrator/);
|
||||
assert.match(view.refs.stepInspectorDrawerEl.textContent, /\+79\.1k/);
|
||||
|
||||
// Close drawer cleanly by clicking same row again
|
||||
rows[0].onclick();
|
||||
assert.equal(view.refs.stepInspectorDrawerEl.hasAttribute('hidden'), true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user