/** * @license * Copyright 2026 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import type React from 'react'; import { useMemo, useEffect, useState } from 'react'; import { Box, Text } from 'ink'; import { theme } from '../semantic-colors.js'; import { type Config, UserAccountManager, AuthType, } from '@google/gemini-cli-core'; interface UserIdentityProps { config: Config; } export const UserIdentity: React.FC = ({ config }) => { const authType = config.getContentGeneratorConfig()?.authType; const [email, setEmail] = useState(); useEffect(() => { if (authType) { const userAccountManager = new UserAccountManager(); setEmail(userAccountManager.getCachedGoogleAccount() ?? undefined); } }, [authType]); const tierName = useMemo( () => (authType ? config.getUserTierName() : undefined), [config, authType], ); if (!authType) { return null; } return ( {/* User Email /auth */} {authType === AuthType.LOGIN_WITH_GOOGLE ? ( {email ?? 'Logged in with Google'} ) : ( `Authenticated with ${authType}` )} /auth {/* Tier Name /upgrade */} {tierName && ( {tierName} /upgrade )} ); };