Add User email detail to about box (#13459)

This commit is contained in:
Preston Holmes
2025-11-19 19:46:21 -08:00
committed by GitHub
parent 2231497b1f
commit 43d6dc3668
6 changed files with 35 additions and 1 deletions

View File

@@ -22,6 +22,9 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
getDetectedIdeDisplayName: vi.fn().mockReturnValue('test-ide'),
}),
},
UserAccountManager: vi.fn().mockImplementation(() => ({
getCachedGoogleAccount: vi.fn().mockReturnValue('test-email@example.com'),
})),
};
});
@@ -98,6 +101,7 @@ describe('aboutCommand', () => {
selectedAuthType: 'test-auth',
gcpProject: 'test-gcp-project',
ideClient: 'test-ide',
userEmail: 'test-email@example.com',
},
expect.any(Number),
);

View File

@@ -9,7 +9,11 @@ import type { CommandContext, SlashCommand } from './types.js';
import { CommandKind } from './types.js';
import process from 'node:process';
import { MessageType, type HistoryItemAbout } from '../types.js';
import { IdeClient } from '@google/gemini-cli-core';
import {
IdeClient,
UserAccountManager,
debugLogger,
} from '@google/gemini-cli-core';
export const aboutCommand: SlashCommand = {
name: 'about',
@@ -32,6 +36,13 @@ export const aboutCommand: SlashCommand = {
const gcpProject = process.env['GOOGLE_CLOUD_PROJECT'] || '';
const ideClient = await getIdeClientName(context);
const userAccountManager = new UserAccountManager();
const cachedAccount = userAccountManager.getCachedGoogleAccount();
debugLogger.log('AboutCommand: Retrieved cached Google account', {
cachedAccount,
});
const userEmail = cachedAccount ?? undefined;
const aboutItem: Omit<HistoryItemAbout, 'id'> = {
type: MessageType.ABOUT,
cliVersion,
@@ -41,6 +52,7 @@ export const aboutCommand: SlashCommand = {
selectedAuthType,
gcpProject,
ideClient,
userEmail,
};
context.ui.addItem(aboutItem, Date.now());

View File

@@ -17,6 +17,7 @@ interface AboutBoxProps {
selectedAuthType: string;
gcpProject: string;
ideClient: string;
userEmail?: string;
}
export const AboutBox: React.FC<AboutBoxProps> = ({
@@ -27,6 +28,7 @@ export const AboutBox: React.FC<AboutBoxProps> = ({
selectedAuthType,
gcpProject,
ideClient,
userEmail,
}) => (
<Box
borderStyle="round"
@@ -105,6 +107,18 @@ export const AboutBox: React.FC<AboutBoxProps> = ({
</Text>
</Box>
</Box>
{userEmail && (
<Box flexDirection="row">
<Box width="35%">
<Text bold color={theme.text.link}>
User Email
</Text>
</Box>
<Box>
<Text color={theme.text.primary}>{userEmail}</Text>
</Box>
</Box>
)}
{gcpProject && (
<Box flexDirection="row">
<Box width="35%">

View File

@@ -108,6 +108,7 @@ export const HistoryItemDisplay: React.FC<HistoryItemDisplayProps> = ({
selectedAuthType={itemForDisplay.selectedAuthType}
gcpProject={itemForDisplay.gcpProject}
ideClient={itemForDisplay.ideClient}
userEmail={itemForDisplay.userEmail}
/>
)}
{itemForDisplay.type === 'help' && commands && (

View File

@@ -131,6 +131,7 @@ export type HistoryItemAbout = HistoryItemBase & {
selectedAuthType: string;
gcpProject: string;
ideClient: string;
userEmail?: string;
};
export type HistoryItemHelp = HistoryItemBase & {
@@ -302,6 +303,7 @@ export type Message =
selectedAuthType: string;
gcpProject: string;
ideClient: string;
userEmail?: string;
content?: string; // Optional content, not really used for ABOUT
}
| {

View File

@@ -54,6 +54,7 @@ export * from './utils/gitIgnoreParser.js';
export * from './utils/gitUtils.js';
export * from './utils/editor.js';
export * from './utils/quotaErrorDetection.js';
export * from './utils/userAccountManager.js';
export * from './utils/googleQuotaErrors.js';
export * from './utils/fileUtils.js';
export * from './utils/retry.js';