Merge pull request #400 from AutoMaker-Org/feat/codex-usage

feat: improve codex plan and usage detection
This commit is contained in:
Shirone
2026-01-10 15:29:33 +00:00
committed by GitHub
19 changed files with 1134 additions and 463 deletions

View File

@@ -1,12 +1,8 @@
import { type CodexCreditsSnapshot, type CodexPlanType } from '@/store/app-store';
import { type CodexPlanType } from '@/store/app-store';
const WINDOW_DEFAULT_LABEL = 'Usage window';
const RESET_LABEL = 'Resets';
const UNKNOWN_LABEL = 'Unknown';
const UNAVAILABLE_LABEL = 'Unavailable';
const UNLIMITED_LABEL = 'Unlimited';
const AVAILABLE_LABEL = 'Available';
const NONE_LABEL = 'None';
const DAY_UNIT = 'day';
const HOUR_UNIT = 'hour';
const MINUTE_UNIT = 'min';
@@ -77,10 +73,3 @@ export function formatCodexPlanType(plan: CodexPlanType | null): string {
if (!plan) return UNKNOWN_LABEL;
return PLAN_TYPE_LABELS[plan] ?? plan;
}
export function formatCodexCredits(snapshot: CodexCreditsSnapshot | null): string {
if (!snapshot) return UNAVAILABLE_LABEL;
if (snapshot.unlimited) return UNLIMITED_LABEL;
if (snapshot.balance) return snapshot.balance;
return snapshot.hasCredits ? AVAILABLE_LABEL : NONE_LABEL;
}

View File

@@ -727,6 +727,20 @@ export interface ElectronAPI {
ideation?: IdeationAPI;
codex?: {
getUsage: () => Promise<CodexUsageResponse>;
getModels: (refresh?: boolean) => Promise<{
success: boolean;
models?: Array<{
id: string;
label: string;
description: string;
hasThinking: boolean;
supportsVision: boolean;
tier: 'premium' | 'standard' | 'basic';
isDefault: boolean;
}>;
cachedAt?: number;
error?: string;
}>;
};
settings?: {
getStatus: () => Promise<{

View File

@@ -2053,6 +2053,25 @@ export class HttpApiClient implements ElectronAPI {
// Codex API
codex = {
getUsage: (): Promise<CodexUsageResponse> => this.get('/api/codex/usage'),
getModels: (
refresh = false
): Promise<{
success: boolean;
models?: Array<{
id: string;
label: string;
description: string;
hasThinking: boolean;
supportsVision: boolean;
tier: 'premium' | 'standard' | 'basic';
isDefault: boolean;
}>;
cachedAt?: number;
error?: string;
}> => {
const url = `/api/codex/models${refresh ? '?refresh=true' : ''}`;
return this.get(url);
},
};
// Context API