mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(panel): 3-tier update modes, topbar update prompt, and Gemini Hydrogen & Helix support (v1.4.4)
This commit is contained in:
@@ -69,6 +69,58 @@ test('BUG-01 & INCON-01: Google-proxied Claude/GPT/o-series never misclassify as
|
||||
|
||||
const m20 = h.resolveModelInfo('MODEL_PLACEHOLDER_M20', new Map(), 'API_PROVIDER_GOOGLE_GEMINI');
|
||||
assert.equal(m20.modelId, 'gemini-3.5-flash');
|
||||
|
||||
// Gemini Hydrogen (3.8 Flash pricing) & Helix (3.5 Flash Lite pricing), shared Gemini pool
|
||||
const dynHydrogenMap = new Map([
|
||||
['MODEL_PLACEHOLDER_M480', { modelId: '', label: 'Gemini 4 Hydrogen (High)' }],
|
||||
['MODEL_PLACEHOLDER_M481', { modelId: '', label: 'Gemini 4 Hydrogen (Low)' }],
|
||||
['MODEL_PLACEHOLDER_M482', { modelId: '', label: 'Gemini 4 Helix' }],
|
||||
]);
|
||||
const hydroHigh = h.resolveModelInfo('MODEL_PLACEHOLDER_M480', dynHydrogenMap);
|
||||
assert.equal(hydroHigh.family, 'Gemini');
|
||||
assert.equal(hydroHigh.shortName, 'hydrogen-4-high');
|
||||
assert.deepEqual(
|
||||
{ i: hydroHigh.pricing?.input, c: hydroHigh.pricing?.cache, o: hydroHigh.pricing?.output },
|
||||
{ i: 0.75, c: 0.075, o: 3.75 }
|
||||
);
|
||||
const hydroLow = h.resolveModelInfo('MODEL_PLACEHOLDER_M481', dynHydrogenMap);
|
||||
assert.equal(hydroLow.shortName, 'hydrogen-4-low');
|
||||
assert.deepEqual(
|
||||
{ i: hydroLow.pricing?.input, c: hydroLow.pricing?.cache, o: hydroLow.pricing?.output },
|
||||
{ i: 0.3, c: 0.03, o: 2.5 }
|
||||
);
|
||||
const hydroCodename = h.resolveModelInfo('gemini-hydrogen');
|
||||
assert.equal(hydroCodename.family, 'Gemini');
|
||||
assert.equal(hydroCodename.label, 'Gemini Hydrogen');
|
||||
assert.equal(hydroCodename.pricing?.input, 0.75);
|
||||
|
||||
const helixInfo = h.resolveModelInfo('MODEL_PLACEHOLDER_M482', dynHydrogenMap);
|
||||
assert.equal(helixInfo.family, 'Gemini');
|
||||
assert.equal(helixInfo.shortName, 'helix-4');
|
||||
assert.deepEqual(
|
||||
{ i: helixInfo.pricing?.input, c: helixInfo.pricing?.cache, o: helixInfo.pricing?.output },
|
||||
{ i: 0.3, c: 0.03, o: 2.5 }
|
||||
);
|
||||
const helixCodename = h.resolveModelInfo('gemini-helix');
|
||||
assert.equal(helixCodename.family, 'Gemini');
|
||||
assert.equal(helixCodename.label, 'Gemini Helix');
|
||||
assert.equal(helixCodename.pricing?.output, 2.5);
|
||||
|
||||
const { quotaPoolsMap } = h.buildOfficialQuotaPools(null, [
|
||||
{
|
||||
modelOrAlias: { model: 'MODEL_PLACEHOLDER_M480' },
|
||||
label: 'Gemini 4 Hydrogen (High)',
|
||||
quotaInfo: { remainingFraction: 0.8, resetTime: new Date(nowMs + 3600_000).toISOString() },
|
||||
},
|
||||
{
|
||||
modelOrAlias: { model: 'MODEL_PLACEHOLDER_M482' },
|
||||
label: 'Gemini 4 Helix',
|
||||
quotaInfo: { remainingFraction: 0.8, resetTime: new Date(nowMs + 3600_000).toISOString() },
|
||||
},
|
||||
]);
|
||||
assert.equal(quotaPoolsMap.has('Hydrogen'), false, 'Hydrogen has no dedicated quota pool');
|
||||
assert.equal(quotaPoolsMap.has('Helix'), false, 'Helix has no dedicated quota pool');
|
||||
assert.equal(quotaPoolsMap.get('Gemini')?.isAvailable, true);
|
||||
});
|
||||
|
||||
test('BUG-02 & BUG-11: ide:<uuid> external sessions do not double-count live conversations, cross-account entries are isolated, and orphan subagents never leak to top-level list', async () => {
|
||||
@@ -261,7 +313,7 @@ test('BUG-09, BUG-14 & BUG-15: SemVer 2.0 prerelease/build ordering, future-only
|
||||
assert.equal(formatCountdown(new Date(nowMs + 30_000).toISOString(), nowMs), '<1分钟后重置');
|
||||
assert.equal(formatCountdown('1969-12-31T23:59:59Z', nowMs), '未知重置时间');
|
||||
assert.equal(formatUsd(0.0004, { precise: true }), '<$0.001');
|
||||
assert.equal(formatUsd(12.34, { unpricedCalls: 1, compactPending: true }), '$12.34+');
|
||||
assert.equal(formatUsd(12.34, { unpricedCalls: 1, compactPending: true }), '$12.34');
|
||||
assert.equal(speedReasonText('short_timing'), '耗时过短 (<0.5s)');
|
||||
});
|
||||
|
||||
|
||||
@@ -144,6 +144,6 @@ export function backendHarness({
|
||||
return {ok:true,json:async()=>data};
|
||||
},
|
||||
};
|
||||
vm.runInNewContext(source+'\n globalThis.api={buildTelemetryPayloadInternal,computeStepCost,resolveModelInfo,inferFamilyFromProviderOrKey,isCarbonModelIdentifier,PLACEHOLDER_MAP,normalizeQuotaFraction,classifyOfficialBucketWindow,classifyQuotaPoolIdentity,buildOfficialQuotaPools,resolveTimeWindow,sanitizeCatalogPayload,rebuildActiveCatalog,syncCloudCatalog,getCloudStatus,isValidSemver,compareSemver,performPluginUpdate};',ctx);
|
||||
vm.runInNewContext(source+'\n globalThis.api={buildTelemetryPayloadInternal,computeStepCost,resolveModelInfo,inferFamilyFromProviderOrKey,isCarbonModelIdentifier,PLACEHOLDER_MAP,normalizeQuotaFraction,classifyOfficialBucketWindow,classifyQuotaPoolIdentity,buildOfficialQuotaPools,resolveTimeWindow,sanitizeCatalogPayload,rebuildActiveCatalog,syncCloudCatalog,getCloudStatus,isValidSemver,compareSemver,performPluginUpdate,loadSettings,executeSettingsAction};',ctx);
|
||||
return {...ctx.api,state};
|
||||
}
|
||||
|
||||
@@ -275,3 +275,57 @@ test('performPluginUpdate pulls fast-forward when git worktree is clean, on main
|
||||
assert.equal(res.currentVersion, '1.4.0');
|
||||
assert.equal(gitCalls.length, 6); // status, rev-parse, fetch, show, merge-base, pull
|
||||
});
|
||||
|
||||
test('pluginUpdateMode supports manual (default), auto, and off with legacy autoUpdatePlugin compatibility', async () => {
|
||||
const defaultH = backendHarness();
|
||||
assert.equal(defaultH.loadSettings().pluginUpdateMode, 'manual');
|
||||
assert.equal(defaultH.loadSettings().autoUpdatePlugin, false);
|
||||
|
||||
const legacyAutoH = backendHarness({ settings: { autoUpdatePlugin: true } });
|
||||
assert.equal(legacyAutoH.loadSettings().pluginUpdateMode, 'auto');
|
||||
assert.equal(legacyAutoH.loadSettings().autoUpdatePlugin, true);
|
||||
|
||||
const offSettings = {};
|
||||
let gitTriggered = false;
|
||||
const offH = backendHarness({
|
||||
settings: offSettings,
|
||||
hasGitDir: true,
|
||||
pluginRootPath: '/Users/test/.gemini/config/plugins/usage-monitor',
|
||||
pluginManifest: { name: 'usage-monitor', version: '1.4.0' },
|
||||
remoteFetch: async () => ({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
schemaVersion: 1,
|
||||
catalogVersion: '2026.11.11.9',
|
||||
updatedAt: '2026-11-11T22:00:00+09:00',
|
||||
latestPluginVersion: '1.5.0',
|
||||
pricing: {
|
||||
'gemini-4-argon': { input: 2.0, cache: 0.1, output: 10.0, short: 'argon-4', family: 'Gemini' },
|
||||
},
|
||||
}),
|
||||
}),
|
||||
execFileImpl: (_cmd, _args, opts, cb) => {
|
||||
gitTriggered = true;
|
||||
const fn = typeof opts === 'function' ? opts : cb;
|
||||
fn(null, '', '');
|
||||
},
|
||||
});
|
||||
|
||||
const saveOff = offH.executeSettingsAction({ pluginUpdateMode: 'off' }).updated;
|
||||
assert.equal(saveOff.pluginUpdateMode, 'off');
|
||||
assert.equal(saveOff.autoUpdatePlugin, false);
|
||||
Object.assign(offSettings, saveOff);
|
||||
|
||||
await offH.syncCloudCatalog({ force: true });
|
||||
await new Promise((r) => setTimeout(r, 20));
|
||||
assert.equal(gitTriggered, false, 'pluginUpdateMode=off must never trigger auto update');
|
||||
|
||||
const saveAuto = offH.executeSettingsAction({ pluginUpdateMode: 'auto' }).updated;
|
||||
assert.equal(saveAuto.pluginUpdateMode, 'auto');
|
||||
assert.equal(saveAuto.autoUpdatePlugin, true);
|
||||
Object.assign(offSettings, saveAuto);
|
||||
|
||||
await offH.syncCloudCatalog({ force: true });
|
||||
await new Promise((r) => setTimeout(r, 20));
|
||||
assert.equal(gitTriggered, true, 'pluginUpdateMode=auto triggers background update check');
|
||||
});
|
||||
|
||||
@@ -177,9 +177,9 @@ test('empty session does not invent an Argon model or a model quota pool', async
|
||||
assert.equal(p.quotas.activePool.isAvailable,false); assert.equal(p.quotas.activePool.family,'Unknown');
|
||||
});
|
||||
|
||||
test('unknown cost renders as pending, known subtotals disclose missing calls', () => {
|
||||
test('unknown single-step cost renders as pending while aggregate subtotals omit pending suffix', () => {
|
||||
assert.equal(formatUsd(null),'待定'); assert.equal(formatUsd(0),'$0.00');
|
||||
assert.equal(formatUsd(0.1,{unpricedCalls:1}),'$0.10 + 待定');
|
||||
assert.equal(formatUsd(0.1,{unpricedCalls:1}),'$0.10');
|
||||
});
|
||||
|
||||
test('custom cost budget cannot claim a complete remaining percentage when prices are missing', async () => {
|
||||
|
||||
@@ -817,8 +817,8 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
},
|
||||
consumption: {
|
||||
selectedRange: { key: 'today', label: '今天', startMs: 1, endMs: 2 },
|
||||
session: { totalTokens: 128000, costUsd: 0.42 },
|
||||
account: { totalTokens: 500000, costUsd: 1.5 },
|
||||
session: { totalTokens: 128000, costUsd: 0.42, unpricedCalls: 12 },
|
||||
account: { totalTokens: 500000, costUsd: 1.5, unpricedCalls: 3993 },
|
||||
trendSeries: [],
|
||||
monthlySeries: [],
|
||||
},
|
||||
@@ -949,7 +949,16 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
|
||||
// Verify hovering right capsule closes unpinned multi-session panel and opens rich 3-card hover overview HUD (.wm-hover-tip)
|
||||
assert.ok(hoverTipEl, 'Hover overview HUD mounted in portal shadow root');
|
||||
assert.equal(hoverTipEl.children.length, 3, 'Hover HUD has 3 signature cards (matrix + context + quotas)');
|
||||
assert.equal(
|
||||
hoverTipEl.children.length,
|
||||
4,
|
||||
'Hover HUD has optional update banner + 3 signature cards (matrix + context + quotas)'
|
||||
);
|
||||
assert.equal(
|
||||
multiPanelEl.querySelector('.wm-multi-empty-hint'),
|
||||
null,
|
||||
'Redundant hover/pin hint copy removed from multi-session empty state'
|
||||
);
|
||||
|
||||
capsuleBtn.dispatchEvent({ type: 'mouseenter', clientX: 960, clientY: 18 });
|
||||
assert.equal(ov.isMultiOpen(), false, 'Mutual exclusion closes unpinned multi-session panel');
|
||||
@@ -1126,6 +1135,81 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
assert.equal(capSlots[0].children.length, 2, 'Ring SVG re-attached on Slot 0');
|
||||
assert.equal(capSlots[0].querySelector('.wm-ctx-pct').textContent, '50%');
|
||||
|
||||
// Verify 3-tier update mode select (manual default -> off hides topbar/hover prompts -> auto -> manual)
|
||||
const topbarUpdateBtn = capsuleHost.shadowRoot.querySelector('.wm-update-btn');
|
||||
const hoverUpdateBar = hoverTipEl.querySelector('.wm-hover-update-bar');
|
||||
const headerUpdateBtn = popoverEl.querySelector('.update-badge-btn');
|
||||
assert.ok(topbarUpdateBtn, 'Topbar subtle update pill button mounted');
|
||||
assert.ok(hoverUpdateBar, 'Hover card update banner mounted');
|
||||
assert.equal(topbarUpdateBtn.hasAttribute('hidden'), false, 'Update pill visible in default manual mode');
|
||||
assert.equal(topbarUpdateBtn.querySelector('.wm-update-label').textContent, 'v1.5.0');
|
||||
assert.ok(
|
||||
topbarUpdateBtn.children[0].children[0].getAttribute('d').includes('13.2l3.8-3.8'),
|
||||
'Topbar update pill uses downward arrow matching panel & settings design language'
|
||||
);
|
||||
assert.equal(hoverUpdateBar.hasAttribute('hidden'), false, 'Hover update bar visible in default manual mode');
|
||||
assert.ok(
|
||||
hoverUpdateBar
|
||||
.querySelector('.wm-hover-update-left')
|
||||
.children[0].children[0].getAttribute('d')
|
||||
.includes('13.2l3.8-3.8'),
|
||||
'Hover update bar uses downward arrow matching panel & settings design language'
|
||||
);
|
||||
assert.equal(
|
||||
hoverUpdateBar.querySelector('.wm-hover-update-left').children[1].textContent,
|
||||
'发现新版本 v1.5.0'
|
||||
);
|
||||
assert.equal(
|
||||
hoverUpdateBar.querySelector('.wm-hover-update-hint').textContent,
|
||||
'点击顶栏 v1.5.0 即可更新'
|
||||
);
|
||||
assert.equal(headerUpdateBtn.hasAttribute('hidden'), false);
|
||||
|
||||
const updateModeSelectEl = settingsSelects[5];
|
||||
assert.equal(updateModeSelectEl.querySelector('.select-label').textContent, '仅提示新版本,手动更新');
|
||||
updateModeSelectEl.querySelector('.select-trigger').dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
const updateOpts = updateModeSelectEl.querySelectorAll('.select-option');
|
||||
assert.equal(updateOpts.length, 3, '3 update modes rendered (manual, auto, off)');
|
||||
assert.equal(updateOpts[0].querySelector('.select-option-text').textContent, '仅提示新版本,手动更新');
|
||||
assert.equal(updateOpts[1].querySelector('.select-option-text').textContent, '自动更新');
|
||||
assert.equal(updateOpts[2].querySelector('.select-option-text').textContent, '关闭更新');
|
||||
|
||||
updateOpts[2].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
assert.equal(mockSettings.pluginUpdateMode, 'off');
|
||||
assert.equal(mockSettings.autoUpdatePlugin, false);
|
||||
assert.equal(topbarUpdateBtn.hasAttribute('hidden'), true, 'Topbar update pill hidden when mode=off');
|
||||
assert.equal(hoverUpdateBar.hasAttribute('hidden'), true, 'Hover update bar hidden when mode=off');
|
||||
assert.equal(headerUpdateBtn.hasAttribute('hidden'), true, 'Header update button hidden when mode=off');
|
||||
|
||||
updateModeSelectEl.querySelector('.select-trigger').dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
updateModeSelectEl.querySelectorAll('.select-option')[1].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
assert.equal(mockSettings.pluginUpdateMode, 'auto');
|
||||
assert.equal(mockSettings.autoUpdatePlugin, true);
|
||||
assert.equal(topbarUpdateBtn.hasAttribute('hidden'), false, 'Topbar update pill restored when mode=auto');
|
||||
|
||||
updateModeSelectEl.querySelector('.select-trigger').dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
updateModeSelectEl.querySelectorAll('.select-option')[0].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 260));
|
||||
assert.equal(mockSettings.pluginUpdateMode, 'manual');
|
||||
assert.equal(mockSettings.autoUpdatePlugin, false);
|
||||
assert.equal(topbarUpdateBtn.hasAttribute('hidden'), false, 'Topbar update pill visible when mode=manual');
|
||||
|
||||
// Verify ConsumptionView omits "+ 待定" / "3993 步费用待定" and StepsDetailView protects header title
|
||||
pillTabs[1].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 15));
|
||||
const heroCostEl = popoverEl.querySelector('.cons-hero-cost');
|
||||
assert.equal(heroCostEl.textContent, '$1.50', 'Consumption hero cost omits + 待定');
|
||||
const heroCostBaseline = heroCostEl.parentElement;
|
||||
assert.equal(
|
||||
heroCostBaseline.children[1].textContent,
|
||||
'≈ ¥11',
|
||||
'Consumption sub-label renders CNY approx instead of 步费用待定'
|
||||
);
|
||||
assert.ok(popoverEl.querySelector('.steps-panel-header'), 'Steps header flex wrapper present');
|
||||
assert.ok(popoverEl.querySelector('.steps-panel-title'), 'Steps title non-shrinking class present');
|
||||
|
||||
// Verify bundle version bump NEVER calls window.location.reload() in overlay mode
|
||||
currentBundleVer = 'ver-200';
|
||||
mockLocation.pathname = '/c/cccccccc-4444-5555-6666-dddddddddddd';
|
||||
|
||||
Reference in New Issue
Block a user