|
1 | 1 | // Copyright 2025, Command Line Inc. |
2 | 2 | // SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
| 4 | +import { WaveStreamdown } from "@/app/element/streamdown"; |
4 | 5 | import { cn } from "@/util/util"; |
| 6 | +import { useAtomValue } from "jotai"; |
5 | 7 | import { memo } from "react"; |
6 | | -import { Streamdown } from "streamdown"; |
7 | 8 | import { getFileIcon } from "./ai-utils"; |
8 | 9 | import { WaveUIMessage, WaveUIMessagePart } from "./aitypes"; |
| 10 | +import { WaveAIModel } from "./waveai-model"; |
9 | 11 |
|
10 | 12 | const AIThinking = memo(() => ( |
11 | 13 | <div className="flex items-center gap-2"> |
@@ -72,30 +74,21 @@ interface AIMessagePartProps { |
72 | 74 | } |
73 | 75 |
|
74 | 76 | const AIMessagePart = memo(({ part, role, isStreaming }: AIMessagePartProps) => { |
| 77 | + const model = WaveAIModel.getInstance(); |
| 78 | + |
75 | 79 | if (part.type === "text") { |
76 | 80 | const content = part.text ?? ""; |
77 | 81 |
|
78 | 82 | if (role === "user") { |
79 | 83 | return <div className="whitespace-pre-wrap break-words">{content}</div>; |
80 | 84 | } else { |
81 | 85 | return ( |
82 | | - <Streamdown |
| 86 | + <WaveStreamdown |
| 87 | + text={content} |
83 | 88 | parseIncompleteMarkdown={isStreaming} |
84 | | - className="markdown-content text-gray-100" |
85 | | - shikiTheme={["github-dark", "github-dark"]} |
86 | | - controls={{ |
87 | | - code: true, |
88 | | - table: true, |
89 | | - mermaid: true, |
90 | | - }} |
91 | | - mermaidConfig={{ |
92 | | - theme: "dark", |
93 | | - darkMode: true, |
94 | | - }} |
95 | | - defaultOrigin="http://localhost" |
96 | | - > |
97 | | - {content} |
98 | | - </Streamdown> |
| 89 | + className="text-gray-100" |
| 90 | + codeBlockMaxWidthAtom={model.codeBlockMaxWidth} |
| 91 | + /> |
99 | 92 | ); |
100 | 93 | } |
101 | 94 | } |
@@ -139,9 +132,7 @@ export const AIMessage = memo(({ message, isStreaming }: AIMessageProps) => { |
139 | 132 | <div |
140 | 133 | className={cn( |
141 | 134 | "px-2 py-2 rounded-lg", |
142 | | - message.role === "user" |
143 | | - ? "bg-accent-800 text-white max-w-[calc(100%-20px)]" |
144 | | - : "bg-gray-800 text-gray-100" |
| 135 | + message.role === "user" ? "bg-accent-800 text-white max-w-[calc(100%-20px)]" : null |
145 | 136 | )} |
146 | 137 | > |
147 | 138 | {showThinkingOnly ? ( |
|
0 commit comments