Skip to content

Build your personal knowledge base with Trilium Notes

fix(llm): drop the extra padding around an edit's code blocks

Elian Doranb734330807db
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/EditNoteContentDiff.css b/apps/client/src/widgets/type_widgets/llm_chat/EditNoteContentDiff.css
index e4ffcbbcd4..a2744d6199 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/EditNoteContentDiff.css
+++ b/apps/client/src/widgets/type_widgets/llm_chat/EditNoteContentDiff.css
@@ -23,8 +23,8 @@
padding-left: 0.5rem;
border-left: 2px solid transparent;
- > pre {
- margin: 0;
+ > .llm-diff-code {
+ font-family: var(--monospace-font-family, monospace);
font-size: 0.8rem;
white-space: pre-wrap;
overflow-wrap: anywhere;
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/EditNoteContentDiff.tsx b/apps/client/src/widgets/type_widgets/llm_chat/EditNoteContentDiff.tsx
index e4153ab8d8..777e9fd325 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/EditNoteContentDiff.tsx
+++ b/apps/client/src/widgets/type_widgets/llm_chat/EditNoteContentDiff.tsx
@@ -76,7 +76,7 @@ function DiffHunk({ edit, markdown }: { edit: NoteContentEdit; markdown: boolean
<div key={idx} className={`llm-diff-block llm-diff-block-${block.type}`}>
{markdown
? <ReadOnlyTextContent html={renderMarkdown(block.text)} className="llm-chat-markdown" />
- : <pre>{block.text || " "}</pre>}
+ : <div className="llm-diff-code">{block.text || " "}</div>}
</div>
))}
</div>
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ToolCallCard.spec.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ToolCallCard.spec.tsx
index 0ed190d34c..03fc552f0f 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ToolCallCard.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ToolCallCard.spec.tsx
@@ -424,7 +424,7 @@ describe("ToolCallCard", () => {
expect(blocks[2]?.querySelector(".markdown-stub")?.textContent).toContain("<strong>new</strong>");
const codeRemoved = code?.querySelector(".llm-diff-block-remove");
- expect(codeRemoved?.querySelector("pre")?.textContent).toBe("y = 2");
+ expect(codeRemoved?.querySelector(".llm-diff-code")?.textContent).toBe("y = 2");
expect(codeRemoved?.querySelector(".markdown-stub")).toBeNull();
});