Optimize provider plugin defaults and profile summaries

This commit is contained in:
musistudio
2026-07-24 16:01:11 +08:00
parent 4b0868f8a7
commit 834da64a33
3 changed files with 49 additions and 8 deletions
@@ -24,6 +24,7 @@ import type { LocalAgentProviderCandidate } from "@ccr/core/contracts/app";
import type { ReactNode } from "react";
const useClientLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
const emptyProviderPlugins: unknown[] = [];
export function ProvidersView({ accountSnapshots, addProvider, editProvider, notify, providers, removeProvider, setProviderEnabled }: {
accountSnapshots: ProviderAccountSnapshot[];
@@ -1975,7 +1976,7 @@ export function AddProviderForm({
onSelectStep,
probe,
probeLoading,
providerPlugins = [],
providerPlugins = emptyProviderPlugins,
providers
}: {
activeStep?: ProviderSetupStepId;
@@ -2013,6 +2014,10 @@ export function AddProviderForm({
const detectedBaseUrl = providerCapabilityBaseUrlForProtocol(draft.baseUrl, detectedProtocol, probe);
const safetyIssue = providerDraftSafetyIssue(draft, detectedBaseUrl);
const localAgentImport = draft.providerPlugins.length > 0;
const localAgentProviderPlugins = useMemo(
() => [...providerPlugins, ...draft.providerPlugins],
[draft.providerPlugins, providerPlugins]
);
const manualProtocolDetection = draft.protocolDetectionMode === "manual";
const providerPresetOptions = [
{ iconUrl: draft.icon, label: t("Other / custom API endpoint"), value: customProviderPresetId },
@@ -2265,7 +2270,7 @@ export function AddProviderForm({
<LocalAgentProviderImportPanel
mode={mode}
onChange={onChange}
providerPlugins={[...providerPlugins, ...draft.providerPlugins]}
providerPlugins={localAgentProviderPlugins}
providers={providers}
/>
<div className="block min-w-0 space-y-1 sm:col-span-2">
@@ -3159,7 +3164,7 @@ export function AddProviderDialog({
onSubmit,
probe,
probeLoading,
providerPlugins = [],
providerPlugins = emptyProviderPlugins,
providers,
submitLabel,
title
@@ -1440,12 +1440,12 @@ export function profileSummaryItems(
const resolvedBotGateway = savedBot?.botGateway ?? profile.botGateway ?? config.botGateway;
const botSummaryItems = surface !== "cli" && resolvedBotGateway?.enabled && resolvedBotGateway.platform !== "none"
? [{ label: t("Bot"), value: `${t("Enabled")} (${savedBot ? botGatewaySavedConfigLabel(savedBot, t) : t(botGatewayPlatformLabel(resolvedBotGateway.platform))})` }]
: surface !== "cli" && profile.botGateway
? [{ label: t("Bot"), value: t("Disabled") }]
: [];
: [];
const managedCompactItems = profile.agent === "zcode"
? []
: [{ label: t("CCR managed compact"), value: profile.managedCompact ? t("Enabled") : t("Disabled") }];
: profile.managedCompact
? [{ label: t("CCR managed compact"), value: t("Enabled") }]
: [];
const smallFastModel = profile.smallFastModel?.trim() || "";
const modelValue = profile.model.trim()
? profileModelDisplayValue(
@@ -1497,7 +1497,7 @@ export function profileSummaryItems(
return [
{ label: t("Model"), value: modelValue },
{ label: t("Provider ID"), value: profile.providerId ?? "claude-code-router" },
...(profile.agent === "zcode" || profile.agent === "opencode" ? [] : [{ label: t("Show all sessions"), value: profile.showAllSessions ? t("Enabled") : t("Disabled") }]),
...(profile.agent === "zcode" || profile.agent === "opencode" || !profile.showAllSessions ? [] : [{ label: t("Show all sessions"), value: t("Enabled") }]),
...managedCompactItems,
...appPathSummaryItems,
...botSummaryItems,
@@ -152,6 +152,42 @@ test("profileSummaryItems uses Kimi-specific model labels", () => {
assert.equal(items[1]?.value, "2");
});
test("profileSummaryItems omits disabled profile properties from cards", () => {
const config = appConfigFixture();
const disabledItems = profileSummaryItems({
agent: "codex",
botGateway: { enabled: false, platform: "slack" } as NonNullable<ProfileConfig["botGateway"]>,
enabled: true,
id: "codex-main",
managedCompact: false,
model: "openai/gpt-5.2",
name: "Codex Main",
providerId: "claude-code-router",
scope: "ccr",
showAllSessions: false,
surface: "auto"
}, config, (value) => value);
assert.deepEqual(disabledItems.map((item) => item.label), ["Model", "Provider ID"]);
assert.doesNotMatch(disabledItems.map((item) => item.value).join(" "), /Disabled/);
const enabledItems = profileSummaryItems({
agent: "codex",
enabled: true,
id: "codex-main",
managedCompact: true,
model: "openai/gpt-5.2",
name: "Codex Main",
providerId: "claude-code-router",
scope: "ccr",
showAllSessions: true,
surface: "auto"
}, config, (value) => value);
assert.match(enabledItems.map((item) => item.label).join(" "), /Show all sessions/);
assert.match(enabledItems.map((item) => item.label).join(" "), /CCR managed compact/);
});
test("detected CHATGPT_APP_PATH is used as the Codex profile default", () => {
const detectedPath = "/Applications/ChatGPT.app/Contents/MacOS/ChatGPT";
const draft = profileDraftWithDetectedAppPath(createProfileDraft("codex"), ` ${detectedPath} `);