Skip to content

Build your personal knowledge base with Trilium Notes

feat(llm): show chat errors in an extended admonition

Elian Doran3bcbeefe4c17
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.css b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.css
index 77988ba026..12b57f8a04 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.css
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.css
@@ -167,14 +167,24 @@ body.background-effects.theme-supports-background-effects .llm-chat-message-user
text-align: right;
}
-/* Error message — rendered as a real "caution" admonition (styled by
- packages/ckeditor5/src/theme/ck-content.css) so it stays visually identical to
- admonitions the model itself emits. Only chat-specific tweaks live here. */
+/* Error message — rendered as a "caution" extended admonition (see
+ widgets/react/Admonition.css, layered on the base admonition styling from
+ packages/ckeditor5/src/theme/ck-content.css). Only chat-specific tweaks live here. */
.admonition.llm-chat-error {
margin: 0;
user-select: text;
}
+/* The body is the provider's raw error text: monospace, with newlines kept and
+ long unbroken tokens (URLs, JSON payloads) allowed to break mid-word so they
+ can't push the card wider than the chat column. */
+.llm-chat-error-text {
+ font-family: var(--monospace-font-family, monospace);
+ font-size: 0.9em;
+ white-space: pre-wrap;
+ overflow-wrap: anywhere;
+}
+
.llm-chat-error-actions {
margin-top: 0.75rem;
}
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.tsx
index 84456edea5..4ad15df566 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.tsx
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.tsx
@@ -7,6 +7,7 @@ import { useMemo } from "preact/hooks";
import { t } from "../../../services/i18n.js";
import utils from "../../../services/utils.js";
+import { ExtendedAdmonition } from "../../react/Admonition.js";
import Button from "../../react/Button.js";
import { ReadOnlyTextContent } from "../text/ReadOnlyText.js";
import { renderMarkdown } from "./chat_markdown.js";
@@ -158,13 +159,19 @@ function ChatMessage({ message, isStreaming, onRetry }: Props) {
);
}
- // Render error messages as a "caution" admonition, matching the callouts the
- // model itself can emit in its responses.
+ // Render error messages as a "caution" extended admonition: the header names the
+ // failure so the (often long and technical) provider message reads as the detail
+ // rather than as the assistant's own prose.
if (isError) {
return (
<div className="llm-chat-message-wrapper llm-chat-message-wrapper-assistant">
- <div className="admonition caution llm-chat-error">
- {textContent}
+ <ExtendedAdmonition
+ type="caution"
+ icon="bx bx-error-circle"
+ title={t("llm_chat.error")}
+ className="llm-chat-error"
+ >
+ <div className="llm-chat-error-text">{textContent}</div>
{onRetry && (
<div className="llm-chat-error-actions">
<Button
@@ -175,7 +182,7 @@ function ChatMessage({ message, isStreaming, onRetry }: Props) {
/>
</div>
)}
- </div>
+ </ExtendedAdmonition>
</div>
);
}