fix(input-field): wrong toast when selecting built-in agents other than quick-answer / smart-reasoning

When selecting an agent from the chat page's agent selector dropdown,
built-in agents other than `builtin-quick-answer` and
`builtin-smart-reasoning` trigger the wrong toast. "Switched to
Intelligent Reasoning" pops up regardless of which agent was actually
picked — Wiki Questioner, Data Analyst, Wiki Fixer, etc.

Root cause: the toast logic checks only `agent.is_builtin`, then
branches on `agent_mode === 'smart-reasoning'` to pick between the
"Switched to Intelligent Reasoning" / "Switched to Quick Q&A" strings.
Those strings were designed for the two original built-ins
(`builtin-quick-answer` and `builtin-smart-reasoning`), which the
dropdown re-brands as "Normal Mode" / "Agent Mode". They don't make
sense for any other built-in.

Narrow the special-case branch to those two IDs. Other built-ins fall
back to the generic `agentSelected` toast (the path custom agents
already take), so they get a toast naming the agent that was actually
selected.
This commit is contained in:
jackson.jia
2026-05-26 14:24:17 +08:00
committed by lyingbug
parent af2f55c29f
commit dbdae65e9b
+9 -1
View File
@@ -1810,7 +1810,15 @@ const handleSelectAgent = (agent: CustomAgent, sourceTenantId?: string) => {
showAgentModeSelector.value = false;
const message = agent.is_builtin
// Only the two "mode-entry" built-ins are re-branded as "Normal / Agent Mode"
// in the dropdown — the switched-on/off toasts only make sense for them.
// Other built-ins (wiki researcher, data analyst, etc.) share `is_builtin`
// but should fall back to the generic agentSelected toast like custom agents,
// otherwise selecting e.g. the Wiki Questioner incorrectly says
// "Switched to Intelligent Reasoning".
const isModeBuiltin =
agent.id === BUILTIN_QUICK_ANSWER_ID || agent.id === BUILTIN_SMART_REASONING_ID;
const message = isModeBuiltin
? (isAgentType ? t('input.messages.agentSwitchedOn') : t('input.messages.agentSwitchedOff'))
: t('input.messages.agentSelected', { name: agent.name });
MessagePlugin.success(message);