fix(quota): fetch quota for paused accounts + simplify exhausted display

- Remove early return for paused accounts in quota fetcher
- Check both auth/ and auth-paused/ directories when reading auth data
- Allows users to see quota status of paused accounts to know when to unpause
- Remove "Exhausted" text in tooltip, just show 0% in red (saves width)
This commit is contained in:
kaitranntt committed 2026-01-25 17:12:45 -05:00
1 parent b2b8a85af6
commit 27e8813cae
3 files changed
+13 -24

No files matched your search

+11 -22
View File
@@ -11,7 +11,7 @@ import { getAuthDir } from './config-generator';
import { CLIProxyProvider } from './types'; import { CLIProxyProvider } from './types';
import { import {
getProviderAccounts, getProviderAccounts,
isAccountPaused, getPausedDir,
setAccountTier, setAccountTier,
type AccountInfo, type AccountInfo,
type AccountTier, type AccountTier,
@@ -242,17 +242,17 @@ async function refreshAccessToken(
* Read auth data from auth file (access token, project_id, expiry status) * Read auth data from auth file (access token, project_id, expiry status)
*/ */
function readAuthData(provider: CLIProxyProvider, accountId: string): AuthData | null { function readAuthData(provider: CLIProxyProvider, accountId: string): AuthData | null {
const authDir = getAuthDir(); // Check both active and paused auth directories (quota needed for paused accounts too)
const authDirs = [getAuthDir(), getPausedDir()];
// Check if auth directory exists
if (!fs.existsSync(authDir)) {
return null;
}
// Sanitize accountId (email) to match auth file naming: @ and . → _ // Sanitize accountId (email) to match auth file naming: @ and . → _
const sanitizedId = sanitizeEmail(accountId); const sanitizedId = sanitizeEmail(accountId);
const prefix = provider === 'agy' ? 'antigravity-' : `${provider}-`; const prefix = provider === 'agy' ? 'antigravity-' : `${provider}-`;
const expectedFile = `${prefix}${sanitizedId}.json`; const expectedFile = `${prefix}${sanitizedId}.json`;
for (const authDir of authDirs) {
if (!fs.existsSync(authDir)) continue;
const filePath = path.join(authDir, expectedFile); const filePath = path.join(authDir, expectedFile);
// Direct file access (most common case) // Direct file access (most common case)
@@ -260,7 +260,7 @@ function readAuthData(provider: CLIProxyProvider, accountId: string): AuthData |
try { try {
const content = fs.readFileSync(filePath, 'utf-8'); const content = fs.readFileSync(filePath, 'utf-8');
const data = JSON.parse(content) as AntigravityAuthFile; const data = JSON.parse(content) as AntigravityAuthFile;
if (!data.access_token) return null; if (!data.access_token) continue;
return { return {
accessToken: data.access_token, accessToken: data.access_token,
refreshToken: data.refresh_token || null, refreshToken: data.refresh_token || null,
@@ -269,7 +269,7 @@ function readAuthData(provider: CLIProxyProvider, accountId: string): AuthData |
expiresAt: data.expired || null, expiresAt: data.expired || null,
}; };
} catch { } catch {
return null; continue;
} }
} }
@@ -296,6 +296,7 @@ function readAuthData(provider: CLIProxyProvider, accountId: string): AuthData |
} }
} }
} }
}
return null; return null;
} }
@@ -554,19 +555,7 @@ export async function fetchAccountQuota(
}; };
} }
// Check if account is paused (token moved to auth-paused/ directory) // Read auth data from auth file (checks both active and paused directories)
if (isAccountPaused(provider, accountId)) {
const error = 'Account is paused';
if (verbose) console.error(`[i] ${error}`);
return {
success: false,
models: [],
lastUpdated: Date.now(),
error,
};
}
// Read auth data from auth file
const authData = readAuthData(provider, accountId); const authData = readAuthData(provider, accountId);
if (!authData) { if (!authData) {
const error = 'Auth file not found for account'; const error = 'Auth file not found for account';
@@ -240,7 +240,7 @@ export function AccountCard({
{m.displayName} {m.displayName}
</span> </span>
<span className={cn('font-mono', m.exhausted && 'text-red-500')}> <span className={cn('font-mono', m.exhausted && 'text-red-500')}>
{m.exhausted ? 'Exhausted' : `${m.percentage}%`} {m.percentage}%
</span> </span>
</div> </div>
))} ))}
@@ -370,7 +370,7 @@ export function AccountItem({
{m.displayName} {m.displayName}
</span> </span>
<span className={cn('font-mono', m.exhausted && 'text-red-500')}> <span className={cn('font-mono', m.exhausted && 'text-red-500')}>
{m.exhausted ? 'Exhausted' : `${m.percentage}%`} {m.percentage}%
</span> </span>
</div> </div>
))} ))}