Skip to content

Build your personal knowledge base with Trilium Notes

fix(llm): disable the Claude Code card in standalone

Elian Doranf7cbbd9a78d8
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index d36e65625b..0c2ccf0e03 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -3848,6 +3848,7 @@
"provider_name": "Name",
"beta": "Beta",
"provider_desc_claude_agent": "Requires Claude Code on the machine running Trilium.",
+ "provider_unavailable_standalone": "Unavailable in the browser version: this provider works by running Claude Code as a separate program, and there is no machine here to run it on.",
"actions": "Actions",
"delete_provider": "Delete",
"delete_provider_confirmation": "Are you sure you want to delete the provider \"{{name}}\"?",
diff --git a/apps/client/src/widgets/react/SelectableCard.css b/apps/client/src/widgets/react/SelectableCard.css
index ada9bc222a..9efdb8bcb5 100644
--- a/apps/client/src/widgets/react/SelectableCard.css
+++ b/apps/client/src/widgets/react/SelectableCard.css
@@ -22,10 +22,25 @@ body.mobile .selectable-card-grid {
cursor: pointer;
}
-.selectable-card:hover {
+.selectable-card:hover:not(:disabled) {
border-color: var(--main-text-color);
}
+/* A choice that exists but can't be taken here. The icon and name fade so the tile
+ reads as out of reach at a glance, while the description — which carries the
+ reason — stays at its normal weight, since that is the one part still worth
+ reading. */
+.selectable-card:disabled {
+ cursor: not-allowed;
+ background: transparent;
+}
+
+.selectable-card:disabled .selectable-card-name,
+.selectable-card:disabled .masked-icon,
+.selectable-card:disabled .selectable-card-bxicon {
+ opacity: 0.5;
+}
+
.selectable-card.selected {
border-color: var(--main-text-color);
background: var(--active-item-background-color);
diff --git a/apps/client/src/widgets/react/SelectableCard.tsx b/apps/client/src/widgets/react/SelectableCard.tsx
index 94be321dd4..f3954a59fc 100644
--- a/apps/client/src/widgets/react/SelectableCard.tsx
+++ b/apps/client/src/widgets/react/SelectableCard.tsx
@@ -13,6 +13,13 @@ export interface SelectableCardProps {
icon?: string;
selected: boolean;
onSelect: () => void;
+ /**
+ * Greys the tile out and makes it unpickable, while leaving it in the list —
+ * for a choice that exists but can't be taken here. Say why in
+ * {@link description}: a card that simply refuses to respond is worse than no
+ * card at all.
+ */
+ disabled?: boolean;
className?: string;
}
@@ -21,9 +28,9 @@ export interface SelectableCardProps {
* state. Used by the import and export dialogs to pick a provider/format. Lay several out together with
* {@link SelectableCardGrid}.
*/
-export default function SelectableCard({ title, description, iconUrl, icon, selected, onSelect, className }: SelectableCardProps) {
+export default function SelectableCard({ title, description, iconUrl, icon, selected, onSelect, disabled, className }: SelectableCardProps) {
return (
- <button type="button" className={`selectable-card ${selected ? "selected" : ""} ${className ?? ""}`} onClick={onSelect}>
+ <button type="button" className={`selectable-card ${selected ? "selected" : ""} ${className ?? ""}`} onClick={onSelect} disabled={disabled}>
{iconUrl
? <MaskedIcon url={iconUrl} />
: icon ? <span className={`selectable-card-bxicon ${icon}`} /> : null}
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.ts
index d56687be6a..839fa26093 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
@@ -81,6 +81,14 @@ describe("AddProviderModal provider cards", () => {
expect(byId.get("claude-agent")?.baseUrl).toBe("none");
});
+ it("marks Claude Code as the only card a browser-only build cannot run", () => {
+ // It works by running the Claude Code CLI as a separate process, which the
+ // standalone build — whose entire server is a worker in the page — has
+ // nowhere to do; the picker disables that card there rather than dropping
+ // it. Every other provider is reached over HTTP and so runs anywhere.
+ expect(PROVIDER_TYPES.filter(p => p.needsHostProcess).map(p => p.id)).toEqual(["claude-agent"]);
+ });
+
it("gives every card a logo", () => {
// SelectableCard is only passed `iconUrl`, so a card without one renders
// with an empty icon slot rather than falling back to anything.
diff --git a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx
index 7e2e9e521a..8d0b7f7f91 100644
--- a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx
+++ b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx
@@ -6,6 +6,7 @@ import { useMemo, useState } from "preact/hooks";
import { Trans } from "react-i18next";
import { t } from "../../../../services/i18n";
+import { isStandalone } from "../../../../services/utils";
import { Badge } from "../../../react/Badge";
import { Card, CardSection } from "../../../react/Card";
import FormTextBox from "../../../react/FormTextBox";
@@ -52,6 +53,15 @@ export interface ProviderType {
setupHintKey?: string;
/** Marks the provider as beta, shown as a badge next to its name. */
beta?: boolean;
+ /**
+ * The provider drives a program on the machine, so the standalone build —
+ * where the whole server is a worker inside the page — has nothing to run it
+ * on; core refuses to instantiate it there at all. Such a card is shown
+ * disabled with the reason in place of its blurb, rather than dropped: the
+ * provider is documented and the user may well be looking for it, and a list
+ * that silently omits it leaves them hunting.
+ */
+ needsHostProcess?: boolean;
/**
* How the provider authenticates: a key it requires (vendor APIs), one it may
* take (self-hosted endpoints that sit behind a proxy or gateway), or none at
@@ -103,7 +113,7 @@ export const PROVIDER_TYPES: ProviderType[] = [
{ id: "deepseek", name: "DeepSeek", group: "cloud", defaultBaseUrl: "https://api.deepseek.com/v1", iconUrl: PROVIDER_ICONS.deepseek, beta: true },
// 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: PROVIDER_ICONS["claude-agent"], description: t("llm.provider_desc_claude_agent"), beta: true, apiKey: "none", baseUrl: "none" },
+ { id: "claude-agent", name: "Claude Code", group: "subscription", defaultBaseUrl: "", iconUrl: PROVIDER_ICONS["claude-agent"], description: t("llm.provider_desc_claude_agent"), beta: true, apiKey: "none", baseUrl: "none", needsHostProcess: true },
// The three self-hosted cards share one server-side provider; they differ only in
// the endpoint they prefill and the setup hint they show.
// No blurbs: the group heading already says local/self-hosted, and how to start
@@ -425,18 +435,27 @@ function ProviderGroup({ heading, description, columns, providers, selectedProvi
<CardSection>
<p className="add-provider-group-description">{description}</p>
<SelectableCardGrid columns={columns}>
- {providers.map((provider) => (
- <SelectableCard
- key={provider.id}
- iconUrl={provider.iconUrl}
- title={provider.beta
- ? <span className="add-provider-card-heading">{provider.name}<Badge text={t("llm.beta")} className="add-provider-beta-badge" outline /></span>
- : provider.name}
- description={provider.description}
- selected={selectedProvider === provider.id}
- onSelect={() => onSelect(provider.id)}
- />
- ))}
+ {providers.map((provider) => {
+ // A provider this build can't run keeps its place in the list but
+ // states why in place of its blurb — the blurb describes a setup
+ // that isn't on offer here, so it would only mislead.
+ const unavailableReason = provider.needsHostProcess && isStandalone
+ ? t("llm.provider_unavailable_standalone")
+ : undefined;
+ return (
+ <SelectableCard
+ key={provider.id}
+ iconUrl={provider.iconUrl}
+ title={provider.beta
+ ? <span className="add-provider-card-heading">{provider.name}<Badge text={t("llm.beta")} className="add-provider-beta-badge" outline /></span>
+ : provider.name}
+ description={unavailableReason ?? provider.description}
+ selected={selectedProvider === provider.id}
+ onSelect={() => onSelect(provider.id)}
+ disabled={!!unavailableReason}
+ />
+ );
+ })}
</SelectableCardGrid>
</CardSection>
</Card>