fix: preserve thinking variant for generated messages

Uses the selected thinking variant for Git-generated session prompts
Preserves current variant for voice-triggered messages
This commit is contained in:
Bohdan Triapitsyn
2026-06-02 13:41:19 +03:00
parent f53985f525
commit 23d732cf9c
3 changed files with 27 additions and 4 deletions
+7 -2
View File
@@ -140,6 +140,7 @@ export function useBrowserVoice(): UseBrowserVoiceReturn {
const currentProviderId = useConfigStore((state) => state.currentProviderId); const currentProviderId = useConfigStore((state) => state.currentProviderId);
const currentModelId = useConfigStore((state) => state.currentModelId); const currentModelId = useConfigStore((state) => state.currentModelId);
const currentAgentName = useConfigStore((state) => state.currentAgentName); const currentAgentName = useConfigStore((state) => state.currentAgentName);
const currentVariant = useConfigStore((state) => state.currentVariant);
const voiceModeEnabled = useConfigStore((state) => state.voiceModeEnabled); const voiceModeEnabled = useConfigStore((state) => state.voiceModeEnabled);
const voiceProvider = useConfigStore((state) => state.voiceProvider); const voiceProvider = useConfigStore((state) => state.voiceProvider);
const speechRate = useConfigStore((state) => state.speechRate); const speechRate = useConfigStore((state) => state.speechRate);
@@ -446,7 +447,11 @@ export function useBrowserVoice(): UseBrowserVoiceReturn {
finalText.trim(), finalText.trim(),
currentProviderId, currentProviderId,
currentModelId, currentModelId,
currentAgentName ?? undefined currentAgentName ?? undefined,
undefined,
undefined,
undefined,
currentVariant ?? undefined,
); );
// Wait for AI response and speak it // Wait for AI response and speak it
@@ -602,7 +607,7 @@ export function useBrowserVoice(): UseBrowserVoiceReturn {
setStatus('error'); setStatus('error');
processingMessageRef.current = false; processingMessageRef.current = false;
} }
}, [currentSessionId, currentProviderId, currentModelId, currentAgentName, language, sendMessage, setPendingInputText, createSession, speechRate, speechPitch, speechVolume, isServerTTSAvailable, speakServerTTS, isSayTTSAvailable, speakSayTTS, voiceProvider, sayVoice, browserVoice, openaiVoice, openaiCompatibleVoice, openaiCompatibleUrl, openaiCompatibleTtsModel, conversationMode, startCurrentSTT]); }, [currentSessionId, currentProviderId, currentModelId, currentAgentName, currentVariant, language, sendMessage, setPendingInputText, createSession, speechRate, speechPitch, speechVolume, isServerTTSAvailable, speakServerTTS, isSayTTSAvailable, speakSayTTS, voiceProvider, sayVoice, browserVoice, openaiVoice, openaiCompatibleVoice, openaiCompatibleUrl, openaiCompatibleTtsModel, conversationMode, startCurrentSTT]);
// Handle speech recognition result // Handle speech recognition result
const handleSpeechResult = useCallback(async (text: string, isFinal: boolean) => { const handleSpeechResult = useCallback(async (text: string, isFinal: boolean) => {
+9
View File
@@ -348,6 +348,7 @@ type SessionGenerationContext = {
providerID: string; providerID: string;
modelID: string; modelID: string;
agent?: string; agent?: string;
variant?: string;
}; };
const resolveSessionGenerationContext = (): SessionGenerationContext | null => { const resolveSessionGenerationContext = (): SessionGenerationContext | null => {
@@ -370,11 +371,17 @@ const resolveSessionGenerationContext = (): SessionGenerationContext | null => {
return null; return null;
} }
const agentVariant = agent
? context.getAgentModelVariantForSession(sessionId, agent, selectedModel.providerId, selectedModel.modelId)
: undefined;
const variant = agentVariant || config.currentVariant || undefined;
return { return {
sessionId, sessionId,
providerID: selectedModel.providerId, providerID: selectedModel.providerId,
modelID: selectedModel.modelId, modelID: selectedModel.modelId,
agent, agent,
variant,
}; };
}; };
@@ -399,6 +406,7 @@ const runStructuredGenerationInActiveSession = async ({
providerID: generationSession.providerID, providerID: generationSession.providerID,
modelID: generationSession.modelID, modelID: generationSession.modelID,
agent: generationSession.agent, agent: generationSession.agent,
variant: generationSession.variant,
}); });
const trimmedDirectory = typeof directory === 'string' ? directory.trim() : ''; const trimmedDirectory = typeof directory === 'string' ? directory.trim() : '';
const visiblePromptText = typeof visiblePrompt === 'string' ? visiblePrompt.trim() : ''; const visiblePromptText = typeof visiblePrompt === 'string' ? visiblePrompt.trim() : '';
@@ -429,6 +437,7 @@ const runStructuredGenerationInActiveSession = async ({
modelID: generationSession.modelID, modelID: generationSession.modelID,
}, },
...(generationSession.agent ? { agent: generationSession.agent } : {}), ...(generationSession.agent ? { agent: generationSession.agent } : {}),
...(generationSession.variant ? { variant: generationSession.variant } : {}),
parts: promptParts, parts: promptParts,
}); });
}); });
@@ -33,7 +33,7 @@ export const realtimeClientTools = {
} }
// Get current provider and model from config store // Get current provider and model from config store
const { currentProviderId, currentModelId, currentAgentName } = useConfigStore.getState(); const { currentProviderId, currentModelId, currentAgentName, currentVariant } = useConfigStore.getState();
if (!currentProviderId || !currentModelId) { if (!currentProviderId || !currentModelId) {
console.error("[Voice] No provider/model selected"); console.error("[Voice] No provider/model selected");
return "error (no provider or model selected)"; return "error (no provider or model selected)";
@@ -43,7 +43,16 @@ export const realtimeClientTools = {
console.log("[Voice] Sending message to session:", sessionId); console.log("[Voice] Sending message to session:", sessionId);
await useSessionUIStore await useSessionUIStore
.getState() .getState()
.sendMessage(parsed.data.message, currentProviderId, currentModelId, currentAgentName ?? undefined); .sendMessage(
parsed.data.message,
currentProviderId,
currentModelId,
currentAgentName ?? undefined,
undefined,
undefined,
undefined,
currentVariant ?? undefined,
);
return "sent"; return "sent";
} catch (error) { } catch (error) {
console.error("[Voice] Failed to send message:", error); console.error("[Voice] Failed to send message:", error);