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): keep the chat from sending attachments the model cannot read
Elian Doran51b2f26d75e4
diff --git a/apps/client/src/services/llm_providers.spec.ts b/apps/client/src/services/llm_providers.spec.tsnew file mode 100644index 0000000000..9668348031--- /dev/null+++ b/apps/client/src/services/llm_providers.spec.ts@@ -0,0 +1,31 @@+import type { LlmModelInfo } from "@triliumnext/commons";+import { describe, expect, it } from "vitest";++import { readsAttachmentKind, unreadableAttachments } from "./llm_providers.js";++const textOnly: LlmModelInfo = { id: "deepseek-v4-pro", name: "DeepSeek V4 Pro", attachmentKinds: [] };+const imagesOnly: LlmModelInfo = { id: "codex", name: "Codex", attachmentKinds: [ "image" ] };+const everything: LlmModelInfo = { id: "claude", name: "Claude" };++const png = { type: "image", mime: "image/png" };+const svg = { type: "image", mime: "image/svg+xml" };+const pdf = { type: "file", mime: "application/pdf" };+const markdown = { type: "text_file", mime: "text/markdown" };++describe("attachment support", () => {+ it("finds the attachments a model cannot read, never text files or SVGs", () => {+ const all = [ png, svg, pdf, markdown ];+ expect(unreadableAttachments(textOnly, all)).toEqual([ png, pdf ]);+ expect(unreadableAttachments(imagesOnly, all)).toEqual([ pdf ]);+ // No `attachmentKinds`, or no model at all, restricts nothing.+ expect(unreadableAttachments(everything, all)).toEqual([]);+ expect(unreadableAttachments(undefined, all)).toEqual([]);+ });++ it("says whether a model reads a kind", () => {+ expect(readsAttachmentKind(textOnly, "image")).toBe(false);+ expect(readsAttachmentKind(imagesOnly, "image")).toBe(true);+ expect(readsAttachmentKind(imagesOnly, "file")).toBe(false);+ expect(readsAttachmentKind(everything, "file")).toBe(true);+ });+});diff --git a/apps/client/src/services/llm_providers.ts b/apps/client/src/services/llm_providers.tsindex 26cba7c112..1303364a8c 100644--- a/apps/client/src/services/llm_providers.ts+++ b/apps/client/src/services/llm_providers.ts@@ -1,4 +1,4 @@-import type { LlmModelInfo } from "@triliumnext/commons";+import type { LlmAttachmentKind, LlmModelInfo } from "@triliumnext/commons";import { formatModelCost } from "./llm_model_cost.js";import options from "./options.js";@@ -70,6 +70,30 @@ export function resolveSelectedModel(&& (!selectedProviderId || m.providerId === selectedProviderId));}+/**+ * The attachments `model` cannot read natively. Text files and SVGs reach every model as text, and+ * a model without `attachmentKinds`, or no model at all, restricts nothing.+ */+export function unreadableAttachments<T extends { type: string; mime: string }>(model: LlmModelInfo | undefined, attachments: T[]): T[] {+ return attachments.filter(att => {+ const kind = nativeAttachmentKind(att.type, att.mime);+ return kind !== null && !readsAttachmentKind(model, kind);+ });+}++/** Whether `model` reads an attachment of `kind` natively. */+export function readsAttachmentKind(model: LlmModelInfo | undefined, kind: LlmAttachmentKind): boolean {+ return !model?.attachmentKinds || model.attachmentKinds.includes(kind);+}++/** The kind a model must read natively to take an attachment, or null for one every model gets as text. */+export function nativeAttachmentKind(type: string, mime: string): LlmAttachmentKind | null {+ if (type === "image") {+ return mime === "image/svg+xml" ? null : "image";+ }+ return type === "file" ? "file" : null;+}+/** Minimal shape of a provider config as stored in the `llmProviders` option. */interface StoredProviderConfig {id: string;diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 1963741840..6a392fda01 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -2690,7 +2690,11 @@"dashboards": "Dashboards"},"web_sources_count_one": "({{count}} source)",- "web_sources_count_other": "({{count}} sources)"+ "web_sources_count_other": "({{count}} sources)",+ "attachment_model_cannot_read_image": "{{- model}} can't read images.",+ "attachment_model_cannot_read_file": "{{- model}} can't read PDFs.",+ "attachment_refused": "\"{{name}}\" wasn't attached. {{- reason}}",+ "remove_unreadable_attachments": "Remove the attachments {{- model}} can't read"},"sidebar_chat": {"title": "AI Chat",diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.css b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.cssindex c1f669b150..bed67138ac 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.css+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.css@@ -133,6 +133,26 @@cursor: not-allowed;}+.llm-chat-attachment-chip-unreadable {+ border-color: var(--admonition-warning-accent-color);++ & > :first-child {+ opacity: 0.45;+ }+}++.llm-chat-attachment-unreadable-icon {+ position: absolute;+ bottom: 2px;+ left: 2px;+ border-radius: 50%;+ background: var(--accented-background-color);+ color: var(--admonition-warning-accent-color);+ font-size: 1rem;+ line-height: 1;+ pointer-events: none;+}+/** The editor. Stripped of its own chrome so the island owns the border, the* background and the focus ring. The `!important`s override CKEditor's bundleddiff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsxindex fde6c0df1c..c25896c19f 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx@@ -25,8 +25,8 @@ import { editorHtmlToMarkdown } from "./chat_input_markdown.js";import { shortModelName } from "./model_name.js";import ReasoningEffortDropdown from "./ReasoningEffortDropdown.js";import { SafeImage } from "./retry_image.js";-import { getAttachmentLightbox, useChatAttachments } from "./useChatAttachments.js";-import { type ModelOption, resolveSelectedModel } from "../../../services/llm_providers.js";+import { getAttachmentLightbox, unreadableReason, useChatAttachments } from "./useChatAttachments.js";+import { type ModelOption, nativeAttachmentKind, resolveSelectedModel, unreadableAttachments } from "../../../services/llm_providers.js";import { type AttachmentBlock, type UseLlmChatReturn } from "./useLlmChat.js";const READ_ONLY_LOCK = "llm-chat-streaming";@@ -143,14 +143,15 @@ export default function ChatInputBar({// the draft state) avoids the React-render / CKEditor-change-event race that left// the editor visually populated after submit.const handleSubmit = useCallback((e: Event) => {- const hasResolvedModel = !!resolveSelectedModel(chat.availableModels, chat.selectedModel, chat.selectedProvider, chat.selectedProviderId);- const willSubmit = (chat.hasInputText || chat.pendingAttachments.length > 0) && !chat.isStreaming && hasResolvedModel;+ const model = resolveSelectedModel(chat.availableModels, chat.selectedModel, chat.selectedProvider, chat.selectedProviderId);+ const willSubmit = (chat.hasInputText || chat.pendingAttachments.length > 0) && !chat.isStreaming && !!model+ && unreadableAttachments(model, chat.pendingAttachments).length === 0;baseSubmit(e);if (willSubmit) {editorApiRef.current?.setText("");editorApiRef.current?.focus();}- }, [baseSubmit, chat.hasInputText, chat.isStreaming, chat.pendingAttachments.length, chat.availableModels, chat.selectedModel, chat.selectedProvider, chat.selectedProviderId]);+ }, [baseSubmit, chat.hasInputText, chat.isStreaming, chat.pendingAttachments, chat.availableModels, chat.selectedModel, chat.selectedProvider, chat.selectedProviderId]);submitRef.current = handleSubmit;// Expose the reply-input editor to the chat hook so timeline actions (e.g. quoting a selection)@@ -243,6 +244,14 @@ export default function ChatInputBar({// shows as selected is exactly what will be sent (see resolveSelectedModel).const currentModel = resolveSelectedModel(chat.availableModels, chat.selectedModel, chat.selectedProvider, chat.selectedProviderId);const isSelectedModel = (m: ModelOption) => m === currentModel;+ const unreadable = unreadableAttachments(currentModel, chat.pendingAttachments);+ const unreadableReasons = new Map<string, string>();+ for (const att of unreadable) {+ const kind = nativeAttachmentKind(att.type, att.mime);+ if (currentModel && kind) {+ unreadableReasons.set(att.attachmentId, unreadableReason(currentModel, kind));+ }+ }// Gemini 2.x cannot combine googleSearch with function tools in a single// request. When note tools are enabled on a Gemini model we silently drop// web search server-side; reflect that here by disabling the toggle so the@@ -302,22 +311,13 @@ export default function ChatInputBar({{chat.pendingAttachments.length > 0 && (<div className="llm-chat-attachments">{chat.pendingAttachments.map((att) => (- <div+ <PendingAttachmentChipkey={att.attachmentId}- className={`llm-chat-attachment-chip llm-chat-attachment-chip-${att.type}`}- title={att.title}- >- <AttachmentChipPreview att={att} />- <button- type="button"- className="llm-chat-attachment-remove"- title={t("llm_chat.remove_attachment")}- onClick={() => chat.removePendingAttachment(att.attachmentId)}- disabled={chat.isStreaming}- >- <span className="bx bx-x" />- </button>- </div>+ att={att}+ reason={unreadableReasons.get(att.attachmentId)}+ onRemove={() => chat.removePendingAttachment(att.attachmentId)}+ disabled={chat.isStreaming}+ />))}</div>)}@@ -553,9 +553,11 @@ export default function ChatInputBar({icon={chat.isStreaming ? "bx bx-stop" : "bx bx-up-arrow-alt"}text={chat.isStreaming? t("llm_chat.stop")- : !currentModel ? t("llm_chat.no_model_selected") : t("llm_chat.send")}+ : !currentModel ? t("llm_chat.no_model_selected")+ : unreadable.length > 0 ? t("llm_chat.remove_unreadable_attachments", { model: currentModel.name })+ : t("llm_chat.send")}onClick={chat.isStreaming ? chat.stopStreaming : handleSubmit}- disabled={!chat.isStreaming && (!currentModel || (!chat.hasInputText && chat.pendingAttachments.length === 0))}+ disabled={!chat.isStreaming && (!currentModel || unreadable.length > 0 || (!chat.hasInputText && chat.pendingAttachments.length === 0))}className={`llm-chat-send-btn ${chat.isStreaming ? "llm-chat-stop-btn" : ""}`}/></div>@@ -596,6 +598,34 @@ export default function ChatInputBar({);}+/** A pending attachment above the input, marked when the selected model can't read it. */+function PendingAttachmentChip({ att, reason, onRemove, disabled }: {+ att: AttachmentBlock;+ /** Why the selected model can't read it; undefined when it can. */+ reason?: string;+ onRemove: () => void;+ disabled: boolean;+}) {+ return (+ <div+ className={`llm-chat-attachment-chip llm-chat-attachment-chip-${att.type} ${reason ? "llm-chat-attachment-chip-unreadable" : ""}`}+ title={reason ? `${att.title}\n${reason}` : att.title}+ >+ <AttachmentChipPreview att={att} />+ {reason && <span className="bx bx-error llm-chat-attachment-unreadable-icon" />}+ <button+ type="button"+ className="llm-chat-attachment-remove"+ title={t("llm_chat.remove_attachment")}+ onClick={onRemove}+ disabled={disabled}+ >+ <span className="bx bx-x" />+ </button>+ </div>+ );+}+/** The inside of a pending attachment's chip; an image or PDF opens in the lightbox when clicked. */function AttachmentChipPreview({ att }: { att: AttachmentBlock }) {const lightbox = getAttachmentLightbox(att);diff --git a/apps/client/src/widgets/type_widgets/llm_chat/useChatAttachments.spec.ts b/apps/client/src/widgets/type_widgets/llm_chat/useChatAttachments.spec.tsindex dc1bd6ddd4..52c9cfa56f 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/useChatAttachments.spec.ts+++ b/apps/client/src/widgets/type_widgets/llm_chat/useChatAttachments.spec.ts@@ -1,6 +1,11 @@-import { describe, expect, it } from "vitest";+import type { LlmModelInfo } from "@triliumnext/commons";+import { describe, expect, it, vi } from "vitest";-import { getAttachmentLightbox } from "./useChatAttachments";+vi.mock("../../../services/i18n.js", () => ({+ t: (key: string, options?: Record<string, unknown>) => (options ? `${key} ${JSON.stringify(options)}` : key)+}));++import { acceptAttrFor, getAttachmentLightbox, uploadRefusal } from "./useChatAttachments";describe("getAttachmentLightbox", () => {it("previews images and PDFs, and nothing else", () => {@@ -17,3 +22,31 @@ describe("getAttachmentLightbox", () => {})).toBeUndefined();});});++describe("attachments a model cannot read", () => {+ const textOnly: LlmModelInfo = { id: "deepseek-v4-pro", name: "DeepSeek V4 Pro", attachmentKinds: [] };+ const imagesOnly: LlmModelInfo = { id: "codex", name: "Codex", attachmentKinds: [ "image" ] };+ const file = (name: string, type: string) => new File([ "x" ], name, { type });++ it("offers in the file picker only what the model reads, plus SVGs and text files", () => {+ const accepted = (model?: LlmModelInfo) => acceptAttrFor(model).split(",");+ expect(accepted()).toEqual(expect.arrayContaining([ "image/png", "application/pdf", "image/svg+xml", ".md" ]));+ expect(accepted(imagesOnly)).toContain("image/png");+ expect(accepted(imagesOnly)).not.toContain("application/pdf");+ expect(accepted(textOnly)).toEqual(expect.arrayContaining([ "image/svg+xml", ".md" ]));+ expect(accepted(textOnly)).not.toContain("image/png");+ expect(accepted(textOnly)).not.toContain("application/pdf");+ });++ it("refuses an upload the model cannot read, naming the file and the reason", () => {+ expect(uploadRefusal(textOnly, file("report.pdf", "application/pdf"), "binary_file"))+ .toBe(`llm_chat.attachment_refused {"name":"report.pdf","reason":"llm_chat.attachment_model_cannot_read_file {\\"model\\":\\"DeepSeek V4 Pro\\"}"}`);+ expect(uploadRefusal(textOnly, file("cat.png", "image/png"), "image")).toContain("attachment_model_cannot_read_image");++ // Text files, SVGs, a model that reads the kind, and no model at all go through.+ expect(uploadRefusal(textOnly, file("notes.md", "text/markdown"), "text_file")).toBeUndefined();+ expect(uploadRefusal(textOnly, file("d.svg", "image/svg+xml"), "image")).toBeUndefined();+ expect(uploadRefusal(imagesOnly, file("cat.png", "image/png"), "image")).toBeUndefined();+ expect(uploadRefusal(undefined, file("report.pdf", "application/pdf"), "binary_file")).toBeUndefined();+ });+});diff --git a/apps/client/src/widgets/type_widgets/llm_chat/useChatAttachments.ts b/apps/client/src/widgets/type_widgets/llm_chat/useChatAttachments.tsindex de348c266f..30421413dd 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/useChatAttachments.ts+++ b/apps/client/src/widgets/type_widgets/llm_chat/useChatAttachments.ts@@ -1,7 +1,9 @@+import type { LlmAttachmentKind, LlmModelInfo } from "@triliumnext/commons";import { RefObject } from "preact";import { useCallback, useRef } from "preact/hooks";import { t } from "../../../services/i18n.js";+import { nativeAttachmentKind, readsAttachmentKind, resolveSelectedModel } from "../../../services/llm_providers.js";import server from "../../../services/server.js";import toast from "../../../services/toast.js";import type { LightboxOptions } from "../../dialogs/lightbox.js";@@ -35,8 +37,6 @@ const ACCEPTED_TEXT_EXTENSIONS = [".html", ".htm", ".css", ".scss", ".vue", ".svelte"];-/** Joined `accept=` value for the hidden `<input type="file">` element. */-const ACCEPT_ATTR = [...ACCEPTED_IMAGE_TYPES, ...ACCEPTED_BINARY_FILE_TYPES, ...ACCEPTED_TEXT_EXTENSIONS].join(",");/** Best-effort classification of an uploaded file. */type UploadKind = "image" | "binary_file" | "text_file" | null;@@ -156,6 +156,12 @@ export function useChatAttachments(chat: UseLlmChatReturn): UseChatAttachmentsRetoast.showError(t("llm_chat.attachment_unsupported_type", { name: file.name }));return;}+ const model = resolveSelectedModel(chat.availableModels, chat.selectedModel, chat.selectedProvider, chat.selectedProviderId);+ const refusal = uploadRefusal(model, file, kind);+ if (refusal) {+ toast.showError(refusal);+ return;+ }const block = await uploadFileAsAttachment(chat.chatNoteId, file, kind);if (block) {chat.addPendingAttachment(block);@@ -216,9 +222,11 @@ export function useChatAttachments(chat: UseLlmChatReturn): UseChatAttachmentsRefileInputRef.current?.click();}, []);+ const model = resolveSelectedModel(chat.availableModels, chat.selectedModel, chat.selectedProvider, chat.selectedProviderId);+return {fileInputRef,- acceptAttr: ACCEPT_ATTR,+ acceptAttr: acceptAttrFor(model),pasteHandlerRef,openFilePicker,handleFilePickerChange,@@ -227,6 +235,27 @@ export function useChatAttachments(chat: UseLlmChatReturn): UseChatAttachmentsRe};}+/** `accept` for the file input: what `model` reads natively, plus SVGs and text files, which every model gets as text. */+export function acceptAttrFor(model: LlmModelInfo | undefined): string {+ const images = readsAttachmentKind(model, "image") ? ACCEPTED_IMAGE_TYPES : [ "image/svg+xml" ];+ const files = readsAttachmentKind(model, "file") ? ACCEPTED_BINARY_FILE_TYPES : [];+ return [ ...images, ...files, ...ACCEPTED_TEXT_EXTENSIONS ].join(",");+}++/** Why `model` can't read an attachment of `kind`. */+export function unreadableReason(model: LlmModelInfo, kind: LlmAttachmentKind): string {+ return t(`llm_chat.attachment_model_cannot_read_${kind}`, { model: model.name });+}++/** The error for a file `model` can't read, which is then not uploaded; undefined when it can. */+export function uploadRefusal(model: LlmModelInfo | undefined, file: File, kind: Exclude<UploadKind, null>): string | undefined {+ const nativeKind = nativeAttachmentKind(kind === "binary_file" ? "file" : kind, file.type);+ if (!model || !nativeKind || readsAttachmentKind(model, nativeKind)) {+ return undefined;+ }+ return t("llm_chat.attachment_refused", { name: file.name, reason: unreadableReason(model, nativeKind) });+}+/*** What the lightbox shows for an attachment: an image, or a PDF read through* `attachments/<id>/open`. Other files have no preview and return `undefined`.diff --git a/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.spec.tsx b/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.spec.tsxindex 91e9184230..69923ba83d 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.spec.tsx+++ b/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.spec.tsx@@ -162,6 +162,35 @@ describe("useLlmChat", () => {expect(options.providerId).toBe("ca_1");});+ it("holds back a message whose attachments the model cannot read, until the model changes", async () => {+ optionsGetJsonMock.mockReturnValue([+ { id: "ds_1", name: "DeepSeek", provider: "deepseek", selectedModels: [+ { id: "deepseek-v4-pro", name: "DeepSeek V4 Pro", isDefault: true, attachmentKinds: [] }+ ] },+ { id: "a_1", name: "Anthropic", provider: "anthropic", selectedModels: [{ id: "opus", name: "Opus" }] }+ ]);+ await mountChat();+ expect(api().selectedModel).toBe("deepseek-v4-pro");+ await act(async () => {+ api().setInput("Summarize this");+ api().addPendingAttachment({ type: "file", attachmentId: "pdf1", mime: "application/pdf", title: "report.pdf", url: "#" });+ });++ await act(async () => {+ await api().handleSubmit(new Event("submit"));+ });+ expect(streamChatCompletionMock).not.toHaveBeenCalled();+ expect(api().pendingAttachments).toHaveLength(1);++ await act(async () => {+ api().setSelectedModel("opus", "anthropic", "a_1");+ });+ await act(async () => {+ await api().handleSubmit(new Event("submit"));+ });+ expect(streamChatCompletionMock).toHaveBeenCalledOnce();+ });+it("resolves the provider by model ID for chats saved before selectedProvider existed", async () => {await mountChat();// A pre-selectedProvider chat: content carries a model but no provider.diff --git a/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts b/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.tsindex 1f188f7b6a..4428605cdd 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts+++ b/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts@@ -3,7 +3,7 @@ import { RefObject } from "preact";import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "preact/hooks";import { streamChatCompletion } from "../../../services/llm_chat.js";-import { type ModelOption, type ModelProviderGroup, readSelectedModels, resolveSelectedModel } from "../../../services/llm_providers.js";+import { type ModelOption, type ModelProviderGroup, readSelectedModels, resolveSelectedModel, unreadableAttachments } from "../../../services/llm_providers.js";import { randomString } from "../../../services/utils.js";import { useTriliumEvent } from "../../react/hooks.js";import { estimateTokens, quantizeDraftTokens } from "./chat_context_usage.js";@@ -839,12 +839,15 @@ export function useLlmChat(// restore a model ID that has since been deselected (so it's absent from// availableModels). Sending it anyway would let the server silently fall// back to some default, so block until an available model is chosen.- if (!resolveSelectedModel(availableModelsRef.current, selectedModelRef.current, selectedProviderRef.current, selectedProviderIdRef.current)) {+ const model = resolveSelectedModel(availableModelsRef.current, selectedModelRef.current, selectedProviderRef.current, selectedProviderIdRef.current);+ if (!model) {return;}const trimmedInput = inputRef.current.trim();const attachments = pendingAttachmentsRef.current;if (!trimmedInput && attachments.length === 0) return;+ // An attachment the model can't read would reach it as a placeholder only; the input bar says why Send is blocked.+ if (unreadableAttachments(model, attachments).length > 0) return;// If there are attachments, build a block-shaped content array so the// images travel alongside the text. Otherwise stay with the simplediff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI.htmlindex 89c8209c80..4ec0670e95 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI.html@@ -247,9 +247,19 @@ class="admonition note"><li>SVG images (sent as raw HTML).</li><li>Text files.</li></ul>-<p>A model that can't read an attachment receives only its name, such as <code>[attached file: report.pdf]</code>,- so it can tell you it doesn't see the content. DeepSeek reads no PDFs,- and images only with its vision models.</p>+<p>Not every model reads every kind of attachment: DeepSeek reads no PDFs,+ and images only with its vision models; OpenAI Codex, GitHub Copilot and+ Google Antigravity read images but no PDFs. For such a model:</p>+<ul>+ <li>The attach button offers only the kinds the model reads, and a pasted+ or dropped file it can't read is not attached.</li>+ <li>After switching to such a model, an attachment it can't read is marked+ with a <span class="tn-icon bx bx-error"></span> warning, and the message+ can't be sent until the attachment is removed or another model is selected.</li>+ <li>An attachment sent in an earlier message reaches the model as its name+ only, such as <code>[attached file: report.pdf]</code>, so it can tell you+ it doesn't see the content.</li>+</ul><p>To upload an attachment:</p><ul><li>Press the dedicated <em>Attach</em> button (paperclip icon) underneath thediff --git a/docs/User Guide/User Guide/AI.md b/docs/User Guide/User Guide/AI.mdindex ad49a4a7cd..ee3a4e8509 100644--- a/docs/User Guide/User Guide/AI.md+++ b/docs/User Guide/User Guide/AI.md@@ -153,7 +153,11 @@ Since Trilium v0.140.0, <a class="reference-link" href="Basic%20Concepts%20and%* SVG images (sent as raw HTML).* Text files.-A model that can't read an attachment receives only its name, such as `[attached file: report.pdf]`, so it can tell you it doesn't see the content. DeepSeek reads no PDFs, and images only with its vision models.+Not every model reads every kind of attachment: DeepSeek reads no PDFs, and images only with its vision models; OpenAI Codex, GitHub Copilot and Google Antigravity read images but no PDFs. For such a model:++* The attach button offers only the kinds the model reads, and a pasted or dropped file it can't read is not attached.+* After switching to such a model, an attachment it can't read is marked with a <span class="tn-icon bx bx-error"></span> warning, and the message can't be sent until the attachment is removed or another model is selected.+* An attachment sent in an earlier message reaches the model as its name only, such as `[attached file: report.pdf]`, so it can tell you it doesn't see the content.To upload an attachment: