Skip to content

Build your personal knowledge base with Trilium Notes

feat(llm): give each provider group its own card

Elian Dorand56629d64591
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index c7f4859c37..e019eb8847 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -3157,7 +3157,6 @@
"configured_providers": "Configured Providers",
"no_providers_configured": "No providers configured yet.",
"provider_name": "Name",
- "provider_type": "Provider",
"beta": "Beta",
"provider_desc_anthropic": "Claude models via the Anthropic API.",
"provider_desc_claude_agent": "Requires Claude Code on the machine running Trilium.",
diff --git a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.css b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.css
index c6bf7228ae..b63c7534e3 100644
--- a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.css
+++ b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.css
@@ -13,26 +13,10 @@
margin-bottom: 0;
}
- /* Sections of the provider list ("Cloud" / "Local"), separated by a rule so the
- self-hosted options read as a distinct family rather than more of the same. */
- .add-provider-group + .add-provider-group {
- margin-top: 1em;
- padding-top: 1em;
- border-top: 1px solid var(--main-border-color);
- }
-
- .add-provider-group-heading {
- margin-bottom: 0.15em;
- color: var(--muted-text-color);
- font-size: 0.85em;
- font-weight: bold;
- text-transform: uppercase;
- letter-spacing: 0.04em;
- }
-
- /* Where the notes end up — the distinction the groups exist to draw. */
+ /* Where the notes end up — the distinction the groups exist to draw. Sits at
+ the top of its group's card, ahead of the providers it qualifies. */
.add-provider-group-description {
- margin-bottom: 0.6em;
+ margin-bottom: 0.75em;
color: var(--muted-text-color);
font-size: 0.85em;
}
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 ceec5ea66c..f1d812aba0 100644
--- a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx
+++ b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx
@@ -8,10 +8,10 @@ import { Trans } from "react-i18next";
import { t } from "../../../../services/i18n";
import { Badge } from "../../../react/Badge";
import { Card, CardSection } from "../../../react/Card";
-import FormGroup from "../../../react/FormGroup";
import FormTextBox from "../../../react/FormTextBox";
import Modal from "../../../react/Modal";
import SelectableCard, { SelectableCardGrid } from "../../../react/SelectableCard";
+import OptionsRow from "../components/OptionsRow";
import anthropicIcon from "./icons/anthropic.svg?url";
import claudeAgentIcon from "./icons/claude-ai.svg?url";
import geminiIcon from "./icons/gemini.svg?url";
@@ -196,7 +196,7 @@ export default function AddProviderModal({ show, onHidden, onSave, existingProvi
// (the endpoint is their primary connection detail) or after it for vendor
// ones, where it is only an override — hence the focus following the same rule.
const baseUrlField = (
- <FormGroup name="base-url" label={t("llm.base_url")} description={baseUrlDescription}>
+ <OptionsRow name="base-url" label={t("llm.base_url")} description={baseUrlDescription} stacked>
<FormTextBox
type="text"
currentValue={baseUrl}
@@ -204,7 +204,7 @@ export default function AddProviderModal({ show, onHidden, onSave, existingProvi
placeholder={providerType?.defaultBaseUrl}
autoFocus={baseUrlMode === "required"}
/>
- </FormGroup>
+ </OptionsRow>
);
const modelQuery = useMemo(
@@ -318,34 +318,34 @@ export default function AddProviderModal({ show, onHidden, onSave, existingProvi
}
>
{step === "provider" ? (
- <Card heading={t("llm.provider_type")}>
- <CardSection>
- {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>
+ // One card per group rather than one "Provider" card holding them all:
+ // the groups are the step's structure, so each gets the heading and the
+ // enclosure, and the choices below it are only the ones it describes.
+ 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}
+ />
+ ))
) : step === "connection" ? (
- // A single unlabelled section: the step holds a handful of fields for
- // one provider — already named in the modal title — so splitting them
- // across headed cards would announce structure that isn't there.
+ // A single unlabelled card of settings rows: the step holds a handful of
+ // fields for one provider — already named in the modal title — so the
+ // hairline between rows is all the structure it needs.
<Card>
<CardSection>
{/* Self-hosted providers lead with the endpoint — the port is the
detail that has to be right — and treat the key as optional. */}
{baseUrlMode === "required" && baseUrlField}
{usesApiKey && (
- <FormGroup
+ <OptionsRow
name="api-key"
label={t("llm.api_key")}
description={apiKeyMode === "optional" ? t("llm.api_key_optional_description") : undefined}
+ stacked
>
<FormTextBox
type="password"
@@ -354,7 +354,7 @@ export default function AddProviderModal({ show, onHidden, onSave, existingProvi
placeholder={t("llm.api_key_placeholder")}
autoFocus={baseUrlMode !== "required"}
/>
- </FormGroup>
+ </OptionsRow>
)}
{baseUrlMode === "advanced" && baseUrlField}
{!usesApiKey && baseUrlMode === "none" && (
@@ -384,10 +384,14 @@ export default function AddProviderModal({ show, onHidden, onSave, existingProvi
}
/**
- * One labelled section of the provider list. Laid out one provider per row so
- * each description fits on a single line — the list is the whole step, so it can
- * afford the width, and it stays identical on mobile where a grid would collapse
- * to one column anyway.
+ * One group of the provider list, as its own card. The blurb sits inside the card
+ * above the choices, the way the settings pages place a section description, so it
+ * reads as an introduction to the rows it qualifies rather than as a caption
+ * floating between two boxes.
+ *
+ * Laid out one provider per row so each description fits on a single line — the
+ * list is the whole step, so it can afford the width, and it stays identical on
+ * mobile where a grid would collapse to one column anyway.
*/
function ProviderGroup({ heading, description, providers, selectedProvider, onSelect }: {
heading: string;
@@ -399,24 +403,25 @@ function ProviderGroup({ heading, description, providers, selectedProvider, onSe
onSelect: (providerId: string) => void;
}) {
return (
- <div className="add-provider-group">
- <h5 className="add-provider-group-heading">{heading}</h5>
- <p className="add-provider-group-description">{description}</p>
- <SelectableCardGrid columns={1}>
- {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)}
- />
- ))}
- </SelectableCardGrid>
- </div>
+ <Card heading={heading} className="add-provider-group">
+ <CardSection>
+ <p className="add-provider-group-description">{description}</p>
+ <SelectableCardGrid columns={1}>
+ {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)}
+ />
+ ))}
+ </SelectableCardGrid>
+ </CardSection>
+ </Card>
);
}