mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(panel): add hybrid SQLite+WAL reader, side-question dedup, and cache throttling
- Read local conversation_summaries.db and <id>.db (+ .db-wal composite signatures) first while falling back to RPC when local DBs are absent - Deduplicate cloned parent steps and gen_metadata across forks and Side Questions, render zh/en Side Question badges, and protect mainline context watermarks - Throttle trajectory_usage_cache.json writes to 30s during RUNNING sessions and flush immediately on IDLE or exit - Add phased pricing for gemini-4-argon-b and gemini-4-argon-trial, and suppress false upstream update prompts on custom GitHub forks Co-authored-by: orbitoo <elbertoo001@gmail.com>
This commit is contained in:
@@ -523,6 +523,11 @@ export function aggregateMultiWindowUsage({
|
||||
let latestSelectedStepMs = 0;
|
||||
|
||||
const currentYear = new Date(nowMs).getFullYear();
|
||||
const monthBoundsMs = Array.from({ length: 13 }, (_, idx) =>
|
||||
new Date(currentYear, idx, 1).getTime()
|
||||
);
|
||||
const yearStartMs = monthBoundsMs[0];
|
||||
const nextYearStartMs = monthBoundsMs[12];
|
||||
const monthlySeries = Array.from({ length: 12 }, (_, idx) => ({
|
||||
month: idx + 1,
|
||||
label: `${idx + 1}月`,
|
||||
@@ -665,21 +670,25 @@ export function aggregateMultiWindowUsage({
|
||||
const stepUsage = { inTok, cacheTok, outTok, thinkTok, respTok, stepTotalTokens,
|
||||
resolvedCost, savedCost, unpriced };
|
||||
|
||||
if (tMs > 0) {
|
||||
const stepDate = new Date(tMs);
|
||||
if (stepDate.getFullYear() === currentYear) {
|
||||
const mBucket = monthlySeries[stepDate.getMonth()];
|
||||
if (mBucket) {
|
||||
mBucket.calls += 1;
|
||||
mBucket.inputTokens += inTok;
|
||||
mBucket.cacheReadTokens += cacheTok;
|
||||
mBucket.responseTokens += respTok;
|
||||
mBucket.thinkingTokens += thinkTok;
|
||||
mBucket.totalTokens += stepTotalTokens;
|
||||
mBucket.costUsd += resolvedCost;
|
||||
mBucket.unpricedCalls = (mBucket.unpricedCalls || 0) + unpriced;
|
||||
if (tMs >= yearStartMs && tMs < nextYearStartMs) {
|
||||
let monthIdx = 11;
|
||||
for (let m = 0; m < 12; m++) {
|
||||
if (tMs < monthBoundsMs[m + 1]) {
|
||||
monthIdx = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const mBucket = monthlySeries[monthIdx];
|
||||
if (mBucket) {
|
||||
mBucket.calls += 1;
|
||||
mBucket.inputTokens += inTok;
|
||||
mBucket.cacheReadTokens += cacheTok;
|
||||
mBucket.responseTokens += respTok;
|
||||
mBucket.thinkingTokens += thinkTok;
|
||||
mBucket.totalTokens += stepTotalTokens;
|
||||
mBucket.costUsd += resolvedCost;
|
||||
mBucket.unpricedCalls = (mBucket.unpricedCalls || 0) + unpriced;
|
||||
}
|
||||
}
|
||||
|
||||
for (const k of presetKeys) {
|
||||
|
||||
Reference in New Issue
Block a user