Skip to content

Build your personal knowledge base with Trilium Notes

feat(llm): shorten model names and mark them with the provider

Elian Dorandb8447dc6d5e
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.css b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.css
index 8e08043761..144c0d6ec8 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.css
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.css
@@ -248,6 +248,24 @@
white-space: nowrap;
}
+/*
+ * The provider's mark, standing in for the vendor word `shortModelName` drops — the same
+ * information in a glyph's width rather than a word's. Sized just under the label so it
+ * reads as a marker rather than competing with the name it qualifies.
+ */
+.llm-chat-model-icon {
+ --masked-icon-size: 1.05em;
+
+ opacity: 0.8;
+}
+
+/* In the menu the mark sits ahead of the name, which is plain text rather than a wrapped
+ element — so the gap is the icon's own margin. */
+.llm-chat-model-dropdown .llm-chat-model-icon {
+ margin-inline-end: 0.45em;
+ vertical-align: -0.15em;
+}
+
/* Scoped to the dropdown wrapper (not `.llm-chat-model-selector`) so these menu styles
survive `portalToBody`, which reparents the menu to <body> under this same class. */
.llm-chat-model-dropdown small {
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx
index 8563306478..d1b9fdc073 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx
@@ -14,10 +14,13 @@ import CKEditor, { type CKEditorApi } from "../../react/CKEditor.js";
import Dropdown from "../../react/Dropdown.js";
import { FormListHeader, FormListItem } from "../../react/FormList.js";
import { useLegacyImperativeHandlers } from "../../react/hooks.js";
+import MaskedIcon from "../../react/MaskedIcon.js";
import AddProviderModal, { type LlmProviderConfig, type ProviderStep } from "../options/llm/AddProviderModal.js";
+import { providerIconUrl } from "../options/llm/provider_icons.js";
import { computeContextUsage } from "./chat_context_usage.js";
import { insertNewBlock as insertNewBlockCommand, isSelectionInCodeBlock, outdentListItemAtStart } from "./chat_input_editing.js";
import { editorHtmlToMarkdown } from "./chat_input_markdown.js";
+import { shortModelName } from "./model_name.js";
import { SafeImage } from "./retry_image.js";
import { useChatAttachments } from "./useChatAttachments.js";
import { type ModelOption, resolveSelectedModel, type UseLlmChatReturn } from "./useLlmChat.js";
@@ -387,8 +390,14 @@ export default function ChatInputBar({
<div className="llm-chat-options">
<div className="llm-chat-model-selector">
<Dropdown
+ // The provider's mark stands in for the vendor word `shortModelName`
+ // removes — the same information in a glyph's worth of width instead
+ // of a word's, and the only provider signal the collapsed button has.
text={currentModel
- ? <span className="llm-chat-model-select-name">{currentModel.name}</span>
+ ? <>
+ <MaskedIcon url={providerIconUrl(currentModel.provider)} className="llm-chat-model-icon" />
+ <span className="llm-chat-model-select-name">{shortModelName(currentModel.name, currentModel.provider)}</span>
+ </>
: <span className="llm-chat-model-select-name llm-chat-model-placeholder">{t("llm_chat.no_model_selected")}</span>}
disabled={chat.isStreaming}
// The selector is the only item in the row that shrinks, so a long
@@ -422,7 +431,8 @@ export default function ChatInputBar({
onClick={() => handleModelSelect(model)}
checked={isSelectedModel(model)}
>
- {model.name}{model.costDescription && <> <small>({model.costDescription})</small></>}
+ <MaskedIcon url={providerIconUrl(model.provider)} className="llm-chat-model-icon" />
+ {shortModelName(model.name, model.provider)}{model.costDescription && <> <small>({model.costDescription})</small></>}
</FormListItem>
)) : (
// Provider configured before model selection existed (or with
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/model_name.spec.ts b/apps/client/src/widgets/type_widgets/llm_chat/model_name.spec.ts
new file mode 100644
index 0000000000..f1c22eb250
--- /dev/null
+++ b/apps/client/src/widgets/type_widgets/llm_chat/model_name.spec.ts
@@ -0,0 +1,38 @@
+import { describe, expect, it } from "vitest";
+
+import { shortModelName } from "./model_name.js";
+
+describe("shortModelName", () => {
+ it("drops the vendor word when a family word remains", () => {
+ expect(shortModelName("Claude Sonnet 4.5", "anthropic")).toBe("Sonnet 4.5");
+ expect(shortModelName("Claude Opus 4.8", "claude-agent")).toBe("Opus 4.8");
+ expect(shortModelName("DeepSeek V4 Pro", "deepseek")).toBe("V4 Pro");
+ });
+
+ it("keeps the vendor word when dropping it would leave a bare version", () => {
+ // For Gemini the vendor word is the family word — "3.1 Pro" identifies nothing.
+ expect(shortModelName("Gemini 3.1 Pro", "google")).toBe("Gemini 3.1 Pro");
+ expect(shortModelName("Gemini 3.5 Flash Lite", "google")).toBe("Gemini 3.5 Flash Lite");
+ // ...but a named Gemini model shortens like any other.
+ expect(shortModelName("Gemini Nano Pro", "google")).toBe("Nano Pro");
+ });
+
+ it("leaves alone providers that don't prefix, and names that don't carry the prefix", () => {
+ expect(shortModelName("GPT-5", "openai")).toBe("GPT-5");
+ expect(shortModelName("GPT-4.1 Mini", "openai")).toBe("GPT-4.1 Mini");
+ expect(shortModelName("llama3.2", "ollama")).toBe("llama3.2");
+ // Right vendor, but the name doesn't start with it.
+ expect(shortModelName("Sonnet 4.5", "anthropic")).toBe("Sonnet 4.5");
+ });
+
+ it("only strips a whole leading word, never a partial match", () => {
+ // "Claudette" starts with "Claude" as a substring but is a different word.
+ expect(shortModelName("Claudette 2", "anthropic")).toBe("Claudette 2");
+ expect(shortModelName("Claude", "anthropic")).toBe("Claude");
+ });
+
+ it("handles an unknown or missing provider without guessing", () => {
+ expect(shortModelName("Claude Sonnet 4.5", undefined)).toBe("Claude Sonnet 4.5");
+ expect(shortModelName("Claude Sonnet 4.5", "openai-compatible")).toBe("Claude Sonnet 4.5");
+ });
+});
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/model_name.ts b/apps/client/src/widgets/type_widgets/llm_chat/model_name.ts
new file mode 100644
index 0000000000..be16e26092
--- /dev/null
+++ b/apps/client/src/widgets/type_widgets/llm_chat/model_name.ts
@@ -0,0 +1,45 @@
+/**
+ * Shortening of model names for display.
+ *
+ * Vendors label their models with their own name in front — "Claude Sonnet 4.5",
+ * "DeepSeek V4 Pro" — and in the picker that word is already carried by the provider's
+ * mark and its group heading, so it is the least informative token on the row. It is also
+ * the token truncation protects: ellipsis is left-anchored, so a squeezed selector shows
+ * "DeepSeek V4…", spending its width on the redundant half and dropping the half that
+ * identifies the model.
+ *
+ * Display only. Model names are persisted inside the `llmProviders` option and selection
+ * matches on `id` (see `resolveSelectedModel`), so nothing here can disturb stored
+ * configuration or which model actually gets sent.
+ */
+
+/**
+ * The vendor word each provider puts in front of its model names. Keyed by provider *type*,
+ * so an OpenAI-compatible endpoint serving someone else's weights is left alone rather than
+ * guessed at. OpenAI is absent deliberately: it labels models "GPT-5", where "GPT" is the
+ * family rather than the vendor, and dropping it would leave "-5".
+ */
+const VENDOR_PREFIXES: Record<string, string> = {
+ anthropic: "Claude",
+ "claude-agent": "Claude",
+ deepseek: "DeepSeek",
+ google: "Gemini"
+};
+
+/**
+ * Drop the vendor word from a model name, but only when what remains still reads as a name.
+ *
+ * "Claude Sonnet 4.5" → "Sonnet 4.5" and "DeepSeek V4 Pro" → "V4 Pro" keep a family word and
+ * lose nothing. "Gemini 3.1 Pro" would become "3.1 Pro" — a bare version — so it keeps its
+ * prefix: for Gemini the vendor word *is* the family word, and it is load-bearing. The guard
+ * is what makes one rule serve both cases instead of needing a per-vendor decision.
+ */
+export function shortModelName(name: string, provider: string | undefined): string {
+ const prefix = provider && VENDOR_PREFIXES[provider];
+ if (!prefix || !name.startsWith(`${prefix} `)) {
+ return name;
+ }
+
+ const remainder = name.slice(prefix.length + 1).trimStart();
+ return /^\p{L}/u.test(remainder) ? remainder : name;
+}
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 7663382c55..7e2e9e521a 100644
--- a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx
+++ b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx
@@ -13,15 +13,8 @@ import MaskedIcon from "../../../react/MaskedIcon";
import SelectableCard, { SelectableCardGrid } from "../../../react/SelectableCard";
import WizardModal, { type WizardStep } from "../../../react/WizardModal";
import OptionsRow from "../components/OptionsRow";
-import anthropicIcon from "./icons/anthropic.svg?url";
-import claudeAgentIcon from "./icons/claude-ai.svg?url";
-import deepseekIcon from "./icons/deepseek.svg?url";
-import geminiIcon from "./icons/gemini.svg?url";
-import lmStudioIcon from "./icons/lmstudio.svg?url";
-import ollamaIcon from "./icons/ollama.svg?url";
-import openaiIcon from "./icons/openai.svg?url";
-import openAiCompatibleIcon from "./icons/robot.svg?url";
import ModelSelection from "./ModelSelection";
+import { PROVIDER_ICONS } from "./provider_icons.js";
export interface LlmProviderConfig {
id: string;
@@ -101,35 +94,35 @@ const PROVIDER_GROUPS = [
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 },
- { id: "openai", name: "OpenAI", group: "cloud", defaultBaseUrl: "https://api.openai.com/v1", iconUrl: openaiIcon },
- { id: "google", name: "Google Gemini", group: "cloud", defaultBaseUrl: "https://generativelanguage.googleapis.com/v1beta", iconUrl: geminiIcon },
+ { id: "anthropic", name: "Anthropic", group: "cloud", defaultBaseUrl: "https://api.anthropic.com/v1", iconUrl: PROVIDER_ICONS.anthropic },
+ { id: "openai", name: "OpenAI", group: "cloud", defaultBaseUrl: "https://api.openai.com/v1", iconUrl: PROVIDER_ICONS.openai },
+ { id: "google", name: "Google Gemini", group: "cloud", defaultBaseUrl: "https://generativelanguage.googleapis.com/v1beta", iconUrl: PROVIDER_ICONS.google },
// Reachable through the custom endpoint card too — it speaks the OpenAI API —
// but carded here so its models resolve against the committed price table,
// which a nameless endpoint never can.
- { id: "deepseek", name: "DeepSeek", group: "cloud", defaultBaseUrl: "https://api.deepseek.com/v1", iconUrl: deepseekIcon, beta: true },
+ { 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: claudeAgentIcon, 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" },
// 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
// each server belongs on the connection step, where the setup hints live.
{
id: "ollama", name: "Ollama", group: "local", defaultBaseUrl: "http://localhost:11434", prefillBaseUrl: true,
- iconUrl: ollamaIcon,
+ iconUrl: PROVIDER_ICONS.ollama,
setupHintKey: "llm.setup_hint_ollama", apiKey: "none", baseUrl: "required",
beta: true
},
{
id: "lmstudio", name: "LM Studio", group: "local", defaultBaseUrl: "http://localhost:1234/v1", prefillBaseUrl: true,
- iconUrl: lmStudioIcon,
+ iconUrl: PROVIDER_ICONS.lmstudio,
setupHintKey: "llm.setup_hint_lmstudio", apiKey: "none", baseUrl: "required",
beta: true
},
{
id: "openai-compatible", name: t("llm.provider_openai_compatible"), group: "custom", defaultBaseUrl: "http://localhost:8080/v1",
- iconUrl: openAiCompatibleIcon, description: t("llm.provider_desc_openai_compatible"),
+ iconUrl: PROVIDER_ICONS["openai-compatible"], description: t("llm.provider_desc_openai_compatible"),
setupHintKey: "llm.setup_hint_openai_compatible", apiKey: "optional", baseUrl: "required",
beta: true
}
diff --git a/apps/client/src/widgets/type_widgets/options/llm/provider_icons.ts b/apps/client/src/widgets/type_widgets/options/llm/provider_icons.ts
new file mode 100644
index 0000000000..a37183f0a9
--- /dev/null
+++ b/apps/client/src/widgets/type_widgets/options/llm/provider_icons.ts
@@ -0,0 +1,40 @@
+/**
+ * Per-provider marks, shared by the provider setup wizard and the chat model picker.
+ *
+ * Keyed by provider *type* (`LlmProviderConfig.provider`), not by the user's configuration
+ * id — two Ollama configurations show the same mark, which is why the model picker keeps its
+ * per-configuration group headers rather than relying on the icon alone to tell them apart.
+ *
+ * Rendered through `MaskedIcon`, so these are tinted monochrome with `currentColor` rather
+ * than shown in brand colours: the shape is what distinguishes them, and monochrome sits
+ * with the rest of Trilium's chrome.
+ */
+
+import anthropicIcon from "./icons/anthropic.svg?url";
+import claudeAgentIcon from "./icons/claude-ai.svg?url";
+import deepseekIcon from "./icons/deepseek.svg?url";
+import geminiIcon from "./icons/gemini.svg?url";
+import lmStudioIcon from "./icons/lmstudio.svg?url";
+import ollamaIcon from "./icons/ollama.svg?url";
+import openaiIcon from "./icons/openai.svg?url";
+import openAiCompatibleIcon from "./icons/robot.svg?url";
+
+export const PROVIDER_ICONS: Record<string, string> = {
+ anthropic: anthropicIcon,
+ "claude-agent": claudeAgentIcon,
+ deepseek: deepseekIcon,
+ google: geminiIcon,
+ lmstudio: lmStudioIcon,
+ ollama: ollamaIcon,
+ openai: openaiIcon,
+ "openai-compatible": openAiCompatibleIcon
+};
+
+/**
+ * The mark for a provider type, falling back to the generic one so a provider added later —
+ * or a configuration restored from a newer version — still gets a glyph rather than a gap
+ * that would misalign the row.
+ */
+export function providerIconUrl(provider: string | undefined): string {
+ return (provider && PROVIDER_ICONS[provider]) || openAiCompatibleIcon;
+}