Skip to content

Commit 5ab3d09

Browse files
committed
Merge branch 'bot_ui_mermaid_wait_stream_ends' into 'master'
Bot UI: Don't render mermaid until message streaming is complete See merge request postgres-ai/database-lab!911
2 parents 53e2af4 + 441296c commit 5ab3d09

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

ui/packages/platform/src/pages/Bot/Messages/Message/Message.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ type BaseMessageProps = {
2222
formattedTime?: string;
2323
aiModel?: string
2424
stateMessage?: StateMessage | null
25+
isCurrentStreamMessage?: boolean
2526
}
2627

2728
type AiMessageProps = BaseMessageProps & {
2829
isAi: true;
2930
content: string;
3031
aiModel: string
32+
isCurrentStreamMessage?: boolean
3133
}
3234

3335
type HumanMessageProps = BaseMessageProps & {
@@ -256,7 +258,8 @@ export const Message = React.memo((props: MessageProps) => {
256258
created_at,
257259
isLoading,
258260
aiModel,
259-
stateMessage
261+
stateMessage,
262+
isCurrentStreamMessage
260263
} = props;
261264

262265
const [isDebugVisible, setDebugVisible] = useState(false);
@@ -280,7 +283,7 @@ export const Message = React.memo((props: MessageProps) => {
280283
if (!inline) {
281284
return (
282285
<>
283-
{matchMermaid && <MermaidDiagram chart={String(children).replace(/\n$/, '')} />}
286+
{matchMermaid && !isCurrentStreamMessage && <MermaidDiagram chart={String(children).replace(/\n$/, '')} />}
284287
<CodeBlock value={String(children).replace(/\n$/, '')} language={match?.[1]} />
285288
</>
286289
)

ui/packages/platform/src/pages/Bot/Messages/Messages.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ export const Messages = React.memo(() => {
281281
isAi
282282
content={currentStreamMessage.content}
283283
aiModel={currentStreamMessage.ai_model}
284+
isCurrentStreamMessage
284285
/>
285286
}
286287
{isWaitingForAnswer &&

0 commit comments

Comments
 (0)