@copilotkit/react-core 1.83.0 → 2.0.0-rc.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.
Files changed (75) hide show
  1. package/dist/{runtime-context-CrHq-iTf.d.mts → MarkdownRendererContext-B4Us6mwL.d.cts} +127 -97
  2. package/dist/MarkdownRendererContext-B4Us6mwL.d.cts.map +1 -0
  3. package/dist/{runtime-context-D3NcP9oE.d.cts → MarkdownRendererContext-CRKFzsEB.d.mts} +127 -97
  4. package/dist/MarkdownRendererContext-CRKFzsEB.d.mts.map +1 -0
  5. package/dist/{MarkdownSurfaces-FF5za2kU.cjs → MarkdownSurfaces-C2XZISKn.cjs} +203 -55
  6. package/dist/MarkdownSurfaces-C2XZISKn.cjs.map +1 -0
  7. package/dist/{MarkdownSurfaces-DGpjmPaB.mjs → MarkdownSurfaces-ChSlVYOk.mjs} +171 -47
  8. package/dist/MarkdownSurfaces-ChSlVYOk.mjs.map +1 -0
  9. package/dist/{v2/context.cjs → context.cjs} +2 -2
  10. package/dist/context.cjs.map +1 -0
  11. package/dist/{v2/context.d.cts → context.d.cts} +5 -5
  12. package/dist/context.d.cts.map +1 -0
  13. package/dist/{v2/context.d.mts → context.d.mts} +5 -5
  14. package/dist/context.d.mts.map +1 -0
  15. package/dist/{v2/context.mjs → context.mjs} +2 -2
  16. package/dist/context.mjs.map +1 -0
  17. package/dist/{v2/generative-ui.cjs → generative-ui.cjs} +40 -43
  18. package/dist/generative-ui.cjs.map +1 -0
  19. package/dist/{v2/generative-ui.d.cts → generative-ui.d.cts} +14 -12
  20. package/dist/generative-ui.d.cts.map +1 -0
  21. package/dist/{v2/generative-ui.d.mts → generative-ui.d.mts} +14 -12
  22. package/dist/generative-ui.d.mts.map +1 -0
  23. package/dist/{v2/generative-ui.mjs → generative-ui.mjs} +40 -43
  24. package/dist/generative-ui.mjs.map +1 -0
  25. package/dist/{v2/headless.cjs → headless.cjs} +68 -53
  26. package/dist/headless.cjs.map +1 -0
  27. package/dist/{v2/headless.d.cts → headless.d.cts} +24 -23
  28. package/dist/headless.d.cts.map +1 -0
  29. package/dist/{v2/headless.d.mts → headless.d.mts} +21 -20
  30. package/dist/headless.d.mts.map +1 -0
  31. package/dist/{v2/headless.mjs → headless.mjs} +51 -36
  32. package/dist/headless.mjs.map +1 -0
  33. package/dist/index.cjs +15391 -1862
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.css +2 -0
  36. package/dist/index.d.cts +3252 -1370
  37. package/dist/index.d.cts.map +1 -1
  38. package/dist/index.d.mts +3234 -1369
  39. package/dist/index.d.mts.map +1 -1
  40. package/dist/index.mjs +13733 -1815
  41. package/dist/index.mjs.map +1 -1
  42. package/dist/index.umd.js +11944 -5481
  43. package/dist/index.umd.js.map +1 -1
  44. package/package.json +21 -30
  45. package/dist/MarkdownSurfaces-DGpjmPaB.mjs.map +0 -1
  46. package/dist/MarkdownSurfaces-FF5za2kU.cjs.map +0 -1
  47. package/dist/copilotkit-BuIuo-Z1.cjs +0 -16531
  48. package/dist/copilotkit-BuIuo-Z1.cjs.map +0 -1
  49. package/dist/copilotkit-C765tOUi.d.mts +0 -4112
  50. package/dist/copilotkit-C765tOUi.d.mts.map +0 -1
  51. package/dist/copilotkit-DyxwF9wL.mjs +0 -16025
  52. package/dist/copilotkit-DyxwF9wL.mjs.map +0 -1
  53. package/dist/copilotkit-wqaNanhw.d.cts +0 -4129
  54. package/dist/copilotkit-wqaNanhw.d.cts.map +0 -1
  55. package/dist/runtime-context-CrHq-iTf.d.mts.map +0 -1
  56. package/dist/runtime-context-D3NcP9oE.d.cts.map +0 -1
  57. package/dist/v2/context.cjs.map +0 -1
  58. package/dist/v2/context.d.cts.map +0 -1
  59. package/dist/v2/context.d.mts.map +0 -1
  60. package/dist/v2/context.mjs.map +0 -1
  61. package/dist/v2/generative-ui.cjs.map +0 -1
  62. package/dist/v2/generative-ui.d.cts.map +0 -1
  63. package/dist/v2/generative-ui.d.mts.map +0 -1
  64. package/dist/v2/generative-ui.mjs.map +0 -1
  65. package/dist/v2/headless.cjs.map +0 -1
  66. package/dist/v2/headless.d.cts.map +0 -1
  67. package/dist/v2/headless.d.mts.map +0 -1
  68. package/dist/v2/headless.mjs.map +0 -1
  69. package/dist/v2/index.cjs +0 -1635
  70. package/dist/v2/index.css +0 -2
  71. package/dist/v2/index.d.cts +0 -4
  72. package/dist/v2/index.d.mts +0 -4
  73. package/dist/v2/index.mjs +0 -8
  74. package/dist/v2/index.umd.js +0 -20695
  75. package/dist/v2/index.umd.js.map +0 -1
@@ -1,13 +1,51 @@
1
- import React, { Component, createContext, memo, useCallback, useContext, useEffect, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
2
1
  import { extractFenceOperations, flattenInformationalCards, getMarkdownOperationSurfaceId, prepareSurfaceOperations, segmentSurfaceProse, splitA2UIMarkdown } from "@copilotkit/core";
3
- import { A2UI_COMPONENT_ENVELOPE_KEYS, A2UI_INDEX_FUNCTION, A2UI_VERSION, DEFAULT_AGENT_ID, GENERATIVE_UI_ACTIVITY_TYPE, GENERATIVE_UI_CHAT_TARGET, GENERATIVE_UI_FUNCTIONS, GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE, GENERATIVE_UI_RENDER_TOOL, GENERATIVE_UI_ROOT_ID, applyChildRefMarks, childIdsAtRefs, collectChildRefs, functionCallers, getOperationKind, hasBoundChildRef, isActionBinding, isCallBinding, isPathBinding, isValidationResult, mapAtChildRef, randomUUID, schemaToJsonSchema, validateOperation } from "@copilotkit/shared";
4
- import { CopilotKitContext, useCopilotKit, useDefaultAgentId } from "@copilotkit/react-core/v2/context";
2
+ import React, { Component, createContext, memo, useCallback, useContext, useEffect, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
5
3
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
- import { Streamdown } from "streamdown";
4
+ import { StreamingMarkdownRenderer, createStreamingMarkdownNodeRenderers } from "@copilotkit/markdown-renderer/react";
5
+ import { warnUnsupportedRichSyntaxOnce } from "@copilotkit/markdown-renderer";
6
+ import { twMerge } from "tailwind-merge";
7
+ import { A2UI_COMPONENT_ENVELOPE_KEYS, A2UI_INDEX_FUNCTION, A2UI_VERSION, DEFAULT_AGENT_ID, GENERATIVE_UI_ACTIVITY_TYPE, GENERATIVE_UI_CHAT_TARGET, GENERATIVE_UI_FUNCTIONS, GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE, GENERATIVE_UI_RENDER_TOOL, GENERATIVE_UI_ROOT_ID, applyChildRefMarks, childIdsAtRefs, collectChildRefs, functionCallers, getOperationKind, hasBoundChildRef, isActionBinding, isCallBinding, isPathBinding, isValidationResult, mapAtChildRef, randomUUID, schemaToJsonSchema, validateOperation } from "@copilotkit/shared";
8
+ import { CopilotKitContext, useCopilotKit, useDefaultAgentId } from "@copilotkit/react-core/context";
7
9
  import { z } from "zod";
8
10
  import { zodToJsonSchema } from "zod-to-json-schema";
9
11
 
10
- //#region src/v2/lib/shallow-stable-ref.ts
12
+ //#region src/components/chat/StreamingMarkdownDefaultRenderer.tsx
13
+ const defaultNodeRenderers = createStreamingMarkdownNodeRenderers({ codeBlock: ({ node }) => /* @__PURE__ */ jsx("pre", {
14
+ className: "cpk:overflow-x-auto cpk:rounded-lg cpk:bg-muted cpk:text-foreground cpk:p-3",
15
+ children: /* @__PURE__ */ jsx("code", {
16
+ "data-code-info": node.info ?? void 0,
17
+ children: node.text
18
+ })
19
+ }) });
20
+ /**
21
+ * react-core's built-in default markdown renderer — a thin adapter over
22
+ * `@copilotkit/markdown-renderer`'s streaming renderer. Maps the pluggable
23
+ * renderer contract (`{ content, isStreaming, className }`) onto the streaming
24
+ * renderer for streaming-safe incremental rendering + per-token animation.
25
+ * Still overridable via the slot/provider pluggable interface.
26
+ */
27
+ function StreamingMarkdownDefaultRenderer({ content, isStreaming, className, nodeRenderers, caret, options, onLinkClick, onCitationClick }) {
28
+ const mergedNodeRenderers = useMemo(() => nodeRenderers ? createStreamingMarkdownNodeRenderers({
29
+ ...defaultNodeRenderers,
30
+ ...nodeRenderers
31
+ }) : defaultNodeRenderers, [nodeRenderers]);
32
+ if (!content) return null;
33
+ warnUnsupportedRichSyntaxOnce(content);
34
+ return /* @__PURE__ */ jsx(StreamingMarkdownRenderer, {
35
+ className,
36
+ isComplete: !isStreaming,
37
+ caret: caret ?? !!isStreaming,
38
+ nodeRenderers: mergedNodeRenderers,
39
+ options,
40
+ onLinkClick,
41
+ onCitationClick,
42
+ children: content
43
+ });
44
+ }
45
+ StreamingMarkdownDefaultRenderer.displayName = "StreamingMarkdownDefaultRenderer";
46
+
47
+ //#endregion
48
+ //#region src/lib/shallow-stable-ref.ts
11
49
  /**
12
50
  * Shallow equality comparison for objects.
13
51
  */
@@ -49,7 +87,7 @@ function useShallowStableRef(value) {
49
87
  }
50
88
 
51
89
  //#endregion
52
- //#region src/v2/providers/CopilotChatConfigurationProvider.tsx
90
+ //#region src/providers/CopilotChatConfigurationProvider.tsx
53
91
  const CopilotChatDefaultLabels = {
54
92
  chatInputPlaceholder: "Type a message...",
55
93
  chatInputToolbarStartTranscribeButtonLabel: "Transcribe",
@@ -352,26 +390,85 @@ const ControlledModalOpenScope = ({ children, open, onOpenChange }) => {
352
390
  ControlledModalOpenScope.displayName = "ControlledModalOpenScope";
353
391
 
354
392
  //#endregion
355
- //#region src/v2/hooks/useKatexStyles.ts
356
- let injected = false;
393
+ //#region src/lib/slots.tsx
357
394
  /**
358
- * Dynamically injects KaTeX CSS at runtime to avoid the Next.js
359
- * "Global CSS cannot be imported from within node_modules" build error.
360
- *
361
- * Uses a singleton flag so the stylesheet is only injected once.
395
+ * Check if a value is a React component type (function, class, forwardRef, memo, etc.)
362
396
  */
363
- function useKatexStyles() {
364
- useEffect(() => {
365
- if (injected || typeof document === "undefined") return;
366
- injected = true;
367
- import("katex/dist/katex.min.css").catch(() => {
368
- console.warn("[CopilotKit] Failed to load katex styles — math content may render without formatting");
397
+ function isReactComponentType(value) {
398
+ if (typeof value === "function") return true;
399
+ if (value && typeof value === "object" && "$$typeof" in value && !React.isValidElement(value)) return true;
400
+ return false;
401
+ }
402
+ /**
403
+ * Internal function to render a slot value as a React element (non-memoized).
404
+ */
405
+ function renderSlotElement(slot, DefaultComponent, props) {
406
+ if (typeof slot === "string") {
407
+ const existingClassName = props.className;
408
+ return React.createElement(DefaultComponent, {
409
+ ...props,
410
+ className: twMerge(existingClassName, slot)
369
411
  });
370
- }, []);
412
+ }
413
+ if (isReactComponentType(slot)) return React.createElement(slot, props);
414
+ if (slot && typeof slot === "object" && !React.isValidElement(slot)) return React.createElement(DefaultComponent, {
415
+ ...props,
416
+ ...slot
417
+ });
418
+ return React.createElement(DefaultComponent, props);
419
+ }
420
+ /**
421
+ * Internal memoized wrapper component for renderSlot.
422
+ * Uses forwardRef to support ref forwarding.
423
+ */
424
+ const MemoizedSlotWrapper = React.memo(React.forwardRef(function MemoizedSlotWrapper(props, ref) {
425
+ const { $slot, $component, ...rest } = props;
426
+ return renderSlotElement($slot, $component, ref !== null ? {
427
+ ...rest,
428
+ ref
429
+ } : rest);
430
+ }), (prev, next) => {
431
+ if (prev.$slot !== next.$slot) return false;
432
+ if (prev.$component !== next.$component) return false;
433
+ const { $slot: _ps, $component: _pc, ...prevRest } = prev;
434
+ const { $slot: _ns, $component: _nc, ...nextRest } = next;
435
+ return shallowEqual(prevRest, nextRest);
436
+ });
437
+ /**
438
+ * Renders a slot value as a memoized React element.
439
+ * Automatically prevents unnecessary re-renders using shallow prop comparison.
440
+ * Supports ref forwarding.
441
+ *
442
+ * @example
443
+ * renderSlot(customInput, CopilotChatInput, { onSubmit: handleSubmit })
444
+ */
445
+ function renderSlot(slot, DefaultComponent, props) {
446
+ return React.createElement(MemoizedSlotWrapper, {
447
+ ...props,
448
+ $slot: slot,
449
+ $component: DefaultComponent
450
+ });
371
451
  }
372
452
 
373
453
  //#endregion
374
- //#region src/v2/types/defineToolCallRenderer.ts
454
+ //#region src/providers/MarkdownRendererContext.tsx
455
+ const MarkdownRendererContext = createContext(void 0);
456
+ const MarkdownRendererProvider = ({ renderer, children }) => /* @__PURE__ */ jsx(MarkdownRendererContext.Provider, {
457
+ value: renderer,
458
+ children
459
+ });
460
+ /**
461
+ * The markdown renderer set at the provider level, or `undefined` when none was
462
+ * supplied. Message components fall back to the built-in
463
+ * `StreamingMarkdownDefaultRenderer` (via `CopilotChatAssistantMessage.MarkdownRenderer`)
464
+ * when this is `undefined`.
465
+ */
466
+ function useMarkdownRenderer() {
467
+ return useContext(MarkdownRendererContext);
468
+ }
469
+
470
+ //#endregion
471
+ //#region src/types/defineToolCallRenderer.ts
375
472
  function defineToolCallRenderer(def) {
376
473
  const argsSchema = def.name === "*" && !def.args ? z.any() : def.args;
377
474
  return {
@@ -384,7 +481,7 @@ function defineToolCallRenderer(def) {
384
481
  }
385
482
 
386
483
  //#endregion
387
- //#region src/v2/generative-ui/json-schema.ts
484
+ //#region src/generative-ui/json-schema.ts
388
485
  /**
389
486
  * JSON Schema for a Standard Schema (zod v3 via zod-to-json-schema),
390
487
  * inlined, no `$schema`. A prop marked by `child()` or `childList()`
@@ -396,7 +493,7 @@ function toJsonSchema(schema) {
396
493
  }
397
494
 
398
495
  //#endregion
399
- //#region src/v2/generative-ui/catalog.ts
496
+ //#region src/generative-ui/catalog.ts
400
497
  /** The A2UI component envelope: `id`, `component`, `catalogId`, `accessibility`, `metadata`. */
401
498
  const RESERVED_KEYS = new Set([
402
499
  "id",
@@ -699,14 +796,14 @@ function toManifest(definition, modelProps, modelEvents) {
699
796
  }
700
797
 
701
798
  //#endregion
702
- //#region src/v2/generative-ui/is-record.ts
799
+ //#region src/generative-ui/is-record.ts
703
800
  /** True for a plain object: not null, not an array. Internal, not exported. */
704
801
  function isRecord(value) {
705
802
  return typeof value === "object" && value !== null && !Array.isArray(value);
706
803
  }
707
804
 
708
805
  //#endregion
709
- //#region src/v2/generative-ui/errors.ts
806
+ //#region src/generative-ui/errors.ts
710
807
  var GenerativeUIError = class extends Error {
711
808
  constructor(code, message) {
712
809
  super(message);
@@ -716,7 +813,7 @@ var GenerativeUIError = class extends Error {
716
813
  };
717
814
 
718
815
  //#endregion
719
- //#region src/v2/generative-ui/functions.ts
816
+ //#region src/generative-ui/functions.ts
720
817
  /**
721
818
  * The renderer-side functions of the A2UI 1.0 basic catalog. Each one takes
722
819
  * resolved args (no bindings left in them) and gives a plain value. They
@@ -911,7 +1008,7 @@ function givesValidationResult(name) {
911
1008
  }
912
1009
 
913
1010
  //#endregion
914
- //#region src/v2/generative-ui/markdown/source.ts
1011
+ //#region src/generative-ui/markdown/source.ts
915
1012
  /**
916
1013
  * Values by key, from the latest build. A value that a build does not use
917
1014
  * is dropped at the end of that build, so the cache does not grow.
@@ -1542,7 +1639,7 @@ function getMarkdownSurfaceSource(runtime) {
1542
1639
  }
1543
1640
 
1544
1641
  //#endregion
1545
- //#region src/v2/generative-ui/calc.ts
1642
+ //#region src/generative-ui/calc.ts
1546
1643
  const MAX_SERIES = 1e3;
1547
1644
  const OPERATORS = [
1548
1645
  "&&",
@@ -1877,7 +1974,7 @@ function series(args) {
1877
1974
  }
1878
1975
 
1879
1976
  //#endregion
1880
- //#region src/v2/generative-ui/resolve.ts
1977
+ //#region src/generative-ui/resolve.ts
1881
1978
  BASIC_FUNCTIONS.calc = calc;
1882
1979
  BASIC_FUNCTIONS.series = series;
1883
1980
  const NO_DATA = { get: () => void 0 };
@@ -2148,7 +2245,7 @@ var ExpressionParser = class {
2148
2245
  };
2149
2246
 
2150
2247
  //#endregion
2151
- //#region src/v2/generative-ui/schema.ts
2248
+ //#region src/generative-ui/schema.ts
2152
2249
  const ASYNC_ISSUE = { message: "the schema validates asynchronously; component props and state need a schema that validates synchronously" };
2153
2250
  function toResult(result) {
2154
2251
  return result.issues ? {
@@ -2214,7 +2311,7 @@ function formatIssues(issues, fallback = "props") {
2214
2311
  }
2215
2312
 
2216
2313
  //#endregion
2217
- //#region src/v2/generative-ui/runtime-context.ts
2314
+ //#region src/generative-ui/runtime-context.ts
2218
2315
  const GenerativeUIRuntimeContext = createContext(null);
2219
2316
  function useGenerativeUIRuntime() {
2220
2317
  return useContext(GenerativeUIRuntimeContext);
@@ -2237,7 +2334,7 @@ function reportErrorSafely(runtime, info) {
2237
2334
  const GenerativeUINodeContext = createContext(null);
2238
2335
 
2239
2336
  //#endregion
2240
- //#region src/v2/generative-ui/hooks.ts
2337
+ //#region src/generative-ui/hooks.ts
2241
2338
  const noopSubscribe$1 = () => () => {};
2242
2339
  const zero = () => 0;
2243
2340
  /** Re-renders on any surface-manager change. */
@@ -2324,7 +2421,7 @@ function useGenerativeUIFunction(ui, name, handler) {
2324
2421
  }
2325
2422
 
2326
2423
  //#endregion
2327
- //#region src/v2/generative-ui/boundaries.tsx
2424
+ //#region src/generative-ui/boundaries.tsx
2328
2425
  function DefaultNodeFallback({ message, componentId, retry }) {
2329
2426
  return /* @__PURE__ */ jsxs("div", {
2330
2427
  role: "alert",
@@ -2431,7 +2528,7 @@ var SurfaceBoundary = class extends Component {
2431
2528
  };
2432
2529
 
2433
2530
  //#endregion
2434
- //#region src/v2/generative-ui/accessibility.ts
2531
+ //#region src/generative-ui/accessibility.ts
2435
2532
  const LIVE = new Set([
2436
2533
  "off",
2437
2534
  "polite",
@@ -2526,7 +2623,7 @@ function wrapperAria(aria) {
2526
2623
  }
2527
2624
 
2528
2625
  //#endregion
2529
- //#region src/v2/generative-ui/events.ts
2626
+ //#region src/generative-ui/events.ts
2530
2627
  /**
2531
2628
  * The context of a running event binding: it reads the surface data model
2532
2629
  * and resolves relative paths against the template item of the component.
@@ -2642,7 +2739,7 @@ function invokeMatchedEvent(params) {
2642
2739
  }
2643
2740
 
2644
2741
  //#endregion
2645
- //#region src/v2/generative-ui/theme.ts
2742
+ //#region src/generative-ui/theme.ts
2646
2743
  /**
2647
2744
  * The built-in dark values. The light values are the fallbacks in the
2648
2745
  * components, so a surface is light when no variable is set.
@@ -2752,7 +2849,7 @@ function themeStyleSheet(theme) {
2752
2849
  }
2753
2850
 
2754
2851
  //#endregion
2755
- //#region src/v2/generative-ui/SurfaceView.tsx
2852
+ //#region src/generative-ui/SurfaceView.tsx
2756
2853
  const NO_ANCESTORS = [];
2757
2854
  const ROOT_STYLE = { display: "contents" };
2758
2855
  const undefinedSnapshot = () => void 0;
@@ -3318,7 +3415,7 @@ function ResolvedNode({ surface, componentId, definition, properties, runtime, b
3318
3415
  }
3319
3416
 
3320
3417
  //#endregion
3321
- //#region src/v2/generative-ui/chat.tsx
3418
+ //#region src/generative-ui/chat.tsx
3322
3419
  const GenerativeUIChatSlotContext = createContext(void 0);
3323
3420
  function DefaultGenerativeUIChatCard({ surfaceId, isStreaming, error, children }) {
3324
3421
  return /* @__PURE__ */ jsxs("div", {
@@ -3407,7 +3504,30 @@ function GenerativeUIToolCallRenderer() {
3407
3504
  }
3408
3505
 
3409
3506
  //#endregion
3410
- //#region src/v2/generative-ui/markdown/MarkdownSurfaces.tsx
3507
+ //#region src/generative-ui/markdown/ProviderMarkdown.tsx
3508
+ /**
3509
+ * Markdown prose inside generative UI, rendered like the chat text around
3510
+ * it: the renderer set on the provider when there is one, else the built-in
3511
+ * streaming renderer. Config passed here wins over provider config.
3512
+ */
3513
+ function ProviderMarkdown({ content, isStreaming, className, ...config }) {
3514
+ const renderer = useMarkdownRenderer();
3515
+ if (renderer && isReactComponentType(renderer)) return /* @__PURE__ */ jsx(renderer, {
3516
+ content,
3517
+ isStreaming,
3518
+ className
3519
+ });
3520
+ return /* @__PURE__ */ jsx(StreamingMarkdownDefaultRenderer, {
3521
+ ...renderer,
3522
+ ...config,
3523
+ content,
3524
+ isStreaming,
3525
+ className
3526
+ });
3527
+ }
3528
+
3529
+ //#endregion
3530
+ //#region src/generative-ui/markdown/MarkdownSurfaces.tsx
3411
3531
  const FADE_STYLE_ID = "a2ui-markdown-fade";
3412
3532
  /**
3413
3533
  * Components fade in as they stream: each element that appears under a
@@ -3468,13 +3588,14 @@ function ChatSurface({ runtime, threadId, surfaceId, Wrapper }) {
3468
3588
  });
3469
3589
  }
3470
3590
  /** The blocks of one fence: lifted prose and chat surfaces, in order. */
3471
- function FenceBlocks({ blocks, runtime, threadId, markdownProps }) {
3591
+ function FenceBlocks({ blocks, runtime, threadId, isStreaming, markdownProps }) {
3472
3592
  const Wrapper = useContext(GenerativeUIChatSlotContext) ?? DefaultMarkdownChatSurface;
3473
3593
  let surfaceCount = 0;
3474
- return /* @__PURE__ */ jsx(Fragment$1, { children: blocks.map((block) => {
3475
- if (block.kind === "markdown") return /* @__PURE__ */ jsx(Streamdown, {
3594
+ return /* @__PURE__ */ jsx(Fragment$1, { children: blocks.map((block, index) => {
3595
+ if (block.kind === "markdown") return /* @__PURE__ */ jsx(ProviderMarkdown, {
3476
3596
  ...markdownProps,
3477
- children: block.markdown
3597
+ content: block.markdown,
3598
+ isStreaming: isStreaming && index === blocks.length - 1
3478
3599
  }, `md-${surfaceCount}`);
3479
3600
  surfaceCount++;
3480
3601
  return /* @__PURE__ */ jsx(ChatSurface, {
@@ -3503,7 +3624,7 @@ function FenceBlocks({ blocks, runtime, threadId, markdownProps }) {
3503
3624
  * <MarkdownSurfaces content={message.content} messageId={message.id} />
3504
3625
  * ```
3505
3626
  */
3506
- function MarkdownSurfaces({ content, messageId, ...markdownProps }) {
3627
+ function MarkdownSurfaces({ content, messageId, isStreaming = false, ...markdownProps }) {
3507
3628
  const runtime = useRequiredGenerativeUIRuntime();
3508
3629
  const chatThreadId = useCopilotChatConfiguration()?.threadId;
3509
3630
  useManagerVersion(runtime);
@@ -3511,9 +3632,11 @@ function MarkdownSurfaces({ content, messageId, ...markdownProps }) {
3511
3632
  const threadId = chatThreadId ?? runtime.manager.getActiveThread();
3512
3633
  const source = getMarkdownSurfaceSource(runtime);
3513
3634
  return /* @__PURE__ */ jsx(Fragment$1, { children: segments.map((segment, index) => {
3514
- if (segment.type === "markdown") return /* @__PURE__ */ jsx(Streamdown, {
3635
+ const isLast = index === segments.length - 1;
3636
+ if (segment.type === "markdown") return /* @__PURE__ */ jsx(ProviderMarkdown, {
3515
3637
  ...markdownProps,
3516
- children: segment.text
3638
+ content: segment.text,
3639
+ isStreaming: isStreaming && isLast
3517
3640
  }, `md-${index}`);
3518
3641
  const blocks = threadId ? source.getFenceBlocks(threadId, messageId, segment.index) : void 0;
3519
3642
  if (!threadId || !blocks) return null;
@@ -3521,11 +3644,12 @@ function MarkdownSurfaces({ content, messageId, ...markdownProps }) {
3521
3644
  blocks,
3522
3645
  runtime,
3523
3646
  threadId,
3647
+ isStreaming: isStreaming && isLast,
3524
3648
  markdownProps
3525
3649
  }, `a2ui-${segment.index}`);
3526
3650
  }) });
3527
3651
  }
3528
3652
 
3529
3653
  //#endregion
3530
- export { isRecord as A, useCopilotChatConfiguration as B, validateSchemaSync as C, BASIC_FUNCTIONS as D, getMarkdownSurfaceSource as E, defineToolCallRenderer as F, useShallowStableRef as H, useKatexStyles as I, ControlledModalOpenScope as L, componentCatalogIds as M, createGenerativeUI as N, ExpressionError as O, toJsonSchema as P, CopilotChatConfigurationProvider as R, issueKey as S, containsDynamicValue as T, shallowEqual as V, GenerativeUIRuntimeContext as _, createGenerativeUIActivityRenderer as a, formatIssues as b, DARK_THEME_CSS as c, useGenerativeUIAccessibility as d, wrapperAria as f, GenerativeUINodeContext as g, useManagerVersion as h, GenerativeUIToolCallRenderer as i, catalogIdsOf as j, GenerativeUIError as k, controlAria as l, useGenerativeUIState as m, DefaultGenerativeUIChatCard as n, createGenerativeUIFunctionCallActivityRenderer as o, useGenerativeUIFunction as p, GenerativeUIChatSlotContext as r, SurfaceView as s, MarkdownSurfaces as t, namedRole as u, useGenerativeUIRuntime as v, withoutRejectedNulls as w, isAsyncIssue as x, useRequiredGenerativeUIRuntime as y, CopilotChatDefaultLabels as z };
3531
- //# sourceMappingURL=MarkdownSurfaces-DGpjmPaB.mjs.map
3654
+ export { GenerativeUIError as A, renderSlot as B, issueKey as C, getMarkdownSurfaceSource as D, containsDynamicValue as E, toJsonSchema as F, useShallowStableRef as G, CopilotChatConfigurationProvider as H, defineToolCallRenderer as I, StreamingMarkdownDefaultRenderer as K, MarkdownRendererProvider as L, catalogIdsOf as M, componentCatalogIds as N, BASIC_FUNCTIONS as O, createGenerativeUI as P, useMarkdownRenderer as R, isAsyncIssue as S, withoutRejectedNulls as T, CopilotChatDefaultLabels as U, ControlledModalOpenScope as V, useCopilotChatConfiguration as W, GenerativeUINodeContext as _, GenerativeUIToolCallRenderer as a, useRequiredGenerativeUIRuntime as b, SurfaceView as c, namedRole as d, useGenerativeUIAccessibility as f, useManagerVersion as g, useGenerativeUIState as h, GenerativeUIChatSlotContext as i, isRecord as j, ExpressionError as k, DARK_THEME_CSS as l, useGenerativeUIFunction as m, ProviderMarkdown as n, createGenerativeUIActivityRenderer as o, wrapperAria as p, DefaultGenerativeUIChatCard as r, createGenerativeUIFunctionCallActivityRenderer as s, MarkdownSurfaces as t, controlAria as u, GenerativeUIRuntimeContext as v, validateSchemaSync as w, formatIssues as x, useGenerativeUIRuntime as y, isReactComponentType as z };
3655
+ //# sourceMappingURL=MarkdownSurfaces-ChSlVYOk.mjs.map