|
1 | 1 | import type { AttachmentMimeType, AttachmentRef } from '@emdash/core/acp/client'; |
2 | | -import { ChatComposer, ImageViewerDialog } from '@emdash/ui/react/components'; |
| 2 | +import { ChatComposer, ImageViewerDialog, MermaidViewerDialog } from '@emdash/ui/react/components'; |
3 | 3 | import type { |
4 | 4 | CommandItem, |
5 | 5 | ComposerAgentOption, |
@@ -631,6 +631,7 @@ export const AcpChatPanel = observer(function AcpChatPanel() { |
631 | 631 | const [heroSlot, setHeroSlot] = useState<HTMLElement | null>(null); |
632 | 632 | const [overlaySlot, setOverlaySlot] = useState<HTMLElement | null>(null); |
633 | 633 | const [viewer, setViewer] = useState<{ src?: string; alt?: string } | null>(null); |
| 634 | + const [mermaidViewer, setMermaidViewer] = useState<{ svg: string | null } | null>(null); |
634 | 635 | const placementConversationRef = useRef<string | null>(null); |
635 | 636 | const placementWasEmptyRef = useRef<boolean | null>(null); |
636 | 637 | // True while the scroll viewport is at the tail. Defaults to true so the |
@@ -721,6 +722,11 @@ export const AcpChatPanel = observer(function AcpChatPanel() { |
721 | 722 | }, |
722 | 723 | resolveAttachment: (attachment) => |
723 | 724 | store ? resolveAttachmentDataUrl(store, attachment.id) : Promise.resolve(null), |
| 725 | + onViewMermaid: (arg) => { |
| 726 | + setMermaidViewer({ |
| 727 | + svg: store?.chatContext.sharedCaches.renderMermaid(arg.chart) ?? null, |
| 728 | + }); |
| 729 | + }, |
724 | 730 | onOpenFile: (arg) => { |
725 | 731 | if (!store) return; |
726 | 732 | const open = arg.source === 'diff' ? openFileInAdjacentPane : openFileInTaskEditor; |
@@ -844,6 +850,13 @@ export const AcpChatPanel = observer(function AcpChatPanel() { |
844 | 850 | src={viewer?.src} |
845 | 851 | alt={viewer?.alt} |
846 | 852 | /> |
| 853 | + <MermaidViewerDialog |
| 854 | + open={!!mermaidViewer} |
| 855 | + onOpenChange={(open) => { |
| 856 | + if (!open) setMermaidViewer(null); |
| 857 | + }} |
| 858 | + svg={mermaidViewer?.svg ?? null} |
| 859 | + /> |
847 | 860 | </div> |
848 | 861 | ); |
849 | 862 | }); |
|
0 commit comments