@copilotkit/react-ui 1.80.0 → 1.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -36,6 +36,7 @@ let _copilotkit_shared = require("@copilotkit/shared");
36
36
  let _headlessui_react = require("@headlessui/react");
37
37
  let react_markdown = require("react-markdown");
38
38
  react_markdown = __toESM(react_markdown);
39
+ let _copilotkit_react_core_v2_generative_ui = require("@copilotkit/react-core/v2/generative-ui");
39
40
  let react_syntax_highlighter = require("react-syntax-highlighter");
40
41
  let remark_gfm = require("remark-gfm");
41
42
  remark_gfm = __toESM(remark_gfm);
@@ -1400,7 +1401,8 @@ const defaultComponents = {
1400
1401
  })
1401
1402
  };
1402
1403
  const MemoizedReactMarkdown = (0, react.memo)(react_markdown.default);
1403
- const Markdown = ({ content, components, remarkPlugins, rehypePlugins, ...rest }) => {
1404
+ const Markdown = ({ content, components, remarkPlugins, rehypePlugins, messageId, ...rest }) => {
1405
+ const rendersSurfaces = (0, _copilotkit_react_core_v2_generative_ui.useGenerativeUIRuntime)()?.transport === "markdown" && messageId !== void 0;
1404
1406
  const mergedComponents = (0, react.useMemo)(() => ({
1405
1407
  ...defaultComponents,
1406
1408
  ...components
@@ -1415,6 +1417,16 @@ const Markdown = ({ content, components, remarkPlugins, rehypePlugins, ...rest }
1415
1417
  ...rehypePlugins ?? [],
1416
1418
  rehype_sanitize.default
1417
1419
  ], [rehypePlugins]);
1420
+ if (rendersSurfaces) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1421
+ className: "copilotKitMarkdown",
1422
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_react_core_v2_generative_ui.MarkdownSurfaces, {
1423
+ content,
1424
+ messageId,
1425
+ components: mergedComponents,
1426
+ remarkPlugins: mergedRemarkPlugins,
1427
+ rehypePlugins: mergedRehypePlugins
1428
+ })
1429
+ });
1418
1430
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1419
1431
  className: "copilotKitMarkdown",
1420
1432
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedReactMarkdown, {
@@ -1499,7 +1511,8 @@ const AssistantMessage = (props) => {
1499
1511
  className: "copilotKitMessage copilotKitAssistantMessage",
1500
1512
  children: [content && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
1501
1513
  content,
1502
- components: markdownTagRenderers
1514
+ components: markdownTagRenderers,
1515
+ messageId: message?.id
1503
1516
  }), content && !isLoading && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1504
1517
  className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`,
1505
1518
  children: [