Show model in history (#13034)

This commit is contained in:
Tommaso Sciortino
2025-11-13 19:11:06 -08:00
committed by GitHub
parent 0fcbff506e
commit ab11b2c27f
10 changed files with 96 additions and 6 deletions
+25 -1
View File
@@ -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,