Skip to content

Commit f28789e

Browse files
committed
fix: agent markdown output
1 parent b3e0f43 commit f28789e

File tree

6 files changed

+267
-82
lines changed

6 files changed

+267
-82
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"react-markdown": "^9.0.1",
6565
"react-responsive": "^10.0.0",
6666
"recharts": "^3.1.2",
67+
"remark-gfm": "^4.0.1",
6768
"server-only": "^0.0.1",
6869
"sonic-boom": "^4.2.0",
6970
"streamdown": "^1.6.10",

pnpm-lock.yaml

Lines changed: 26 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/assistant-ui/assistant-message.tsx

Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,8 @@ import {
44
MessagePrimitive,
55
type ToolCallMessagePartProps,
66
} from "@assistant-ui/react";
7-
import ReactMarkdown from "react-markdown";
8-
import type { FC, ReactNode } from "react";
9-
10-
const markdownComponents = {
11-
h1: ({ children }: { children?: ReactNode }) => (
12-
<h1 className="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-3">
13-
{children}
14-
</h1>
15-
),
16-
h2: ({ children }: { children?: ReactNode }) => (
17-
<h2 className="text-base font-semibold text-gray-900 dark:text-gray-100 mb-2 mt-4">
18-
{children}
19-
</h2>
20-
),
21-
h3: ({ children }: { children?: ReactNode }) => (
22-
<h3 className="text-sm font-semibold text-gray-900 dark:text-gray-100 mb-2 mt-3">
23-
{children}
24-
</h3>
25-
),
26-
p: ({ children }: { children?: ReactNode }) => (
27-
<p className="text-sm text-gray-700 dark:text-gray-300 leading-relaxed mb-3">
28-
{children}
29-
</p>
30-
),
31-
strong: ({ children }: { children?: ReactNode }) => (
32-
<strong className="font-semibold text-gray-900 dark:text-gray-100">
33-
{children}
34-
</strong>
35-
),
36-
ul: ({ children }: { children?: ReactNode }) => (
37-
<ul className="list-disc ml-4 mb-3 space-y-1 text-sm text-gray-700 dark:text-gray-300">
38-
{children}
39-
</ul>
40-
),
41-
ol: ({ children }: { children?: ReactNode }) => (
42-
<ol className="list-decimal ml-4 mb-3 space-y-1 text-sm text-gray-700 dark:text-gray-300">
43-
{children}
44-
</ol>
45-
),
46-
li: ({ children }: { children?: ReactNode }) => (
47-
<li className="leading-relaxed">{children}</li>
48-
),
49-
code: ({ children }: { children?: ReactNode }) => (
50-
<code className="bg-gray-100 dark:bg-gray-800 text-primary px-1 py-0.5 rounded text-xs font-mono">
51-
{children}
52-
</code>
53-
),
54-
pre: ({ children }: { children?: ReactNode }) => (
55-
<pre className="bg-gray-50 dark:bg-gray-900 rounded-lg p-3 overflow-x-auto mb-3 text-xs">
56-
{children}
57-
</pre>
58-
),
59-
};
7+
import type { FC } from "react";
8+
import { MarkdownText } from "./markdown-text";
609

6110
// Only show a minimal loading indicator while tool is running, hide result
6211
const ToolFallback: FC<ToolCallMessagePartProps> = ({ toolName, result }) => {
@@ -89,11 +38,7 @@ const AssistantMessage: FC = () => {
8938
<div className="max-w-[95%]">
9039
<MessagePrimitive.Content
9140
components={{
92-
Text: ({ text }) => (
93-
<ReactMarkdown components={markdownComponents}>
94-
{text}
95-
</ReactMarkdown>
96-
),
41+
Text: MarkdownText,
9742
tools: {
9843
Fallback: ToolFallback,
9944
},

src/components/assistant-ui/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export { Thread } from "./thread";
33
export { Composer } from "./composer";
44
export { AssistantMessage } from "./assistant-message";
55
export { UserMessage } from "./user-message";
6+
export { MarkdownText } from "./markdown-text";

0 commit comments

Comments
 (0)