feat(usage): claude quota tracker

This commit is contained in:
decolua 2026-03-12 09:42:17 +07:00
parent fe49b61dfb
commit f1bf027c68
4 changed files with 80 additions and 28 deletions

View file

@ -247,22 +247,11 @@ export default function ProviderLimits() {
USAGE_SUPPORTED_PROVIDERS.includes(conn.provider) && conn.authType === "oauth"
);
// Sort providers: antigravity first, then kiro, then others alphabetically
// Sort providers by USAGE_SUPPORTED_PROVIDERS order, then alphabetically
const sortedConnections = [...filteredConnections].sort((a, b) => {
const getProviderPriority = (provider) => {
if (provider === "antigravity") return 1;
if (provider === "kiro") return 2;
return 3;
};
const priorityA = getProviderPriority(a.provider);
const priorityB = getProviderPriority(b.provider);
if (priorityA !== priorityB) {
return priorityA - priorityB;
}
// Same priority: sort alphabetically
const orderA = USAGE_SUPPORTED_PROVIDERS.indexOf(a.provider);
const orderB = USAGE_SUPPORTED_PROVIDERS.indexOf(b.provider);
if (orderA !== orderB) return orderA - orderB;
return a.provider.localeCompare(b.provider);
});

View file

@ -120,8 +120,7 @@ export async function GET(request, { params }) {
const usage = await getUsageForProvider(connection);
return Response.json(usage);
} catch (error) {
console.error("[Usage API] Error fetching usage:", error);
console.error("[Usage API] Error stack:", error.stack);
console.warn(`[Usage] ${connection?.provider}: ${error.message}`);
return Response.json({ error: error.message }, { status: 500 });
}
}

View file

@ -105,4 +105,4 @@ export const ID_TO_ALIAS = Object.values(AI_PROVIDERS).reduce((acc, p) => {
}, {});
// Providers that support usage/quota API
export const USAGE_SUPPORTED_PROVIDERS = ["antigravity", "kiro", "github", "codex"];
export const USAGE_SUPPORTED_PROVIDERS = [ "claude", "antigravity", "kiro", "github", "codex"];