/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import type React from 'react'; import { useMemo } 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, tierName } = useMemo(() => { if (!authType) { return { email: undefined, tierName: undefined }; } const userAccountManager = new UserAccountManager(); return { email: userAccountManager.getCachedGoogleAccount(), tierName: config.getUserTierName(), }; }, [config, authType]); if (!authType) { return null; } return ( {authType === AuthType.LOGIN_WITH_GOOGLE ? ( Logged in with Google{email ? ':' : ''} {email ? ` ${email}` : ''} ) : ( `Authenticated with ${authType}` )} /auth {tierName && ( Plan: {tierName} )} ); };