refactor: drop always-false takeover fields and derive the quota app list from APP_SPECS (#9632)

ProxyTakeoverStatus.opencode/openclaw were hardcoded false and nothing reads
them (the only reader indexes by a route-mode app id); the TS type also
declared a hermes key the backend never sends. The official-subscription app
list was written by hand in three places; it is now the officialSubscription
cap in APP_SPECS.
This commit is contained in:
SaladDay
2026-11-17 09:38:25 +08:00
committed by GitHub
parent 28d25d14a2
commit 0c7a85e27f
9 changed files with 22 additions and 19 deletions
-2
View File
@@ -45,8 +45,6 @@ pub async fn stop_proxy_server(state: tauri::State<'_, AppState>) -> Result<(),
|| takeover.gemini
|| takeover.grokbuild
|| takeover.claude_desktop
|| takeover.opencode
|| takeover.openclaw
{
return Err(
"仍有应用处于代理接管状态,请先在设置中关闭对应应用接管后再停止本地路由。".to_string(),
-2
View File
@@ -82,8 +82,6 @@ pub struct ProxyTakeoverStatus {
pub grokbuild: bool,
#[serde(rename = "claude-desktop", default)]
pub claude_desktop: bool,
pub opencode: bool,
pub openclaw: bool,
}
/// Provider健康状态
-3
View File
@@ -180,9 +180,6 @@ impl ProxyService {
gemini,
grokbuild,
claude_desktop,
// OpenCode and OpenClaw don't support proxy features
opencode: false,
openclaw: false,
})
}
+1 -2
View File
@@ -206,8 +206,7 @@ function detectBalanceProvider(baseUrl: string | undefined): boolean {
}
function isOfficialSubscriptionProvider(provider: Provider, appId: AppId) {
if (!["claude", "codex", "gemini", "grokbuild", "agy"].includes(appId))
return false;
if (!appHas(appId, "officialSubscription")) return false;
if (provider.category === "official") return true;
const config = provider.settingsConfig as Record<string, any>;
+1 -2
View File
@@ -314,8 +314,7 @@ export function ProviderCard({
provider.meta?.usage_script?.enabled ??
(isBoundCodexOfficial || Boolean(claudeBoundAccountId));
const supportsOfficialSubscription =
isOfficial &&
["claude", "codex", "gemini", "grokbuild", "agy"].includes(appId);
isOfficial && appHas(appId, "officialSubscription");
const isOfficialSubscriptionUsage =
provider.meta?.usage_script?.templateType ===
TEMPLATE_TYPES.OFFICIAL_SUBSCRIPTION;
+18
View File
@@ -40,6 +40,8 @@ export interface AppCaps {
* `ProviderService::editor_view` 投影。
*/
editorView: boolean;
/** 官方卡能查订阅额度(后端 `get_subscription_quota`) */
officialSubscription: boolean;
}
/** 键的顺序就是应用的默认顺序(侧栏、应用页)。 */
@@ -55,6 +57,7 @@ export const APP_SPECS = {
managedAccount: true,
piFamily: false,
editorView: true,
officialSubscription: true,
},
"claude-desktop": {
localProxy: false,
@@ -67,6 +70,7 @@ export const APP_SPECS = {
managedAccount: true,
piFamily: false,
editorView: false,
officialSubscription: false,
},
codex: {
localProxy: true,
@@ -79,6 +83,7 @@ export const APP_SPECS = {
managedAccount: true,
piFamily: false,
editorView: true,
officialSubscription: true,
},
gemini: {
localProxy: true,
@@ -91,6 +96,7 @@ export const APP_SPECS = {
managedAccount: false,
piFamily: false,
editorView: true,
officialSubscription: true,
},
grokbuild: {
localProxy: true,
@@ -103,6 +109,7 @@ export const APP_SPECS = {
managedAccount: false,
piFamily: false,
editorView: true,
officialSubscription: true,
},
opencode: {
localProxy: false,
@@ -115,6 +122,7 @@ export const APP_SPECS = {
managedAccount: false,
piFamily: false,
editorView: false,
officialSubscription: false,
},
openclaw: {
localProxy: false,
@@ -127,6 +135,7 @@ export const APP_SPECS = {
managedAccount: false,
piFamily: false,
editorView: false,
officialSubscription: false,
},
hermes: {
localProxy: false,
@@ -139,6 +148,7 @@ export const APP_SPECS = {
managedAccount: false,
piFamily: false,
editorView: false,
officialSubscription: false,
},
pi: {
localProxy: false,
@@ -151,6 +161,7 @@ export const APP_SPECS = {
managedAccount: false,
piFamily: true,
editorView: false,
officialSubscription: false,
},
mcode: {
localProxy: false,
@@ -163,6 +174,7 @@ export const APP_SPECS = {
managedAccount: false,
piFamily: false,
editorView: false,
officialSubscription: false,
},
kimi: {
localProxy: false,
@@ -175,6 +187,7 @@ export const APP_SPECS = {
managedAccount: false,
piFamily: false,
editorView: false,
officialSubscription: false,
},
dsh: {
localProxy: false,
@@ -187,6 +200,7 @@ export const APP_SPECS = {
managedAccount: false,
piFamily: false,
editorView: false,
officialSubscription: false,
},
agy: {
localProxy: false,
@@ -199,6 +213,7 @@ export const APP_SPECS = {
managedAccount: true,
piFamily: false,
editorView: false,
officialSubscription: true,
},
omp: {
localProxy: false,
@@ -211,6 +226,7 @@ export const APP_SPECS = {
managedAccount: false,
piFamily: true,
editorView: false,
officialSubscription: false,
},
copilot: {
localProxy: false,
@@ -223,6 +239,7 @@ export const APP_SPECS = {
managedAccount: true,
piFamily: false,
editorView: false,
officialSubscription: false,
},
workbuddy: {
localProxy: false,
@@ -235,6 +252,7 @@ export const APP_SPECS = {
managedAccount: true,
piFamily: false,
editorView: false,
officialSubscription: false,
},
} as const satisfies Record<AppId, AppCaps>;
+2 -3
View File
@@ -16,6 +16,7 @@ import type {
import type { ManagedAuthStatus } from "@/lib/api/auth";
import { resolveManagedAccountId } from "@/lib/authBinding";
import { PROVIDER_TYPES } from "@/config/constants";
import { appHas } from "@/config/appSpecs";
import { resolveDisplayUsage, type LastGoodSnapshot } from "./queries";
import { extractErrorMessage } from "@/utils/errorUtils";
@@ -100,9 +101,7 @@ export function useSubscriptionQuota(
const query = useQuery({
queryKey: subscriptionKeys.quota(appId),
queryFn: () => subscriptionApi.getQuota(appId),
enabled:
enabled &&
["claude", "codex", "gemini", "grokbuild", "agy"].includes(appId),
enabled: enabled && appHas(appId, "officialSubscription"),
refetchInterval,
refetchIntervalInBackground: Boolean(refetchInterval),
refetchOnWindowFocus: Boolean(refetchInterval),
-3
View File
@@ -34,9 +34,6 @@ export interface ProxyTakeoverStatus {
codex: boolean;
gemini: boolean;
grokbuild: boolean;
opencode: boolean;
openclaw: boolean;
hermes: boolean;
}
/** Applied under the backend switch lock, not inferred from a possibly stale UI mode. */
-2
View File
@@ -83,8 +83,6 @@ describe("useProxyStatus", () => {
codex: false,
gemini: false,
grokbuild: false,
opencode: false,
openclaw: false,
});
}