forked from bots-garden/ori
| ✨ Introduce new feature(s): ACP web client — Go backend (agent, bridge, httpserver, mockagent) + React SPA (Zed-like agent panel), tests, quality gate PASS | 1 | /** |
| 2 | * Markdown renders agent text (GitHub-flavoured: tables, task lists, ...). | |
| 3 | * Kept as the single markdown entry point so styling and plugins stay | |
| 4 | * consistent everywhere agent content appears. | |
| 5 | * | |
| 6 | * @example | |
| 7 | * <Markdown text="**bold** and `code`" /> | |
| 8 | */ | |
| 9 | ||
| 10 | import ReactMarkdown from "react-markdown"; | |
| 11 | import remarkGfm from "remark-gfm"; | |
| Add copy-paste functionality for code blocks and completion widgets | 12 | import type { Components } from "react-markdown"; |
| 13 | import { CopyButton } from "./CopyButton"; | |
| ✨ Introduce new feature(s): ACP web client — Go backend (agent, bridge, httpserver, mockagent) + React SPA (Zed-like agent panel), tests, quality gate PASS | 14 | |
| 15 | export function Markdown({ text }: { text: string }) { | |
| Add copy-paste functionality for code blocks and completion widgets | 16 | const components: Components = { |
| 17 | pre: ({ children, ...props }) => { | |
| 18 | // Extract code content from pre > code structure | |
| 19 | const codeElement = children as React.ReactElement; | |
| 20 | const codeContent = | |
| 21 | codeElement?.props?.children && | |
| 22 | typeof codeElement.props.children === "string" | |
| 23 | ? codeElement.props.children | |
| 24 | : ""; | |
| 25 | ||
| 26 | return ( | |
| 27 | <div className="code-block-wrapper"> | |
| 28 | {codeContent && <CopyButton content={codeContent} label="Copy code" />} | |
| 29 | <pre {...props}>{children}</pre> | |
| 30 | </div> | |
| 31 | ); | |
| 32 | }, | |
| 33 | }; | |
| 34 | ||
| ✨ Introduce new feature(s): ACP web client — Go backend (agent, bridge, httpserver, mockagent) + React SPA (Zed-like agent panel), tests, quality gate PASS | 35 | return ( |
| 36 | <div className="markdown"> | |
| Add copy-paste functionality for code blocks and completion widgets | 37 | <ReactMarkdown remarkPlugins={[remarkGfm]} components={components}> |
| 38 | {text} | |
| 39 | </ReactMarkdown> | |
| ✨ Introduce new feature(s): ACP web client — Go backend (agent, bridge, httpserver, mockagent) + React SPA (Zed-like agent panel), tests, quality gate PASS | 40 | </div> |
| 41 | ); | |
| 42 | } |