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:
@@ -878,6 +878,7 @@ export async function enumerateAndSyncConversations({
|
||||
wasRunning: isRunning,
|
||||
contextLimitTelemetry: true,
|
||||
speedClearedTelemetry: true,
|
||||
turnRailTelemetry: true,
|
||||
steps,
|
||||
subagentRefs,
|
||||
};
|
||||
@@ -900,6 +901,7 @@ export async function enumerateAndSyncConversations({
|
||||
Boolean(prev.wasRunning) !== isRunning ||
|
||||
!prev.contextLimitTelemetry ||
|
||||
!prev.speedClearedTelemetry ||
|
||||
!prev.turnRailTelemetry ||
|
||||
metaChanged ||
|
||||
JSON.stringify(prev.steps) !== JSON.stringify(steps);
|
||||
|
||||
@@ -948,13 +950,28 @@ export async function enumerateAndSyncConversations({
|
||||
const selectedRootId = rawConversations.find(
|
||||
(c) => c.cascadeId.toLowerCase() === contextTelemetryCascadeId
|
||||
)?.rootConversationId || contextTelemetryCascadeId;
|
||||
function hasMissingTurnRailFields(cached) {
|
||||
const steps = cached?.steps || [];
|
||||
const lastCachedStep = steps[steps.length - 1];
|
||||
if (!lastCachedStep) return false;
|
||||
return !Object.prototype.hasOwnProperty.call(lastCachedStep, 'turnIndex');
|
||||
}
|
||||
|
||||
let remainingTimingRefreshes = LEGACY_MIGRATION_BATCH_SIZE;
|
||||
const toFetch = rawConversations.filter((conv) => {
|
||||
const sig = buildConvSig(conv);
|
||||
if (isFetchInCooldown(conv, sig)) return false;
|
||||
const cached = trajectoryCache[conv.cascadeId];
|
||||
if (!cached || conv.needsInitialLoad) return true;
|
||||
if (!cached.contextLimitTelemetry && conv.cascadeId.toLowerCase() === contextTelemetryCascadeId) return true;
|
||||
const lowerCid = conv.cascadeId.toLowerCase();
|
||||
const isSelectedFamily =
|
||||
lowerCid === contextTelemetryCascadeId ||
|
||||
lowerCid === selectedRootId ||
|
||||
Boolean(conv.rootConversationId && conv.rootConversationId.toLowerCase() === selectedRootId);
|
||||
if (!cached.contextLimitTelemetry && lowerCid === contextTelemetryCascadeId) return true;
|
||||
if ((!cached.turnRailTelemetry || hasMissingTurnRailFields(cached)) && isSelectedFamily) {
|
||||
return true;
|
||||
}
|
||||
const hasCurrentSchema = String(cached.signature || '').startsWith(
|
||||
`${CACHE_SCHEMA_VERSION}:`
|
||||
);
|
||||
@@ -1064,10 +1081,13 @@ export async function enumerateAndSyncConversations({
|
||||
|
||||
const targetCacheKey = subConv.cascadeId;
|
||||
const existingSubCache = trajectoryCache[targetCacheKey];
|
||||
const isSelectedSubFamily = rootId === selectedRootId;
|
||||
const hasValidSubCache =
|
||||
existingSubCache &&
|
||||
String(existingSubCache.signature || '').startsWith(`${CACHE_SCHEMA_VERSION}:`) &&
|
||||
!hasMissingStepFields(existingSubCache);
|
||||
!hasMissingStepFields(existingSubCache) &&
|
||||
(!isSelectedSubFamily ||
|
||||
(Boolean(existingSubCache.turnRailTelemetry) && !hasMissingTurnRailFields(existingSubCache)));
|
||||
|
||||
if (hasValidSubCache) {
|
||||
let subMetaUpdated = false;
|
||||
|
||||
@@ -360,6 +360,8 @@ export const DEFAULT_SETTINGS_SCHEMA = Object.freeze({
|
||||
hoverModules: DEFAULT_HOVER_MODULES,
|
||||
overviewModules: DEFAULT_OVERVIEW_MODULES,
|
||||
overviewMetrics: DEFAULT_OVERVIEW_METRICS,
|
||||
showStepTurnRail: true,
|
||||
showStepAgentBadge: true,
|
||||
stepTableColumns: DEFAULT_STEP_TABLE_COLUMNS,
|
||||
modelContextWindows: Object.freeze({}),
|
||||
});
|
||||
@@ -386,6 +388,8 @@ export function createDefaultSettingsObject() {
|
||||
hoverModules: [...DEFAULT_HOVER_MODULES],
|
||||
overviewModules: [...DEFAULT_OVERVIEW_MODULES],
|
||||
overviewMetrics: [...DEFAULT_OVERVIEW_METRICS],
|
||||
showStepTurnRail: DEFAULT_SETTINGS_SCHEMA.showStepTurnRail,
|
||||
showStepAgentBadge: DEFAULT_SETTINGS_SCHEMA.showStepAgentBadge,
|
||||
stepTableColumns: [...DEFAULT_STEP_TABLE_COLUMNS],
|
||||
modelContextWindows: {},
|
||||
};
|
||||
@@ -430,6 +434,8 @@ export function normalizeFullSettings(rawInput) {
|
||||
hoverModules: normalizeHoverModules(safeRaw.hoverModules),
|
||||
overviewModules: normalizeOverviewModules(safeRaw.overviewModules),
|
||||
overviewMetrics: normalizeOverviewMetrics(safeRaw.overviewMetrics),
|
||||
showStepTurnRail: safeRaw.showStepTurnRail !== false,
|
||||
showStepAgentBadge: safeRaw.showStepAgentBadge !== false,
|
||||
stepTableColumns: normalizeStepTableColumns(safeRaw.stepTableColumns),
|
||||
modelContextWindows: normalizeModelContextWindows(safeRaw.modelContextWindows),
|
||||
};
|
||||
|
||||
@@ -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