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.
This commit is contained in:
icarus 2025-09-24 18:41:51 +08:00
parent 11a76ae90f
commit 63fa70863c

View File

@ -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<Props> = ({ 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<Props> = ({ 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