fix(pi): surface pending takeover state

This commit is contained in:
SaladDay
2026-08-03 00:38:34 +00:00
parent 9d0e75d56a
commit 9f910270ef
7 changed files with 28 additions and 6 deletions
+1 -4
View File
@@ -305,10 +305,7 @@ export function ProxyPanel({
</p>
<div className="grid gap-2 sm:grid-cols-2 lg:grid-cols-5">
{PROXY_APP_IDS.map((appType) => {
const isEnabled =
takeoverStatus?.[
appType as keyof typeof takeoverStatus
] ?? false;
const isEnabled = takeoverStatus?.[appType] ?? false;
return (
<div
key={appType}
+18 -2
View File
@@ -5,7 +5,7 @@
* 启用时自动接管 Live 配置,关闭时恢复原始配置
*/
import { Radio, Loader2 } from "lucide-react";
import { AlertTriangle, Radio, Loader2 } from "lucide-react";
import { Switch } from "@/components/ui/switch";
import { useProxyStatus } from "@/hooks/useProxyStatus";
import { cn } from "@/lib/utils";
@@ -32,10 +32,19 @@ export function ProxyToggle({ className, activeApp }: ProxyToggleProps) {
};
const takeoverEnabled = takeoverStatus?.[activeApp] || false;
const piDegraded =
activeApp === "pi" &&
takeoverEnabled &&
takeoverStatus?.pi_operational_state === "degraded";
const appLabel = getAppLabel(activeApp);
const tooltipText = takeoverEnabled
const tooltipText = piDegraded
? t("proxy.takeover.tooltip.degraded", {
appLabel,
defaultValue: `${appLabel} routing is desired but currently degraded; CC Switch will retry it`,
})
: takeoverEnabled
? isRunning
? t("proxy.takeover.tooltip.active", {
appLabel,
@@ -62,6 +71,8 @@ export function ProxyToggle({ className, activeApp }: ProxyToggleProps) {
>
{isPending ? (
<Loader2 className="h-4 w-4 animate-spin text-muted-foreground" />
) : piDegraded ? (
<AlertTriangle className="h-4 w-4 text-amber-500" />
) : (
<Radio
className={cn(
@@ -77,6 +88,11 @@ export function ProxyToggle({ className, activeApp }: ProxyToggleProps) {
onCheckedChange={handleToggle}
disabled={isPending}
/>
{piDegraded && (
<span className="text-[10px] font-medium text-amber-600 dark:text-amber-400">
{t("proxy.takeover.degraded", { defaultValue: "Pending" })}
</span>
)}
</div>
);
}
+2
View File
@@ -2790,10 +2790,12 @@
"hint": "Select apps to route — once enabled, requests from that app will go through local routing",
"enabled": "{{app}} routing enabled",
"disabled": "{{app}} routing disabled",
"degraded": "Pending",
"failed": "Failed to toggle routing: {{detail}}",
"tooltip": {
"active": "{{appLabel}} is routing - {{address}}:{{port}}\nSwitch provider for hot switching",
"broken": "{{appLabel}} is routing, but routing service is not running",
"degraded": "{{appLabel}} routing is desired but currently degraded; CC Switch will retry it",
"inactive": "Route {{appLabel}}'s requests through local routing"
}
},
+2
View File
@@ -2654,10 +2654,12 @@
"hint": "ルーティングするアプリを選択します。有効にすると、そのアプリのリクエストはローカルルーティング経由で転送されます",
"enabled": "{{app}} ルーティング有効",
"disabled": "{{app}} ルーティング無効",
"degraded": "復旧待ち",
"failed": "ルーティングの切り替えに失敗しました: {{detail}}",
"tooltip": {
"active": "{{appLabel}} がルーティング中 - {{address}}:{{port}}\nホットスイッチングのためプロバイダを切り替え",
"broken": "{{appLabel}} がルーティング中ですが、ルーティングサービスが実行されていません",
"degraded": "{{appLabel}} のルーティング要求は保持されていますが、現在は縮退状態です。CC Switch が再試行します",
"inactive": "{{appLabel}} のリクエストをローカルルーティング経由でルーティング"
}
},
+2
View File
@@ -2655,10 +2655,12 @@
"hint": "選擇要路由的應用程式,啟用後該應用程式的請求將透過本地路由轉發",
"enabled": "{{app}} 路由已啟用",
"disabled": "{{app}} 路由已關閉",
"degraded": "等待復原",
"failed": "切換路由狀態失敗:{{detail}}",
"tooltip": {
"active": "{{appLabel}} 路由中 - {{address}}:{{port}}\n切換該應用程式供應商為熱切換",
"broken": "{{appLabel}} 路由中,但路由服務未執行",
"degraded": "{{appLabel}} 路由意圖已保留,但目前處於降級狀態;CC Switch 將繼續重試",
"inactive": "路由 {{appLabel}} 的請求,讓該應用程式請求走本地路由"
}
},
+2
View File
@@ -2790,10 +2790,12 @@
"hint": "选择要路由的应用,启用后该应用的请求将通过本地路由转发",
"enabled": "{{app}} 路由已启用",
"disabled": "{{app}} 路由已关闭",
"degraded": "等待恢复",
"failed": "切换路由状态失败: {{detail}}",
"tooltip": {
"active": "{{appLabel}} 路由中 - {{address}}:{{port}}\n切换该应用供应商为热切换",
"broken": "{{appLabel}} 路由中,但路由服务未运行",
"degraded": "{{appLabel}} 路由意图已保留,但当前处于降级状态;CC Switch 将继续重试",
"inactive": "路由 {{appLabel}} 的请求,让该应用请求走本地路由"
}
},
+1
View File
@@ -51,6 +51,7 @@ export interface ProxyTakeoverStatus {
openclaw: boolean;
hermes: boolean;
pi: boolean;
pi_operational_state: "disabled" | "active" | "degraded";
}
export interface ProviderHealth {