From 63fa70863cada0564372a62f409880cc4a78d3a9 Mon Sep 17 00:00:00 2001 From: icarus Date: Wed, 24 Sep 2025 18:41:51 +0800 Subject: [PATCH] refactor(AgentSessionInputbar): use agent model instead of session model for consistency Use agent's model information instead of session's to maintain consistency across the application. The model ID format changed from "sessionId:modelId" to "provider:modelId" and the model object is now constructed using the actual model details from the agent. --- .../home/Inputbar/AgentSessionInputbar.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/renderer/src/pages/home/Inputbar/AgentSessionInputbar.tsx b/src/renderer/src/pages/home/Inputbar/AgentSessionInputbar.tsx index 618d70e668..00ee0a1639 100644 --- a/src/renderer/src/pages/home/Inputbar/AgentSessionInputbar.tsx +++ b/src/renderer/src/pages/home/Inputbar/AgentSessionInputbar.tsx @@ -2,6 +2,7 @@ import { Tooltip } from '@heroui/react' import { loggerService } from '@logger' import { ActionIconButton } from '@renderer/components/Buttons' import { QuickPanelView } from '@renderer/components/QuickPanel' +import { useAgent } from '@renderer/hooks/agents/useAgent' import { useSession } from '@renderer/hooks/agents/useSession' import { selectNewTopicLoading } from '@renderer/hooks/useMessageOperations' import { getModel } from '@renderer/hooks/useModel' @@ -43,6 +44,7 @@ const AgentSessionInputbar: FC = ({ agentId, sessionId }) => { const [text, setText] = useState(_text) const [inputFocus, setInputFocus] = useState(false) const { session } = useSession(agentId, sessionId) + const { agent } = useAgent(agentId) const { apiServer } = useSettings() const { sendMessageShortcut, fontSize, enableSpellCheck } = useSettings() @@ -161,18 +163,18 @@ const AgentSessionInputbar: FC = ({ agentId, sessionId }) => { }) const userMessageBlocks: MessageBlock[] = [mainBlock] - // Extract the actual model ID from session.model (format: "sessionId:modelId") - const actualModelId = session?.model ? session.model.split(':').pop() : undefined + // Extract the actual model ID from session.model (format: "provider:modelId") + const [providerId, actualModelId] = agent?.model.split(':') ?? [undefined, undefined] // Try to find the actual model from providers - const actualModel = actualModelId ? getModel(actualModelId) : undefined + const actualModel = actualModelId ? getModel(actualModelId, providerId) : undefined - const model: Model | undefined = session?.model + const model: Model | undefined = actualModel ? { - id: session.model, - name: actualModel?.name || actualModelId || session.model, // Use actual model name if found - provider: actualModel?.provider || 'agent-session', - group: actualModel?.group || 'agent-session' + id: actualModel.id, + name: actualModel.name, // Use actual model name if found + provider: actualModel.provider, + group: actualModel.group } : undefined