Merge pull request #8245 from AndersonBY/codex/antigravity-local-usage-stats

fix(accounts): show local Antigravity usage statistics
This commit is contained in:
Wesley Liddick authored and GitHub committed 2026-11-27 17:05:31 +08:00
commit 18f8813da3
2 files changed
+37

No files matched your search

@@ -222,6 +222,11 @@
<!-- Antigravity OAuth accounts: fetch usage from API -->
<template v-else-if="account.platform === 'antigravity' && account.type === 'oauth'">
<div v-if="todayStats" class="mb-1 text-[10px] text-gray-500 dark:text-gray-400">
{{ formatKeyRequests }} req · {{ formatKeyTokens }} ·
<span :title="t('usage.accountBilled')">A ${{ formatKeyCost }}</span>
<span v-if="todayStats.user_cost != null" :title="t('usage.userBilled')"> · U ${{ formatKeyUserCost }}</span>
</div>
<!-- 账户类型徽章 -->
<div v-if="antigravityTierLabel" class="mb-1 flex items-center gap-1">
<span
@@ -113,6 +113,38 @@ const cnUsageCellStubs = {
}
describe('AccountUsageCell', () => {
it('shows Antigravity local usage and separate account/user costs when the upstream query fails', async () => {
getUsage.mockRejectedValue(new Error('upstream quota unavailable'))
const wrapper = mount(AccountUsageCell, {
props: {
account: makeAccount({ id: 6401 }),
todayStats: { requests: 56, tokens: 5715898, cost: 2.6253228, user_cost: 0.003426 }
},
global: { stubs: { AccountQuotaInfo: true } }
})
await flushPromises()
expect(wrapper.text()).toContain('56 req')
expect(wrapper.find('[title="usage.accountBilled"]').text()).toBe('A $2.63')
expect(wrapper.find('[title="usage.userBilled"]').text()).toBe('· U $0.00')
wrapper.unmount()
})
it('renders zero local usage without inventing a user cost', async () => {
getUsage.mockResolvedValue({})
const wrapper = mount(AccountUsageCell, {
props: {
account: makeAccount({ id: 6402 }),
todayStats: { requests: 0, tokens: 0, cost: 0 }
},
global: { stubs: { AccountQuotaInfo: true } }
})
await flushPromises()
expect(wrapper.text()).toContain('0 req')
expect(wrapper.find('[title="usage.accountBilled"]').text()).toBe('A $0.00')
expect(wrapper.find('[title="usage.userBilled"]').exists()).toBe(false)
wrapper.unmount()
})
it.each([
['anthropic', 'oauth'], ['anthropic', 'setup-token'], ['gemini', 'oauth'], ['gemini', 'apikey']
] as const)('refreshes %s %s snapshots without forcing upstream reads and reuses the new cache', async (platform, type) => {