diff --git a/ui/src/hooks/use-cliproxy.ts b/ui/src/hooks/use-cliproxy.ts index 13e8efee..3d310f02 100644 --- a/ui/src/hooks/use-cliproxy.ts +++ b/ui/src/hooks/use-cliproxy.ts @@ -118,6 +118,40 @@ export function useRemoveAccount() { }); } +export function usePauseAccount() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ provider, accountId }: { provider: string; accountId: string }) => + api.cliproxy.accounts.pause(provider, accountId), + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['cliproxy-accounts'] }); + queryClient.invalidateQueries({ queryKey: ['cliproxy-auth'] }); + toast.success('Account paused'); + }, + onError: (error: Error) => { + toast.error(error.message); + }, + }); +} + +export function useResumeAccount() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ provider, accountId }: { provider: string; accountId: string }) => + api.cliproxy.accounts.resume(provider, accountId), + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['cliproxy-accounts'] }); + queryClient.invalidateQueries({ queryKey: ['cliproxy-auth'] }); + toast.success('Account resumed'); + }, + onError: (error: Error) => { + toast.error(error.message); + }, + }); +} + // OAuth flow hook export function useStartAuth() { const queryClient = useQueryClient(); diff --git a/ui/src/lib/api-client.ts b/ui/src/lib/api-client.ts index aae75b09..f8ef47e1 100644 --- a/ui/src/lib/api-client.ts +++ b/ui/src/lib/api-client.ts @@ -71,11 +71,18 @@ export interface UpdateVariant { export interface OAuthAccount { id: string; email?: string; + nickname?: string; provider: 'gemini' | 'codex' | 'agy' | 'qwen' | 'iflow' | 'kiro' | 'ghcp'; isDefault: boolean; tokenFile: string; createdAt: string; lastUsedAt?: string; + /** Whether account is paused (skipped in quota rotation) */ + paused?: boolean; + /** ISO timestamp when account was paused */ + pausedAt?: string; + /** Account tier: free, pro, ultra */ + tier?: 'free' | 'pro' | 'ultra' | 'unknown'; } export interface AuthStatus { @@ -392,6 +399,16 @@ export const api = { }), remove: (provider: string, accountId: string) => request(`/cliproxy/auth/accounts/${provider}/${accountId}`, { method: 'DELETE' }), + pause: (provider: string, accountId: string) => + request<{ provider: string; accountId: string; paused: boolean }>( + `/cliproxy/auth/accounts/${provider}/${accountId}/pause`, + { method: 'POST' } + ), + resume: (provider: string, accountId: string) => + request<{ provider: string; accountId: string; paused: boolean }>( + `/cliproxy/auth/accounts/${provider}/${accountId}/resume`, + { method: 'POST' } + ), }, // OAuth flow auth: {