mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-13 18:29:32 +01:00
Squash of PR #662. The header plan-usage chip gains a Copilot row: the calendar-month premium-request quota, with the request counts and the reset in the tooltip, read every 10 minutes from GitHub's copilot_internal/user endpoint with the Copilot CLI's own sign-in token. It rides showPlanUsageLimits and is on by default while the CLI is installed and signed in; any failure leaves the chip without the row. Merge-time fixes by the maintainer: the gates (setting, then token, then the CLI probe) live in readCopilotPlanUsageIfEnabled() so a host with no Copilot sign-in never runs the login-shell probe each tick, with a test that Plan Usage Limits off means no request; the X-GitHub-Api-Version header the Copilot CLI itself does not send is dropped; and CLAUDE.md, architecture-invariants, README and copilot-integration describe the read. The hooks-config import in server.ts was merged with #666's. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
32 lines
1.5 KiB
TypeScript
32 lines
1.5 KiB
TypeScript
/** @fileoverview Merging Claude status-line usage with polled Codex usage. */
|
|
|
|
import { expect, it } from 'vitest';
|
|
import * as latestModule from '../src/web/plan-usage-latest.js';
|
|
|
|
it('preserves the Codex row when a later Claude status-line sample arrives', () => {
|
|
const module = latestModule as Record<string, unknown>;
|
|
expect(module.setLatestCodexPlanUsage).toBeTypeOf('function');
|
|
const setCodex = module.setLatestCodexPlanUsage as (value: unknown) => unknown;
|
|
const setClaude = module.setLatestPlanUsage as (value: Record<string, unknown>) => unknown;
|
|
|
|
setCodex({ sevenDay: { usedPercentage: 40, resetAt: 3000 } });
|
|
expect(setClaude({ sessionId: 's1', fiveHour: { usedPercentage: 97, resetAt: 1000 } })).toEqual({
|
|
sessionId: 's1',
|
|
fiveHour: { usedPercentage: 97, resetAt: 1000 },
|
|
codex: { sevenDay: { usedPercentage: 40, resetAt: 3000 } },
|
|
});
|
|
});
|
|
|
|
it('preserves the Copilot row when a later Claude status-line sample arrives', () => {
|
|
const module = latestModule as Record<string, unknown>;
|
|
const setCopilot = module.setLatestCopilotPlanUsage as (value: unknown) => unknown;
|
|
const setClaude = module.setLatestPlanUsage as (value: Record<string, unknown>) => unknown;
|
|
|
|
setCopilot({ monthly: { usedPercentage: 12, resetAt: 5000, used: 36, limit: 300 } });
|
|
expect(setClaude({ sessionId: 's2', fiveHour: { usedPercentage: 50, resetAt: 2000 } })).toMatchObject({
|
|
sessionId: 's2',
|
|
fiveHour: { usedPercentage: 50, resetAt: 2000 },
|
|
copilot: { monthly: { usedPercentage: 12, resetAt: 5000, used: 36, limit: 300 } },
|
|
});
|
|
});
|