mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-27 06:20:52 -07:00
Show model in history (#13034)
This commit is contained in:
committed by
GitHub
parent
0fcbff506e
commit
ab11b2c27f
@@ -483,6 +483,15 @@ const SETTINGS_SCHEMA = {
|
||||
description: 'Show citations for generated text in the chat.',
|
||||
showInDialog: true,
|
||||
},
|
||||
showModelInfoInChat: {
|
||||
type: 'boolean',
|
||||
label: 'Show Model Info In Chat',
|
||||
category: 'UI',
|
||||
requiresRestart: false,
|
||||
default: false,
|
||||
description: 'Show the model name in the chat for each model turn.',
|
||||
showInDialog: true,
|
||||
},
|
||||
useFullWidth: {
|
||||
type: 'boolean',
|
||||
label: 'Use Full Width',
|
||||
|
||||
@@ -30,6 +30,7 @@ import { getMCPServerStatus } from '@google/gemini-cli-core';
|
||||
import { ToolsList } from './views/ToolsList.js';
|
||||
import { McpStatus } from './views/McpStatus.js';
|
||||
import { ChatList } from './views/ChatList.js';
|
||||
import { ModelMessage } from './messages/ModelMessage.js';
|
||||
|
||||
interface HistoryItemDisplayProps {
|
||||
item: HistoryItem;
|
||||
@@ -117,6 +118,9 @@ export const HistoryItemDisplay: React.FC<HistoryItemDisplayProps> = ({
|
||||
)}
|
||||
{itemForDisplay.type === 'model_stats' && <ModelStatsDisplay />}
|
||||
{itemForDisplay.type === 'tool_stats' && <ToolStatsDisplay />}
|
||||
{itemForDisplay.type === 'model' && (
|
||||
<ModelMessage model={itemForDisplay.model} />
|
||||
)}
|
||||
{itemForDisplay.type === 'quit' && (
|
||||
<SessionSummaryDisplay duration={itemForDisplay.duration} />
|
||||
)}
|
||||
|
||||
21
packages/cli/src/ui/components/messages/ModelMessage.tsx
Normal file
21
packages/cli/src/ui/components/messages/ModelMessage.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import type React from 'react';
|
||||
import { Text, Box } from 'ink';
|
||||
import { theme } from '../../semantic-colors.js';
|
||||
|
||||
interface ModelMessageProps {
|
||||
model: string;
|
||||
}
|
||||
|
||||
export const ModelMessage: React.FC<ModelMessageProps> = ({ model }) => (
|
||||
<Box marginLeft={3}>
|
||||
<Text color={theme.ui.comment} italic>
|
||||
responding with {model}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
@@ -44,6 +44,7 @@ import type {
|
||||
HistoryItemWithoutId,
|
||||
HistoryItemToolGroup,
|
||||
SlashCommandProcessorResult,
|
||||
HistoryItemModel,
|
||||
} from '../types.js';
|
||||
import { StreamingState, MessageType, ToolCallStatus } from '../types.js';
|
||||
import { isAtCommand, isSlashCommand } from '../utils/commandUtils.js';
|
||||
@@ -714,6 +715,26 @@ export const useGeminiStream = (
|
||||
[addItem, onCancelSubmit, config],
|
||||
);
|
||||
|
||||
const handleChatModelEvent = useCallback(
|
||||
(eventValue: string, userMessageTimestamp: number) => {
|
||||
if (!settings?.merged?.ui?.showModelInfoInChat) {
|
||||
return;
|
||||
}
|
||||
if (pendingHistoryItemRef.current) {
|
||||
addItem(pendingHistoryItemRef.current, userMessageTimestamp);
|
||||
setPendingHistoryItem(null);
|
||||
}
|
||||
addItem(
|
||||
{
|
||||
type: 'model',
|
||||
model: eventValue,
|
||||
} as HistoryItemModel,
|
||||
userMessageTimestamp,
|
||||
);
|
||||
},
|
||||
[addItem, pendingHistoryItemRef, setPendingHistoryItem, settings],
|
||||
);
|
||||
|
||||
const processGeminiStreamEvents = useCallback(
|
||||
async (
|
||||
stream: AsyncIterable<GeminiEvent>,
|
||||
@@ -768,6 +789,9 @@ export const useGeminiStream = (
|
||||
case ServerGeminiEventType.Citation:
|
||||
handleCitationEvent(event.value, userMessageTimestamp);
|
||||
break;
|
||||
case ServerGeminiEventType.ModelInfo:
|
||||
handleChatModelEvent(event.value, userMessageTimestamp);
|
||||
break;
|
||||
case ServerGeminiEventType.LoopDetected:
|
||||
// handle later because we want to move pending history to history
|
||||
// before we add loop detected message to history
|
||||
@@ -799,9 +823,9 @@ export const useGeminiStream = (
|
||||
handleMaxSessionTurnsEvent,
|
||||
handleContextWindowWillOverflowEvent,
|
||||
handleCitationEvent,
|
||||
handleChatModelEvent,
|
||||
],
|
||||
);
|
||||
|
||||
const submitQuery = useCallback(
|
||||
async (
|
||||
query: PartListUnion,
|
||||
|
||||
@@ -151,6 +151,11 @@ export type HistoryItemToolStats = HistoryItemBase & {
|
||||
type: 'tool_stats';
|
||||
};
|
||||
|
||||
export type HistoryItemModel = HistoryItemBase & {
|
||||
type: 'model';
|
||||
model: string;
|
||||
};
|
||||
|
||||
export type HistoryItemQuit = HistoryItemBase & {
|
||||
type: 'quit';
|
||||
duration: string;
|
||||
@@ -250,6 +255,7 @@ export type HistoryItemWithoutId =
|
||||
| HistoryItemStats
|
||||
| HistoryItemModelStats
|
||||
| HistoryItemToolStats
|
||||
| HistoryItemModel
|
||||
| HistoryItemQuit
|
||||
| HistoryItemCompression
|
||||
| HistoryItemExtensionsList
|
||||
|
||||
Reference in New Issue
Block a user