Skip to content

Build your personal knowledge base with Trilium Notes

fix(llm): render the thought process as Markdown

Elian Doranbeab1d2505f2
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 1437f9a8cc..787362f3ff 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.css
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.css
@@ -216,7 +216,6 @@ body.background-effects.theme-supports-background-effects .llm-chat-message-user
padding: 0.5rem 0.75rem;
font-size: 0.9rem;
color: var(--muted-text-color);
- white-space: pre-wrap;
}
/* Markdown styles */
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.spec.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.spec.tsx
index 502df4e24b..84cb40cdc7 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.spec.tsx
@@ -58,3 +58,22 @@ describe("ChatMessage footer", () => {
expect(tokens?.getAttribute("title")).toBe("llm_chat.tokens_detail(800/0)");
});
});
+
+describe("ChatMessage thinking", () => {
+ it("renders the thought process as Markdown, as Codex writes its reasoning summaries", () => {
+ host = document.body.appendChild(document.createElement("div"));
+ const target = host;
+ const message: StoredMessage = {
+ id: "t1", role: "assistant", type: "thinking", createdAt: "2026-01-01T00:00:00.000Z",
+ content: "**Retrieving PC hostname with command**\n\nI'll read `/etc/hostname`."
+ };
+ act(() => render(<ChatMessage message={message} />, target));
+
+ const thinking = target.querySelector(".llm-chat-thinking-content");
+ expect(thinking?.textContent).toContain("Retrieving PC hostname with command");
+ const content = thinking?.querySelector(".markdown-stub");
+ expect(content).not.toBeNull();
+ expect(content?.textContent).toContain("<strong>Retrieving PC hostname with command</strong>");
+ expect(content?.textContent).toContain("<code>/etc/hostname</code>");
+ });
+});
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 a1d9432b88..79a9e418b2 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.tsx
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.tsx
@@ -151,8 +151,7 @@ function ChatMessage({ message, isStreaming, onRetry }: Props) {
<ExpandableCard className="llm-chat-thinking-card">
<ExpandableSection icon="bx bx-brain" label={t("llm_chat.thought_process")}>
<div className="llm-chat-thinking-content">
- {textContent}
- {isStreaming && <span className="llm-chat-cursor" />}
+ <TextBlockContent content={textContent} isStreaming={isStreaming} />
</div>
</ExpandableSection>
</ExpandableCard>