Add the current auth method and GCP Project config to the about message (#2112)
This commit is contained in:
parent
3ebf54f367
commit
3aabb940f5
|
@ -14,6 +14,8 @@ interface AboutBoxProps {
|
||||||
osVersion: string;
|
osVersion: string;
|
||||||
sandboxEnv: string;
|
sandboxEnv: string;
|
||||||
modelVersion: string;
|
modelVersion: string;
|
||||||
|
selectedAuthType: string;
|
||||||
|
gcpProject: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AboutBox: React.FC<AboutBoxProps> = ({
|
export const AboutBox: React.FC<AboutBoxProps> = ({
|
||||||
|
@ -21,6 +23,8 @@ export const AboutBox: React.FC<AboutBoxProps> = ({
|
||||||
osVersion,
|
osVersion,
|
||||||
sandboxEnv,
|
sandboxEnv,
|
||||||
modelVersion,
|
modelVersion,
|
||||||
|
selectedAuthType,
|
||||||
|
gcpProject,
|
||||||
}) => (
|
}) => (
|
||||||
<Box
|
<Box
|
||||||
borderStyle="round"
|
borderStyle="round"
|
||||||
|
@ -87,5 +91,29 @@ export const AboutBox: React.FC<AboutBoxProps> = ({
|
||||||
<Text>{osVersion}</Text>
|
<Text>{osVersion}</Text>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
<Box flexDirection="row">
|
||||||
|
<Box width="35%">
|
||||||
|
<Text bold color={Colors.LightBlue}>
|
||||||
|
Auth Method
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text>
|
||||||
|
{selectedAuthType.startsWith('oauth') ? 'OAuth' : selectedAuthType}
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
{gcpProject && (
|
||||||
|
<Box flexDirection="row">
|
||||||
|
<Box width="35%">
|
||||||
|
<Text bold color={Colors.LightBlue}>
|
||||||
|
GCP Project
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text>{gcpProject}</Text>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|
|
@ -67,6 +67,8 @@ describe('<HistoryItemDisplay />', () => {
|
||||||
osVersion: 'test-os',
|
osVersion: 'test-os',
|
||||||
sandboxEnv: 'test-env',
|
sandboxEnv: 'test-env',
|
||||||
modelVersion: 'test-model',
|
modelVersion: 'test-model',
|
||||||
|
selectedAuthType: 'test-auth',
|
||||||
|
gcpProject: 'test-project',
|
||||||
};
|
};
|
||||||
const { lastFrame } = render(
|
const { lastFrame } = render(
|
||||||
<HistoryItemDisplay {...baseItem} item={item} />,
|
<HistoryItemDisplay {...baseItem} item={item} />,
|
||||||
|
|
|
@ -65,6 +65,8 @@ export const HistoryItemDisplay: React.FC<HistoryItemDisplayProps> = ({
|
||||||
osVersion={item.osVersion}
|
osVersion={item.osVersion}
|
||||||
sandboxEnv={item.sandboxEnv}
|
sandboxEnv={item.sandboxEnv}
|
||||||
modelVersion={item.modelVersion}
|
modelVersion={item.modelVersion}
|
||||||
|
selectedAuthType={item.selectedAuthType}
|
||||||
|
gcpProject={item.gcpProject}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{item.type === 'stats' && (
|
{item.type === 'stats' && (
|
||||||
|
|
|
@ -336,6 +336,89 @@ describe('useSlashCommandProcessor', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('/about command', () => {
|
||||||
|
it('should show the about box with all details including auth and project', async () => {
|
||||||
|
// Arrange
|
||||||
|
mockGetCliVersionFn.mockResolvedValue('test-version');
|
||||||
|
process.env.SANDBOX = 'gemini-sandbox';
|
||||||
|
process.env.GOOGLE_CLOUD_PROJECT = 'test-gcp-project';
|
||||||
|
vi.mocked(mockConfig.getModel).mockReturnValue('test-model-from-config');
|
||||||
|
|
||||||
|
const settings = {
|
||||||
|
merged: {
|
||||||
|
selectedAuthType: 'test-auth-type',
|
||||||
|
contextFileName: 'GEMINI.md',
|
||||||
|
},
|
||||||
|
} as LoadedSettings;
|
||||||
|
|
||||||
|
const { result } = renderHook(() =>
|
||||||
|
useSlashCommandProcessor(
|
||||||
|
mockConfig,
|
||||||
|
settings,
|
||||||
|
[],
|
||||||
|
mockAddItem,
|
||||||
|
mockClearItems,
|
||||||
|
mockLoadHistory,
|
||||||
|
mockRefreshStatic,
|
||||||
|
mockSetShowHelp,
|
||||||
|
mockOnDebugMessage,
|
||||||
|
mockOpenThemeDialog,
|
||||||
|
mockOpenAuthDialog,
|
||||||
|
mockOpenEditorDialog,
|
||||||
|
mockPerformMemoryRefresh,
|
||||||
|
mockCorgiMode,
|
||||||
|
false,
|
||||||
|
mockSetQuittingMessages,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await act(async () => {
|
||||||
|
await result.current.handleSlashCommand('/about');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(mockAddItem).toHaveBeenCalledTimes(2); // user message + about message
|
||||||
|
expect(mockAddItem).toHaveBeenNthCalledWith(
|
||||||
|
2,
|
||||||
|
expect.objectContaining({
|
||||||
|
type: 'about',
|
||||||
|
cliVersion: 'test-version',
|
||||||
|
osVersion: 'test-platform',
|
||||||
|
sandboxEnv: 'gemini-sandbox',
|
||||||
|
modelVersion: 'test-model-from-config',
|
||||||
|
selectedAuthType: 'test-auth-type',
|
||||||
|
gcpProject: 'test-gcp-project',
|
||||||
|
}),
|
||||||
|
expect.any(Number),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show sandbox-exec profile when applicable', async () => {
|
||||||
|
// Arrange
|
||||||
|
mockGetCliVersionFn.mockResolvedValue('test-version');
|
||||||
|
process.env.SANDBOX = 'sandbox-exec';
|
||||||
|
process.env.SEATBELT_PROFILE = 'test-profile';
|
||||||
|
vi.mocked(mockConfig.getModel).mockReturnValue('test-model-from-config');
|
||||||
|
|
||||||
|
const { result } = getProcessorHook();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await act(async () => {
|
||||||
|
await result.current.handleSlashCommand('/about');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(mockAddItem).toHaveBeenNthCalledWith(
|
||||||
|
2,
|
||||||
|
expect.objectContaining({
|
||||||
|
sandboxEnv: 'sandbox-exec (test-profile)',
|
||||||
|
}),
|
||||||
|
expect.any(Number),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('Other commands', () => {
|
describe('Other commands', () => {
|
||||||
it('/help should open help and return true', async () => {
|
it('/help should open help and return true', async () => {
|
||||||
const { handleSlashCommand } = getProcessor();
|
const { handleSlashCommand } = getProcessor();
|
||||||
|
|
|
@ -103,6 +103,8 @@ export const useSlashCommandProcessor = (
|
||||||
osVersion: message.osVersion,
|
osVersion: message.osVersion,
|
||||||
sandboxEnv: message.sandboxEnv,
|
sandboxEnv: message.sandboxEnv,
|
||||||
modelVersion: message.modelVersion,
|
modelVersion: message.modelVersion,
|
||||||
|
selectedAuthType: message.selectedAuthType,
|
||||||
|
gcpProject: message.gcpProject,
|
||||||
};
|
};
|
||||||
} else if (message.type === MessageType.STATS) {
|
} else if (message.type === MessageType.STATS) {
|
||||||
historyItemContent = {
|
historyItemContent = {
|
||||||
|
@ -596,6 +598,8 @@ export const useSlashCommandProcessor = (
|
||||||
}
|
}
|
||||||
const modelVersion = config?.getModel() || 'Unknown';
|
const modelVersion = config?.getModel() || 'Unknown';
|
||||||
const cliVersion = await getCliVersion();
|
const cliVersion = await getCliVersion();
|
||||||
|
const selectedAuthType = settings.merged.selectedAuthType || '';
|
||||||
|
const gcpProject = process.env.GOOGLE_CLOUD_PROJECT || '';
|
||||||
addMessage({
|
addMessage({
|
||||||
type: MessageType.ABOUT,
|
type: MessageType.ABOUT,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
|
@ -603,6 +607,8 @@ export const useSlashCommandProcessor = (
|
||||||
osVersion,
|
osVersion,
|
||||||
sandboxEnv,
|
sandboxEnv,
|
||||||
modelVersion,
|
modelVersion,
|
||||||
|
selectedAuthType,
|
||||||
|
gcpProject,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1007,6 +1013,7 @@ export const useSlashCommandProcessor = (
|
||||||
toggleCorgiMode,
|
toggleCorgiMode,
|
||||||
savedChatTags,
|
savedChatTags,
|
||||||
config,
|
config,
|
||||||
|
settings,
|
||||||
showToolDescriptions,
|
showToolDescriptions,
|
||||||
session,
|
session,
|
||||||
gitService,
|
gitService,
|
||||||
|
|
|
@ -94,6 +94,8 @@ export type HistoryItemAbout = HistoryItemBase & {
|
||||||
osVersion: string;
|
osVersion: string;
|
||||||
sandboxEnv: string;
|
sandboxEnv: string;
|
||||||
modelVersion: string;
|
modelVersion: string;
|
||||||
|
selectedAuthType: string;
|
||||||
|
gcpProject: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type HistoryItemStats = HistoryItemBase & {
|
export type HistoryItemStats = HistoryItemBase & {
|
||||||
|
@ -169,6 +171,8 @@ export type Message =
|
||||||
osVersion: string;
|
osVersion: string;
|
||||||
sandboxEnv: string;
|
sandboxEnv: string;
|
||||||
modelVersion: string;
|
modelVersion: string;
|
||||||
|
selectedAuthType: string;
|
||||||
|
gcpProject: string;
|
||||||
content?: string; // Optional content, not really used for ABOUT
|
content?: string; // Optional content, not really used for ABOUT
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
|
|
Loading…
Reference in New Issue