@yourgpt/copilot-sdk 1.2.7 → 1.2.9
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/ui/index.cjs +104 -197
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +2 -3
- package/dist/ui/index.d.ts +2 -3
- package/dist/ui/index.js +62 -150
- package/dist/ui/index.js.map +1 -1
- package/package.json +3 -6
package/dist/ui/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
3
|
import React__default from 'react';
|
|
4
|
-
import { Components } from 'react-markdown';
|
|
5
4
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
5
|
import { VariantProps } from 'class-variance-authority';
|
|
7
6
|
import * as use_stick_to_bottom from 'use-stick-to-bottom';
|
|
@@ -20,9 +19,9 @@ type MarkdownProps = {
|
|
|
20
19
|
children: string;
|
|
21
20
|
id?: string;
|
|
22
21
|
className?: string;
|
|
23
|
-
|
|
22
|
+
isStreaming?: boolean;
|
|
24
23
|
};
|
|
25
|
-
declare function MarkdownComponent({ children,
|
|
24
|
+
declare function MarkdownComponent({ children, className, isStreaming, }: MarkdownProps): react_jsx_runtime.JSX.Element;
|
|
26
25
|
declare const Markdown: React$1.MemoExoticComponent<typeof MarkdownComponent>;
|
|
27
26
|
|
|
28
27
|
type CodeBlockProps = {
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
3
|
import React__default from 'react';
|
|
4
|
-
import { Components } from 'react-markdown';
|
|
5
4
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
5
|
import { VariantProps } from 'class-variance-authority';
|
|
7
6
|
import * as use_stick_to_bottom from 'use-stick-to-bottom';
|
|
@@ -20,9 +19,9 @@ type MarkdownProps = {
|
|
|
20
19
|
children: string;
|
|
21
20
|
id?: string;
|
|
22
21
|
className?: string;
|
|
23
|
-
|
|
22
|
+
isStreaming?: boolean;
|
|
24
23
|
};
|
|
25
|
-
declare function MarkdownComponent({ children,
|
|
24
|
+
declare function MarkdownComponent({ children, className, isStreaming, }: MarkdownProps): react_jsx_runtime.JSX.Element;
|
|
26
25
|
declare const Markdown: React$1.MemoExoticComponent<typeof MarkdownComponent>;
|
|
27
26
|
|
|
28
27
|
type CodeBlockProps = {
|
package/dist/ui/index.js
CHANGED
|
@@ -2,14 +2,11 @@ import { useCopilot, useThreadManager } from '../chunk-EYNSW3NR.js';
|
|
|
2
2
|
import { createServerAdapter } from '../chunk-CVD3X4MN.js';
|
|
3
3
|
import { clsx } from 'clsx';
|
|
4
4
|
import { twMerge } from 'tailwind-merge';
|
|
5
|
-
import { jsx,
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import remarkBreaks from 'remark-breaks';
|
|
11
|
-
import remarkGfm from 'remark-gfm';
|
|
12
|
-
import { codeToHtml } from 'shiki';
|
|
5
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
|
+
import * as React7 from 'react';
|
|
7
|
+
import React7__default, { memo, createContext, useState, useRef, useLayoutEffect, useId, useCallback, useContext, useEffect } from 'react';
|
|
8
|
+
import { Streamdown } from 'streamdown';
|
|
9
|
+
import { code } from '@streamdown/code';
|
|
13
10
|
import { Slot } from '@radix-ui/react-slot';
|
|
14
11
|
import { cva } from 'class-variance-authority';
|
|
15
12
|
import { useStickToBottomContext, StickToBottom as StickToBottom$1 } from 'use-stick-to-bottom';
|
|
@@ -416,6 +413,15 @@ function Loader({
|
|
|
416
413
|
return /* @__PURE__ */ jsx(CircularLoader, { size, className });
|
|
417
414
|
}
|
|
418
415
|
}
|
|
416
|
+
function MarkdownComponent({
|
|
417
|
+
children,
|
|
418
|
+
className,
|
|
419
|
+
isStreaming = false
|
|
420
|
+
}) {
|
|
421
|
+
return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(Streamdown, { plugins: { code }, isAnimating: isStreaming, children }) });
|
|
422
|
+
}
|
|
423
|
+
var Markdown = memo(MarkdownComponent);
|
|
424
|
+
Markdown.displayName = "Markdown";
|
|
419
425
|
function CodeBlock({ children, className, ...props }) {
|
|
420
426
|
return /* @__PURE__ */ jsx(
|
|
421
427
|
"div",
|
|
@@ -430,109 +436,6 @@ function CodeBlock({ children, className, ...props }) {
|
|
|
430
436
|
}
|
|
431
437
|
);
|
|
432
438
|
}
|
|
433
|
-
function CodeBlockCode({
|
|
434
|
-
code,
|
|
435
|
-
language = "tsx",
|
|
436
|
-
theme = "github-light",
|
|
437
|
-
className,
|
|
438
|
-
...props
|
|
439
|
-
}) {
|
|
440
|
-
const [highlightedHtml, setHighlightedHtml] = useState(null);
|
|
441
|
-
useEffect(() => {
|
|
442
|
-
async function highlight() {
|
|
443
|
-
if (!code) {
|
|
444
|
-
setHighlightedHtml("<pre><code></code></pre>");
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
const html = await codeToHtml(code, { lang: language, theme });
|
|
448
|
-
setHighlightedHtml(html);
|
|
449
|
-
}
|
|
450
|
-
highlight();
|
|
451
|
-
}, [code, language, theme]);
|
|
452
|
-
const classNames = cn(
|
|
453
|
-
"w-full overflow-x-auto text-[13px] [&>pre]:px-4 [&>pre]:py-4",
|
|
454
|
-
className
|
|
455
|
-
);
|
|
456
|
-
return highlightedHtml ? /* @__PURE__ */ jsx(
|
|
457
|
-
"div",
|
|
458
|
-
{
|
|
459
|
-
className: classNames,
|
|
460
|
-
dangerouslySetInnerHTML: { __html: highlightedHtml },
|
|
461
|
-
...props
|
|
462
|
-
}
|
|
463
|
-
) : /* @__PURE__ */ jsx("div", { className: classNames, ...props, children: /* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { children: code }) }) });
|
|
464
|
-
}
|
|
465
|
-
function parseMarkdownIntoBlocks(markdown) {
|
|
466
|
-
const tokens = marked.lexer(markdown);
|
|
467
|
-
return tokens.map((token) => token.raw);
|
|
468
|
-
}
|
|
469
|
-
function extractLanguage(className) {
|
|
470
|
-
if (!className) return "plaintext";
|
|
471
|
-
const match = className.match(/language-(\w+)/);
|
|
472
|
-
return match ? match[1] : "plaintext";
|
|
473
|
-
}
|
|
474
|
-
var INITIAL_COMPONENTS = {
|
|
475
|
-
code: function CodeComponent({ className, children, ...props }) {
|
|
476
|
-
const isInline = !props.node?.position?.start.line || props.node?.position?.start.line === props.node?.position?.end.line;
|
|
477
|
-
if (isInline) {
|
|
478
|
-
return /* @__PURE__ */ jsx(
|
|
479
|
-
"span",
|
|
480
|
-
{
|
|
481
|
-
className: cn(
|
|
482
|
-
"bg-primary-foreground rounded-sm px-1 font-mono text-sm",
|
|
483
|
-
className
|
|
484
|
-
),
|
|
485
|
-
...props,
|
|
486
|
-
children
|
|
487
|
-
}
|
|
488
|
-
);
|
|
489
|
-
}
|
|
490
|
-
const language = extractLanguage(className);
|
|
491
|
-
return /* @__PURE__ */ jsx(CodeBlock, { className, children: /* @__PURE__ */ jsx(CodeBlockCode, { code: children, language }) });
|
|
492
|
-
},
|
|
493
|
-
pre: function PreComponent({ children }) {
|
|
494
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
var MemoizedMarkdownBlock = memo(
|
|
498
|
-
function MarkdownBlock({
|
|
499
|
-
content,
|
|
500
|
-
components = INITIAL_COMPONENTS
|
|
501
|
-
}) {
|
|
502
|
-
return /* @__PURE__ */ jsx(
|
|
503
|
-
ReactMarkdown,
|
|
504
|
-
{
|
|
505
|
-
remarkPlugins: [remarkGfm, remarkBreaks],
|
|
506
|
-
components,
|
|
507
|
-
children: content
|
|
508
|
-
}
|
|
509
|
-
);
|
|
510
|
-
},
|
|
511
|
-
function propsAreEqual(prevProps, nextProps) {
|
|
512
|
-
return prevProps.content === nextProps.content;
|
|
513
|
-
}
|
|
514
|
-
);
|
|
515
|
-
MemoizedMarkdownBlock.displayName = "MemoizedMarkdownBlock";
|
|
516
|
-
function MarkdownComponent({
|
|
517
|
-
children,
|
|
518
|
-
id,
|
|
519
|
-
className,
|
|
520
|
-
components = INITIAL_COMPONENTS
|
|
521
|
-
}) {
|
|
522
|
-
const generatedId = useId();
|
|
523
|
-
const blockId = id ?? generatedId;
|
|
524
|
-
const blocks = useMemo(() => parseMarkdownIntoBlocks(children), [children]);
|
|
525
|
-
return /* @__PURE__ */ jsx("div", { className, children: blocks.map((block, index) => /* @__PURE__ */ jsx(
|
|
526
|
-
MemoizedMarkdownBlock,
|
|
527
|
-
{
|
|
528
|
-
content: block,
|
|
529
|
-
components
|
|
530
|
-
},
|
|
531
|
-
`${blockId}-block-${index}`
|
|
532
|
-
)) });
|
|
533
|
-
}
|
|
534
|
-
var Markdown = memo(MarkdownComponent);
|
|
535
|
-
Markdown.displayName = "Markdown";
|
|
536
439
|
var buttonVariants = cva(
|
|
537
440
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
538
441
|
{
|
|
@@ -558,7 +461,7 @@ var buttonVariants = cva(
|
|
|
558
461
|
}
|
|
559
462
|
}
|
|
560
463
|
);
|
|
561
|
-
var Button =
|
|
464
|
+
var Button = React7.forwardRef(
|
|
562
465
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
563
466
|
const Comp = asChild ? Slot : "button";
|
|
564
467
|
return /* @__PURE__ */ jsx(
|
|
@@ -799,7 +702,7 @@ function TooltipTrigger({
|
|
|
799
702
|
disabled,
|
|
800
703
|
...props
|
|
801
704
|
}) {
|
|
802
|
-
if (asChild &&
|
|
705
|
+
if (asChild && React7__default.isValidElement(children)) {
|
|
803
706
|
return /* @__PURE__ */ jsx(Tooltip$1.Trigger, { disabled, render: children, ...props });
|
|
804
707
|
}
|
|
805
708
|
return /* @__PURE__ */ jsx(Tooltip$1.Trigger, { disabled, ...props, children });
|
|
@@ -828,7 +731,7 @@ function TooltipContent({
|
|
|
828
731
|
}
|
|
829
732
|
) }) });
|
|
830
733
|
}
|
|
831
|
-
var Avatar =
|
|
734
|
+
var Avatar = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
832
735
|
AvatarPrimitive.Root,
|
|
833
736
|
{
|
|
834
737
|
ref,
|
|
@@ -840,7 +743,7 @@ var Avatar = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
840
743
|
}
|
|
841
744
|
));
|
|
842
745
|
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
|
843
|
-
var AvatarImage =
|
|
746
|
+
var AvatarImage = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
844
747
|
AvatarPrimitive.Image,
|
|
845
748
|
{
|
|
846
749
|
ref,
|
|
@@ -849,7 +752,7 @@ var AvatarImage = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
849
752
|
}
|
|
850
753
|
));
|
|
851
754
|
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
|
852
|
-
var AvatarFallback =
|
|
755
|
+
var AvatarFallback = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
853
756
|
AvatarPrimitive.Fallback,
|
|
854
757
|
{
|
|
855
758
|
ref,
|
|
@@ -890,12 +793,21 @@ var MessageContent = ({
|
|
|
890
793
|
const classNames = cn(
|
|
891
794
|
"rounded-lg p-2 bg-secondary prose break-words whitespace-normal max-w-none",
|
|
892
795
|
"text-foreground prose-headings:text-foreground prose-p:text-foreground prose-strong:text-foreground prose-li:text-foreground prose-a:text-foreground prose-ol:text-foreground prose-ul:text-foreground prose-code:text-foreground",
|
|
796
|
+
// Compact spacing overrides
|
|
797
|
+
"prose-p:my-1 prose-p:leading-relaxed",
|
|
798
|
+
"prose-ul:my-1 prose-ol:my-1 prose-li:my-0.5",
|
|
799
|
+
"prose-headings:my-2 first:prose-headings:mt-0",
|
|
800
|
+
"prose-pre:my-2 prose-blockquote:my-2",
|
|
801
|
+
// Normalize headings for chat UI (same size, just bold)
|
|
802
|
+
"prose-headings:text-[1em] prose-headings:font-semibold",
|
|
803
|
+
// List styling overrides (fix Streamdown's list-inside)
|
|
804
|
+
"[&_ul]:list-outside [&_ol]:list-outside [&_ul]:pl-4 [&_ol]:pl-4 [&_li]:pl-0",
|
|
893
805
|
proseSizeMap[size],
|
|
894
806
|
className
|
|
895
807
|
);
|
|
896
808
|
return markdown ? /* @__PURE__ */ jsx(Markdown, { className: classNames, ...props, children }) : /* @__PURE__ */ jsx("div", { className: classNames, ...props, children });
|
|
897
809
|
};
|
|
898
|
-
var Textarea =
|
|
810
|
+
var Textarea = React7.forwardRef(({ className, ...props }, ref) => {
|
|
899
811
|
return /* @__PURE__ */ jsx(
|
|
900
812
|
"textarea",
|
|
901
813
|
{
|
|
@@ -1059,7 +971,7 @@ function PromptInputAction({
|
|
|
1059
971
|
}
|
|
1060
972
|
var HoverCard = HoverCardPrimitive.Root;
|
|
1061
973
|
var HoverCardTrigger = HoverCardPrimitive.Trigger;
|
|
1062
|
-
var HoverCardContent =
|
|
974
|
+
var HoverCardContent = React7.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1063
975
|
HoverCardPrimitive.Content,
|
|
1064
976
|
{
|
|
1065
977
|
ref,
|
|
@@ -1159,11 +1071,11 @@ function SourceContent({
|
|
|
1159
1071
|
}
|
|
1160
1072
|
) });
|
|
1161
1073
|
}
|
|
1162
|
-
var ReasoningContext =
|
|
1074
|
+
var ReasoningContext = React7.createContext(
|
|
1163
1075
|
null
|
|
1164
1076
|
);
|
|
1165
1077
|
function useReasoningContext() {
|
|
1166
|
-
const context =
|
|
1078
|
+
const context = React7.useContext(ReasoningContext);
|
|
1167
1079
|
if (!context) {
|
|
1168
1080
|
throw new Error(
|
|
1169
1081
|
"Reasoning components must be used within a Reasoning provider"
|
|
@@ -1179,11 +1091,11 @@ function Reasoning({
|
|
|
1179
1091
|
defaultOpen = false,
|
|
1180
1092
|
className
|
|
1181
1093
|
}) {
|
|
1182
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
1183
|
-
const prevStreamingRef =
|
|
1094
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React7.useState(defaultOpen);
|
|
1095
|
+
const prevStreamingRef = React7.useRef(isStreaming);
|
|
1184
1096
|
const isControlled = controlledOpen !== void 0;
|
|
1185
1097
|
const isOpen = isControlled ? controlledOpen : uncontrolledOpen;
|
|
1186
|
-
const setIsOpen =
|
|
1098
|
+
const setIsOpen = React7.useCallback(
|
|
1187
1099
|
(open) => {
|
|
1188
1100
|
if (onOpenChange) {
|
|
1189
1101
|
onOpenChange(open);
|
|
@@ -1194,7 +1106,7 @@ function Reasoning({
|
|
|
1194
1106
|
},
|
|
1195
1107
|
[isControlled, onOpenChange]
|
|
1196
1108
|
);
|
|
1197
|
-
|
|
1109
|
+
React7.useEffect(() => {
|
|
1198
1110
|
if (isStreaming && !prevStreamingRef.current) {
|
|
1199
1111
|
setIsOpen(true);
|
|
1200
1112
|
} else if (!isStreaming && prevStreamingRef.current) {
|
|
@@ -1250,9 +1162,9 @@ function ReasoningContent({
|
|
|
1250
1162
|
className
|
|
1251
1163
|
}) {
|
|
1252
1164
|
const { isOpen } = useReasoningContext();
|
|
1253
|
-
const contentRef =
|
|
1254
|
-
const [height, setHeight] =
|
|
1255
|
-
|
|
1165
|
+
const contentRef = React7.useRef(null);
|
|
1166
|
+
const [height, setHeight] = React7.useState(0);
|
|
1167
|
+
React7.useEffect(() => {
|
|
1256
1168
|
if (contentRef.current) {
|
|
1257
1169
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
1258
1170
|
for (const entry of entries) {
|
|
@@ -1301,11 +1213,11 @@ function SimpleReasoning({
|
|
|
1301
1213
|
/* @__PURE__ */ jsx(ReasoningContent, { markdown, children: content })
|
|
1302
1214
|
] });
|
|
1303
1215
|
}
|
|
1304
|
-
var CopilotUIContext =
|
|
1216
|
+
var CopilotUIContext = React7.createContext(
|
|
1305
1217
|
null
|
|
1306
1218
|
);
|
|
1307
1219
|
function useCopilotUI() {
|
|
1308
|
-
const context =
|
|
1220
|
+
const context = React7.useContext(CopilotUIContext);
|
|
1309
1221
|
if (!context) {
|
|
1310
1222
|
return {
|
|
1311
1223
|
debug: false,
|
|
@@ -1320,7 +1232,7 @@ function CopilotUIProvider({
|
|
|
1320
1232
|
debug = false,
|
|
1321
1233
|
defaultDebugExpanded = false
|
|
1322
1234
|
}) {
|
|
1323
|
-
const value =
|
|
1235
|
+
const value = React7.useMemo(
|
|
1324
1236
|
() => ({
|
|
1325
1237
|
debug,
|
|
1326
1238
|
defaultDebugExpanded,
|
|
@@ -1462,7 +1374,7 @@ function ToolStep({
|
|
|
1462
1374
|
}) {
|
|
1463
1375
|
const { isDebug, defaultDebugExpanded } = useCopilotUI();
|
|
1464
1376
|
const debug = debugProp ?? isDebug;
|
|
1465
|
-
const [expanded, setExpanded] =
|
|
1377
|
+
const [expanded, setExpanded] = React7.useState(
|
|
1466
1378
|
defaultExpanded ?? defaultDebugExpanded ?? false
|
|
1467
1379
|
);
|
|
1468
1380
|
const displayTitle = getDisplayTitle(step);
|
|
@@ -1927,9 +1839,9 @@ function ArrowUpRightIcon({ className }) {
|
|
|
1927
1839
|
}
|
|
1928
1840
|
);
|
|
1929
1841
|
}
|
|
1930
|
-
var ConfirmationContext =
|
|
1842
|
+
var ConfirmationContext = React7.createContext(null);
|
|
1931
1843
|
function useConfirmationContext() {
|
|
1932
|
-
const context =
|
|
1844
|
+
const context = React7.useContext(ConfirmationContext);
|
|
1933
1845
|
if (!context) {
|
|
1934
1846
|
throw new Error(
|
|
1935
1847
|
"Confirmation components must be used within a Confirmation provider"
|
|
@@ -2101,8 +2013,8 @@ function PermissionConfirmation({
|
|
|
2101
2013
|
permissionOptions = DEFAULT_PERMISSION_OPTIONS,
|
|
2102
2014
|
className
|
|
2103
2015
|
}) {
|
|
2104
|
-
const [selectedPermission, setSelectedPermission] =
|
|
2105
|
-
const [showOptions, setShowOptions] =
|
|
2016
|
+
const [selectedPermission, setSelectedPermission] = React7.useState("ask");
|
|
2017
|
+
const [showOptions, setShowOptions] = React7.useState(false);
|
|
2106
2018
|
const handleApprove = () => {
|
|
2107
2019
|
onApprove?.(selectedPermission);
|
|
2108
2020
|
};
|
|
@@ -2232,7 +2144,7 @@ function CompactPermissionConfirmation({
|
|
|
2232
2144
|
onReject,
|
|
2233
2145
|
className
|
|
2234
2146
|
}) {
|
|
2235
|
-
const [rememberChoice, setRememberChoice] =
|
|
2147
|
+
const [rememberChoice, setRememberChoice] = React7.useState(false);
|
|
2236
2148
|
const handleApprove = () => {
|
|
2237
2149
|
onApprove?.(rememberChoice ? "allow_always" : "ask");
|
|
2238
2150
|
};
|
|
@@ -2775,9 +2687,9 @@ function ModelSelector({
|
|
|
2775
2687
|
showCapabilities = true,
|
|
2776
2688
|
className
|
|
2777
2689
|
}) {
|
|
2778
|
-
const [isOpen, setIsOpen] =
|
|
2779
|
-
const containerRef =
|
|
2780
|
-
|
|
2690
|
+
const [isOpen, setIsOpen] = React7.useState(false);
|
|
2691
|
+
const containerRef = React7.useRef(null);
|
|
2692
|
+
React7.useEffect(() => {
|
|
2781
2693
|
function handleClickOutside(event) {
|
|
2782
2694
|
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
2783
2695
|
setIsOpen(false);
|
|
@@ -2786,7 +2698,7 @@ function ModelSelector({
|
|
|
2786
2698
|
document.addEventListener("mousedown", handleClickOutside);
|
|
2787
2699
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2788
2700
|
}, []);
|
|
2789
|
-
const selectedModel =
|
|
2701
|
+
const selectedModel = React7.useMemo(() => {
|
|
2790
2702
|
if (!value) return null;
|
|
2791
2703
|
if (providers) {
|
|
2792
2704
|
for (const provider of providers) {
|
|
@@ -3012,7 +2924,7 @@ function PopoverTrigger({
|
|
|
3012
2924
|
className,
|
|
3013
2925
|
...props
|
|
3014
2926
|
}) {
|
|
3015
|
-
if (asChild &&
|
|
2927
|
+
if (asChild && React7.isValidElement(children)) {
|
|
3016
2928
|
return /* @__PURE__ */ jsx(Popover$1.Trigger, { render: children, className, ...props });
|
|
3017
2929
|
}
|
|
3018
2930
|
return /* @__PURE__ */ jsx(Popover$1.Trigger, { className, ...props, children });
|
|
@@ -3147,8 +3059,8 @@ function ThreadPicker({
|
|
|
3147
3059
|
itemClassName,
|
|
3148
3060
|
newButtonClassName
|
|
3149
3061
|
}) {
|
|
3150
|
-
const [isOpen, setIsOpen] =
|
|
3151
|
-
const selectedThread =
|
|
3062
|
+
const [isOpen, setIsOpen] = React7.useState(false);
|
|
3063
|
+
const selectedThread = React7.useMemo(() => {
|
|
3152
3064
|
if (!value) return null;
|
|
3153
3065
|
return threads.find((t) => t.id === value) ?? null;
|
|
3154
3066
|
}, [value, threads]);
|
|
@@ -3354,7 +3266,7 @@ function ThreadCard({
|
|
|
3354
3266
|
showDelete = true,
|
|
3355
3267
|
className
|
|
3356
3268
|
}) {
|
|
3357
|
-
const [isHovered, setIsHovered] =
|
|
3269
|
+
const [isHovered, setIsHovered] = React7.useState(false);
|
|
3358
3270
|
const handleDelete = (e) => {
|
|
3359
3271
|
e.stopPropagation();
|
|
3360
3272
|
onDelete?.();
|
|
@@ -3605,7 +3517,7 @@ function DefaultMessage({
|
|
|
3605
3517
|
}) {
|
|
3606
3518
|
const isUser = message.role === "user";
|
|
3607
3519
|
const isStreaming = isLastMessage && isLoading;
|
|
3608
|
-
const { cleanContent, followUps } =
|
|
3520
|
+
const { cleanContent, followUps } = React7.useMemo(() => {
|
|
3609
3521
|
if (isUser || !message.content) {
|
|
3610
3522
|
return { cleanContent: message.content, followUps: [] };
|
|
3611
3523
|
}
|
|
@@ -3743,7 +3655,7 @@ function DefaultMessage({
|
|
|
3743
3655
|
toolName: exec.name
|
|
3744
3656
|
};
|
|
3745
3657
|
const output = toolDef.render(renderProps);
|
|
3746
|
-
return /* @__PURE__ */ jsx(
|
|
3658
|
+
return /* @__PURE__ */ jsx(React7.Fragment, { children: output }, exec.id);
|
|
3747
3659
|
}
|
|
3748
3660
|
return null;
|
|
3749
3661
|
}) }),
|
|
@@ -3779,7 +3691,7 @@ function DefaultMessage({
|
|
|
3779
3691
|
approval: approvalCallbacks
|
|
3780
3692
|
};
|
|
3781
3693
|
const output = toolDef.render(renderProps);
|
|
3782
|
-
return /* @__PURE__ */ jsx(
|
|
3694
|
+
return /* @__PURE__ */ jsx(React7.Fragment, { children: output }, tool.id);
|
|
3783
3695
|
}
|
|
3784
3696
|
return /* @__PURE__ */ jsx(
|
|
3785
3697
|
PermissionConfirmation,
|
|
@@ -3811,7 +3723,7 @@ function DefaultMessage({
|
|
|
3811
3723
|
] });
|
|
3812
3724
|
}
|
|
3813
3725
|
function AttachmentPreview({ attachment }) {
|
|
3814
|
-
const [expanded, setExpanded] =
|
|
3726
|
+
const [expanded, setExpanded] = React7.useState(false);
|
|
3815
3727
|
if (attachment.type !== "image") {
|
|
3816
3728
|
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-lg border bg-muted/50 px-3 py-2 text-sm", children: [
|
|
3817
3729
|
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: attachment.type }),
|
|
@@ -4562,7 +4474,7 @@ function Chat({
|
|
|
4562
4474
|
onSendMessage?.(question);
|
|
4563
4475
|
}
|
|
4564
4476
|
};
|
|
4565
|
-
return renderMessage ? /* @__PURE__ */ jsx(
|
|
4477
|
+
return renderMessage ? /* @__PURE__ */ jsx(React7__default.Fragment, { children: renderMessage(messageWithExecutions, index) }, message.id) : /* @__PURE__ */ jsx(
|
|
4566
4478
|
DefaultMessage,
|
|
4567
4479
|
{
|
|
4568
4480
|
message: messageWithExecutions,
|
|
@@ -5230,7 +5142,7 @@ function CopilotChat(props) {
|
|
|
5230
5142
|
footer: classNames.footer
|
|
5231
5143
|
} : void 0;
|
|
5232
5144
|
const { threadManager, handleSwitchThread, handleNewThread, isBusy } = threadManagerResult;
|
|
5233
|
-
const handleDeleteThread =
|
|
5145
|
+
const handleDeleteThread = React7__default.useCallback(
|
|
5234
5146
|
(threadId) => {
|
|
5235
5147
|
const isCurrentThread = threadManager.currentThreadId === threadId;
|
|
5236
5148
|
threadManager.deleteThread(threadId);
|