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 currentModelId = useConfigStore((state) => state.currentModelId);
const currentAgentName = useConfigStore((state) => state.currentAgentName);
const currentVariant = useConfigStore((state) => state.currentVariant);
const voiceModeEnabled = useConfigStore((state) => state.voiceModeEnabled);
const voiceProvider = useConfigStore((state) => state.voiceProvider);
const speechRate = useConfigStore((state) => state.speechRate);
@@ -446,7 +447,11 @@ export function useBrowserVoice(): UseBrowserVoiceReturn {
finalText.trim(),
currentProviderId,
currentModelId,
currentAgentName ?? undefined
currentAgentName ?? undefined,
undefined,
undefined,
undefined,
currentVariant ?? undefined,
);
// Wait for AI response and speak it
@@ -602,7 +607,7 @@ export function useBrowserVoice(): UseBrowserVoiceReturn {
setStatus('error');
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
const handleSpeechResult = useCallback(async (text: string, isFinal: boolean) => {
+9
View File
@@ -348,6 +348,7 @@ type SessionGenerationContext = {
providerID: string;
modelID: string;
agent?: string;
variant?: string;
};
const resolveSessionGenerationContext = (): SessionGenerationContext | null => {
@@ -370,11 +371,17 @@ const resolveSessionGenerationContext = (): SessionGenerationContext | null => {
return null;
}
const agentVariant = agent
? context.getAgentModelVariantForSession(sessionId, agent, selectedModel.providerId, selectedModel.modelId)
: undefined;
const variant = agentVariant || config.currentVariant || undefined;
return {
sessionId,
providerID: selectedModel.providerId,
modelID: selectedModel.modelId,
agent,
variant,
};
};
@@ -399,6 +406,7 @@ const runStructuredGenerationInActiveSession = async ({
providerID: generationSession.providerID,
modelID: generationSession.modelID,
agent: generationSession.agent,
variant: generationSession.variant,
});
const trimmedDirectory = typeof directory === 'string' ? directory.trim() : '';
const visiblePromptText = typeof visiblePrompt === 'string' ? visiblePrompt.trim() : '';
@@ -429,6 +437,7 @@ const runStructuredGenerationInActiveSession = async ({
modelID: generationSession.modelID,
},
...(generationSession.agent ? { agent: generationSession.agent } : {}),
...(generationSession.variant ? { variant: generationSession.variant } : {}),
parts: promptParts,
});
});
@@ -33,7 +33,7 @@ export const realtimeClientTools = {
}
// Get current provider and model from config store
const { currentProviderId, currentModelId, currentAgentName } = useConfigStore.getState();
const { currentProviderId, currentModelId, currentAgentName, currentVariant } = useConfigStore.getState();
if (!currentProviderId || !currentModelId) {
console.error("[Voice] No provider/model selected");
return "error (no provider or model selected)";
@@ -43,7 +43,16 @@ export const realtimeClientTools = {
console.log("[Voice] Sending message to session:", sessionId);
await useSessionUIStore
.getState()
.sendMessage(parsed.data.message, currentProviderId, currentModelId, currentAgentName ?? undefined);
.sendMessage(
parsed.data.message,
currentProviderId,
currentModelId,
currentAgentName ?? undefined,
undefined,
undefined,
undefined,
currentVariant ?? undefined,
);
return "sent";
} catch (error) {
console.error("[Voice] Failed to send message:", error);