修复新会话页面连接到未安装的agent时,后续连接其它agent没有反应了

This commit is contained in:
xintaofei
2026-03-23 19:05:34 +08:00
parent ccff5ac7d9
commit 22c7c47dac

View File

@@ -717,16 +717,8 @@ const ConversationTabView = memo(function ConversationTabView({
setModeId(null) setModeId(null)
setAgentConnectError(null) setAgentConnectError(null)
// If not yet connected, just update state — auto-connect will use the
// new agentType once canAutoConnect is satisfied.
const s = connStatusRef.current const s = connStatusRef.current
if (!s || s === "disconnected" || s === "error") return const doConnect = () => {
connDisconnect()
.catch((e) =>
console.error("[ConversationTabView] disconnect old agent:", e)
)
.finally(() => {
if (!workingDirForConnection) return if (!workingDirForConnection) return
connConnect(nextAgentType, workingDirForConnection, undefined, { connConnect(nextAgentType, workingDirForConnection, undefined, {
source: "auto_link", source: "auto_link",
@@ -740,7 +732,19 @@ const ConversationTabView = memo(function ConversationTabView({
console.error("[ConversationTabView] switch agent:", e) console.error("[ConversationTabView] switch agent:", e)
} }
}) })
}) }
// If not yet connected, directly attempt to connect with the new agent.
if (!s || s === "disconnected" || s === "error") {
doConnect()
return
}
connDisconnect()
.catch((e) =>
console.error("[ConversationTabView] disconnect old agent:", e)
)
.finally(doConnect)
}, },
[connConnect, connDisconnect, workingDirForConnection] [connConnect, connDisconnect, workingDirForConnection]
) )