fix(proxy): unify node switching and connection cleanup (#8592)

Route frontend and tray node selections through the same backend flow for
selection, persistence, state refresh, and connection cleanup. Read the
group's previous selection before switching and preserve the original
rule of closing only connections whose chains contain that selection.

Run optional cleanup in the background and keep its failures separate
from successful selection. Remove redundant frontend effects and unused
IPC commands, and refresh the proxy view for every successful switch.

Refs: 32095daf90
Refs: bea0dde074
This commit is contained in:
Tunglies
2026-11-09 14:28:44 +00:00
committed by GitHub
parent 7764289ba5
commit 05a6e9a64f
12 changed files with 115 additions and 255 deletions
+2 -5
View File
@@ -470,9 +470,6 @@ function NormalProxyGroups(props: { mode: string }) {
}, [handleScroll])
const { select } = useProxySelection({
onSuccess: () => {
onProxies()
},
onError: (error) => {
console.error('代理切换失败', error)
onProxies()
@@ -487,12 +484,12 @@ function NormalProxyGroups(props: { mode: string }) {
if (group.name === globalGroupName) {
pendingRevealRef.current =
member.kind === 'group' ? member.ref.name : null
// The selection refetches the view, so skip onHeadState's refetch.
// The backend selection event refreshes the view.
if (member.kind === 'group') {
setHeadState(member.ref.name, { open: true })
}
}
select(group.name, member.ref.name, group.now!, group.fixed!)
select(group.name, member.ref.name, group.fixed!)
},
[globalGroupName, select, setHeadState],
)