fix(pi): refresh desired takeover state after failures

This commit is contained in:
SaladDay
2026-08-03 02:08:52 +00:00
parent 5360061bb6
commit 1e9e59051a
4 changed files with 100 additions and 19 deletions
+14 -14
View File
@@ -45,21 +45,21 @@ export function ProxyToggle({ className, activeApp }: ProxyToggleProps) {
defaultValue: `${appLabel} routing is desired but currently degraded; CC Switch will retry it`,
})
: takeoverEnabled
? isRunning
? t("proxy.takeover.tooltip.active", {
? isRunning
? t("proxy.takeover.tooltip.active", {
appLabel,
address: status?.address,
port: status?.port,
defaultValue: `${appLabel} 已接管 - ${status?.address}:${status?.port}\n切换该应用供应商为热切换`,
})
: t("proxy.takeover.tooltip.broken", {
appLabel,
defaultValue: `${appLabel} 已接管,但代理服务未运行`,
})
: t("proxy.takeover.tooltip.inactive", {
appLabel,
address: status?.address,
port: status?.port,
defaultValue: `${appLabel} 已接管 - ${status?.address}:${status?.port}\n切换该应用供应商为热切换`,
})
: t("proxy.takeover.tooltip.broken", {
appLabel,
defaultValue: `${appLabel} 已接管,但代理服务未运行`,
})
: t("proxy.takeover.tooltip.inactive", {
appLabel,
defaultValue: `接管 ${appLabel} 的 Live 配置,让该应用请求走本地代理`,
});
defaultValue: `接管 ${appLabel} 的 Live 配置,让该应用请求走本地代理`,
});
return (
<div
+14 -3
View File
@@ -129,9 +129,6 @@ export function useProxyStatus() {
}),
{ closeButton: true },
);
queryClient.invalidateQueries({ queryKey: proxyKeys.status });
queryClient.invalidateQueries({ queryKey: proxyKeys.takeoverStatus });
},
onError: (error: Error) => {
const detail =
@@ -144,6 +141,20 @@ export function useProxyStatus() {
}),
);
},
// Pi persists desired takeover before attempting listener/runtime work.
// A rejected IPC can therefore still have changed authoritative state.
onSettled: async () => {
await Promise.all([
queryClient.refetchQueries({
queryKey: proxyKeys.status,
type: "active",
}),
queryClient.refetchQueries({
queryKey: proxyKeys.takeoverStatus,
type: "active",
}),
]);
},
});
return {