mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
Add User email detail to about box (#13459)
This commit is contained in:
@@ -22,6 +22,9 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
|||||||
getDetectedIdeDisplayName: vi.fn().mockReturnValue('test-ide'),
|
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',
|
selectedAuthType: 'test-auth',
|
||||||
gcpProject: 'test-gcp-project',
|
gcpProject: 'test-gcp-project',
|
||||||
ideClient: 'test-ide',
|
ideClient: 'test-ide',
|
||||||
|
userEmail: 'test-email@example.com',
|
||||||
},
|
},
|
||||||
expect.any(Number),
|
expect.any(Number),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,7 +9,11 @@ import type { CommandContext, SlashCommand } from './types.js';
|
|||||||
import { CommandKind } from './types.js';
|
import { CommandKind } from './types.js';
|
||||||
import process from 'node:process';
|
import process from 'node:process';
|
||||||
import { MessageType, type HistoryItemAbout } from '../types.js';
|
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 = {
|
export const aboutCommand: SlashCommand = {
|
||||||
name: 'about',
|
name: 'about',
|
||||||
@@ -32,6 +36,13 @@ export const aboutCommand: SlashCommand = {
|
|||||||
const gcpProject = process.env['GOOGLE_CLOUD_PROJECT'] || '';
|
const gcpProject = process.env['GOOGLE_CLOUD_PROJECT'] || '';
|
||||||
const ideClient = await getIdeClientName(context);
|
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'> = {
|
const aboutItem: Omit<HistoryItemAbout, 'id'> = {
|
||||||
type: MessageType.ABOUT,
|
type: MessageType.ABOUT,
|
||||||
cliVersion,
|
cliVersion,
|
||||||
@@ -41,6 +52,7 @@ export const aboutCommand: SlashCommand = {
|
|||||||
selectedAuthType,
|
selectedAuthType,
|
||||||
gcpProject,
|
gcpProject,
|
||||||
ideClient,
|
ideClient,
|
||||||
|
userEmail,
|
||||||
};
|
};
|
||||||
|
|
||||||
context.ui.addItem(aboutItem, Date.now());
|
context.ui.addItem(aboutItem, Date.now());
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ interface AboutBoxProps {
|
|||||||
selectedAuthType: string;
|
selectedAuthType: string;
|
||||||
gcpProject: string;
|
gcpProject: string;
|
||||||
ideClient: string;
|
ideClient: string;
|
||||||
|
userEmail?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AboutBox: React.FC<AboutBoxProps> = ({
|
export const AboutBox: React.FC<AboutBoxProps> = ({
|
||||||
@@ -27,6 +28,7 @@ export const AboutBox: React.FC<AboutBoxProps> = ({
|
|||||||
selectedAuthType,
|
selectedAuthType,
|
||||||
gcpProject,
|
gcpProject,
|
||||||
ideClient,
|
ideClient,
|
||||||
|
userEmail,
|
||||||
}) => (
|
}) => (
|
||||||
<Box
|
<Box
|
||||||
borderStyle="round"
|
borderStyle="round"
|
||||||
@@ -105,6 +107,18 @@ export const AboutBox: React.FC<AboutBoxProps> = ({
|
|||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
</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 && (
|
{gcpProject && (
|
||||||
<Box flexDirection="row">
|
<Box flexDirection="row">
|
||||||
<Box width="35%">
|
<Box width="35%">
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ export const HistoryItemDisplay: React.FC<HistoryItemDisplayProps> = ({
|
|||||||
selectedAuthType={itemForDisplay.selectedAuthType}
|
selectedAuthType={itemForDisplay.selectedAuthType}
|
||||||
gcpProject={itemForDisplay.gcpProject}
|
gcpProject={itemForDisplay.gcpProject}
|
||||||
ideClient={itemForDisplay.ideClient}
|
ideClient={itemForDisplay.ideClient}
|
||||||
|
userEmail={itemForDisplay.userEmail}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{itemForDisplay.type === 'help' && commands && (
|
{itemForDisplay.type === 'help' && commands && (
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ export type HistoryItemAbout = HistoryItemBase & {
|
|||||||
selectedAuthType: string;
|
selectedAuthType: string;
|
||||||
gcpProject: string;
|
gcpProject: string;
|
||||||
ideClient: string;
|
ideClient: string;
|
||||||
|
userEmail?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type HistoryItemHelp = HistoryItemBase & {
|
export type HistoryItemHelp = HistoryItemBase & {
|
||||||
@@ -302,6 +303,7 @@ export type Message =
|
|||||||
selectedAuthType: string;
|
selectedAuthType: string;
|
||||||
gcpProject: string;
|
gcpProject: string;
|
||||||
ideClient: string;
|
ideClient: string;
|
||||||
|
userEmail?: string;
|
||||||
content?: string; // Optional content, not really used for ABOUT
|
content?: string; // Optional content, not really used for ABOUT
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ export * from './utils/gitIgnoreParser.js';
|
|||||||
export * from './utils/gitUtils.js';
|
export * from './utils/gitUtils.js';
|
||||||
export * from './utils/editor.js';
|
export * from './utils/editor.js';
|
||||||
export * from './utils/quotaErrorDetection.js';
|
export * from './utils/quotaErrorDetection.js';
|
||||||
|
export * from './utils/userAccountManager.js';
|
||||||
export * from './utils/googleQuotaErrors.js';
|
export * from './utils/googleQuotaErrors.js';
|
||||||
export * from './utils/fileUtils.js';
|
export * from './utils/fileUtils.js';
|
||||||
export * from './utils/retry.js';
|
export * from './utils/retry.js';
|
||||||
|
|||||||
Reference in New Issue
Block a user