@@ -47,6 +47,7 @@ import {
4747 type IdeInfo ,
4848 type IdeContext ,
4949 type UserTierId ,
50+ type GeminiUserTier ,
5051 type UserFeedbackPayload ,
5152 type AgentDefinition ,
5253 type ApprovalMode ,
@@ -82,6 +83,8 @@ import {
8283 CoreToolCallStatus ,
8384 generateSteeringAckMessage ,
8485 buildUserSteeringHintPrompt ,
86+ logBillingEvent ,
87+ ApiKeyUpdatedEvent ,
8588} from '@google/gemini-cli-core' ;
8689import { validateAuthMethod } from '../config/auth.js' ;
8790import process from 'node:process' ;
@@ -391,6 +394,9 @@ export const AppContainer = (props: AppContainerProps) => {
391394 ? { remaining, limit, resetTime }
392395 : undefined ;
393396 } ) ;
397+ const [ paidTier , setPaidTier ] = useState < GeminiUserTier | undefined > (
398+ undefined ,
399+ ) ;
394400
395401 const [ isConfigInitialized , setConfigInitialized ] = useState ( false ) ;
396402
@@ -686,10 +692,17 @@ export const AppContainer = (props: AppContainerProps) => {
686692 handleProQuotaChoice,
687693 validationRequest,
688694 handleValidationChoice,
695+ // G1 AI Credits
696+ overageMenuRequest,
697+ handleOverageMenuChoice,
698+ emptyWalletRequest,
699+ handleEmptyWalletChoice,
689700 } = useQuotaAndFallback ( {
690701 config,
691702 historyManager,
692703 userTier,
704+ paidTier,
705+ settings,
693706 setModelSwitchedFromQuotaError,
694707 onShowAuthSelection : ( ) => setAuthState ( AuthState . Updating ) ,
695708 } ) ;
@@ -729,6 +742,8 @@ export const AppContainer = (props: AppContainerProps) => {
729742 const handleAuthSelect = useCallback (
730743 async ( authType : AuthType | undefined , scope : LoadableSettingScope ) => {
731744 if ( authType ) {
745+ const previousAuthType =
746+ config . getContentGeneratorConfig ( ) ?. authType ?? 'unknown' ;
732747 if ( authType === AuthType . LOGIN_WITH_GOOGLE ) {
733748 setAuthContext ( { requiresRestart : true } ) ;
734749 } else {
@@ -741,6 +756,10 @@ export const AppContainer = (props: AppContainerProps) => {
741756 config . setRemoteAdminSettings ( undefined ) ;
742757 await config . refreshAuth ( authType ) ;
743758 setAuthState ( AuthState . Authenticated ) ;
759+ logBillingEvent (
760+ config ,
761+ new ApiKeyUpdatedEvent ( previousAuthType , authType ) ,
762+ ) ;
744763 } catch ( e ) {
745764 if ( e instanceof ChangeAuthRequestedError ) {
746765 return ;
@@ -803,6 +822,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
803822 // Only sync when not currently authenticating
804823 if ( authState === AuthState . Authenticated ) {
805824 setUserTier ( config . getUserTier ( ) ) ;
825+ setPaidTier ( config . getUserPaidTier ( ) ) ;
806826 }
807827 } , [ config , authState ] ) ;
808828
@@ -2006,6 +2026,8 @@ Logging in with Google... Restarting Gemini CLI to continue.
20062026 showIdeRestartPrompt ||
20072027 ! ! proQuotaRequest ||
20082028 ! ! validationRequest ||
2029+ ! ! overageMenuRequest ||
2030+ ! ! emptyWalletRequest ||
20092031 isSessionBrowserOpen ||
20102032 authState === AuthState . AwaitingApiKeyInput ||
20112033 ! ! newAgents ;
@@ -2033,6 +2055,8 @@ Logging in with Google... Restarting Gemini CLI to continue.
20332055 hasLoopDetectionConfirmationRequest ||
20342056 ! ! proQuotaRequest ||
20352057 ! ! validationRequest ||
2058+ ! ! overageMenuRequest ||
2059+ ! ! emptyWalletRequest ||
20362060 ! ! customDialog ;
20372061
20382062 const allowPlanMode =
@@ -2243,6 +2267,9 @@ Logging in with Google... Restarting Gemini CLI to continue.
22432267 stats : quotaStats ,
22442268 proQuotaRequest,
22452269 validationRequest,
2270+ // G1 AI Credits dialog state
2271+ overageMenuRequest,
2272+ emptyWalletRequest,
22462273 } ,
22472274 contextFileNames,
22482275 errorCount,
@@ -2367,6 +2394,8 @@ Logging in with Google... Restarting Gemini CLI to continue.
23672394 quotaStats ,
23682395 proQuotaRequest ,
23692396 validationRequest ,
2397+ overageMenuRequest ,
2398+ emptyWalletRequest ,
23702399 contextFileNames ,
23712400 errorCount ,
23722401 availableTerminalHeight ,
@@ -2448,6 +2477,9 @@ Logging in with Google... Restarting Gemini CLI to continue.
24482477 handleClearScreen,
24492478 handleProQuotaChoice,
24502479 handleValidationChoice,
2480+ // G1 AI Credits handlers
2481+ handleOverageMenuChoice,
2482+ handleEmptyWalletChoice,
24512483 openSessionBrowser,
24522484 closeSessionBrowser,
24532485 handleResumeSession,
@@ -2534,6 +2566,8 @@ Logging in with Google... Restarting Gemini CLI to continue.
25342566 handleClearScreen ,
25352567 handleProQuotaChoice ,
25362568 handleValidationChoice ,
2569+ handleOverageMenuChoice ,
2570+ handleEmptyWalletChoice ,
25372571 openSessionBrowser ,
25382572 closeSessionBrowser ,
25392573 handleResumeSession ,
0 commit comments