mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-17 00:31:44 -07:00
feat(cli): extract QuotaContext and resolve infinite render loop (#24959)
This commit is contained in:
34
packages/cli/src/ui/contexts/QuotaContext.tsx
Normal file
34
packages/cli/src/ui/contexts/QuotaContext.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2026 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { createContext, useContext } from 'react';
|
||||
import type { QuotaStats } from '../types.js';
|
||||
import type { UserTierId } from '@google/gemini-cli-core';
|
||||
import type {
|
||||
ProQuotaDialogRequest,
|
||||
ValidationDialogRequest,
|
||||
OverageMenuDialogRequest,
|
||||
EmptyWalletDialogRequest,
|
||||
} from './UIStateContext.js';
|
||||
|
||||
export interface QuotaState {
|
||||
userTier?: UserTierId;
|
||||
stats?: QuotaStats;
|
||||
proQuotaRequest?: ProQuotaDialogRequest | null;
|
||||
validationRequest?: ValidationDialogRequest | null;
|
||||
overageMenuRequest?: OverageMenuDialogRequest | null;
|
||||
emptyWalletRequest?: EmptyWalletDialogRequest | null;
|
||||
}
|
||||
|
||||
export const QuotaContext = createContext<QuotaState | null>(null);
|
||||
|
||||
export const useQuotaState = () => {
|
||||
const context = useContext(QuotaContext);
|
||||
if (!context) {
|
||||
throw new Error('useQuotaState must be used within a QuotaProvider');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
@@ -9,7 +9,6 @@ import type {
|
||||
HistoryItem,
|
||||
ThoughtSummary,
|
||||
ConfirmationRequest,
|
||||
QuotaStats,
|
||||
LoopDetectionConfirmationRequest,
|
||||
HistoryItemWithoutId,
|
||||
StreamingState,
|
||||
@@ -21,7 +20,6 @@ import type { CommandContext, SlashCommand } from '../commands/types.js';
|
||||
import type {
|
||||
IdeContext,
|
||||
ApprovalMode,
|
||||
UserTierId,
|
||||
IdeInfo,
|
||||
AuthType,
|
||||
FallbackIntent,
|
||||
@@ -86,16 +84,6 @@ import { type RestartReason } from '../hooks/useIdeTrustListener.js';
|
||||
import type { TerminalBackgroundColor } from '../utils/terminalCapabilityManager.js';
|
||||
import type { BackgroundTask } from '../hooks/useExecutionLifecycle.js';
|
||||
|
||||
export interface QuotaState {
|
||||
userTier: UserTierId | undefined;
|
||||
stats: QuotaStats | undefined;
|
||||
proQuotaRequest: ProQuotaDialogRequest | null;
|
||||
validationRequest: ValidationDialogRequest | null;
|
||||
// G1 AI Credits overage flow
|
||||
overageMenuRequest: OverageMenuDialogRequest | null;
|
||||
emptyWalletRequest: EmptyWalletDialogRequest | null;
|
||||
}
|
||||
|
||||
export interface AccountSuspensionInfo {
|
||||
message: string;
|
||||
appealUrl?: string;
|
||||
@@ -169,8 +157,6 @@ export interface UIState {
|
||||
queueErrorMessage: string | null;
|
||||
showApprovalModeIndicator: ApprovalMode;
|
||||
allowPlanMode: boolean;
|
||||
// Quota-related state
|
||||
quota: QuotaState;
|
||||
currentModel: string;
|
||||
contextFileNames: string[];
|
||||
errorCount: number;
|
||||
|
||||
Reference in New Issue
Block a user