mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(panel): add conversation turn rail, prompt preview, and decoupled step toggles
- Track user input turn boundaries and prompt previews in extractModelSteps while stripping compaction summary headers - Align interleaved main and subagent steps onto unified rootTurnIndex in telemetry-builder and scope lazy cache refresh to the active session family - Render dynamic left-edge turn rail and viewport-clamped prompt tooltip in StepsDetailView across arbitrary custom column orders - Decouple [主]/[子] agent badges from step index and add independent switches for Turn Rail and Agent Badge under Preferences -> Structure Co-authored-by: Swei <sweilo@qq.com>
This commit is contained in:
@@ -169,6 +169,31 @@ function enrichActiveConversationSteps(
|
||||
};
|
||||
});
|
||||
|
||||
// 关联每轮用户提问摘要与最新轮次标识,供步骤表极简导轨与气泡展示
|
||||
let maxTurnIndex = 0;
|
||||
const promptByTurn = new Map();
|
||||
for (const st of enrichedActiveSteps) {
|
||||
const tIdx = st.turnIndex;
|
||||
if (!Number.isInteger(tIdx) || tIdx <= 0) continue;
|
||||
if (tIdx > maxTurnIndex) maxTurnIndex = tIdx;
|
||||
if (st.turnPrompt && (st.isTurnStart || !promptByTurn.has(tIdx))) {
|
||||
promptByTurn.set(tIdx, st.turnPrompt);
|
||||
}
|
||||
}
|
||||
for (const st of enrichedActiveSteps) {
|
||||
const tIdx = st.turnIndex;
|
||||
if (!Number.isInteger(tIdx) || tIdx <= 0) {
|
||||
st.turnIndex = null;
|
||||
st.isTurnStart = false;
|
||||
st.isLatestTurn = false;
|
||||
st.turnPrompt = '';
|
||||
continue;
|
||||
}
|
||||
st.isTurnStart = Boolean(st.isTurnStart);
|
||||
st.isLatestTurn = tIdx === maxTurnIndex;
|
||||
st.turnPrompt = promptByTurn.get(tIdx) || '';
|
||||
}
|
||||
|
||||
const latestEnriched =
|
||||
enrichedActiveSteps.length > 0 ? enrichedActiveSteps[enrichedActiveSteps.length - 1] : null;
|
||||
const sessionAvgTokPerSec = roundMetric(sessionSpeed.avgTokPerSec);
|
||||
@@ -526,6 +551,54 @@ export async function buildTelemetryPayloadInternal(
|
||||
(a.agentIndex || 0) - (b.agentIndex || 0) ||
|
||||
(a.stepIndex || 0) - (b.stepIndex || 0)
|
||||
);
|
||||
|
||||
// 在多代理汇总视图下,将并行交错的子代理步骤按时间归入对应的主会话用户轮次,避免导轨被交错步骤切碎
|
||||
const mainTurnByIdx = new Map();
|
||||
let maxRootTurn = 0;
|
||||
for (const mSt of enrichedActiveSteps) {
|
||||
const tIdx = mSt.turnIndex;
|
||||
if (!Number.isInteger(tIdx) || tIdx <= 0) continue;
|
||||
if (tIdx > maxRootTurn) maxRootTurn = tIdx;
|
||||
if (!mainTurnByIdx.has(tIdx) || mSt.isTurnStart) {
|
||||
mainTurnByIdx.set(tIdx, {
|
||||
turnIndex: tIdx,
|
||||
startMs: mSt.createdAtMs || 0,
|
||||
prompt: mSt.turnPrompt || '',
|
||||
});
|
||||
}
|
||||
}
|
||||
const mainTurns = Array.from(mainTurnByIdx.values()).sort(
|
||||
(a, b) => a.turnIndex - b.turnIndex
|
||||
);
|
||||
if (mainTurns.length > 0) {
|
||||
const seenRootStarts = new Set();
|
||||
for (const st of allCombinedEnrichedSteps) {
|
||||
let matched = null;
|
||||
if (!st.isSubagent && Number.isInteger(st.turnIndex) && st.turnIndex > 0) {
|
||||
matched = mainTurnByIdx.get(st.turnIndex) || null;
|
||||
} else {
|
||||
const ts = st.createdAtMs || 0;
|
||||
for (let k = mainTurns.length - 1; k >= 0; k--) {
|
||||
if (ts >= mainTurns[k].startMs) {
|
||||
matched = mainTurns[k];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!matched) matched = mainTurns[0];
|
||||
}
|
||||
if (matched) {
|
||||
st.rootTurnIndex = matched.turnIndex;
|
||||
st.isRootLatestTurn = matched.turnIndex === maxRootTurn;
|
||||
st.rootTurnPrompt = matched.prompt || '';
|
||||
if (!seenRootStarts.has(matched.turnIndex)) {
|
||||
seenRootStarts.add(matched.turnIndex);
|
||||
st.isRootTurnStart = true;
|
||||
} else {
|
||||
st.isRootTurnStart = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const combinedSpeed = summarizeSpeed(allCombinedRawSteps);
|
||||
const combinedTtft = summarizeTtft(allCombinedRawSteps);
|
||||
const combinedAvgTokPerSec = roundMetric(combinedSpeed.avgTokPerSec);
|
||||
|
||||
Reference in New Issue
Block a user