mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-10-25 17:22:27 +08:00
Switch-style apps (Claude Code, Codex, Gemini CLI, Grok Build) get a mode row (Direct / Routing / Stack). Tabs only change what is viewed; taking effect goes through buttons that state the consequence, with a confirm dialog for entering a proxy mode and a one-step, undoable return to direct. Provider cards are drawn from a per-mode presentation model (status, buttons, chips, queue order, disabled reasons) instead of each card inspecting proxy state, and additive apps get Added / Available sections. Backend: entering a mode can pick the route target in the same step, `get_app_mode` reports the effective mode per app, and startup attach failures are kept for the UI to surface with a retry. Settings gains a Local Routing section (service, listen address, apps using routing, failover tuning) replacing the old proxy tab and toggles. Claude Desktop gets an access bar for model mapping and service state.
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
const PROVIDER_CARD_TSX = path.resolve(
|
|
__dirname,
|
|
"..",
|
|
"..",
|
|
"src",
|
|
"components",
|
|
"providers",
|
|
"ProviderCard.tsx",
|
|
);
|
|
const PROVIDER_LIST_TSX = path.resolve(
|
|
__dirname,
|
|
"..",
|
|
"..",
|
|
"src",
|
|
"components",
|
|
"providers",
|
|
"ProviderList.tsx",
|
|
);
|
|
|
|
describe("ProviderCard layout", () => {
|
|
const source = fs.readFileSync(PROVIDER_CARD_TSX, "utf8");
|
|
|
|
it("lets website links use available card width before truncating", () => {
|
|
expect(source).not.toContain("max-w-[280px]");
|
|
expect(source).toContain('<div className="min-w-0 flex-1">');
|
|
expect(source).toContain(
|
|
"inline-flex max-w-full items-center overflow-hidden text-start",
|
|
);
|
|
});
|
|
|
|
it("does not add a Pi-only model list to provider cards", () => {
|
|
expect(source).not.toContain("ProviderModelSummary");
|
|
expect(source).not.toContain("extractPiModelSummaryItems");
|
|
});
|
|
|
|
it("keeps Pi provider cards independent from routing capability state", () => {
|
|
const listSource = fs.readFileSync(PROVIDER_LIST_TSX, "utf8");
|
|
|
|
expect(source).not.toContain("piCurrentRoute");
|
|
expect(source).not.toContain("isFailoverEligible");
|
|
expect(listSource).not.toContain("gatewayStatus");
|
|
expect(listSource).not.toContain("activeRoute");
|
|
expect(listSource).not.toContain("pi.gatewayReason");
|
|
expect(listSource).not.toContain("pi.route");
|
|
});
|
|
});
|