Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(llm): split subscription providers into their own group
Elian Doran7e92801cd41d
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 5861d050ee..4b32c1bde5 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -3162,7 +3162,7 @@"advanced_options": "Advanced options","beta": "Beta","provider_desc_anthropic": "Claude models via the Anthropic API. Requires an API key.",- "provider_desc_claude_agent": "Uses your Claude Pro/Max subscription, no API key. Requires Claude Code on the machine running Trilium.",+ "provider_desc_claude_agent": "Claude models via Claude Code, installed on the machine running Trilium.","provider_desc_openai": "GPT models via the OpenAI API. Requires an API key.","provider_desc_google": "Gemini models via the Google API. Requires an API key.","actions": "Actions",@@ -3176,9 +3176,11 @@"claude_agent_description": "Uses your Claude Pro/Max subscription through Claude Code, so no API key is needed. Claude Code must be installed on the machine running Trilium (the server when self-hosting, or this computer on desktop); sign in once by running \"claude /login\" there.","add_provider_title_named": "Add {{name}}","provider_group_cloud": "Cloud providers",- "provider_group_cloud_description": "Your notes are sent to the provider's servers.",+ "provider_group_cloud_description": "Pay per use with an API key, billed separately from any subscription you already have. Your notes are sent to the provider's servers.",+ "provider_group_subscription": "Subscription",+ "provider_group_subscription_description": "Reuses a subscription you already pay for, at no extra cost. Your notes are sent to the provider's servers.","provider_group_local": "Local / self-hosted",- "provider_group_local_description": "Your notes only reach the machine running the model.",+ "provider_group_local_description": "No usage cost. Your notes only reach the machine running the model.","provider_desc_ollama": "Local models via an Ollama instance. No API key needed — just the instance URL.","provider_desc_lmstudio": "Local models via LM Studio's built-in server. No API key needed — just the server URL.","provider_openai_compatible": "OpenAI-compatible",diff --git a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.spec.ts b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.spec.tsindex 9dc2a860ef..b8ce7bca5c 100644--- a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.spec.ts+++ b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.spec.ts@@ -32,12 +32,22 @@ describe("AddProviderModal provider cards", () => {}});- it("sorts every card into a list section, with the local one matching the self-hosted set", () => {- // The two are independent fields but describe the same thing, so a card- // added to one and not the other would land in the wrong section.- expect(PROVIDER_TYPES.filter(p => p.group === "local").map(p => p.id)).toEqual(SELF_HOSTED);+ it("sorts every card into a billing section, with the local one matching the self-hosted set", () => {+ // Groups follow the user guide's taxonomy: metered API keys, a fixed-fee+ // subscription reused from elsewhere, and self-hosted. `group` and+ // `baseUrl` are independent fields describing the same split for the local+ // set, so a card added to one and not the other would land in the wrong section.expect(PROVIDER_TYPES.filter(p => p.group === "cloud").map(p => p.id))- .toEqual(["anthropic", "claude-agent", "openai", "google"]);+ .toEqual(["anthropic", "openai", "google"]);+ expect(PROVIDER_TYPES.filter(p => p.group === "subscription").map(p => p.id))+ .toEqual(["claude-agent"]);+ expect(PROVIDER_TYPES.filter(p => p.group === "local").map(p => p.id)).toEqual(SELF_HOSTED);+ });++ it("bills every subscription provider through an existing account rather than a key", () => {+ for (const card of PROVIDER_TYPES.filter(p => p.group === "subscription")) {+ expect(card.apiKey, `${card.id} should not ask for an API key`).toBe("none");+ }});it("keeps vendor cards on a required key and an advanced endpoint override", () => {diff --git a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsxindex e31a732c34..8b96e6fd58 100644--- a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx+++ b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx@@ -62,18 +62,33 @@ export interface ProviderType {* an advanced override (vendor APIs), or not applicable. Defaults to `"advanced"`.*/baseUrl?: "required" | "advanced" | "none";- /** Which section of the provider list this card belongs to. */- group: "cloud" | "local";+ /**+ * Which section of the provider list this card belongs to — how it is billed,+ * mirroring the three the user guide describes: metered API keys, a fixed-fee+ * subscription reused from elsewhere, and self-hosted.+ */+ group: ProviderGroupId;}-// The two Claude-powered providers lead the list so they sit together at the top,-// making the subscription-vs-API-key choice easy to spot.+/**+ * List sections, in the order they are shown. Keys are spelled out rather than+ * built from the id so they stay greppable for the translation tooling.+ */+const PROVIDER_GROUPS = [+ { id: "cloud", headingKey: "llm.provider_group_cloud", descriptionKey: "llm.provider_group_cloud_description" },+ { id: "subscription", headingKey: "llm.provider_group_subscription", descriptionKey: "llm.provider_group_subscription_description" },+ { id: "local", headingKey: "llm.provider_group_local", descriptionKey: "llm.provider_group_local_description" }+] as const;++type ProviderGroupId = (typeof PROVIDER_GROUPS)[number]["id"];+export const PROVIDER_TYPES: ProviderType[] = [{ id: "anthropic", name: "Anthropic", group: "cloud", defaultBaseUrl: "https://api.anthropic.com/v1", iconUrl: anthropicIcon, description: t("llm.provider_desc_anthropic") },- // Uses the Claude Agent SDK on the server; auth belongs to Claude Code (`claude /login`).- { id: "claude-agent", name: "Claude Code", group: "cloud", defaultBaseUrl: "", iconUrl: claudeAgentIcon, description: t("llm.provider_desc_claude_agent"), beta: true, apiKey: "none", baseUrl: "none" },{ id: "openai", name: "OpenAI", group: "cloud", defaultBaseUrl: "https://api.openai.com/v1", iconUrl: openaiIcon, description: t("llm.provider_desc_openai") },{ id: "google", name: "Google Gemini", group: "cloud", defaultBaseUrl: "https://generativelanguage.googleapis.com/v1beta", iconUrl: geminiIcon, description: t("llm.provider_desc_google") },+ // Uses the Claude Agent SDK on the server; auth belongs to Claude Code (`claude /login`),+ // and usage is covered by the subscription rather than charged per token.+ { id: "claude-agent", name: "Claude Code", group: "subscription", defaultBaseUrl: "", iconUrl: claudeAgentIcon, description: t("llm.provider_desc_claude_agent"), beta: true, apiKey: "none", baseUrl: "none" },// The three self-hosted cards share one server-side provider; they differ only in// the endpoint they prefill and the setup hint they show.{@@ -286,20 +301,16 @@ export default function AddProviderModal({ show, onHidden, onSave, existingProvi{step === "provider" ? (<Card heading={t("llm.provider_type")}><CardSection>- <ProviderGroup- heading={t("llm.provider_group_cloud")}- description={t("llm.provider_group_cloud_description")}- providers={PROVIDER_TYPES.filter(p => p.group === "cloud")}- selectedProvider={providerChosen ? selectedProvider : undefined}- onSelect={selectProviderType}- />- <ProviderGroup- heading={t("llm.provider_group_local")}- description={t("llm.provider_group_local_description")}- providers={PROVIDER_TYPES.filter(p => p.group === "local")}- selectedProvider={providerChosen ? selectedProvider : undefined}- onSelect={selectProviderType}- />+ {PROVIDER_GROUPS.map(group => (+ <ProviderGroup+ key={group.id}+ heading={t(group.headingKey)}+ description={t(group.descriptionKey)}+ providers={PROVIDER_TYPES.filter(p => p.group === group.id)}+ selectedProvider={providerChosen ? selectedProvider : undefined}+ onSelect={selectProviderType}+ />+ ))}</CardSection></Card>) : step === "connection" ? (