Align GitHub Copilot quota usage with AI credits
This commit is contained in:
@@ -19,6 +19,7 @@ const AUTH = JSON.stringify({
|
||||
'opencode-go': { key: 'test-token' },
|
||||
'zai-coding-plan': { key: 'test-token' },
|
||||
deepseek: { key: 'test-token' },
|
||||
'github-copilot': { access: 'test-token' },
|
||||
});
|
||||
((fs as unknown) as { existsSync: () => boolean }).existsSync = () => true;
|
||||
((fs as unknown) as { readFileSync: () => string }).readFileSync = () => AUTH;
|
||||
@@ -173,6 +174,26 @@ describe('Codex quota provider (VS Code parity)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('GitHub Copilot quota provider (VS Code parity)', () => {
|
||||
test('exposes only premium interactions as the primary usage window', async () => {
|
||||
stubFetchReturning(() => Promise.resolve(mockResponse({
|
||||
quota_reset_date: '2026-09-01T00:00:00Z',
|
||||
quota_snapshots: {
|
||||
chat: { entitlement: 100, remaining: 80 },
|
||||
completions: { entitlement: 1000, remaining: 900 },
|
||||
premium_interactions: { entitlement: 300, remaining: 225 },
|
||||
},
|
||||
})));
|
||||
|
||||
const result = await fetchQuotaForProvider('github-copilot');
|
||||
|
||||
assert.equal(result.ok, true);
|
||||
assert.deepEqual(Object.keys(result.usage!.windows), ['premium_interactions']);
|
||||
assert.equal(result.usage!.windows.premium_interactions!.usedPercent, 25);
|
||||
assert.equal(result.usage!.windows.premium_interactions!.valueLabel, '225 / 300 left');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Z.ai quota provider (VS Code parity)', () => {
|
||||
test('surfaces 5-hour, weekly, and MCP quota windows', async () => {
|
||||
stubFetchReturning(() => Promise.resolve(mockResponse({
|
||||
|
||||
@@ -1362,9 +1362,7 @@ const buildCopilotWindows = (payload: Record<string, unknown>) => {
|
||||
});
|
||||
};
|
||||
|
||||
addWindow('chat', quota.chat as Record<string, unknown> | undefined);
|
||||
addWindow('completions', quota.completions as Record<string, unknown> | undefined);
|
||||
addWindow('premium', quota.premium_interactions as Record<string, unknown> | undefined);
|
||||
addWindow('premium_interactions', quota.premium_interactions as Record<string, unknown> | undefined);
|
||||
|
||||
return windows;
|
||||
};
|
||||
@@ -1462,7 +1460,9 @@ const fetchCopilotAddonQuota = async (): Promise<ProviderResult> => {
|
||||
|
||||
const payload = await response.json() as Record<string, unknown>;
|
||||
const windows = buildCopilotWindows(payload);
|
||||
const premium = windows.premium ? { premium: windows.premium } : windows;
|
||||
const premium = windows.premium_interactions
|
||||
? { premium_interactions: windows.premium_interactions }
|
||||
: windows;
|
||||
|
||||
return buildResult({
|
||||
providerId: 'github-copilot-addon',
|
||||
|
||||
Reference in New Issue
Block a user