mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
perf(panel): virtualize large step tables and optimize steps view switching and LOESS fit
This commit is contained in:
@@ -119,6 +119,7 @@ export const App = defineComponent({
|
||||
} else if (activeView === 'consumption') {
|
||||
consumptionView.refs?.viewScrollbar?.refresh();
|
||||
} else if (activeView === 'steps') {
|
||||
stepsView.refs?.refreshStepTableViewport?.();
|
||||
stepsView.refs?.stepsScroll?.refresh();
|
||||
stepsView.refs?.modelsScroll?.refresh();
|
||||
} else if (activeView === 'settings') {
|
||||
|
||||
@@ -327,7 +327,7 @@ export function computePublicationFit(
|
||||
|
||||
if (sw <= 1e-12) {
|
||||
const fallbackVal = ols.intercept + ols.slope * x0;
|
||||
return { rawFit: fallbackVal, leverageNormSq: 1 / n, diagHat: 1 / n };
|
||||
return { rawFit: fallbackVal, leverageNormSq: 1 / n, diagHat: 1 / n, localHatDiag: 1 / n };
|
||||
}
|
||||
|
||||
const mx = swx / sw;
|
||||
@@ -343,6 +343,7 @@ export function computePublicationFit(
|
||||
const useSlope = sxxW > 1e-12;
|
||||
const inverseWeightSum = 1 / sw;
|
||||
const slopeScale = useSlope ? dx0 / sxxW : 0;
|
||||
const localHatDiag = inverseWeightSum + (useSlope ? (dx0 * dx0) / sxxW : 0);
|
||||
let rawFit = 0;
|
||||
let leverageNormSq = 0;
|
||||
let diagHat = 0;
|
||||
@@ -356,21 +357,53 @@ export function computePublicationFit(
|
||||
if (j === diagIdx) diagHat = lj;
|
||||
}
|
||||
|
||||
return { rawFit, leverageNormSq, diagHat };
|
||||
return { rawFit, leverageNormSq, diagHat, localHatDiag };
|
||||
}
|
||||
|
||||
const rawSampleFits = new Float64Array(n);
|
||||
const sampleLevSq = new Float64Array(n);
|
||||
let sse = 0;
|
||||
let traceL = 0;
|
||||
let precomputedGridEval = null;
|
||||
|
||||
for (let i = 0; i < n; i++) {
|
||||
const res = evalLoessPoint(xs[i], i);
|
||||
rawSampleFits[i] = res.rawFit;
|
||||
sampleLevSq[i] = res.leverageNormSq;
|
||||
traceL += res.diagHat;
|
||||
const diff = ys[i] - res.rawFit;
|
||||
sse += diff * diff;
|
||||
// 大样本(n > 200 且 x 单调有序)采用与 R `stats::loess(surface = "interpolate")` 一致的网格插值加速:
|
||||
// 仅在 M 个均匀网格顶点做精确 LOESS(O(M·N)),再线性插值样本拟合值与杠杆度,避免 O(N²) 阻塞主线程。
|
||||
if (n > 200 && sortedXs && M >= 2) {
|
||||
const gridRawFit = new Float64Array(M);
|
||||
const gridLevSq = new Float64Array(M);
|
||||
const gridHatDiag = new Float64Array(M);
|
||||
for (let k = 0; k < M; k++) {
|
||||
const res = evalLoessPoint(gridXs[k], -1);
|
||||
gridRawFit[k] = res.rawFit;
|
||||
gridLevSq[k] = res.leverageNormSq;
|
||||
gridHatDiag[k] = res.localHatDiag;
|
||||
}
|
||||
precomputedGridEval = { gridRawFit, gridLevSq };
|
||||
|
||||
const invSpan = (M - 1) / xSpan;
|
||||
const maxK0 = M - 2;
|
||||
for (let i = 0; i < n; i++) {
|
||||
const u = (xs[i] - xMin) * invSpan;
|
||||
const k0 = u <= 0 ? 0 : u >= maxK0 ? maxK0 : Math.floor(u);
|
||||
const frac = Math.max(0, Math.min(1, u - k0));
|
||||
const rf = gridRawFit[k0] + frac * (gridRawFit[k0 + 1] - gridRawFit[k0]);
|
||||
const ls = Math.max(0, gridLevSq[k0] + frac * (gridLevSq[k0 + 1] - gridLevSq[k0]));
|
||||
const hd = gridHatDiag[k0] + frac * (gridHatDiag[k0 + 1] - gridHatDiag[k0]);
|
||||
rawSampleFits[i] = rf;
|
||||
sampleLevSq[i] = ls;
|
||||
traceL += hd;
|
||||
const diff = ys[i] - rf;
|
||||
sse += diff * diff;
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < n; i++) {
|
||||
const res = evalLoessPoint(xs[i], i);
|
||||
rawSampleFits[i] = res.rawFit;
|
||||
sampleLevSq[i] = res.leverageNormSq;
|
||||
traceL += res.diagHat;
|
||||
const diff = ys[i] - res.rawFit;
|
||||
sse += diff * diff;
|
||||
}
|
||||
}
|
||||
|
||||
const dfRes = Math.max(1, n - traceL);
|
||||
@@ -394,16 +427,27 @@ export function computePublicationFit(
|
||||
clampedSse += d * d;
|
||||
}
|
||||
|
||||
const grid = gridXs.map((gx) => {
|
||||
const res = evalLoessPoint(gx, -1);
|
||||
const half = tCrit * sigmaHat * Math.sqrt(res.leverageNormSq);
|
||||
return {
|
||||
x: gx,
|
||||
fit: clampValue(res.rawFit, minVal, maxVal),
|
||||
ciLow: clampValue(res.rawFit - half, minVal, maxVal),
|
||||
ciHigh: clampValue(res.rawFit + half, minVal, maxVal),
|
||||
};
|
||||
});
|
||||
const grid = precomputedGridEval
|
||||
? gridXs.map((gx, k) => {
|
||||
const rf = precomputedGridEval.gridRawFit[k];
|
||||
const half = tCrit * sigmaHat * Math.sqrt(Math.max(0, precomputedGridEval.gridLevSq[k]));
|
||||
return {
|
||||
x: gx,
|
||||
fit: clampValue(rf, minVal, maxVal),
|
||||
ciLow: clampValue(rf - half, minVal, maxVal),
|
||||
ciHigh: clampValue(rf + half, minVal, maxVal),
|
||||
};
|
||||
})
|
||||
: gridXs.map((gx) => {
|
||||
const res = evalLoessPoint(gx, -1);
|
||||
const half = tCrit * sigmaHat * Math.sqrt(res.leverageNormSq);
|
||||
return {
|
||||
x: gx,
|
||||
fit: clampValue(res.rawFit, minVal, maxVal),
|
||||
ciLow: clampValue(res.rawFit - half, minVal, maxVal),
|
||||
ciHigh: clampValue(res.rawFit + half, minVal, maxVal),
|
||||
};
|
||||
});
|
||||
|
||||
const r2Loess = syy > 1e-12 ? clampValue(1 - clampedSse / syy, 0, 1) : 1;
|
||||
|
||||
@@ -1659,14 +1703,19 @@ export function createModelFitChart() {
|
||||
const rect = svg.getBoundingClientRect();
|
||||
if (!rect || rect.width <= 0) return;
|
||||
const relX = ((e.clientX - rect.left) / rect.width) * viewW;
|
||||
let bestIdx = 0;
|
||||
let bestDist = Math.abs(currentSamples[0].x - relX);
|
||||
for (let i = 1; i < currentSamples.length; i++) {
|
||||
const d = Math.abs(currentSamples[i].x - relX);
|
||||
if (d < bestDist) {
|
||||
bestDist = d;
|
||||
bestIdx = i;
|
||||
}
|
||||
let lo = 0;
|
||||
let hi = currentSamples.length - 1;
|
||||
while (lo < hi) {
|
||||
const mid = (lo + hi) >>> 1;
|
||||
if (currentSamples[mid].x < relX) lo = mid + 1;
|
||||
else hi = mid;
|
||||
}
|
||||
let bestIdx = lo;
|
||||
if (
|
||||
lo > 0 &&
|
||||
Math.abs(currentSamples[lo - 1].x - relX) <= Math.abs(currentSamples[lo].x - relX)
|
||||
) {
|
||||
bestIdx = lo - 1;
|
||||
}
|
||||
showHoverAt(bestIdx);
|
||||
});
|
||||
@@ -2080,16 +2129,28 @@ export function createModelFitChart() {
|
||||
|
||||
const dotRadius =
|
||||
combinedSamples.length > 80 ? '1.8' : combinedSamples.length > 36 ? '2.1' : '2.4';
|
||||
const dedupOverdraw = combinedSamples.length > 200;
|
||||
const scatterTarget =
|
||||
typeof document.createDocumentFragment === 'function'
|
||||
? document.createDocumentFragment()
|
||||
: scatterGroup;
|
||||
|
||||
for (const s of seriesList) {
|
||||
const binCounts = dedupOverdraw ? new Map() : null;
|
||||
for (const sp of s.samples) {
|
||||
if (binCounts) {
|
||||
const binKey = (Math.round(sp.x * 2) << 11) ^ Math.round(sp.rawY * 2);
|
||||
const prevCnt = binCounts.get(binKey) || 0;
|
||||
if (prevCnt >= 6) continue;
|
||||
binCounts.set(binKey, prevCnt + 1);
|
||||
}
|
||||
const dot = document.createElementNS(SVG_NS, 'circle');
|
||||
dot.setAttribute('cx', sp.x.toFixed(1));
|
||||
dot.setAttribute('cy', sp.rawY.toFixed(1));
|
||||
dot.setAttribute('r', dotRadius);
|
||||
dot.setAttribute('class', 'sstep-scatter-dot is-multi');
|
||||
patchStyleVar(dot, '--sstep-fit-accent', s.colorVar);
|
||||
scatterGroup.appendChild(dot);
|
||||
scatterTarget.appendChild(dot);
|
||||
}
|
||||
|
||||
if (s.samples.length === 1) {
|
||||
@@ -2139,6 +2200,9 @@ export function createModelFitChart() {
|
||||
multiCurveGroup.appendChild(curveEl);
|
||||
}
|
||||
}
|
||||
if (scatterTarget !== scatterGroup) {
|
||||
scatterGroup.appendChild(scatterTarget);
|
||||
}
|
||||
|
||||
while (multiLegendEl.firstChild) multiLegendEl.removeChild(multiLegendEl.firstChild);
|
||||
for (const s of seriesList) {
|
||||
@@ -2271,13 +2335,27 @@ export function createModelFitChart() {
|
||||
// 2. 绘制半透明冷蓝灰实心观测散点(自然呈现局部密度,不抢夺拟合曲线焦点)
|
||||
while (scatterGroup.firstChild) scatterGroup.removeChild(scatterGroup.firstChild);
|
||||
const dotRadius = samples.length > 80 ? '1.8' : samples.length > 36 ? '2.1' : '2.4';
|
||||
const binCounts = samples.length > 200 ? new Map() : null;
|
||||
const scatterTarget =
|
||||
typeof document.createDocumentFragment === 'function'
|
||||
? document.createDocumentFragment()
|
||||
: scatterGroup;
|
||||
for (const s of samples) {
|
||||
if (binCounts) {
|
||||
const binKey = (Math.round(s.x * 2) << 11) ^ Math.round(s.rawY * 2);
|
||||
const prevCnt = binCounts.get(binKey) || 0;
|
||||
if (prevCnt >= 6) continue;
|
||||
binCounts.set(binKey, prevCnt + 1);
|
||||
}
|
||||
const dot = document.createElementNS(SVG_NS, 'circle');
|
||||
dot.setAttribute('cx', s.x.toFixed(1));
|
||||
dot.setAttribute('cy', s.rawY.toFixed(1));
|
||||
dot.setAttribute('r', dotRadius);
|
||||
dot.setAttribute('class', 'sstep-scatter-dot');
|
||||
scatterGroup.appendChild(dot);
|
||||
scatterTarget.appendChild(dot);
|
||||
}
|
||||
if (scatterTarget !== scatterGroup) {
|
||||
scatterGroup.appendChild(scatterTarget);
|
||||
}
|
||||
|
||||
// 3. 绘制 95% CI 置信带闭合多边形与回归拟合曲线(绝不向底部 X 轴填充面积!)
|
||||
|
||||
@@ -2203,6 +2203,7 @@ export function mountWindowOverlay() {
|
||||
} else if (activeView === 'consumption') {
|
||||
refs?.consumptionView?.refs?.viewScrollbar?.refresh();
|
||||
} else if (activeView === 'steps') {
|
||||
refs?.stepsView?.refs?.refreshStepTableViewport?.();
|
||||
refs?.stepsView?.refs?.stepsScroll?.refresh();
|
||||
refs?.stepsView?.refs?.modelsScroll?.refresh();
|
||||
} else if (activeView === 'settings') {
|
||||
|
||||
@@ -34,6 +34,7 @@ export const CustomScrollbar = defineComponent({
|
||||
let isDragging = false;
|
||||
let dragStartY = 0;
|
||||
let dragStartScrollTop = 0;
|
||||
let scrollRafId = 0;
|
||||
|
||||
function syncThumb() {
|
||||
const scrollHeight = Number(contentEl.scrollHeight || 0);
|
||||
@@ -60,7 +61,15 @@ export const CustomScrollbar = defineComponent({
|
||||
}
|
||||
|
||||
function onContentScroll() {
|
||||
syncThumb();
|
||||
if (isDragging || typeof requestAnimationFrame !== 'function') {
|
||||
syncThumb();
|
||||
return;
|
||||
}
|
||||
if (scrollRafId) return;
|
||||
scrollRafId = requestAnimationFrame(() => {
|
||||
scrollRafId = 0;
|
||||
syncThumb();
|
||||
});
|
||||
}
|
||||
|
||||
function onDocMouseMove(e) {
|
||||
@@ -115,7 +124,7 @@ export const CustomScrollbar = defineComponent({
|
||||
syncThumb();
|
||||
});
|
||||
|
||||
contentEl.addEventListener('scroll', onContentScroll);
|
||||
contentEl.addEventListener('scroll', onContentScroll, { passive: true });
|
||||
hostEl.addEventListener('mouseenter', syncThumb);
|
||||
|
||||
let resizeObserver = null;
|
||||
@@ -129,6 +138,10 @@ export const CustomScrollbar = defineComponent({
|
||||
|
||||
onCleanup(() => {
|
||||
onDocMouseUp();
|
||||
if (scrollRafId && typeof cancelAnimationFrame === 'function') {
|
||||
cancelAnimationFrame(scrollRafId);
|
||||
scrollRafId = 0;
|
||||
}
|
||||
contentEl.removeEventListener('scroll', onContentScroll);
|
||||
hostEl.removeEventListener('mouseenter', syncThumb);
|
||||
if (resizeObserver) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -494,7 +494,7 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
[data-modern-ui="true"] .data-table tbody tr {
|
||||
[data-modern-ui="true"] .data-table tbody tr:not(.step-vspacer):not(.step-vsizer) {
|
||||
transition: background-color 130ms var(--ease-modern);
|
||||
}
|
||||
|
||||
@@ -506,11 +506,13 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
|
||||
animation: anim-modern-step-cell-in 300ms cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||
}
|
||||
|
||||
[data-modern-ui="true"] .data-table tbody tr:nth-child(even) {
|
||||
[data-modern-ui="true"] .data-table:not(.is-virtualized) tbody tr:nth-child(even),
|
||||
[data-modern-ui="true"] .data-table.is-virtualized tbody tr.is-stripe-even {
|
||||
background: var(--modern-stripe-bg);
|
||||
}
|
||||
|
||||
[data-modern-ui="true"] .data-table tbody tr:hover {
|
||||
[data-modern-ui="true"] .data-table tbody tr:not(.step-vspacer):not(.step-vsizer):hover,
|
||||
[data-modern-ui="true"] .data-table.is-virtualized tbody tr.is-stripe-even:hover {
|
||||
background: var(--modern-surface-hover);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
.table-viewport.is-step-table {
|
||||
overflow-x: auto;
|
||||
overflow-anchor: none;
|
||||
}
|
||||
|
||||
/* --- 2. 粘性表头数据表 (Sticky-Header Data Table) --- */
|
||||
@@ -72,10 +73,44 @@
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.data-table tbody tr:hover {
|
||||
.data-table tbody tr:not(.step-vspacer):not(.step-vsizer):hover {
|
||||
background: var(--surface-hover);
|
||||
}
|
||||
|
||||
.data-table tbody tr.step-vspacer,
|
||||
.data-table tbody tr.step-vspacer:hover,
|
||||
.data-table tbody tr.step-vsizer,
|
||||
.data-table tbody tr.step-vsizer:hover {
|
||||
background: transparent !important;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.data-table tbody tr.step-vsizer {
|
||||
visibility: hidden;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.data-table tbody tr.step-vsizer td {
|
||||
padding-top: 0 !important;
|
||||
padding-bottom: 0 !important;
|
||||
border: none !important;
|
||||
line-height: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.step-vsizer-inner {
|
||||
display: block;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.data-table tbody tr.step-vspacer td.step-vspacer-cell {
|
||||
padding: 0 !important;
|
||||
border: none !important;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
.step-model-cell {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
|
||||
@@ -260,8 +260,10 @@ export const StepsDetailView = defineComponent({
|
||||
});
|
||||
|
||||
// --- 子视图 1:单步明细表(委托给可复用的 `StepTableWidget` 解耦组件) ---
|
||||
let stepsScroll = null;
|
||||
const stepTableWidget = StepTableWidget({
|
||||
onSelectAgentScopes: applyAgentScopesSelection,
|
||||
onVirtualHeightChange: () => stepsScroll?.refresh(),
|
||||
});
|
||||
const {
|
||||
stepsTablePane,
|
||||
@@ -272,8 +274,9 @@ export const StepsDetailView = defineComponent({
|
||||
hideTurnTip,
|
||||
syncTableHeaderColumns,
|
||||
renderStepTable,
|
||||
refreshViewport: refreshStepTableViewport,
|
||||
} = stepTableWidget.refs;
|
||||
const stepsScroll = CustomScrollbar({
|
||||
stepsScroll = CustomScrollbar({
|
||||
contentEl: stepsTablePane,
|
||||
className: 'table-scroll-host',
|
||||
});
|
||||
@@ -432,6 +435,19 @@ export const StepsDetailView = defineComponent({
|
||||
|
||||
let latestSlice = null;
|
||||
let isDirty = false;
|
||||
let cachedChronoSrc = null;
|
||||
let cachedChronoMerged = false;
|
||||
let cachedChronoOut = [];
|
||||
|
||||
function getMemoizedChronoSteps(steps, isMergedMultiAgents) {
|
||||
if (cachedChronoSrc === steps && cachedChronoMerged === isMergedMultiAgents) {
|
||||
return cachedChronoOut;
|
||||
}
|
||||
cachedChronoSrc = steps;
|
||||
cachedChronoMerged = isMergedMultiAgents;
|
||||
cachedChronoOut = toChronologicalSteps(steps, isMergedMultiAgents);
|
||||
return cachedChronoOut;
|
||||
}
|
||||
|
||||
function resolveDefaultActiveModelKey(scopedConv, chronoSteps, models, availableModelKeys) {
|
||||
if (scopedConv?.hasKnownModel !== false) {
|
||||
@@ -618,33 +634,14 @@ export const StepsDetailView = defineComponent({
|
||||
|
||||
const showAgentPrefix = isMergedMultiAgents;
|
||||
const showModels = uiSt.stepsSubTab === 'models';
|
||||
const chronoSteps = toChronologicalSteps(steps, isMergedMultiAgents);
|
||||
|
||||
const stepTtftFallbackMap = new Map();
|
||||
const stepModelOptionMap = new Map();
|
||||
for (const st of chronoSteps) {
|
||||
const gk = getStepModelGroupKey(st);
|
||||
if (!stepModelOptionMap.has(gk)) {
|
||||
const disp = resolveModelDisplayInfo(st, displaySettings, { fallback: gk });
|
||||
stepModelOptionMap.set(gk, {
|
||||
label: disp.baseText || disp.text || gk,
|
||||
calls: 0,
|
||||
});
|
||||
}
|
||||
stepModelOptionMap.get(gk).calls += 1;
|
||||
|
||||
if (showModels && !st.isCompactionStep && Number.isFinite(st.ttftSec) && st.ttftSec >= 0) {
|
||||
const prev = stepTtftFallbackMap.get(gk) || { sum: 0, count: 0 };
|
||||
prev.sum += Number(st.ttftSec);
|
||||
prev.count += 1;
|
||||
stepTtftFallbackMap.set(gk, prev);
|
||||
}
|
||||
}
|
||||
|
||||
const availableModelKeys = new Set();
|
||||
const modelColorByGroup = new Map();
|
||||
const perModelOptions = [];
|
||||
let breakdownCalls = 0;
|
||||
for (const m of models) {
|
||||
if (!m || typeof m !== 'object') continue;
|
||||
breakdownCalls += Math.max(0, Number(m.calls || 0));
|
||||
const gk = getStepModelGroupKey(m);
|
||||
if (availableModelKeys.has(gk)) continue;
|
||||
availableModelKeys.add(gk);
|
||||
@@ -662,18 +659,35 @@ export const StepsDetailView = defineComponent({
|
||||
meta: t('header.convMetaSteps', { count: Number(m.calls || 0) }),
|
||||
});
|
||||
}
|
||||
for (const [gk, info] of stepModelOptionMap.entries()) {
|
||||
if (!availableModelKeys.has(gk)) {
|
||||
availableModelKeys.add(gk);
|
||||
modelColorByGroup.set(
|
||||
gk,
|
||||
MODEL_COLOR_VARS[(availableModelKeys.size - 1) % MODEL_COLOR_VARS.length]
|
||||
);
|
||||
perModelOptions.push({
|
||||
value: gk,
|
||||
label: info.label,
|
||||
meta: t('header.convMetaSteps', { count: info.calls }),
|
||||
});
|
||||
|
||||
const needStepModelFallback =
|
||||
steps.length > 0 && (models.length === 0 || breakdownCalls < steps.length);
|
||||
if (needStepModelFallback) {
|
||||
const stepModelOptionMap = new Map();
|
||||
for (const st of steps) {
|
||||
const gk = getStepModelGroupKey(st);
|
||||
if (!stepModelOptionMap.has(gk)) {
|
||||
const disp = resolveModelDisplayInfo(st, displaySettings, { fallback: gk });
|
||||
stepModelOptionMap.set(gk, {
|
||||
label: disp.baseText || disp.text || gk,
|
||||
calls: 0,
|
||||
});
|
||||
}
|
||||
stepModelOptionMap.get(gk).calls += 1;
|
||||
}
|
||||
for (const [gk, info] of stepModelOptionMap.entries()) {
|
||||
if (!availableModelKeys.has(gk)) {
|
||||
availableModelKeys.add(gk);
|
||||
modelColorByGroup.set(
|
||||
gk,
|
||||
MODEL_COLOR_VARS[(availableModelKeys.size - 1) % MODEL_COLOR_VARS.length]
|
||||
);
|
||||
perModelOptions.push({
|
||||
value: gk,
|
||||
label: info.label,
|
||||
meta: t('header.convMetaSteps', { count: info.calls }),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -749,6 +763,23 @@ export const StepsDetailView = defineComponent({
|
||||
allowNewRowFade: shouldAnimateNewRows,
|
||||
});
|
||||
stepsScroll.refresh();
|
||||
fitPinnedWhileVisible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const chronoSteps = getMemoizedChronoSteps(steps, isMergedMultiAgents);
|
||||
const stepTtftFallbackMap = new Map();
|
||||
const needTtftFallback = models.some((m) => m && m.avgTtftSec == null);
|
||||
if (needTtftFallback) {
|
||||
for (const st of chronoSteps) {
|
||||
if (!st.isCompactionStep && Number.isFinite(st.ttftSec) && st.ttftSec >= 0) {
|
||||
const gk = getStepModelGroupKey(st);
|
||||
const prev = stepTtftFallbackMap.get(gk) || { sum: 0, count: 0 };
|
||||
prev.sum += Number(st.ttftSec);
|
||||
prev.count += 1;
|
||||
stepTtftFallbackMap.set(gk, prev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 顶部“会话走势”更新
|
||||
@@ -768,15 +799,11 @@ export const StepsDetailView = defineComponent({
|
||||
? ['__all__']
|
||||
: Array.from(new Set(fitLockedModelKeys.filter((k) => availableModelKeys.has(k))));
|
||||
|
||||
if (!showModels) {
|
||||
fitPinnedWhileVisible = false;
|
||||
}
|
||||
if ((!fitPinnedWhileVisible && !fitUserPicked) || sanitizedLocked.length === 0) {
|
||||
fitLockedModelKeys = [defaultActiveModelKey];
|
||||
} else {
|
||||
fitLockedModelKeys = sanitizedLocked;
|
||||
}
|
||||
if (!showModels) return;
|
||||
if (availableModelKeys.size > 0) fitPinnedWhileVisible = true;
|
||||
|
||||
patchAttr(lineModelSelect.el, 'hidden', !hasMultipleModels);
|
||||
@@ -1049,6 +1076,7 @@ export const StepsDetailView = defineComponent({
|
||||
if (getVisibleMonitorView() === 'steps' && latestSlice) {
|
||||
renderStepsData(latestSlice);
|
||||
} else if (tab === 'steps') {
|
||||
refreshStepTableViewport();
|
||||
stepsScroll.refresh();
|
||||
} else {
|
||||
modelsScroll.refresh();
|
||||
@@ -1173,6 +1201,7 @@ export const StepsDetailView = defineComponent({
|
||||
fitMetricSwitch,
|
||||
stepsScroll,
|
||||
modelsScroll,
|
||||
refreshStepTableViewport,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user