Skip to content

Commit 43d6dc3

Browse files
authored
Add User email detail to about box (#13459)
1 parent 2231497 commit 43d6dc3

File tree

6 files changed

+35
-1
lines changed

6 files changed

+35
-1
lines changed

packages/cli/src/ui/commands/aboutCommand.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
2222
getDetectedIdeDisplayName: vi.fn().mockReturnValue('test-ide'),
2323
}),
2424
},
25+
UserAccountManager: vi.fn().mockImplementation(() => ({
26+
getCachedGoogleAccount: vi.fn().mockReturnValue('[email protected]'),
27+
})),
2528
};
2629
});
2730

@@ -98,6 +101,7 @@ describe('aboutCommand', () => {
98101
selectedAuthType: 'test-auth',
99102
gcpProject: 'test-gcp-project',
100103
ideClient: 'test-ide',
104+
userEmail: '[email protected]',
101105
},
102106
expect.any(Number),
103107
);

packages/cli/src/ui/commands/aboutCommand.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import type { CommandContext, SlashCommand } from './types.js';
99
import { CommandKind } from './types.js';
1010
import process from 'node:process';
1111
import { MessageType, type HistoryItemAbout } from '../types.js';
12-
import { IdeClient } from '@google/gemini-cli-core';
12+
import {
13+
IdeClient,
14+
UserAccountManager,
15+
debugLogger,
16+
} from '@google/gemini-cli-core';
1317

1418
export const aboutCommand: SlashCommand = {
1519
name: 'about',
@@ -32,6 +36,13 @@ export const aboutCommand: SlashCommand = {
3236
const gcpProject = process.env['GOOGLE_CLOUD_PROJECT'] || '';
3337
const ideClient = await getIdeClientName(context);
3438

39+
const userAccountManager = new UserAccountManager();
40+
const cachedAccount = userAccountManager.getCachedGoogleAccount();
41+
debugLogger.log('AboutCommand: Retrieved cached Google account', {
42+
cachedAccount,
43+
});
44+
const userEmail = cachedAccount ?? undefined;
45+
3546
const aboutItem: Omit<HistoryItemAbout, 'id'> = {
3647
type: MessageType.ABOUT,
3748
cliVersion,
@@ -41,6 +52,7 @@ export const aboutCommand: SlashCommand = {
4152
selectedAuthType,
4253
gcpProject,
4354
ideClient,
55+
userEmail,
4456
};
4557

4658
context.ui.addItem(aboutItem, Date.now());

packages/cli/src/ui/components/AboutBox.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface AboutBoxProps {
1717
selectedAuthType: string;
1818
gcpProject: string;
1919
ideClient: string;
20+
userEmail?: string;
2021
}
2122

2223
export const AboutBox: React.FC<AboutBoxProps> = ({
@@ -27,6 +28,7 @@ export const AboutBox: React.FC<AboutBoxProps> = ({
2728
selectedAuthType,
2829
gcpProject,
2930
ideClient,
31+
userEmail,
3032
}) => (
3133
<Box
3234
borderStyle="round"
@@ -105,6 +107,18 @@ export const AboutBox: React.FC<AboutBoxProps> = ({
105107
</Text>
106108
</Box>
107109
</Box>
110+
{userEmail && (
111+
<Box flexDirection="row">
112+
<Box width="35%">
113+
<Text bold color={theme.text.link}>
114+
User Email
115+
</Text>
116+
</Box>
117+
<Box>
118+
<Text color={theme.text.primary}>{userEmail}</Text>
119+
</Box>
120+
</Box>
121+
)}
108122
{gcpProject && (
109123
<Box flexDirection="row">
110124
<Box width="35%">

packages/cli/src/ui/components/HistoryItemDisplay.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export const HistoryItemDisplay: React.FC<HistoryItemDisplayProps> = ({
108108
selectedAuthType={itemForDisplay.selectedAuthType}
109109
gcpProject={itemForDisplay.gcpProject}
110110
ideClient={itemForDisplay.ideClient}
111+
userEmail={itemForDisplay.userEmail}
111112
/>
112113
)}
113114
{itemForDisplay.type === 'help' && commands && (

packages/cli/src/ui/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export type HistoryItemAbout = HistoryItemBase & {
131131
selectedAuthType: string;
132132
gcpProject: string;
133133
ideClient: string;
134+
userEmail?: string;
134135
};
135136

136137
export type HistoryItemHelp = HistoryItemBase & {
@@ -302,6 +303,7 @@ export type Message =
302303
selectedAuthType: string;
303304
gcpProject: string;
304305
ideClient: string;
306+
userEmail?: string;
305307
content?: string; // Optional content, not really used for ABOUT
306308
}
307309
| {

packages/core/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export * from './utils/gitIgnoreParser.js';
5454
export * from './utils/gitUtils.js';
5555
export * from './utils/editor.js';
5656
export * from './utils/quotaErrorDetection.js';
57+
export * from './utils/userAccountManager.js';
5758
export * from './utils/googleQuotaErrors.js';
5859
export * from './utils/fileUtils.js';
5960
export * from './utils/retry.js';

0 commit comments

Comments
 (0)