A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode,DeepSeek Harness and more. Only official website: ccswitch.io
Rust ai-toolsclaude-codecodexdeepseek-harnessdesktop-appgrokgrokbuildhermeskimi-codemcpopen-sourceopencodepiprovider-managementrustskillsskills-managementtauriwsl-support
fix(agy): show gateway models on cards and drop stale login and direct labels
Jason64f987192fa9
diff --git a/src-tauri/src/tray.rs b/src-tauri/src/tray.rsindex 4a78dceef..9c1369155 100644--- a/src-tauri/src/tray.rs+++ b/src-tauri/src/tray.rs@@ -2248,6 +2248,8 @@ fn app_children(let mut children = Vec::new();let header = match snapshot.mode {+ // 没有路由模式的应用(Antigravity)只有直连,写出来没有信息量+ TrayMode::Direct if !snapshot.app.spec().route_mode => None,TrayMode::Direct => Some(texts.header_direct.to_string()),TrayMode::Route => Some(texts.header_route.to_string()),TrayMode::Failover => Some(texts.header_failover.to_string()),@@ -2513,7 +2515,7 @@ pub struct PanelApp {pub name: &'static str,/// 在用那家的名字。pub current: Option<String>,- /// 直连 / 路由 / 聚合。+ /// 直连 / 路由 / 聚合;没有路由模式的应用为空串。pub mode: &'static str,/// 同一模式的机器可读值(`direct` / `route` / `stack`),面板按它给模式名上主题色。pub mode_kind: &'static str,@@ -2747,6 +2749,7 @@ pub(crate) fn collect_panel_model(app_state: &AppState) -> Result<PanelModel, Apname: snapshot.app.display_name(),current: snapshot.current().map(|p| p.name.clone()),mode: match snapshot.mode {+ TrayMode::Direct if !snapshot.app.spec().route_mode => "",TrayMode::Direct => texts.header_direct,TrayMode::Route | TrayMode::Failover => texts.mode_route,TrayMode::Stack => texts.mode_stack,diff --git a/src-tauri/src/tray/tests.rs b/src-tauri/src/tray/tests.rsindex 61e75da07..c4b5130d6 100644--- a/src-tauri/src/tray/tests.rs+++ b/src-tauri/src/tray/tests.rs@@ -1821,6 +1821,28 @@ fn direct_submenu_sends_needs_routing_providers_to_the_app_page() {assert!(matches!(&children[4], TrayEntry::Item { id, .. } if id == "nav:app:claude"));}+#[test]+fn apps_without_route_mode_have_no_direct_header() {+ let app = snapshot(+ AppType::Agy,+ TrayMode::Direct,+ vec![+ entry("google", "Google Official"),+ entry("packy", "PackyCode"),+ ],+ );+ let children = children_of(&model(&[], &[app]), &AppType::Agy);+ assert_eq!(+ texts_of(&children),+ [+ "Google Official",+ "PackyCode",+ "---",+ "打开 Antigravity 页面"+ ]+ );+}+#[test]fn route_submenu_disables_official_plans_with_the_reason() {let mut official = entry("xai", "xAI Official");diff --git a/src/components/providers/ProviderCard.tsx b/src/components/providers/ProviderCard.tsxindex 1cb704e77..4da1e8754 100644--- a/src/components/providers/ProviderCard.tsx+++ b/src/components/providers/ProviderCard.tsx@@ -55,7 +55,6 @@ import { isWorkBuddyOfficial } from "@/components/providers/workbuddyOfficial";import { WorkBuddyOfficialAccountLine } from "@/components/providers/WorkBuddyOfficialAccountLine";import { WorkBuddyQuotaFooter } from "@/components/providers/WorkBuddyQuotaFooter";import {- AgyInUseChip,AgyOfficialSubtitle,CodebuddyOfficialAccountLine,CodebuddyOfficialQuota,@@ -70,6 +69,7 @@ import {terminalNeedsRoute,} from "./OpenTerminalDialog";import type { CardChip, CardPresentation, CardTone } from "./presentation";+import { agyGatewayFromSettings } from "./forms/AgyGatewayFields";import { appHas } from "@/config/appSpecs";const copilotPlan = (data: unknown) => (data as CopilotQuota).plan;@@ -200,9 +200,26 @@ function extractCopilotSummary(provider: Provider): string | null {return model || baseUrl || null;}-/** Antigravity 卡片直接显示当前模型,省得进编辑才知道。 */+/**+ * Antigravity 卡片直接显示模型,省得进编辑才知道。Key 卡写的是网关:显示网关的默认模型+ * (多个时带 +N),没填模型 ID 时 agy 向地址取列表,返回 null 让副标题回落成地址。旧卡+ * `config.model.name` / `GEMINI_MODEL` 里的显示名网关不认,只对官方登录卡有意义。+ */function extractAgyModel(provider: Provider): string | null {const config = provider.settingsConfig as Record<string, any>;+ const apiKey = config?.env?.GEMINI_API_KEY;+ if (+ !isOfficialProvider(provider, "agy") &&+ typeof apiKey === "string" &&+ apiKey.trim()+ ) {+ const ids = agyGatewayFromSettings(config)+ .models.split(",")+ .map((id) => id.trim())+ .filter(Boolean);+ if (ids.length === 0) return null;+ return ids.length > 1 ? `${ids[0]} +${ids.length - 1}` : ids[0];+ }const model = config?.config?.model?.name;if (typeof model === "string" && model.trim()) return model.trim();const envModel = config?.env?.GEMINI_MODEL;@@ -571,12 +588,6 @@ export function ProviderCard({{presentation.chips.map((chip) => (<CardChipBadge key={chip.key} chip={chip} />))}- {canShowAgyAccount && !presentation.status && (- <AgyInUseChip- boundAccountId={agyBoundAccountId}- renderChip={(chip) => <CardChipBadge chip={chip} />}- />- )}{presentation.showHealth && health && (<HealthChipconsecutiveFailures={health.consecutive_failures}diff --git a/src/components/providers/ProviderCardAccountLines.tsx b/src/components/providers/ProviderCardAccountLines.tsxindex 50c2361a8..2d71fef05 100644--- a/src/components/providers/ProviderCardAccountLines.tsx+++ b/src/components/providers/ProviderCardAccountLines.tsx@@ -9,38 +9,14 @@ import {} from "@/lib/query/managedAuth";import CodebuddyAccountQuotaFooter from "@/components/CodebuddyAccountQuotaFooter";import { codebuddyRegion } from "@/components/providers/forms/CodebuddyLogin";-import type { CardChip } from "./presentation";function useResolvedAgyAccount(boundAccountId: string | null) {const { data } = useQuery(managedAuthStatusQuery("agy_oauth"));- const activeAccountId = data?.default_account_id;- const targetAccountId = boundAccountId ?? activeAccountId;+ const targetAccountId = boundAccountId ?? data?.default_account_id;const account = targetAccountId? data?.accounts.find((item) => item.id === targetAccountId): undefined;- return { account, activeAccountId };-}--/** Antigravity 官方卡标题旁的「agy 在用」徽标,仅在支持切号的 Antigravity 官方卡上挂载。 */-export function AgyInUseChip({- boundAccountId,- renderChip,-}: {- boundAccountId: string | null;- renderChip: (chip: CardChip) => ReactNode;-}) {- const { t } = useTranslation();- const { account, activeAccountId } = useResolvedAgyAccount(boundAccountId);-- if (!account || account.id !== activeAccountId) {- return null;- }-- return renderChip({- key: "agy-login",- label: t("authCenter.inUseBy", { app: "agy" }),- tone: "success",- });+ return { account };}/** Antigravity 官方卡副标题(账号邮箱 + 当前模型 + 套餐),未查到账号且无模型时回落默认副标题。 */diff --git a/src/tray-panel/TrayPanel.tsx b/src/tray-panel/TrayPanel.tsxindex d7b9eccf9..55d6136ea 100644--- a/src/tray-panel/TrayPanel.tsx+++ b/src/tray-panel/TrayPanel.tsx@@ -317,10 +317,13 @@ function AppRow({app.addText) : (<>- {app.current && `${app.current} · `}- <span className={cn("font-medium", MODE_TEXT[app.modeKind])}>- {app.mode}- </span>+ {app.current}+ {app.current && app.mode && " · "}+ {app.mode && (+ <span className={cn("font-medium", MODE_TEXT[app.modeKind])}>+ {app.mode}+ </span>+ )}</>)}</span>diff --git a/tests/components/ProviderCard.agyModel.test.tsx b/tests/components/ProviderCard.agyModel.test.tsxindex 5ea473dde..a057c9325 100644--- a/tests/components/ProviderCard.agyModel.test.tsx+++ b/tests/components/ProviderCard.agyModel.test.tsx@@ -84,12 +84,25 @@ const relay: Provider = {};describe("ProviderCard Antigravity model", () => {- it("shows the configured model instead of the endpoint", () => {+ it("shows the gateway default model on key cards, not the legacy display name", () => {+ renderCard({+ ...relay,+ settingsConfig: {+ ...relay.settingsConfig,+ gateway: {+ models: ["gemini-3.6-pro", "gemini-3.8-flash"],+ defaultModel: "gemini-3.8-flash",+ },+ },+ });+ expect(screen.getByText("gemini-3.8-flash +1")).toBeInTheDocument();+ expect(screen.queryByText("Gemini 3.1 Pro (High)")).not.toBeInTheDocument();+ });++ it("shows the endpoint on key cards without gateway models", () => {renderCard(relay);- expect(screen.getByText("Gemini 3.1 Pro (High)")).toBeInTheDocument();- expect(- screen.queryByText("https://relay.example.com"),- ).not.toBeInTheDocument();+ expect(screen.getByText("https://relay.example.com")).toBeInTheDocument();+ expect(screen.queryByText("Gemini 3.1 Pro (High)")).not.toBeInTheDocument();});it("falls back to GEMINI_MODEL and leaves other apps alone", () => {@@ -247,7 +260,7 @@ describe("ProviderCard cached Antigravity auth status isolation", () => {platform.mac = true;renderCard(relay, "agy", cachedAgyAuthStatus);- expect(screen.getByText("Gemini 3.1 Pro (High)")).toBeInTheDocument();+ expect(screen.getByText("https://relay.example.com")).toBeInTheDocument();expect(screen.queryByText("[email protected]")).not.toBeInTheDocument();expect(screen.queryByText("authCenter.inUseBy")).not.toBeInTheDocument();});@@ -261,12 +274,12 @@ describe("ProviderCard cached Antigravity auth status isolation", () => {expect(screen.queryByText("authCenter.inUseBy")).not.toBeInTheDocument();});- it("shows active agy email and in-use badge on supported Antigravity official cards", () => {+ it("shows the active agy email without an in-use badge (the current card says so)", () => {platform.mac = true;renderCard(agyOfficial, "agy", cachedAgyAuthStatus);expect(screen.getByText("[email protected]")).toBeInTheDocument();- expect(screen.getByText("authCenter.inUseBy")).toBeInTheDocument();+ expect(screen.queryByText("authCenter.inUseBy")).not.toBeInTheDocument();});it("shows bound account email without in-use badge when another agy account is active", () => {diff --git a/tests/components/TrayPanel.test.tsx b/tests/components/TrayPanel.test.tsxindex fbc0604ec..eebdc1bb8 100644--- a/tests/components/TrayPanel.test.tsx+++ b/tests/components/TrayPanel.test.tsx@@ -747,6 +747,16 @@ describe("TrayPanel window layout", () => {},);+ it("shows only the provider name when an app has no mode label", async () => {+ vi.mocked(trayPanelApi.state).mockResolvedValue({+ ...state,+ apps: [{ ...state.apps[0], mode: "", modeKind: "direct" }],+ });+ vi.mocked(trayPanelApi.placement).mockResolvedValue(windows);+ renderPanel();+ await screen.findByRole("button", { name: "Claude Code default" });+ });+it("opens Windows top/left taskbars toward the opposite edges", async () => {const { container } = await openPanel(windows);await act(async () => {