fix(admin): add Markdown rendering to assessment & collection chat drawers

Both directive chat drawers were rendering AI responses as plain text.
Apply the same ReactMarkdown + remark-gfm treatment used in supervisor.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-08 21:03:22 -08:00
parent 12e622040a
commit 3b6e1586b7
2 changed files with 22 additions and 2 deletions

View File

@ -1,6 +1,8 @@
import { useState, useEffect, useRef } from 'react'; import { useState, useEffect, useRef } from 'react';
import { Drawer, Button, Input, Tag, Spin } from 'antd'; import { Drawer, Button, Input, Tag, Spin } from 'antd';
import { RobotOutlined, SendOutlined } from '@ant-design/icons'; import { RobotOutlined, SendOutlined } from '@ant-design/icons';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import { useDirectiveChat } from '../../application/useAssessmentConfig'; import { useDirectiveChat } from '../../application/useAssessmentConfig';
import type { ChatMessage } from '../../infrastructure/assessment-config.api'; import type { ChatMessage } from '../../infrastructure/assessment-config.api';
@ -94,7 +96,15 @@ export function DirectiveChatDrawer({ open, onClose }: DirectiveChatDrawerProps)
> >
{msg.role === 'user' ? '管理员' : 'AI 助手'} {msg.role === 'user' ? '管理员' : 'AI 助手'}
</Tag> </Tag>
<div className="whitespace-pre-wrap">{msg.content}</div> {msg.role === 'assistant' ? (
<div className="supervisor-markdown">
<ReactMarkdown remarkPlugins={[remarkGfm]}>
{msg.content}
</ReactMarkdown>
</div>
) : (
<div className="whitespace-pre-wrap">{msg.content}</div>
)}
</div> </div>
))} ))}

View File

@ -1,6 +1,8 @@
import { useState, useEffect, useRef } from 'react'; import { useState, useEffect, useRef } from 'react';
import { Drawer, Button, Input, Tag, Spin } from 'antd'; import { Drawer, Button, Input, Tag, Spin } from 'antd';
import { RobotOutlined, SendOutlined } from '@ant-design/icons'; import { RobotOutlined, SendOutlined } from '@ant-design/icons';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import { useDirectiveChat } from '../../application/useCollectionConfig'; import { useDirectiveChat } from '../../application/useCollectionConfig';
import type { ChatMessage } from '../../infrastructure/collection-config.api'; import type { ChatMessage } from '../../infrastructure/collection-config.api';
@ -94,7 +96,15 @@ export function CollectionChatDrawer({ open, onClose }: CollectionChatDrawerProp
> >
{msg.role === 'user' ? '管理员' : 'AI 助手'} {msg.role === 'user' ? '管理员' : 'AI 助手'}
</Tag> </Tag>
<div className="whitespace-pre-wrap">{msg.content}</div> {msg.role === 'assistant' ? (
<div className="supervisor-markdown">
<ReactMarkdown remarkPlugins={[remarkGfm]}>
{msg.content}
</ReactMarkdown>
</div>
) : (
<div className="whitespace-pre-wrap">{msg.content}</div>
)}
</div> </div>
))} ))}