mirror of
https://github.com/NanmiCoder/claude-code-haha.git
synced 2026-10-10 20:03:13 +08:00
fix: keep disabled state across in-flight reconnect results
A reconnect request that completes after the server was disabled no longer overwrites the disabled state. Connection attempts fold into disabled when the config no longer allows the server, closing any fresh connection and clearing its caches; the mcp_toggle enable and mcp_reconnect handlers apply the same check before writing their results, and the reconnect failure path keeps disabled when the server was disabled mid-flight.
This commit is contained in:
+139
-77
File diff suppressed because it is too large
Load Diff
@@ -325,6 +325,21 @@ export function useManageMCPConnections(
|
||||
commands: Command[]
|
||||
resources?: ServerResource[]
|
||||
}) => {
|
||||
// A connect that completes after the server was disabled (e.g. disable
|
||||
// during a reconnect request) must not resurrect the server: close any
|
||||
// fresh connection, clear its caches, and mark it disabled instead.
|
||||
if (isMcpServerDisabled(client.name)) {
|
||||
if (client.type === 'connected') {
|
||||
void clearServerCache(client.name, client.config)
|
||||
}
|
||||
updateServer({
|
||||
name: client.name,
|
||||
type: 'disabled',
|
||||
config: client.config,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
updateServer({ ...client, tools, commands, resources })
|
||||
|
||||
// Handle side effects based on client state
|
||||
@@ -1027,7 +1042,11 @@ export function useManageMCPConnections(
|
||||
`Max reconnection attempts (${MAX_RECONNECT_ATTEMPTS}) reached, giving up`,
|
||||
)
|
||||
reconnectTimersRef.current.delete(name)
|
||||
updateServer({ ...client, type: 'failed' })
|
||||
if (isMcpServerDisabled(name)) {
|
||||
updateServer({ name, type: 'disabled', config: client.config })
|
||||
} else {
|
||||
updateServer({ ...client, type: 'failed' })
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user