mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(panel): add 3rd-level structure menu, real-UI live previews, drag reorder, and unified capsule tones
This commit is contained in:
@@ -0,0 +1,390 @@
|
||||
/**
|
||||
* @fileoverview Realistic Simulated Telemetry Builder (`structurePreviewMock.js`)
|
||||
* for `SettingsStructureTab` real-UI live previews.
|
||||
* Exercises all 13 capsule metrics, 8 overview metrics, 10 context channels + subagents,
|
||||
* multi-pool quotas, live running task + subagent, and 12 step table columns.
|
||||
*/
|
||||
|
||||
import { t } from '../../i18n/index.js';
|
||||
|
||||
export function buildStructurePreviewTelemetry(baseSettings = {}, draftOverrides = {}) {
|
||||
const anchorMinMs = Math.floor(Date.now() / 60000) * 60000;
|
||||
const reset5hIso = new Date(anchorMinMs + (2 * 60 + 42) * 60000).toISOString();
|
||||
const resetWkIso = new Date(anchorMinMs + (4 * 24 * 60 + 180) * 60000).toISOString();
|
||||
const resetClaude5hIso = new Date(anchorMinMs + (1 * 60 + 18) * 60000).toISOString();
|
||||
|
||||
const mergedSettings = {
|
||||
...(baseSettings && typeof baseSettings === 'object' ? baseSettings : {}),
|
||||
...draftOverrides,
|
||||
};
|
||||
|
||||
const sessionTitle = t('settings.mock.sessionTitle');
|
||||
const subRole = t('settings.mock.subRole');
|
||||
const promptLatest = t('settings.mock.turnPromptLatest');
|
||||
const promptPrev = t('settings.mock.turnPromptPrev');
|
||||
|
||||
const mainContext = {
|
||||
totalTokens: 142800,
|
||||
limitTokens: 256000,
|
||||
compactionLimitTokens: 256000,
|
||||
usedPct: 55.8,
|
||||
toolResultsTokens: 86400,
|
||||
assistantTokens: 24200,
|
||||
systemToolsTokens: 11800,
|
||||
checkpointTokens: 7600,
|
||||
systemPromptTokens: 5800,
|
||||
skillsTokens: 3100,
|
||||
userRulesTokens: 1900,
|
||||
userInputTokens: 1120,
|
||||
mcpToolsTokens: 540,
|
||||
subagentTokens: 340,
|
||||
};
|
||||
|
||||
const subContext = {
|
||||
totalTokens: 72704,
|
||||
limitTokens: 256000,
|
||||
compactionLimitTokens: 256000,
|
||||
usedPct: 28.4,
|
||||
toolResultsTokens: 51200,
|
||||
assistantTokens: 11400,
|
||||
systemToolsTokens: 5600,
|
||||
systemPromptTokens: 3400,
|
||||
userInputTokens: 1104,
|
||||
checkpointTokens: 0,
|
||||
skillsTokens: 0,
|
||||
userRulesTokens: 0,
|
||||
mcpToolsTokens: 0,
|
||||
subagentTokens: 0,
|
||||
};
|
||||
|
||||
const mockSteps = [
|
||||
{
|
||||
stepIndex: 24,
|
||||
agentCascadeId: 'mock-main',
|
||||
agentId: 'main',
|
||||
agentIndex: 0,
|
||||
isSubagent: false,
|
||||
agentBadge: '主',
|
||||
agentLabel: t('fmt.mainAgent'),
|
||||
modelLabel: 'Gemini 4 Carbon (High)',
|
||||
modelShort: 'gemini-4-carbon',
|
||||
rawModel: 'MODEL_PLACEHOLDER_M37',
|
||||
upstreamModel: 'gemini-4-carbon-high',
|
||||
tokPerSec: 68.4,
|
||||
ttftSec: 1.15,
|
||||
totalDurationSec: 12.6,
|
||||
streamDurationSec: 11.45,
|
||||
contextTokens: 142800,
|
||||
inputTokens: 7800,
|
||||
cacheReadTokens: 133580,
|
||||
outputTokens: 1420,
|
||||
thinkingTokens: 860,
|
||||
responseTokens: 560,
|
||||
cacheHitPct: 94.5,
|
||||
costUsd: 0.042,
|
||||
createdAtMs: anchorMinMs - 14_000,
|
||||
turnIndex: 2,
|
||||
rootTurnIndex: 2,
|
||||
isTurnStart: false,
|
||||
isRootTurnStart: false,
|
||||
isLatestTurn: true,
|
||||
isRootLatestTurn: true,
|
||||
turnPrompt: promptLatest,
|
||||
rootTurnPrompt: promptLatest,
|
||||
},
|
||||
{
|
||||
stepIndex: 8,
|
||||
agentCascadeId: 'mock-sub-1',
|
||||
agentId: 'sub-1',
|
||||
agentIndex: 1,
|
||||
isSubagent: true,
|
||||
agentBadge: '子1',
|
||||
agentRole: subRole,
|
||||
agentLabel: subRole,
|
||||
modelLabel: 'Gemini 3.8 Flash',
|
||||
modelShort: 'gemini-3.8-flash',
|
||||
rawModel: 'MODEL_PLACEHOLDER_M42',
|
||||
upstreamModel: 'gemini-3.8-flash-n',
|
||||
tokPerSec: 96.2,
|
||||
ttftSec: 0.68,
|
||||
totalDurationSec: 5.4,
|
||||
streamDurationSec: 4.72,
|
||||
contextTokens: 72704,
|
||||
inputTokens: 8600,
|
||||
cacheReadTokens: 63400,
|
||||
outputTokens: 704,
|
||||
thinkingTokens: 240,
|
||||
responseTokens: 464,
|
||||
cacheHitPct: 88.1,
|
||||
costUsd: 0.009,
|
||||
createdAtMs: anchorMinMs - 42_000,
|
||||
turnIndex: 1,
|
||||
rootTurnIndex: 2,
|
||||
isTurnStart: true,
|
||||
isRootTurnStart: false,
|
||||
isLatestTurn: true,
|
||||
isRootLatestTurn: true,
|
||||
turnPrompt: promptLatest,
|
||||
rootTurnPrompt: promptLatest,
|
||||
},
|
||||
{
|
||||
stepIndex: 22,
|
||||
agentCascadeId: 'mock-main',
|
||||
agentId: 'main',
|
||||
agentIndex: 0,
|
||||
isSubagent: false,
|
||||
agentBadge: '主',
|
||||
agentLabel: t('fmt.mainAgent'),
|
||||
modelLabel: 'Gemini 4 Carbon (High)',
|
||||
modelShort: 'gemini-4-carbon',
|
||||
rawModel: 'MODEL_PLACEHOLDER_M37',
|
||||
upstreamModel: 'gemini-4-carbon-high',
|
||||
tokPerSec: 46.5,
|
||||
ttftSec: 3.4,
|
||||
totalDurationSec: 15.8,
|
||||
streamDurationSec: 12.4,
|
||||
contextTokens: 128400,
|
||||
inputTokens: 49200,
|
||||
cacheReadTokens: 78100,
|
||||
outputTokens: 1100,
|
||||
thinkingTokens: 720,
|
||||
responseTokens: 380,
|
||||
cacheHitPct: 61.4,
|
||||
costUsd: 0.068,
|
||||
createdAtMs: anchorMinMs - 88_000,
|
||||
turnIndex: 2,
|
||||
rootTurnIndex: 2,
|
||||
isTurnStart: true,
|
||||
isRootTurnStart: true,
|
||||
isLatestTurn: true,
|
||||
isRootLatestTurn: true,
|
||||
turnPrompt: promptLatest,
|
||||
rootTurnPrompt: promptLatest,
|
||||
},
|
||||
{
|
||||
stepIndex: 19,
|
||||
agentCascadeId: 'mock-main',
|
||||
agentId: 'main',
|
||||
agentIndex: 0,
|
||||
isSubagent: false,
|
||||
agentBadge: '主',
|
||||
agentLabel: t('fmt.mainAgent'),
|
||||
modelLabel: 'Gemini 4 Carbon (High)',
|
||||
modelShort: 'gemini-4-carbon',
|
||||
rawModel: 'MODEL_PLACEHOLDER_M37',
|
||||
upstreamModel: 'gemini-4-carbon-high',
|
||||
tokPerSec: 17.8,
|
||||
ttftSec: 19.4,
|
||||
totalDurationSec: 31.2,
|
||||
streamDurationSec: 11.8,
|
||||
contextTokens: 96200,
|
||||
inputTokens: 95400,
|
||||
cacheReadTokens: 0,
|
||||
outputTokens: 800,
|
||||
thinkingTokens: 540,
|
||||
responseTokens: 260,
|
||||
cacheHitPct: 0,
|
||||
costUsd: 0.198,
|
||||
createdAtMs: anchorMinMs - 215_000,
|
||||
turnIndex: 1,
|
||||
rootTurnIndex: 1,
|
||||
isTurnStart: true,
|
||||
isRootTurnStart: true,
|
||||
isLatestTurn: false,
|
||||
isRootLatestTurn: false,
|
||||
turnPrompt: promptPrev,
|
||||
rootTurnPrompt: promptPrev,
|
||||
},
|
||||
];
|
||||
|
||||
const mainAgent = {
|
||||
agentId: 'main',
|
||||
cascadeId: 'mock-main',
|
||||
isMain: true,
|
||||
index: 0,
|
||||
badgeText: '主',
|
||||
role: t('fmt.mainAgent'),
|
||||
isRunning: true,
|
||||
stepCount: 16,
|
||||
speedSampleCount: 15,
|
||||
latestTokPerSec: 68.4,
|
||||
avgTokPerSec: 54.8,
|
||||
latestTtftSec: 1.15,
|
||||
avgTtftSec: 1.62,
|
||||
latestStepCostUsd: 0.042,
|
||||
sessionCostUsd: 1.16,
|
||||
latestCacheHitPct: 94.5,
|
||||
sessionCacheHitPct: 89.2,
|
||||
latestPromptTokens: 141380,
|
||||
inputTokens: 152400,
|
||||
cacheReadTokens: 1260000,
|
||||
outputTokens: 22100,
|
||||
totalTokens: 1434500,
|
||||
latestModelLabel: 'Gemini 4 Carbon (High)',
|
||||
latestModelShort: 'gemini-4-carbon',
|
||||
latestRawModel: 'MODEL_PLACEHOLDER_M37',
|
||||
latestUpstreamModel: 'gemini-4-carbon-high',
|
||||
activeModelLabel: 'Gemini 4 Carbon (High)',
|
||||
activeModelShort: 'gemini-4-carbon',
|
||||
context: mainContext,
|
||||
recentSteps: mockSteps.filter((s) => !s.isSubagent),
|
||||
};
|
||||
|
||||
const subAgent1 = {
|
||||
agentId: 'sub-1',
|
||||
cascadeId: 'mock-sub-1',
|
||||
isMain: false,
|
||||
index: 1,
|
||||
badgeText: '子1',
|
||||
shortLabel: `${t('fmt.subAgent')} #1`,
|
||||
role: subRole,
|
||||
isRunning: false,
|
||||
stepCount: 8,
|
||||
speedSampleCount: 8,
|
||||
latestTokPerSec: 96.2,
|
||||
avgTokPerSec: 88.5,
|
||||
latestTtftSec: 0.68,
|
||||
avgTtftSec: 0.82,
|
||||
latestStepCostUsd: 0.009,
|
||||
sessionCostUsd: 0.12,
|
||||
latestCacheHitPct: 88.1,
|
||||
sessionCacheHitPct: 86.4,
|
||||
latestPromptTokens: 72000,
|
||||
inputTokens: 34000,
|
||||
cacheReadTokens: 280000,
|
||||
outputTokens: 6300,
|
||||
totalTokens: 320300,
|
||||
latestModelLabel: 'Gemini 3.8 Flash',
|
||||
latestModelShort: 'gemini-3.8-flash',
|
||||
latestRawModel: 'MODEL_PLACEHOLDER_M42',
|
||||
latestUpstreamModel: 'gemini-3.8-flash-n',
|
||||
activeModelLabel: 'Gemini 3.8 Flash',
|
||||
activeModelShort: 'gemini-3.8-flash',
|
||||
context: subContext,
|
||||
recentSteps: mockSteps.filter((s) => s.isSubagent),
|
||||
};
|
||||
|
||||
const aggregated = {
|
||||
...mainAgent,
|
||||
stepCount: 24,
|
||||
speedSampleCount: 23,
|
||||
avgTokPerSec: 59.6,
|
||||
avgTtftSec: 1.38,
|
||||
sessionCostUsd: 1.28,
|
||||
sessionCacheHitPct: 88.9,
|
||||
inputTokens: 186400,
|
||||
cacheReadTokens: 1540000,
|
||||
outputTokens: 28400,
|
||||
totalTokens: 1754800,
|
||||
activeAgentBadge: '主',
|
||||
recentSteps: mockSteps,
|
||||
};
|
||||
|
||||
return {
|
||||
settings: mergedSettings,
|
||||
account: {
|
||||
planName: 'Google AI Pro',
|
||||
aiCredits: 1200,
|
||||
},
|
||||
quotas: {
|
||||
activePool: {
|
||||
family: 'Gemini',
|
||||
poolKey: 'Gemini',
|
||||
poolLabel: 'Gemini',
|
||||
usedPct: 36,
|
||||
remainingPct: 64,
|
||||
resetTime: reset5hIso,
|
||||
weeklyUsedPct: 48,
|
||||
weeklyRemainingPct: 52,
|
||||
weeklyResetTime: resetWkIso,
|
||||
},
|
||||
pools: [
|
||||
{
|
||||
poolKey: 'Gemini',
|
||||
poolLabel: 'Gemini',
|
||||
family: 'Gemini',
|
||||
usedPct: 36,
|
||||
remainingPct: 64,
|
||||
resetTime: reset5hIso,
|
||||
weeklyUsedPct: 48,
|
||||
weeklyRemainingPct: 52,
|
||||
weeklyResetTime: resetWkIso,
|
||||
cycle5h: { tokens: 1754800, costUsd: 1.28, calls: 24 },
|
||||
cycleWeekly: { tokens: 14200000, costUsd: 11.4, calls: 186 },
|
||||
},
|
||||
{
|
||||
poolKey: 'Claude & GPT',
|
||||
poolLabel: 'Claude & GPT',
|
||||
family: 'Claude & GPT',
|
||||
usedPct: 68,
|
||||
remainingPct: 32,
|
||||
resetTime: resetClaude5hIso,
|
||||
weeklyUsedPct: 41,
|
||||
weeklyRemainingPct: 59,
|
||||
weeklyResetTime: resetWkIso,
|
||||
cycle5h: { tokens: 620000, costUsd: 2.15, calls: 11 },
|
||||
cycleWeekly: { tokens: 5800000, costUsd: 18.6, calls: 92 },
|
||||
},
|
||||
],
|
||||
weekly: {
|
||||
isOfficial: true,
|
||||
usedPct: 48,
|
||||
remainingPct: 52,
|
||||
resetTime: resetWkIso,
|
||||
tokens: 20000000,
|
||||
costUsd: 30.0,
|
||||
calls: 278,
|
||||
},
|
||||
},
|
||||
runningConversations: [
|
||||
{
|
||||
cascadeId: 'mock-preview-conv',
|
||||
title: sessionTitle,
|
||||
isCurrentSelected: true,
|
||||
isMainRunning: true,
|
||||
isRunning: true,
|
||||
subagentCount: 1,
|
||||
runningSubagentCount: 0,
|
||||
latestTokPerSec: 68.4,
|
||||
contextUsedPct: 55.8,
|
||||
mainActivity: {
|
||||
phase: 'generating',
|
||||
label: t('live.generating'),
|
||||
stepProgress: '#24',
|
||||
detail: 'src/auth/tokenRefresh.ts',
|
||||
startedAtMs: Date.now() - 8000,
|
||||
signature: 'mock-preview:24',
|
||||
},
|
||||
subagents: [
|
||||
{
|
||||
cascadeId: 'mock-sub-1',
|
||||
index: 1,
|
||||
badgeText: '子1',
|
||||
shortLabel: `${t('fmt.subAgent')} #1`,
|
||||
role: subRole,
|
||||
isRunning: false,
|
||||
stepCount: 8,
|
||||
lastModifiedMs: anchorMinMs - 42_000,
|
||||
liveActivity: {
|
||||
phase: 'done',
|
||||
label: t('live.done'),
|
||||
detail: '',
|
||||
stepProgress: '',
|
||||
startedAtMs: anchorMinMs - 42_000,
|
||||
signature: 'mock-sub-1:8',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
activeConversation: {
|
||||
...mainAgent,
|
||||
cascadeId: 'mock-preview-conv',
|
||||
title: sessionTitle,
|
||||
hasSubagents: true,
|
||||
agents: [mainAgent, subAgent1],
|
||||
aggregated,
|
||||
recentSteps: mockSteps,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user