mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(panel): add inline CLI statusLine capsule, step speed color toggle, and refined defaults
- Auto-provision native Antigravity CLI `statusLine` (`stack_with_default: false`) in `~/.gemini/antigravity-cli/settings.json` while strictly preserving custom third-party `statusLine.command` scripts, using zero-double-quote Windows commands compatible with Go `syscall.EscapeArg` under `cmd /c` - Add `cli-statusline.mjs` and `cli-statusline-config.mjs` to render a single-line transparent 24-bit ANSI footer (`? for shortcuts` left, live multi-session & 1..5 capsule metrics centered, deduplicated `mode · model · effort` right) with responsive narrow-terminal fallbacks and `stdin` quota fallback - Persist `cli-status-snapshot.json` during telemetry builds and self-heal sidecar restarts inside `executeTelemetryAction` error paths when `computeRuntimeCodeVersion()` advances - Add `enableCliStatusLine` and `showStepSpeedColor` preferences in Settings -> Structure, rename the mount sub-tab/section label in `zh-CN` to `挂载胶囊`, set default `topbarCapsuleSlots` to `['tps', 'ttft', 'context']`, and default `showStepTurnRail` and `showStepSpeedColor` to `false` - Add unit and end-to-end tests across `backend.test.mjs` and `window-bridge.test.mjs`, and update `README.md` / `README.zh-CN.md`
This commit is contained in:
@@ -18,11 +18,13 @@ import {
|
||||
summarizeTtft,
|
||||
} from '../speed-metrics.mjs';
|
||||
import {
|
||||
CLI_STATUS_SNAPSHOT_FILE,
|
||||
computeRuntimeCodeVersion,
|
||||
inFlightRequests,
|
||||
loadSettings,
|
||||
lsRuntimeEndpoint,
|
||||
roundMetric,
|
||||
saveJson,
|
||||
trajectoryCache,
|
||||
} from './config.mjs';
|
||||
import { getContextWindowGroups, getContextWindowModels } from './context-windows.mjs';
|
||||
@@ -1383,7 +1385,7 @@ export async function buildTelemetryPayloadInternal(
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
const finalPayload = {
|
||||
timestamp: new Date().toISOString(),
|
||||
uiBundleVersion,
|
||||
settings,
|
||||
@@ -1528,6 +1530,55 @@ export async function buildTelemetryPayloadInternal(
|
||||
},
|
||||
modelBreakdown,
|
||||
};
|
||||
|
||||
if (lsRuntimeEndpoint.addr !== 'test.invalid') {
|
||||
try {
|
||||
saveJson(CLI_STATUS_SNAPSHOT_FILE, buildCliStatusSnapshot(finalPayload, Date.now()));
|
||||
} catch {
|
||||
// 快照落盘属于旁路辅助能力,任何异常绝不阻断主遥测响应
|
||||
}
|
||||
}
|
||||
|
||||
return finalPayload;
|
||||
}
|
||||
|
||||
export function buildCliStatusSnapshot(finalPayload, updatedAtMs = Date.now()) {
|
||||
const ac = finalPayload?.activeConversation || {};
|
||||
const capSource = ac.aggregated || ac;
|
||||
const ctx = ac.context || {};
|
||||
const limitTok = Number(ctx.compactionLimitTokens || ctx.limitTokens || 256000);
|
||||
const totalTok = Number(ctx.totalTokens || 0);
|
||||
const usedPctVal =
|
||||
limitTok > 0 ? Math.min(100, +((totalTok / limitTok) * 100).toFixed(1)) : 0;
|
||||
|
||||
const runningList = Array.isArray(finalPayload?.runningConversations)
|
||||
? finalPayload.runningConversations
|
||||
: [];
|
||||
|
||||
return {
|
||||
updatedAtMs,
|
||||
runningCount: runningList.length,
|
||||
runningSubCount: runningList.reduce(
|
||||
(acc, item) => acc + Number(item?.runningSubagentCount || 0),
|
||||
0
|
||||
),
|
||||
hasWaiting: runningList.some((item) => item?.mainActivity?.phase === 'waiting'),
|
||||
quotas: finalPayload?.quotas || null,
|
||||
activeConversation: {
|
||||
cascadeId: ac.cascadeId || '',
|
||||
isRunning: Boolean(capSource.isRunning || ac.isRunning),
|
||||
stepCount: Number(capSource.stepCount ?? ac.stepCount ?? 0),
|
||||
usedPct: usedPctVal,
|
||||
latestTokPerSec: capSource.latestTokPerSec ?? ac.latestTokPerSec ?? null,
|
||||
avgTokPerSec: capSource.avgTokPerSec ?? ac.avgTokPerSec ?? null,
|
||||
latestTtftSec: capSource.latestTtftSec ?? ac.latestTtftSec ?? null,
|
||||
latestStepCostUsd: capSource.latestStepCostUsd ?? ac.latestStepCostUsd ?? null,
|
||||
sessionCostUsd: capSource.sessionCostUsd ?? ac.sessionCostUsd ?? null,
|
||||
latestCacheHitPct: capSource.latestCacheHitPct ?? ac.latestCacheHitPct ?? null,
|
||||
latestPromptTokens: Number(capSource.latestPromptTokens ?? ac.latestPromptTokens ?? 0),
|
||||
totalTokens: Number(capSource.totalTokens ?? ac.totalTokens ?? 0),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user