@copilotkitnext/react 0.0.14 → 0.0.16
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.d.mts +41 -15
- package/dist/index.d.ts +41 -15
- package/dist/index.js +892 -196
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +922 -219
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -50,6 +50,8 @@ __export(index_exports, {
|
|
|
50
50
|
CopilotKitInspector: () => CopilotKitInspector,
|
|
51
51
|
CopilotKitProvider: () => CopilotKitProvider,
|
|
52
52
|
CopilotModalHeader: () => CopilotModalHeader,
|
|
53
|
+
CopilotPopup: () => CopilotPopup,
|
|
54
|
+
CopilotPopupView: () => CopilotPopupView,
|
|
53
55
|
CopilotSidebar: () => CopilotSidebar,
|
|
54
56
|
CopilotSidebarView: () => CopilotSidebarView,
|
|
55
57
|
WildcardToolCallRender: () => WildcardToolCallRender,
|
|
@@ -560,6 +562,8 @@ function renderSlot(slot, DefaultComponent, props) {
|
|
|
560
562
|
|
|
561
563
|
// src/components/chat/CopilotChatInput.tsx
|
|
562
564
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
565
|
+
var SLASH_MENU_MAX_VISIBLE_ITEMS = 5;
|
|
566
|
+
var SLASH_MENU_ITEM_HEIGHT_PX = 40;
|
|
563
567
|
function CopilotChatInput({
|
|
564
568
|
mode = "input",
|
|
565
569
|
onSubmitMessage,
|
|
@@ -571,15 +575,12 @@ function CopilotChatInput({
|
|
|
571
575
|
value,
|
|
572
576
|
toolsMenu,
|
|
573
577
|
autoFocus = true,
|
|
574
|
-
additionalToolbarItems,
|
|
575
578
|
textArea,
|
|
576
579
|
sendButton,
|
|
577
580
|
startTranscribeButton,
|
|
578
581
|
cancelTranscribeButton,
|
|
579
582
|
finishTranscribeButton,
|
|
580
|
-
|
|
581
|
-
toolsButton,
|
|
582
|
-
toolbar,
|
|
583
|
+
addMenuButton,
|
|
583
584
|
audioRecorder,
|
|
584
585
|
children,
|
|
585
586
|
className,
|
|
@@ -593,10 +594,82 @@ function CopilotChatInput({
|
|
|
593
594
|
}
|
|
594
595
|
}, [isControlled, value]);
|
|
595
596
|
const resolvedValue = isControlled ? value ?? "" : internalValue;
|
|
597
|
+
const [layout, setLayout] = (0, import_react4.useState)("compact");
|
|
598
|
+
const ignoreResizeRef = (0, import_react4.useRef)(false);
|
|
599
|
+
const resizeEvaluationRafRef = (0, import_react4.useRef)(null);
|
|
600
|
+
const isExpanded = mode === "input" && layout === "expanded";
|
|
601
|
+
const [commandQuery, setCommandQuery] = (0, import_react4.useState)(null);
|
|
602
|
+
const [slashHighlightIndex, setSlashHighlightIndex] = (0, import_react4.useState)(0);
|
|
596
603
|
const inputRef = (0, import_react4.useRef)(null);
|
|
604
|
+
const gridRef = (0, import_react4.useRef)(null);
|
|
605
|
+
const addButtonContainerRef = (0, import_react4.useRef)(null);
|
|
606
|
+
const actionsContainerRef = (0, import_react4.useRef)(null);
|
|
597
607
|
const audioRecorderRef = (0, import_react4.useRef)(null);
|
|
608
|
+
const slashMenuRef = (0, import_react4.useRef)(null);
|
|
598
609
|
const config = useCopilotChatConfiguration();
|
|
610
|
+
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
599
611
|
const previousModalStateRef = (0, import_react4.useRef)(void 0);
|
|
612
|
+
const measurementCanvasRef = (0, import_react4.useRef)(null);
|
|
613
|
+
const measurementsRef = (0, import_react4.useRef)({
|
|
614
|
+
singleLineHeight: 0,
|
|
615
|
+
maxHeight: 0,
|
|
616
|
+
paddingLeft: 0,
|
|
617
|
+
paddingRight: 0
|
|
618
|
+
});
|
|
619
|
+
const commandItems = (0, import_react4.useMemo)(() => {
|
|
620
|
+
const entries = [];
|
|
621
|
+
const seen = /* @__PURE__ */ new Set();
|
|
622
|
+
const pushItem = (item) => {
|
|
623
|
+
if (item === "-") {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
if (item.items && item.items.length > 0) {
|
|
627
|
+
for (const nested of item.items) {
|
|
628
|
+
pushItem(nested);
|
|
629
|
+
}
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
if (!seen.has(item.label)) {
|
|
633
|
+
seen.add(item.label);
|
|
634
|
+
entries.push(item);
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
if (onAddFile) {
|
|
638
|
+
pushItem({
|
|
639
|
+
label: labels.chatInputToolbarAddButtonLabel,
|
|
640
|
+
action: onAddFile
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
if (toolsMenu && toolsMenu.length > 0) {
|
|
644
|
+
for (const item of toolsMenu) {
|
|
645
|
+
pushItem(item);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
return entries;
|
|
649
|
+
}, [labels.chatInputToolbarAddButtonLabel, onAddFile, toolsMenu]);
|
|
650
|
+
const filteredCommands = (0, import_react4.useMemo)(() => {
|
|
651
|
+
if (commandQuery === null) {
|
|
652
|
+
return [];
|
|
653
|
+
}
|
|
654
|
+
if (commandItems.length === 0) {
|
|
655
|
+
return [];
|
|
656
|
+
}
|
|
657
|
+
const query = commandQuery.trim().toLowerCase();
|
|
658
|
+
if (query.length === 0) {
|
|
659
|
+
return commandItems;
|
|
660
|
+
}
|
|
661
|
+
const startsWith = [];
|
|
662
|
+
const contains = [];
|
|
663
|
+
for (const item of commandItems) {
|
|
664
|
+
const label = item.label.toLowerCase();
|
|
665
|
+
if (label.startsWith(query)) {
|
|
666
|
+
startsWith.push(item);
|
|
667
|
+
} else if (label.includes(query)) {
|
|
668
|
+
contains.push(item);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
return [...startsWith, ...contains];
|
|
672
|
+
}, [commandItems, commandQuery]);
|
|
600
673
|
(0, import_react4.useEffect)(() => {
|
|
601
674
|
if (!autoFocus) {
|
|
602
675
|
previousModalStateRef.current = config?.isModalOpen;
|
|
@@ -607,6 +680,29 @@ function CopilotChatInput({
|
|
|
607
680
|
}
|
|
608
681
|
previousModalStateRef.current = config?.isModalOpen;
|
|
609
682
|
}, [config?.isModalOpen, autoFocus]);
|
|
683
|
+
(0, import_react4.useEffect)(() => {
|
|
684
|
+
if (commandItems.length === 0 && commandQuery !== null) {
|
|
685
|
+
setCommandQuery(null);
|
|
686
|
+
}
|
|
687
|
+
}, [commandItems.length, commandQuery]);
|
|
688
|
+
const previousCommandQueryRef = (0, import_react4.useRef)(null);
|
|
689
|
+
(0, import_react4.useEffect)(() => {
|
|
690
|
+
if (commandQuery !== null && commandQuery !== previousCommandQueryRef.current && filteredCommands.length > 0) {
|
|
691
|
+
setSlashHighlightIndex(0);
|
|
692
|
+
}
|
|
693
|
+
previousCommandQueryRef.current = commandQuery;
|
|
694
|
+
}, [commandQuery, filteredCommands.length]);
|
|
695
|
+
(0, import_react4.useEffect)(() => {
|
|
696
|
+
if (commandQuery === null) {
|
|
697
|
+
setSlashHighlightIndex(0);
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
if (filteredCommands.length === 0) {
|
|
701
|
+
setSlashHighlightIndex(-1);
|
|
702
|
+
} else if (slashHighlightIndex < 0 || slashHighlightIndex >= filteredCommands.length) {
|
|
703
|
+
setSlashHighlightIndex(0);
|
|
704
|
+
}
|
|
705
|
+
}, [commandQuery, filteredCommands, slashHighlightIndex]);
|
|
610
706
|
(0, import_react4.useEffect)(() => {
|
|
611
707
|
const recorder = audioRecorderRef.current;
|
|
612
708
|
if (!recorder) {
|
|
@@ -620,14 +716,103 @@ function CopilotChatInput({
|
|
|
620
716
|
}
|
|
621
717
|
}
|
|
622
718
|
}, [mode]);
|
|
719
|
+
(0, import_react4.useEffect)(() => {
|
|
720
|
+
if (mode !== "input") {
|
|
721
|
+
setLayout("compact");
|
|
722
|
+
setCommandQuery(null);
|
|
723
|
+
}
|
|
724
|
+
}, [mode]);
|
|
725
|
+
const updateSlashState = (0, import_react4.useCallback)(
|
|
726
|
+
(value2) => {
|
|
727
|
+
if (commandItems.length === 0) {
|
|
728
|
+
setCommandQuery((prev) => prev === null ? prev : null);
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
if (value2.startsWith("/")) {
|
|
732
|
+
const firstLine = value2.split(/\r?\n/, 1)[0] ?? "";
|
|
733
|
+
const query = firstLine.slice(1);
|
|
734
|
+
setCommandQuery((prev) => prev === query ? prev : query);
|
|
735
|
+
} else {
|
|
736
|
+
setCommandQuery((prev) => prev === null ? prev : null);
|
|
737
|
+
}
|
|
738
|
+
},
|
|
739
|
+
[commandItems.length]
|
|
740
|
+
);
|
|
741
|
+
(0, import_react4.useEffect)(() => {
|
|
742
|
+
updateSlashState(resolvedValue);
|
|
743
|
+
}, [resolvedValue, updateSlashState]);
|
|
623
744
|
const handleChange = (e) => {
|
|
624
745
|
const nextValue = e.target.value;
|
|
625
746
|
if (!isControlled) {
|
|
626
747
|
setInternalValue(nextValue);
|
|
627
748
|
}
|
|
628
749
|
onChange?.(nextValue);
|
|
750
|
+
updateSlashState(nextValue);
|
|
629
751
|
};
|
|
752
|
+
const clearInputValue = (0, import_react4.useCallback)(() => {
|
|
753
|
+
if (!isControlled) {
|
|
754
|
+
setInternalValue("");
|
|
755
|
+
}
|
|
756
|
+
if (onChange) {
|
|
757
|
+
onChange("");
|
|
758
|
+
}
|
|
759
|
+
}, [isControlled, onChange]);
|
|
760
|
+
const runCommand = (0, import_react4.useCallback)(
|
|
761
|
+
(item) => {
|
|
762
|
+
clearInputValue();
|
|
763
|
+
item.action?.();
|
|
764
|
+
setCommandQuery(null);
|
|
765
|
+
setSlashHighlightIndex(0);
|
|
766
|
+
requestAnimationFrame(() => {
|
|
767
|
+
inputRef.current?.focus();
|
|
768
|
+
});
|
|
769
|
+
},
|
|
770
|
+
[clearInputValue]
|
|
771
|
+
);
|
|
630
772
|
const handleKeyDown = (e) => {
|
|
773
|
+
if (commandQuery !== null && mode === "input") {
|
|
774
|
+
if (e.key === "ArrowDown") {
|
|
775
|
+
if (filteredCommands.length > 0) {
|
|
776
|
+
e.preventDefault();
|
|
777
|
+
setSlashHighlightIndex((prev) => {
|
|
778
|
+
if (filteredCommands.length === 0) {
|
|
779
|
+
return prev;
|
|
780
|
+
}
|
|
781
|
+
const next = prev === -1 ? 0 : (prev + 1) % filteredCommands.length;
|
|
782
|
+
return next;
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
if (e.key === "ArrowUp") {
|
|
788
|
+
if (filteredCommands.length > 0) {
|
|
789
|
+
e.preventDefault();
|
|
790
|
+
setSlashHighlightIndex((prev) => {
|
|
791
|
+
if (filteredCommands.length === 0) {
|
|
792
|
+
return prev;
|
|
793
|
+
}
|
|
794
|
+
if (prev === -1) {
|
|
795
|
+
return filteredCommands.length - 1;
|
|
796
|
+
}
|
|
797
|
+
return prev <= 0 ? filteredCommands.length - 1 : prev - 1;
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
if (e.key === "Enter") {
|
|
803
|
+
const selected = slashHighlightIndex >= 0 ? filteredCommands[slashHighlightIndex] : void 0;
|
|
804
|
+
if (selected) {
|
|
805
|
+
e.preventDefault();
|
|
806
|
+
runCommand(selected);
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
if (e.key === "Escape") {
|
|
811
|
+
e.preventDefault();
|
|
812
|
+
setCommandQuery(null);
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
631
816
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
632
817
|
e.preventDefault();
|
|
633
818
|
send();
|
|
@@ -655,7 +840,11 @@ function CopilotChatInput({
|
|
|
655
840
|
value: resolvedValue,
|
|
656
841
|
onChange: handleChange,
|
|
657
842
|
onKeyDown: handleKeyDown,
|
|
658
|
-
autoFocus
|
|
843
|
+
autoFocus,
|
|
844
|
+
className: (0, import_tailwind_merge3.twMerge)(
|
|
845
|
+
"w-full py-3",
|
|
846
|
+
isExpanded ? "px-5" : "pr-5"
|
|
847
|
+
)
|
|
659
848
|
});
|
|
660
849
|
const BoundAudioRecorder = renderSlot(audioRecorder, CopilotChatAudioRecorder, {
|
|
661
850
|
ref: audioRecorderRef
|
|
@@ -673,45 +862,20 @@ function CopilotChatInput({
|
|
|
673
862
|
const BoundFinishTranscribeButton = renderSlot(finishTranscribeButton, CopilotChatInput.FinishTranscribeButton, {
|
|
674
863
|
onClick: onFinishTranscribe
|
|
675
864
|
});
|
|
676
|
-
const
|
|
677
|
-
onClick: onAddFile,
|
|
678
|
-
disabled: mode === "transcribe"
|
|
679
|
-
});
|
|
680
|
-
const BoundToolsButton = renderSlot(toolsButton, CopilotChatInput.ToolsButton, {
|
|
865
|
+
const BoundAddMenuButton = renderSlot(addMenuButton, CopilotChatInput.AddMenuButton, {
|
|
681
866
|
disabled: mode === "transcribe",
|
|
867
|
+
onAddFile,
|
|
682
868
|
toolsMenu
|
|
683
869
|
});
|
|
684
|
-
const BoundToolbar = renderSlot(
|
|
685
|
-
typeof toolbar === "string" || toolbar === void 0 ? (0, import_tailwind_merge3.twMerge)(toolbar, "w-full h-[60px] bg-transparent flex items-center justify-between") : toolbar,
|
|
686
|
-
CopilotChatInput.Toolbar,
|
|
687
|
-
{
|
|
688
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
689
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center", children: [
|
|
690
|
-
onAddFile && BoundAddFileButton,
|
|
691
|
-
BoundToolsButton,
|
|
692
|
-
additionalToolbarItems
|
|
693
|
-
] }),
|
|
694
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex items-center", children: mode === "transcribe" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
695
|
-
onCancelTranscribe && BoundCancelTranscribeButton,
|
|
696
|
-
onFinishTranscribe && BoundFinishTranscribeButton
|
|
697
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
698
|
-
onStartTranscribe && BoundStartTranscribeButton,
|
|
699
|
-
BoundSendButton
|
|
700
|
-
] }) })
|
|
701
|
-
] })
|
|
702
|
-
}
|
|
703
|
-
);
|
|
704
870
|
if (children) {
|
|
705
|
-
|
|
871
|
+
const childProps = {
|
|
706
872
|
textArea: BoundTextArea,
|
|
707
873
|
audioRecorder: BoundAudioRecorder,
|
|
708
874
|
sendButton: BoundSendButton,
|
|
709
875
|
startTranscribeButton: BoundStartTranscribeButton,
|
|
710
876
|
cancelTranscribeButton: BoundCancelTranscribeButton,
|
|
711
877
|
finishTranscribeButton: BoundFinishTranscribeButton,
|
|
712
|
-
|
|
713
|
-
toolsButton: BoundToolsButton,
|
|
714
|
-
toolbar: BoundToolbar,
|
|
878
|
+
addMenuButton: BoundAddMenuButton,
|
|
715
879
|
onSubmitMessage,
|
|
716
880
|
onStartTranscribe,
|
|
717
881
|
onCancelTranscribe,
|
|
@@ -719,9 +883,9 @@ function CopilotChatInput({
|
|
|
719
883
|
onAddFile,
|
|
720
884
|
mode,
|
|
721
885
|
toolsMenu,
|
|
722
|
-
autoFocus
|
|
723
|
-
|
|
724
|
-
|
|
886
|
+
autoFocus
|
|
887
|
+
};
|
|
888
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: children(childProps) });
|
|
725
889
|
}
|
|
726
890
|
const handleContainerClick = (e) => {
|
|
727
891
|
const target = e.target;
|
|
@@ -729,7 +893,227 @@ function CopilotChatInput({
|
|
|
729
893
|
inputRef.current.focus();
|
|
730
894
|
}
|
|
731
895
|
};
|
|
732
|
-
|
|
896
|
+
const ensureMeasurements = (0, import_react4.useCallback)(() => {
|
|
897
|
+
const textarea = inputRef.current;
|
|
898
|
+
if (!textarea) {
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
const previousValue = textarea.value;
|
|
902
|
+
const previousHeight = textarea.style.height;
|
|
903
|
+
textarea.style.height = "auto";
|
|
904
|
+
const computedStyle = window.getComputedStyle(textarea);
|
|
905
|
+
const paddingLeft = parseFloat(computedStyle.paddingLeft) || 0;
|
|
906
|
+
const paddingRight = parseFloat(computedStyle.paddingRight) || 0;
|
|
907
|
+
const paddingTop = parseFloat(computedStyle.paddingTop) || 0;
|
|
908
|
+
const paddingBottom = parseFloat(computedStyle.paddingBottom) || 0;
|
|
909
|
+
textarea.value = "";
|
|
910
|
+
const singleLineHeight = textarea.scrollHeight;
|
|
911
|
+
textarea.value = previousValue;
|
|
912
|
+
const contentHeight = singleLineHeight - paddingTop - paddingBottom;
|
|
913
|
+
const maxHeight = contentHeight * 5 + paddingTop + paddingBottom;
|
|
914
|
+
measurementsRef.current = {
|
|
915
|
+
singleLineHeight,
|
|
916
|
+
maxHeight,
|
|
917
|
+
paddingLeft,
|
|
918
|
+
paddingRight
|
|
919
|
+
};
|
|
920
|
+
textarea.style.height = previousHeight;
|
|
921
|
+
textarea.style.maxHeight = `${maxHeight}px`;
|
|
922
|
+
}, []);
|
|
923
|
+
const adjustTextareaHeight = (0, import_react4.useCallback)(() => {
|
|
924
|
+
const textarea = inputRef.current;
|
|
925
|
+
if (!textarea) {
|
|
926
|
+
return 0;
|
|
927
|
+
}
|
|
928
|
+
if (measurementsRef.current.singleLineHeight === 0) {
|
|
929
|
+
ensureMeasurements();
|
|
930
|
+
}
|
|
931
|
+
const { maxHeight } = measurementsRef.current;
|
|
932
|
+
if (maxHeight) {
|
|
933
|
+
textarea.style.maxHeight = `${maxHeight}px`;
|
|
934
|
+
}
|
|
935
|
+
textarea.style.height = "auto";
|
|
936
|
+
const scrollHeight = textarea.scrollHeight;
|
|
937
|
+
if (maxHeight) {
|
|
938
|
+
textarea.style.height = `${Math.min(scrollHeight, maxHeight)}px`;
|
|
939
|
+
} else {
|
|
940
|
+
textarea.style.height = `${scrollHeight}px`;
|
|
941
|
+
}
|
|
942
|
+
return scrollHeight;
|
|
943
|
+
}, [ensureMeasurements]);
|
|
944
|
+
const updateLayout = (0, import_react4.useCallback)((nextLayout) => {
|
|
945
|
+
setLayout((prev) => {
|
|
946
|
+
if (prev === nextLayout) {
|
|
947
|
+
return prev;
|
|
948
|
+
}
|
|
949
|
+
ignoreResizeRef.current = true;
|
|
950
|
+
return nextLayout;
|
|
951
|
+
});
|
|
952
|
+
}, []);
|
|
953
|
+
const evaluateLayout = (0, import_react4.useCallback)(() => {
|
|
954
|
+
if (mode !== "input") {
|
|
955
|
+
updateLayout("compact");
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
if (typeof window !== "undefined" && typeof window.matchMedia === "function") {
|
|
959
|
+
const isMobileViewport = window.matchMedia("(max-width: 767px)").matches;
|
|
960
|
+
if (isMobileViewport) {
|
|
961
|
+
ensureMeasurements();
|
|
962
|
+
adjustTextareaHeight();
|
|
963
|
+
updateLayout("expanded");
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
const textarea = inputRef.current;
|
|
968
|
+
const grid = gridRef.current;
|
|
969
|
+
const addContainer = addButtonContainerRef.current;
|
|
970
|
+
const actionsContainer = actionsContainerRef.current;
|
|
971
|
+
if (!textarea || !grid || !addContainer || !actionsContainer) {
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
if (measurementsRef.current.singleLineHeight === 0) {
|
|
975
|
+
ensureMeasurements();
|
|
976
|
+
}
|
|
977
|
+
const scrollHeight = adjustTextareaHeight();
|
|
978
|
+
const baseline = measurementsRef.current.singleLineHeight;
|
|
979
|
+
const hasExplicitBreak = resolvedValue.includes("\n");
|
|
980
|
+
const renderedMultiline = baseline > 0 ? scrollHeight > baseline + 1 : false;
|
|
981
|
+
let shouldExpand = hasExplicitBreak || renderedMultiline;
|
|
982
|
+
if (!shouldExpand) {
|
|
983
|
+
const gridStyles = window.getComputedStyle(grid);
|
|
984
|
+
const paddingLeft = parseFloat(gridStyles.paddingLeft) || 0;
|
|
985
|
+
const paddingRight = parseFloat(gridStyles.paddingRight) || 0;
|
|
986
|
+
const columnGap = parseFloat(gridStyles.columnGap) || 0;
|
|
987
|
+
const gridAvailableWidth = grid.clientWidth - paddingLeft - paddingRight;
|
|
988
|
+
if (gridAvailableWidth > 0) {
|
|
989
|
+
const addWidth = addContainer.getBoundingClientRect().width;
|
|
990
|
+
const actionsWidth = actionsContainer.getBoundingClientRect().width;
|
|
991
|
+
const compactWidth = Math.max(gridAvailableWidth - addWidth - actionsWidth - columnGap * 2, 0);
|
|
992
|
+
const canvas = measurementCanvasRef.current ?? document.createElement("canvas");
|
|
993
|
+
if (!measurementCanvasRef.current) {
|
|
994
|
+
measurementCanvasRef.current = canvas;
|
|
995
|
+
}
|
|
996
|
+
const context = canvas.getContext("2d");
|
|
997
|
+
if (context) {
|
|
998
|
+
const textareaStyles = window.getComputedStyle(textarea);
|
|
999
|
+
const font = textareaStyles.font || `${textareaStyles.fontStyle} ${textareaStyles.fontVariant} ${textareaStyles.fontWeight} ${textareaStyles.fontSize}/${textareaStyles.lineHeight} ${textareaStyles.fontFamily}`;
|
|
1000
|
+
context.font = font;
|
|
1001
|
+
const compactInnerWidth = Math.max(
|
|
1002
|
+
compactWidth - (measurementsRef.current.paddingLeft || 0) - (measurementsRef.current.paddingRight || 0),
|
|
1003
|
+
0
|
|
1004
|
+
);
|
|
1005
|
+
if (compactInnerWidth > 0) {
|
|
1006
|
+
const lines = resolvedValue.length > 0 ? resolvedValue.split("\n") : [""];
|
|
1007
|
+
let longestWidth = 0;
|
|
1008
|
+
for (const line of lines) {
|
|
1009
|
+
const metrics = context.measureText(line || " ");
|
|
1010
|
+
if (metrics.width > longestWidth) {
|
|
1011
|
+
longestWidth = metrics.width;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
if (longestWidth > compactInnerWidth) {
|
|
1015
|
+
shouldExpand = true;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
const nextLayout = shouldExpand ? "expanded" : "compact";
|
|
1022
|
+
updateLayout(nextLayout);
|
|
1023
|
+
}, [adjustTextareaHeight, ensureMeasurements, mode, resolvedValue, updateLayout]);
|
|
1024
|
+
(0, import_react4.useLayoutEffect)(() => {
|
|
1025
|
+
evaluateLayout();
|
|
1026
|
+
}, [evaluateLayout]);
|
|
1027
|
+
(0, import_react4.useEffect)(() => {
|
|
1028
|
+
if (typeof ResizeObserver === "undefined") {
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
1031
|
+
const textarea = inputRef.current;
|
|
1032
|
+
const grid = gridRef.current;
|
|
1033
|
+
const addContainer = addButtonContainerRef.current;
|
|
1034
|
+
const actionsContainer = actionsContainerRef.current;
|
|
1035
|
+
if (!textarea || !grid || !addContainer || !actionsContainer) {
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
const scheduleEvaluation = () => {
|
|
1039
|
+
if (ignoreResizeRef.current) {
|
|
1040
|
+
ignoreResizeRef.current = false;
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
1043
|
+
if (typeof window === "undefined") {
|
|
1044
|
+
evaluateLayout();
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1047
|
+
if (resizeEvaluationRafRef.current !== null) {
|
|
1048
|
+
cancelAnimationFrame(resizeEvaluationRafRef.current);
|
|
1049
|
+
}
|
|
1050
|
+
resizeEvaluationRafRef.current = window.requestAnimationFrame(() => {
|
|
1051
|
+
resizeEvaluationRafRef.current = null;
|
|
1052
|
+
evaluateLayout();
|
|
1053
|
+
});
|
|
1054
|
+
};
|
|
1055
|
+
const observer = new ResizeObserver(() => {
|
|
1056
|
+
scheduleEvaluation();
|
|
1057
|
+
});
|
|
1058
|
+
observer.observe(grid);
|
|
1059
|
+
observer.observe(addContainer);
|
|
1060
|
+
observer.observe(actionsContainer);
|
|
1061
|
+
observer.observe(textarea);
|
|
1062
|
+
return () => {
|
|
1063
|
+
observer.disconnect();
|
|
1064
|
+
if (typeof window !== "undefined" && resizeEvaluationRafRef.current !== null) {
|
|
1065
|
+
cancelAnimationFrame(resizeEvaluationRafRef.current);
|
|
1066
|
+
resizeEvaluationRafRef.current = null;
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
1069
|
+
}, [evaluateLayout]);
|
|
1070
|
+
const slashMenuVisible = commandQuery !== null && commandItems.length > 0;
|
|
1071
|
+
(0, import_react4.useEffect)(() => {
|
|
1072
|
+
if (!slashMenuVisible || slashHighlightIndex < 0) {
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
const active = slashMenuRef.current?.querySelector(
|
|
1076
|
+
`[data-slash-index="${slashHighlightIndex}"]`
|
|
1077
|
+
);
|
|
1078
|
+
active?.scrollIntoView({ block: "nearest" });
|
|
1079
|
+
}, [slashMenuVisible, slashHighlightIndex]);
|
|
1080
|
+
const slashMenu = slashMenuVisible ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1081
|
+
"div",
|
|
1082
|
+
{
|
|
1083
|
+
"data-testid": "copilot-slash-menu",
|
|
1084
|
+
role: "listbox",
|
|
1085
|
+
"aria-label": "Slash commands",
|
|
1086
|
+
ref: slashMenuRef,
|
|
1087
|
+
className: "absolute bottom-full left-0 right-0 z-30 mb-2 max-h-64 overflow-y-auto rounded-lg border border-border bg-white shadow-lg dark:border-[#3a3a3a] dark:bg-[#1f1f1f]",
|
|
1088
|
+
style: { maxHeight: `${SLASH_MENU_MAX_VISIBLE_ITEMS * SLASH_MENU_ITEM_HEIGHT_PX}px` },
|
|
1089
|
+
children: filteredCommands.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "px-3 py-2 text-sm text-muted-foreground", children: "No commands found" }) : filteredCommands.map((item, index) => {
|
|
1090
|
+
const isActive = index === slashHighlightIndex;
|
|
1091
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1092
|
+
"button",
|
|
1093
|
+
{
|
|
1094
|
+
type: "button",
|
|
1095
|
+
role: "option",
|
|
1096
|
+
"aria-selected": isActive,
|
|
1097
|
+
"data-active": isActive ? "true" : void 0,
|
|
1098
|
+
"data-slash-index": index,
|
|
1099
|
+
className: (0, import_tailwind_merge3.twMerge)(
|
|
1100
|
+
"w-full px-3 py-2 text-left text-sm transition-colors",
|
|
1101
|
+
"hover:bg-muted dark:hover:bg-[#2f2f2f]",
|
|
1102
|
+
isActive ? "bg-muted dark:bg-[#2f2f2f]" : "bg-transparent"
|
|
1103
|
+
),
|
|
1104
|
+
onMouseEnter: () => setSlashHighlightIndex(index),
|
|
1105
|
+
onMouseDown: (event) => {
|
|
1106
|
+
event.preventDefault();
|
|
1107
|
+
runCommand(item);
|
|
1108
|
+
},
|
|
1109
|
+
children: item.label
|
|
1110
|
+
},
|
|
1111
|
+
`${item.label}-${index}`
|
|
1112
|
+
);
|
|
1113
|
+
})
|
|
1114
|
+
}
|
|
1115
|
+
) : null;
|
|
1116
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
733
1117
|
"div",
|
|
734
1118
|
{
|
|
735
1119
|
className: (0, import_tailwind_merge3.twMerge)(
|
|
@@ -747,10 +1131,62 @@ function CopilotChatInput({
|
|
|
747
1131
|
),
|
|
748
1132
|
onClick: handleContainerClick,
|
|
749
1133
|
...props,
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
1134
|
+
"data-layout": isExpanded ? "expanded" : "compact",
|
|
1135
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1136
|
+
"div",
|
|
1137
|
+
{
|
|
1138
|
+
ref: gridRef,
|
|
1139
|
+
className: (0, import_tailwind_merge3.twMerge)(
|
|
1140
|
+
"grid w-full gap-x-3 gap-y-3 px-3 py-2",
|
|
1141
|
+
isExpanded ? "grid-cols-[auto_minmax(0,1fr)_auto] grid-rows-[auto_auto]" : "grid-cols-[auto_minmax(0,1fr)_auto] items-center"
|
|
1142
|
+
),
|
|
1143
|
+
"data-layout": isExpanded ? "expanded" : "compact",
|
|
1144
|
+
children: [
|
|
1145
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1146
|
+
"div",
|
|
1147
|
+
{
|
|
1148
|
+
ref: addButtonContainerRef,
|
|
1149
|
+
className: (0, import_tailwind_merge3.twMerge)(
|
|
1150
|
+
"flex items-center",
|
|
1151
|
+
isExpanded ? "row-start-2" : "row-start-1",
|
|
1152
|
+
"col-start-1"
|
|
1153
|
+
),
|
|
1154
|
+
children: BoundAddMenuButton
|
|
1155
|
+
}
|
|
1156
|
+
),
|
|
1157
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1158
|
+
"div",
|
|
1159
|
+
{
|
|
1160
|
+
className: (0, import_tailwind_merge3.twMerge)(
|
|
1161
|
+
"relative flex min-w-0 flex-col",
|
|
1162
|
+
isExpanded ? "col-span-3 row-start-1" : "col-start-2 row-start-1"
|
|
1163
|
+
),
|
|
1164
|
+
children: mode === "transcribe" ? BoundAudioRecorder : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1165
|
+
BoundTextArea,
|
|
1166
|
+
slashMenu
|
|
1167
|
+
] })
|
|
1168
|
+
}
|
|
1169
|
+
),
|
|
1170
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1171
|
+
"div",
|
|
1172
|
+
{
|
|
1173
|
+
ref: actionsContainerRef,
|
|
1174
|
+
className: (0, import_tailwind_merge3.twMerge)(
|
|
1175
|
+
"flex items-center justify-end gap-2",
|
|
1176
|
+
isExpanded ? "col-start-3 row-start-2" : "col-start-3 row-start-1"
|
|
1177
|
+
),
|
|
1178
|
+
children: mode === "transcribe" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1179
|
+
onCancelTranscribe && BoundCancelTranscribeButton,
|
|
1180
|
+
onFinishTranscribe && BoundFinishTranscribeButton
|
|
1181
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1182
|
+
onStartTranscribe && BoundStartTranscribeButton,
|
|
1183
|
+
BoundSendButton
|
|
1184
|
+
] })
|
|
1185
|
+
}
|
|
1186
|
+
)
|
|
1187
|
+
]
|
|
1188
|
+
}
|
|
1189
|
+
)
|
|
754
1190
|
}
|
|
755
1191
|
);
|
|
756
1192
|
}
|
|
@@ -811,124 +1247,110 @@ function CopilotChatInput({
|
|
|
811
1247
|
...props
|
|
812
1248
|
}
|
|
813
1249
|
);
|
|
814
|
-
CopilotChatInput2.
|
|
815
|
-
CopilotChatInput2.ToolbarButton,
|
|
816
|
-
{
|
|
817
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react2.Plus, { className: "size-[20px]" }),
|
|
818
|
-
labelKey: "chatInputToolbarAddButtonLabel",
|
|
819
|
-
defaultClassName: "ml-2",
|
|
820
|
-
...props
|
|
821
|
-
}
|
|
822
|
-
);
|
|
823
|
-
CopilotChatInput2.ToolsButton = ({ className, toolsMenu, ...props }) => {
|
|
1250
|
+
CopilotChatInput2.AddMenuButton = ({ className, toolsMenu, onAddFile, disabled, ...props }) => {
|
|
824
1251
|
const config = useCopilotChatConfiguration();
|
|
825
1252
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
826
|
-
const
|
|
827
|
-
|
|
1253
|
+
const menuItems = (0, import_react4.useMemo)(() => {
|
|
1254
|
+
const items = [];
|
|
1255
|
+
if (onAddFile) {
|
|
1256
|
+
items.push({
|
|
1257
|
+
label: labels.chatInputToolbarAddButtonLabel,
|
|
1258
|
+
action: onAddFile
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
if (toolsMenu && toolsMenu.length > 0) {
|
|
1262
|
+
if (items.length > 0) {
|
|
1263
|
+
items.push("-");
|
|
1264
|
+
}
|
|
1265
|
+
for (const item of toolsMenu) {
|
|
1266
|
+
if (item === "-") {
|
|
1267
|
+
if (items.length === 0 || items[items.length - 1] === "-") {
|
|
1268
|
+
continue;
|
|
1269
|
+
}
|
|
1270
|
+
items.push(item);
|
|
1271
|
+
} else {
|
|
1272
|
+
items.push(item);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
while (items.length > 0 && items[items.length - 1] === "-") {
|
|
1276
|
+
items.pop();
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
return items;
|
|
1280
|
+
}, [onAddFile, toolsMenu, labels.chatInputToolbarAddButtonLabel]);
|
|
1281
|
+
const renderMenuItems = (0, import_react4.useCallback)(
|
|
1282
|
+
(items) => items.map((item, index) => {
|
|
828
1283
|
if (item === "-") {
|
|
829
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuSeparator, {}, index);
|
|
830
|
-
}
|
|
1284
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuSeparator, {}, `separator-${index}`);
|
|
1285
|
+
}
|
|
1286
|
+
if (item.items && item.items.length > 0) {
|
|
831
1287
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(DropdownMenuSub, { children: [
|
|
832
1288
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuSubTrigger, { children: item.label }),
|
|
833
1289
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuSubContent, { children: renderMenuItems(item.items) })
|
|
834
|
-
] }, index);
|
|
835
|
-
} else {
|
|
836
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuItem, { onClick: item.action, children: item.label }, index);
|
|
1290
|
+
] }, `group-${index}`);
|
|
837
1291
|
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
1292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuItem, { onClick: item.action, children: item.label }, `item-${index}`);
|
|
1293
|
+
}),
|
|
1294
|
+
[]
|
|
1295
|
+
);
|
|
1296
|
+
const hasMenuItems = menuItems.length > 0;
|
|
1297
|
+
const isDisabled = disabled || !hasMenuItems;
|
|
843
1298
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(DropdownMenu, { children: [
|
|
844
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
855
|
-
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
|
|
1299
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Tooltip, { children: [
|
|
1300
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1301
|
+
Button,
|
|
1302
|
+
{
|
|
1303
|
+
type: "button",
|
|
1304
|
+
variant: "chatInputToolbarSecondary",
|
|
1305
|
+
size: "chatInputToolbarIcon",
|
|
1306
|
+
className: (0, import_tailwind_merge3.twMerge)("ml-1", className),
|
|
1307
|
+
disabled: isDisabled,
|
|
1308
|
+
...props,
|
|
1309
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react2.Plus, { className: "size-[20px]" })
|
|
1310
|
+
}
|
|
1311
|
+
) }) }),
|
|
1312
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TooltipContent, { side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { className: "flex items-center gap-1 text-xs font-medium", children: [
|
|
1313
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "Add files and more" }),
|
|
1314
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("code", { className: "rounded bg-[#4a4a4a] px-1 py-[1px] font-mono text-[11px] text-white dark:bg-[#e0e0e0] dark:text-black", children: "/" })
|
|
1315
|
+
] }) })
|
|
1316
|
+
] }),
|
|
1317
|
+
hasMenuItems && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuContent, { side: "top", align: "start", children: renderMenuItems(menuItems) })
|
|
859
1318
|
] });
|
|
860
1319
|
};
|
|
861
|
-
CopilotChatInput2.
|
|
862
|
-
CopilotChatInput2.TextArea = (0, import_react4.forwardRef)(function TextArea2({ maxRows = 5, style, className, ...props }, ref) {
|
|
1320
|
+
CopilotChatInput2.TextArea = (0, import_react4.forwardRef)(function TextArea2({ style, className, autoFocus, ...props }, ref) {
|
|
863
1321
|
const internalTextareaRef = (0, import_react4.useRef)(null);
|
|
864
|
-
const [maxHeight, setMaxHeight] = (0, import_react4.useState)(0);
|
|
865
1322
|
const config = useCopilotChatConfiguration();
|
|
866
1323
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
867
1324
|
(0, import_react4.useImperativeHandle)(ref, () => internalTextareaRef.current);
|
|
868
|
-
const adjustHeight = () => {
|
|
869
|
-
const textarea = internalTextareaRef.current;
|
|
870
|
-
if (textarea && maxHeight > 0) {
|
|
871
|
-
textarea.style.height = "auto";
|
|
872
|
-
textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
|
|
873
|
-
}
|
|
874
|
-
};
|
|
875
1325
|
(0, import_react4.useEffect)(() => {
|
|
876
|
-
const
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
textarea.
|
|
881
|
-
|
|
882
|
-
const computedStyle = window.getComputedStyle(textarea);
|
|
883
|
-
const paddingTop = parseFloat(computedStyle.paddingTop);
|
|
884
|
-
const paddingBottom = parseFloat(computedStyle.paddingBottom);
|
|
885
|
-
const contentHeight = textarea.scrollHeight - paddingTop - paddingBottom;
|
|
886
|
-
setMaxHeight(contentHeight * maxRows + paddingTop + paddingBottom);
|
|
887
|
-
textarea.value = currentValue;
|
|
888
|
-
if (currentValue) {
|
|
889
|
-
textarea.style.height = "auto";
|
|
890
|
-
textarea.style.height = `${Math.min(textarea.scrollHeight, contentHeight * maxRows + paddingTop + paddingBottom)}px`;
|
|
891
|
-
}
|
|
892
|
-
if (props.autoFocus) {
|
|
893
|
-
textarea.focus();
|
|
894
|
-
}
|
|
895
|
-
}
|
|
1326
|
+
const textarea = internalTextareaRef.current;
|
|
1327
|
+
if (!textarea) return;
|
|
1328
|
+
const handleFocus = () => {
|
|
1329
|
+
setTimeout(() => {
|
|
1330
|
+
textarea.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
1331
|
+
}, 300);
|
|
896
1332
|
};
|
|
897
|
-
|
|
898
|
-
|
|
1333
|
+
textarea.addEventListener("focus", handleFocus);
|
|
1334
|
+
return () => textarea.removeEventListener("focus", handleFocus);
|
|
1335
|
+
}, []);
|
|
899
1336
|
(0, import_react4.useEffect)(() => {
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
const handleInput = (e) => {
|
|
903
|
-
adjustHeight();
|
|
904
|
-
if (props.onChange) {
|
|
905
|
-
props.onChange(e);
|
|
1337
|
+
if (autoFocus) {
|
|
1338
|
+
internalTextareaRef.current?.focus();
|
|
906
1339
|
}
|
|
907
|
-
};
|
|
1340
|
+
}, [autoFocus]);
|
|
908
1341
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
909
1342
|
"textarea",
|
|
910
1343
|
{
|
|
911
1344
|
ref: internalTextareaRef,
|
|
912
1345
|
...props,
|
|
913
|
-
onChange: handleInput,
|
|
914
1346
|
style: {
|
|
915
1347
|
overflow: "auto",
|
|
916
1348
|
resize: "none",
|
|
917
|
-
maxHeight: `${maxHeight}px`,
|
|
918
1349
|
...style
|
|
919
1350
|
},
|
|
920
1351
|
placeholder: labels.chatInputPlaceholder,
|
|
921
1352
|
className: (0, import_tailwind_merge3.twMerge)(
|
|
922
|
-
|
|
923
|
-
"w-full p-5 pb-0",
|
|
924
|
-
// Behavior
|
|
925
|
-
"outline-none resize-none",
|
|
926
|
-
// Background
|
|
927
|
-
"bg-transparent",
|
|
928
|
-
// Typography
|
|
929
|
-
"antialiased font-regular leading-relaxed text-[16px]",
|
|
930
|
-
// Placeholder styles
|
|
931
|
-
"placeholder:text-[#00000077] dark:placeholder:text-[#fffc]",
|
|
1353
|
+
"bg-transparent outline-none antialiased font-regular leading-relaxed text-[16px] placeholder:text-[#00000077] dark:placeholder:text-[#fffc]",
|
|
932
1354
|
className
|
|
933
1355
|
),
|
|
934
1356
|
rows: 1
|
|
@@ -943,9 +1365,7 @@ CopilotChatInput.ToolbarButton.displayName = "CopilotChatInput.ToolbarButton";
|
|
|
943
1365
|
CopilotChatInput.StartTranscribeButton.displayName = "CopilotChatInput.StartTranscribeButton";
|
|
944
1366
|
CopilotChatInput.CancelTranscribeButton.displayName = "CopilotChatInput.CancelTranscribeButton";
|
|
945
1367
|
CopilotChatInput.FinishTranscribeButton.displayName = "CopilotChatInput.FinishTranscribeButton";
|
|
946
|
-
CopilotChatInput.
|
|
947
|
-
CopilotChatInput.ToolsButton.displayName = "CopilotChatInput.ToolsButton";
|
|
948
|
-
CopilotChatInput.Toolbar.displayName = "CopilotChatInput.Toolbar";
|
|
1368
|
+
CopilotChatInput.AddMenuButton.displayName = "CopilotChatInput.AddMenuButton";
|
|
949
1369
|
var CopilotChatInput_default = CopilotChatInput;
|
|
950
1370
|
|
|
951
1371
|
// src/components/chat/CopilotChatAssistantMessage.tsx
|
|
@@ -1859,7 +2279,8 @@ function CopilotChatAssistantMessage({
|
|
|
1859
2279
|
}
|
|
1860
2280
|
);
|
|
1861
2281
|
const hasContent = !!(message.content && message.content.trim().length > 0);
|
|
1862
|
-
const
|
|
2282
|
+
const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
|
|
2283
|
+
const shouldShowToolbar = toolbarVisible && hasContent && !(isRunning && isLatestAssistantMessage);
|
|
1863
2284
|
if (children) {
|
|
1864
2285
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: children({
|
|
1865
2286
|
markdownRenderer: boundMarkdownRenderer,
|
|
@@ -2251,7 +2672,7 @@ var CopilotChatUserMessage_default = CopilotChatUserMessage;
|
|
|
2251
2672
|
var import_react18 = __toESM(require("react"));
|
|
2252
2673
|
var import_lucide_react5 = require("lucide-react");
|
|
2253
2674
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2254
|
-
var baseClasses = "group inline-flex h-8 items-center gap-1.5 rounded-full border border-border/60 bg-background px-3 text-xs leading-none text-foreground transition-colors cursor-pointer hover:bg-accent/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:text-muted-foreground disabled:hover:bg-background disabled:hover:text-muted-foreground pointer-events-auto";
|
|
2675
|
+
var baseClasses = "group inline-flex h-7 sm:h-8 items-center gap-1 sm:gap-1.5 rounded-full border border-border/60 bg-background px-2.5 sm:px-3 text-[11px] sm:text-xs leading-none text-foreground transition-colors cursor-pointer hover:bg-accent/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:text-muted-foreground disabled:hover:bg-background disabled:hover:text-muted-foreground pointer-events-auto";
|
|
2255
2676
|
var labelClasses = "whitespace-nowrap font-medium leading-none";
|
|
2256
2677
|
var CopilotChatSuggestionPill = import_react18.default.forwardRef(function CopilotChatSuggestionPill2({ className, children, icon, isLoading, type, ...props }, ref) {
|
|
2257
2678
|
const showIcon = !isLoading && icon;
|
|
@@ -2266,7 +2687,7 @@ var CopilotChatSuggestionPill = import_react18.default.forwardRef(function Copil
|
|
|
2266
2687
|
disabled: isLoading || props.disabled,
|
|
2267
2688
|
...props,
|
|
2268
2689
|
children: [
|
|
2269
|
-
isLoading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "flex h-4 w-4 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.Loader2, { className: "h-4 w-4 animate-spin", "aria-hidden": "true" }) }) : showIcon && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "flex h-4 w-4 items-center justify-center text-muted-foreground", children: icon }),
|
|
2690
|
+
isLoading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.Loader2, { className: "h-3.5 sm:h-4 w-3.5 sm:w-4 animate-spin", "aria-hidden": "true" }) }) : showIcon && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: icon }),
|
|
2270
2691
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: labelClasses, children })
|
|
2271
2692
|
]
|
|
2272
2693
|
}
|
|
@@ -2284,7 +2705,7 @@ var DefaultContainer = import_react19.default.forwardRef(function DefaultContain
|
|
|
2284
2705
|
{
|
|
2285
2706
|
ref,
|
|
2286
2707
|
className: cn(
|
|
2287
|
-
"flex flex-wrap items-center gap-2
|
|
2708
|
+
"flex flex-wrap items-center gap-1.5 sm:gap-2 pl-0 pr-4 sm:px-0 pointer-events-none",
|
|
2288
2709
|
className
|
|
2289
2710
|
),
|
|
2290
2711
|
...props
|
|
@@ -2427,10 +2848,52 @@ CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
|
|
|
2427
2848
|
var CopilotChatMessageView_default = CopilotChatMessageView;
|
|
2428
2849
|
|
|
2429
2850
|
// src/components/chat/CopilotChatView.tsx
|
|
2430
|
-
var
|
|
2851
|
+
var import_react21 = __toESM(require("react"));
|
|
2431
2852
|
var import_tailwind_merge7 = require("tailwind-merge");
|
|
2432
2853
|
var import_use_stick_to_bottom = require("use-stick-to-bottom");
|
|
2433
2854
|
var import_lucide_react6 = require("lucide-react");
|
|
2855
|
+
|
|
2856
|
+
// src/hooks/use-keyboard-height.tsx
|
|
2857
|
+
var import_react20 = require("react");
|
|
2858
|
+
function useKeyboardHeight() {
|
|
2859
|
+
const [keyboardState, setKeyboardState] = (0, import_react20.useState)({
|
|
2860
|
+
isKeyboardOpen: false,
|
|
2861
|
+
keyboardHeight: 0,
|
|
2862
|
+
availableHeight: typeof window !== "undefined" ? window.innerHeight : 0,
|
|
2863
|
+
viewportHeight: typeof window !== "undefined" ? window.innerHeight : 0
|
|
2864
|
+
});
|
|
2865
|
+
(0, import_react20.useEffect)(() => {
|
|
2866
|
+
if (typeof window === "undefined") {
|
|
2867
|
+
return;
|
|
2868
|
+
}
|
|
2869
|
+
const visualViewport = window.visualViewport;
|
|
2870
|
+
if (!visualViewport) {
|
|
2871
|
+
return;
|
|
2872
|
+
}
|
|
2873
|
+
const updateKeyboardState = () => {
|
|
2874
|
+
const layoutHeight = window.innerHeight;
|
|
2875
|
+
const visualHeight = visualViewport.height;
|
|
2876
|
+
const keyboardHeight = Math.max(0, layoutHeight - visualHeight);
|
|
2877
|
+
const isKeyboardOpen = keyboardHeight > 150;
|
|
2878
|
+
setKeyboardState({
|
|
2879
|
+
isKeyboardOpen,
|
|
2880
|
+
keyboardHeight,
|
|
2881
|
+
availableHeight: visualHeight,
|
|
2882
|
+
viewportHeight: layoutHeight
|
|
2883
|
+
});
|
|
2884
|
+
};
|
|
2885
|
+
updateKeyboardState();
|
|
2886
|
+
visualViewport.addEventListener("resize", updateKeyboardState);
|
|
2887
|
+
visualViewport.addEventListener("scroll", updateKeyboardState);
|
|
2888
|
+
return () => {
|
|
2889
|
+
visualViewport.removeEventListener("resize", updateKeyboardState);
|
|
2890
|
+
visualViewport.removeEventListener("scroll", updateKeyboardState);
|
|
2891
|
+
};
|
|
2892
|
+
}, []);
|
|
2893
|
+
return keyboardState;
|
|
2894
|
+
}
|
|
2895
|
+
|
|
2896
|
+
// src/components/chat/CopilotChatView.tsx
|
|
2434
2897
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2435
2898
|
function CopilotChatView({
|
|
2436
2899
|
messageView,
|
|
@@ -2452,11 +2915,12 @@ function CopilotChatView({
|
|
|
2452
2915
|
className,
|
|
2453
2916
|
...props
|
|
2454
2917
|
}) {
|
|
2455
|
-
const inputContainerRef = (0,
|
|
2456
|
-
const [inputContainerHeight, setInputContainerHeight] = (0,
|
|
2457
|
-
const [isResizing, setIsResizing] = (0,
|
|
2458
|
-
const resizeTimeoutRef = (0,
|
|
2459
|
-
|
|
2918
|
+
const inputContainerRef = (0, import_react21.useRef)(null);
|
|
2919
|
+
const [inputContainerHeight, setInputContainerHeight] = (0, import_react21.useState)(0);
|
|
2920
|
+
const [isResizing, setIsResizing] = (0, import_react21.useState)(false);
|
|
2921
|
+
const resizeTimeoutRef = (0, import_react21.useRef)(null);
|
|
2922
|
+
const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
|
|
2923
|
+
(0, import_react21.useEffect)(() => {
|
|
2460
2924
|
const element = inputContainerRef.current;
|
|
2461
2925
|
if (!element) return;
|
|
2462
2926
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
@@ -2510,15 +2974,16 @@ function CopilotChatView({
|
|
|
2510
2974
|
isResizing,
|
|
2511
2975
|
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "max-w-3xl mx-auto", children: [
|
|
2512
2976
|
BoundMessageView,
|
|
2513
|
-
hasSuggestions ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "
|
|
2977
|
+
hasSuggestions ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "pl-0 pr-4 sm:px-0 mt-4", children: BoundSuggestionView }) : null
|
|
2514
2978
|
] }) })
|
|
2515
2979
|
});
|
|
2516
2980
|
const BoundScrollToBottomButton = renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, {});
|
|
2517
2981
|
const BoundDisclaimer = renderSlot(disclaimer, CopilotChatView.Disclaimer, {});
|
|
2518
2982
|
const BoundInputContainer = renderSlot(inputContainer, CopilotChatView.InputContainer, {
|
|
2519
2983
|
ref: inputContainerRef,
|
|
2984
|
+
keyboardHeight: isKeyboardOpen ? keyboardHeight : 0,
|
|
2520
2985
|
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
2521
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "max-w-3xl mx-auto py-0 px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 pointer-events-auto", children: BoundInput }),
|
|
2986
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "max-w-3xl mx-auto py-0 px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6 pointer-events-auto", children: BoundInput }),
|
|
2522
2987
|
BoundDisclaimer
|
|
2523
2988
|
] })
|
|
2524
2989
|
});
|
|
@@ -2544,7 +3009,7 @@ function CopilotChatView({
|
|
|
2544
3009
|
const ScrollContent = ({ children, scrollToBottomButton, inputContainerHeight, isResizing }) => {
|
|
2545
3010
|
const { isAtBottom, scrollToBottom } = (0, import_use_stick_to_bottom.useStickToBottomContext)();
|
|
2546
3011
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
2547
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_use_stick_to_bottom.StickToBottom.Content, { className: "overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8", children }) }),
|
|
3012
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_use_stick_to_bottom.StickToBottom.Content, { className: "overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) }),
|
|
2548
3013
|
!isAtBottom && !isResizing && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2549
3014
|
"div",
|
|
2550
3015
|
{
|
|
@@ -2568,13 +3033,13 @@ function CopilotChatView({
|
|
|
2568
3033
|
className,
|
|
2569
3034
|
...props
|
|
2570
3035
|
}) => {
|
|
2571
|
-
const [hasMounted, setHasMounted] = (0,
|
|
3036
|
+
const [hasMounted, setHasMounted] = (0, import_react21.useState)(false);
|
|
2572
3037
|
const { scrollRef, contentRef, scrollToBottom } = (0, import_use_stick_to_bottom.useStickToBottom)();
|
|
2573
|
-
const [showScrollButton, setShowScrollButton] = (0,
|
|
2574
|
-
(0,
|
|
3038
|
+
const [showScrollButton, setShowScrollButton] = (0, import_react21.useState)(false);
|
|
3039
|
+
(0, import_react21.useEffect)(() => {
|
|
2575
3040
|
setHasMounted(true);
|
|
2576
3041
|
}, []);
|
|
2577
|
-
(0,
|
|
3042
|
+
(0, import_react21.useEffect)(() => {
|
|
2578
3043
|
if (autoScroll) return;
|
|
2579
3044
|
const scrollElement = scrollRef.current;
|
|
2580
3045
|
if (!scrollElement) return;
|
|
@@ -2592,7 +3057,7 @@ function CopilotChatView({
|
|
|
2592
3057
|
};
|
|
2593
3058
|
}, [scrollRef, autoScroll]);
|
|
2594
3059
|
if (!hasMounted) {
|
|
2595
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8", children }) });
|
|
3060
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) });
|
|
2596
3061
|
}
|
|
2597
3062
|
if (!autoScroll) {
|
|
2598
3063
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
@@ -2605,7 +3070,7 @@ function CopilotChatView({
|
|
|
2605
3070
|
),
|
|
2606
3071
|
...props,
|
|
2607
3072
|
children: [
|
|
2608
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { ref: contentRef, className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8", children }),
|
|
3073
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { ref: contentRef, className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }),
|
|
2609
3074
|
showScrollButton && !isResizing && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2610
3075
|
"div",
|
|
2611
3076
|
{
|
|
@@ -2674,7 +3139,20 @@ function CopilotChatView({
|
|
|
2674
3139
|
...props
|
|
2675
3140
|
}
|
|
2676
3141
|
);
|
|
2677
|
-
CopilotChatView2.InputContainer =
|
|
3142
|
+
CopilotChatView2.InputContainer = import_react21.default.forwardRef(({ children, className, keyboardHeight = 0, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3143
|
+
"div",
|
|
3144
|
+
{
|
|
3145
|
+
ref,
|
|
3146
|
+
className: cn("absolute bottom-0 left-0 right-0 z-20 pointer-events-none", className),
|
|
3147
|
+
style: {
|
|
3148
|
+
// Adjust position when keyboard is open to keep input visible
|
|
3149
|
+
transform: keyboardHeight > 0 ? `translateY(-${keyboardHeight}px)` : void 0,
|
|
3150
|
+
transition: "transform 0.2s ease-out"
|
|
3151
|
+
},
|
|
3152
|
+
...props,
|
|
3153
|
+
children
|
|
3154
|
+
}
|
|
3155
|
+
));
|
|
2678
3156
|
CopilotChatView2.InputContainer.displayName = "CopilotChatView.InputContainer";
|
|
2679
3157
|
CopilotChatView2.Disclaimer = ({ className, ...props }) => {
|
|
2680
3158
|
const config = useCopilotChatConfiguration();
|
|
@@ -2693,14 +3171,14 @@ var CopilotChatView_default = CopilotChatView;
|
|
|
2693
3171
|
|
|
2694
3172
|
// src/components/chat/CopilotChat.tsx
|
|
2695
3173
|
var import_shared7 = require("@copilotkitnext/shared");
|
|
2696
|
-
var
|
|
3174
|
+
var import_react22 = require("react");
|
|
2697
3175
|
var import_ts_deepmerge = require("ts-deepmerge");
|
|
2698
3176
|
var import_client = require("@ag-ui/client");
|
|
2699
3177
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2700
3178
|
function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen, ...props }) {
|
|
2701
3179
|
const existingConfig = useCopilotChatConfiguration();
|
|
2702
3180
|
const resolvedAgentId = agentId ?? existingConfig?.agentId ?? import_shared7.DEFAULT_AGENT_ID;
|
|
2703
|
-
const resolvedThreadId = (0,
|
|
3181
|
+
const resolvedThreadId = (0, import_react22.useMemo)(
|
|
2704
3182
|
() => threadId ?? existingConfig?.threadId ?? (0, import_shared7.randomUUID)(),
|
|
2705
3183
|
[threadId, existingConfig?.threadId]
|
|
2706
3184
|
);
|
|
@@ -2713,7 +3191,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
2713
3191
|
suggestionView: providedSuggestionView,
|
|
2714
3192
|
...restProps
|
|
2715
3193
|
} = props;
|
|
2716
|
-
(0,
|
|
3194
|
+
(0, import_react22.useEffect)(() => {
|
|
2717
3195
|
const connect = async (agent2) => {
|
|
2718
3196
|
try {
|
|
2719
3197
|
await copilotkit.connectAgent({ agent: agent2 });
|
|
@@ -2731,7 +3209,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
2731
3209
|
return () => {
|
|
2732
3210
|
};
|
|
2733
3211
|
}, [resolvedThreadId, agent, copilotkit, resolvedAgentId]);
|
|
2734
|
-
const onSubmitInput = (0,
|
|
3212
|
+
const onSubmitInput = (0, import_react22.useCallback)(
|
|
2735
3213
|
async (value) => {
|
|
2736
3214
|
agent?.addMessage({
|
|
2737
3215
|
id: (0, import_shared7.randomUUID)(),
|
|
@@ -2748,7 +3226,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
2748
3226
|
},
|
|
2749
3227
|
[agent, copilotkit]
|
|
2750
3228
|
);
|
|
2751
|
-
const handleSelectSuggestion = (0,
|
|
3229
|
+
const handleSelectSuggestion = (0, import_react22.useCallback)(
|
|
2752
3230
|
async (suggestion) => {
|
|
2753
3231
|
if (!agent) {
|
|
2754
3232
|
return;
|
|
@@ -2802,7 +3280,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
2802
3280
|
})(CopilotChat || (CopilotChat = {}));
|
|
2803
3281
|
|
|
2804
3282
|
// src/components/chat/CopilotChatToggleButton.tsx
|
|
2805
|
-
var
|
|
3283
|
+
var import_react23 = __toESM(require("react"));
|
|
2806
3284
|
var import_lucide_react7 = require("lucide-react");
|
|
2807
3285
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2808
3286
|
var DefaultOpenIcon = ({
|
|
@@ -2829,11 +3307,11 @@ var BUTTON_BASE_CLASSES = cn(
|
|
|
2829
3307
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
2830
3308
|
"disabled:pointer-events-none disabled:opacity-60"
|
|
2831
3309
|
);
|
|
2832
|
-
var CopilotChatToggleButton =
|
|
3310
|
+
var CopilotChatToggleButton = import_react23.default.forwardRef(function CopilotChatToggleButton2({ openIcon, closeIcon, className, ...buttonProps }, ref) {
|
|
2833
3311
|
const { onClick, type, disabled, ...restProps } = buttonProps;
|
|
2834
3312
|
const configuration = useCopilotChatConfiguration();
|
|
2835
3313
|
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
2836
|
-
const [fallbackOpen, setFallbackOpen] = (0,
|
|
3314
|
+
const [fallbackOpen, setFallbackOpen] = (0, import_react23.useState)(false);
|
|
2837
3315
|
const isOpen = configuration?.isModalOpen ?? fallbackOpen;
|
|
2838
3316
|
const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;
|
|
2839
3317
|
const handleClick = (event) => {
|
|
@@ -2919,10 +3397,10 @@ CopilotChatToggleButton.displayName = "CopilotChatToggleButton";
|
|
|
2919
3397
|
var CopilotChatToggleButton_default = CopilotChatToggleButton;
|
|
2920
3398
|
|
|
2921
3399
|
// src/components/chat/CopilotSidebarView.tsx
|
|
2922
|
-
var
|
|
3400
|
+
var import_react25 = require("react");
|
|
2923
3401
|
|
|
2924
3402
|
// src/components/chat/CopilotModalHeader.tsx
|
|
2925
|
-
var
|
|
3403
|
+
var import_react24 = require("react");
|
|
2926
3404
|
var import_lucide_react8 = require("lucide-react");
|
|
2927
3405
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2928
3406
|
function CopilotModalHeader({
|
|
@@ -2936,7 +3414,7 @@ function CopilotModalHeader({
|
|
|
2936
3414
|
const configuration = useCopilotChatConfiguration();
|
|
2937
3415
|
const fallbackTitle = configuration?.labels.modalHeaderTitle ?? CopilotChatDefaultLabels.modalHeaderTitle;
|
|
2938
3416
|
const resolvedTitle = title ?? fallbackTitle;
|
|
2939
|
-
const handleClose = (0,
|
|
3417
|
+
const handleClose = (0, import_react24.useCallback)(() => {
|
|
2940
3418
|
configuration?.setModalOpen(false);
|
|
2941
3419
|
}, [configuration]);
|
|
2942
3420
|
const BoundTitle = renderSlot(titleContent, CopilotModalHeader.Title, {
|
|
@@ -3012,8 +3490,8 @@ var SIDEBAR_TRANSITION_MS = 260;
|
|
|
3012
3490
|
function CopilotSidebarView({ header, width, ...props }) {
|
|
3013
3491
|
const configuration = useCopilotChatConfiguration();
|
|
3014
3492
|
const isSidebarOpen = configuration?.isModalOpen ?? false;
|
|
3015
|
-
const sidebarRef = (0,
|
|
3016
|
-
const [sidebarWidth, setSidebarWidth] = (0,
|
|
3493
|
+
const sidebarRef = (0, import_react25.useRef)(null);
|
|
3494
|
+
const [sidebarWidth, setSidebarWidth] = (0, import_react25.useState)(width ?? DEFAULT_SIDEBAR_WIDTH);
|
|
3017
3495
|
const widthToCss = (w) => {
|
|
3018
3496
|
return typeof w === "number" ? `${w}px` : w;
|
|
3019
3497
|
};
|
|
@@ -3023,7 +3501,7 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3023
3501
|
}
|
|
3024
3502
|
return w;
|
|
3025
3503
|
};
|
|
3026
|
-
(0,
|
|
3504
|
+
(0, import_react25.useEffect)(() => {
|
|
3027
3505
|
if (width !== void 0) {
|
|
3028
3506
|
return;
|
|
3029
3507
|
}
|
|
@@ -3055,10 +3533,13 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3055
3533
|
"style",
|
|
3056
3534
|
{
|
|
3057
3535
|
dangerouslySetInnerHTML: {
|
|
3058
|
-
__html: `
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3536
|
+
__html: `
|
|
3537
|
+
@media (min-width: 768px) {
|
|
3538
|
+
body {
|
|
3539
|
+
margin-inline-end: ${widthToMargin(sidebarWidth)};
|
|
3540
|
+
transition: margin-inline-end ${SIDEBAR_TRANSITION_MS}ms ease;
|
|
3541
|
+
}
|
|
3542
|
+
}`
|
|
3062
3543
|
}
|
|
3063
3544
|
}
|
|
3064
3545
|
),
|
|
@@ -3069,12 +3550,22 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3069
3550
|
ref: sidebarRef,
|
|
3070
3551
|
"data-copilot-sidebar": true,
|
|
3071
3552
|
className: cn(
|
|
3072
|
-
"fixed right-0 top-0 z-[1200] flex
|
|
3553
|
+
"fixed right-0 top-0 z-[1200] flex",
|
|
3554
|
+
// Height with dvh fallback and safe area support
|
|
3555
|
+
"h-[100vh] h-[100dvh] max-h-screen",
|
|
3556
|
+
// Responsive width: full on mobile, custom on desktop
|
|
3557
|
+
"w-full",
|
|
3073
3558
|
"border-l border-border bg-background text-foreground shadow-xl",
|
|
3074
3559
|
"transition-transform duration-300 ease-out",
|
|
3075
3560
|
isSidebarOpen ? "translate-x-0" : "translate-x-full pointer-events-none"
|
|
3076
3561
|
),
|
|
3077
|
-
style: {
|
|
3562
|
+
style: {
|
|
3563
|
+
// Use CSS custom property for responsive width
|
|
3564
|
+
["--sidebar-width"]: widthToCss(sidebarWidth),
|
|
3565
|
+
// Safe area insets for iOS
|
|
3566
|
+
paddingTop: "env(safe-area-inset-top)",
|
|
3567
|
+
paddingBottom: "env(safe-area-inset-bottom)"
|
|
3568
|
+
},
|
|
3078
3569
|
"aria-hidden": !isSidebarOpen,
|
|
3079
3570
|
"aria-label": "Copilot chat sidebar",
|
|
3080
3571
|
role: "complementary",
|
|
@@ -3088,14 +3579,173 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3088
3579
|
}
|
|
3089
3580
|
CopilotSidebarView.displayName = "CopilotSidebarView";
|
|
3090
3581
|
|
|
3091
|
-
// src/components/chat/
|
|
3092
|
-
var
|
|
3582
|
+
// src/components/chat/CopilotPopupView.tsx
|
|
3583
|
+
var import_react26 = require("react");
|
|
3093
3584
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3585
|
+
var DEFAULT_POPUP_WIDTH = 420;
|
|
3586
|
+
var DEFAULT_POPUP_HEIGHT = 560;
|
|
3587
|
+
var dimensionToCss = (value, fallback) => {
|
|
3588
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
3589
|
+
return `${value}px`;
|
|
3590
|
+
}
|
|
3591
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
3592
|
+
return value;
|
|
3593
|
+
}
|
|
3594
|
+
return `${fallback}px`;
|
|
3595
|
+
};
|
|
3596
|
+
function CopilotPopupView({
|
|
3597
|
+
header,
|
|
3598
|
+
width,
|
|
3599
|
+
height,
|
|
3600
|
+
clickOutsideToClose,
|
|
3601
|
+
className,
|
|
3602
|
+
...restProps
|
|
3603
|
+
}) {
|
|
3604
|
+
const configuration = useCopilotChatConfiguration();
|
|
3605
|
+
const isPopupOpen = configuration?.isModalOpen ?? false;
|
|
3606
|
+
const setModalOpen = configuration?.setModalOpen;
|
|
3607
|
+
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
3608
|
+
const containerRef = (0, import_react26.useRef)(null);
|
|
3609
|
+
const [isRendered, setIsRendered] = (0, import_react26.useState)(isPopupOpen);
|
|
3610
|
+
const [isAnimatingOut, setIsAnimatingOut] = (0, import_react26.useState)(false);
|
|
3611
|
+
(0, import_react26.useEffect)(() => {
|
|
3612
|
+
if (isPopupOpen) {
|
|
3613
|
+
setIsRendered(true);
|
|
3614
|
+
setIsAnimatingOut(false);
|
|
3615
|
+
return;
|
|
3616
|
+
}
|
|
3617
|
+
if (!isRendered) {
|
|
3618
|
+
return;
|
|
3619
|
+
}
|
|
3620
|
+
setIsAnimatingOut(true);
|
|
3621
|
+
const timeout = setTimeout(() => {
|
|
3622
|
+
setIsRendered(false);
|
|
3623
|
+
setIsAnimatingOut(false);
|
|
3624
|
+
}, 200);
|
|
3625
|
+
return () => clearTimeout(timeout);
|
|
3626
|
+
}, [isPopupOpen, isRendered]);
|
|
3627
|
+
(0, import_react26.useEffect)(() => {
|
|
3628
|
+
if (!isPopupOpen) {
|
|
3629
|
+
return;
|
|
3630
|
+
}
|
|
3631
|
+
if (typeof window === "undefined") {
|
|
3632
|
+
return;
|
|
3633
|
+
}
|
|
3634
|
+
const handleKeyDown = (event) => {
|
|
3635
|
+
if (event.key === "Escape") {
|
|
3636
|
+
event.preventDefault();
|
|
3637
|
+
setModalOpen?.(false);
|
|
3638
|
+
}
|
|
3639
|
+
};
|
|
3640
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
3641
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
3642
|
+
}, [isPopupOpen, setModalOpen]);
|
|
3643
|
+
(0, import_react26.useEffect)(() => {
|
|
3644
|
+
if (!isPopupOpen) {
|
|
3645
|
+
return;
|
|
3646
|
+
}
|
|
3647
|
+
const focusTimer = setTimeout(() => {
|
|
3648
|
+
containerRef.current?.focus({ preventScroll: true });
|
|
3649
|
+
}, 200);
|
|
3650
|
+
return () => clearTimeout(focusTimer);
|
|
3651
|
+
}, [isPopupOpen]);
|
|
3652
|
+
(0, import_react26.useEffect)(() => {
|
|
3653
|
+
if (!isPopupOpen || !clickOutsideToClose) {
|
|
3654
|
+
return;
|
|
3655
|
+
}
|
|
3656
|
+
if (typeof document === "undefined") {
|
|
3657
|
+
return;
|
|
3658
|
+
}
|
|
3659
|
+
const handlePointerDown = (event) => {
|
|
3660
|
+
const target = event.target;
|
|
3661
|
+
if (!target) {
|
|
3662
|
+
return;
|
|
3663
|
+
}
|
|
3664
|
+
const container = containerRef.current;
|
|
3665
|
+
if (container?.contains(target)) {
|
|
3666
|
+
return;
|
|
3667
|
+
}
|
|
3668
|
+
const toggleButton = document.querySelector("[data-slot='chat-toggle-button']");
|
|
3669
|
+
if (toggleButton && toggleButton.contains(target)) {
|
|
3670
|
+
return;
|
|
3671
|
+
}
|
|
3672
|
+
setModalOpen?.(false);
|
|
3673
|
+
};
|
|
3674
|
+
document.addEventListener("pointerdown", handlePointerDown);
|
|
3675
|
+
return () => document.removeEventListener("pointerdown", handlePointerDown);
|
|
3676
|
+
}, [isPopupOpen, clickOutsideToClose, setModalOpen]);
|
|
3677
|
+
const headerElement = (0, import_react26.useMemo)(() => renderSlot(header, CopilotModalHeader, {}), [header]);
|
|
3678
|
+
const resolvedWidth = dimensionToCss(width, DEFAULT_POPUP_WIDTH);
|
|
3679
|
+
const resolvedHeight = dimensionToCss(height, DEFAULT_POPUP_HEIGHT);
|
|
3680
|
+
const popupStyle = (0, import_react26.useMemo)(
|
|
3681
|
+
() => ({
|
|
3682
|
+
"--copilot-popup-width": resolvedWidth,
|
|
3683
|
+
"--copilot-popup-height": resolvedHeight,
|
|
3684
|
+
"--copilot-popup-max-width": "calc(100vw - 3rem)",
|
|
3685
|
+
"--copilot-popup-max-height": "calc(100dvh - 7.5rem)",
|
|
3686
|
+
paddingTop: "env(safe-area-inset-top)",
|
|
3687
|
+
paddingBottom: "env(safe-area-inset-bottom)",
|
|
3688
|
+
paddingLeft: "env(safe-area-inset-left)",
|
|
3689
|
+
paddingRight: "env(safe-area-inset-right)"
|
|
3690
|
+
}),
|
|
3691
|
+
[resolvedHeight, resolvedWidth]
|
|
3692
|
+
);
|
|
3693
|
+
const popupAnimationClass = isPopupOpen && !isAnimatingOut ? "pointer-events-auto translate-y-0 opacity-100 md:scale-100" : "pointer-events-none translate-y-4 opacity-0 md:translate-y-5 md:scale-[0.95]";
|
|
3694
|
+
const popupContent = isRendered ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3695
|
+
"div",
|
|
3696
|
+
{
|
|
3697
|
+
className: cn(
|
|
3698
|
+
"fixed inset-0 z-[1200] flex max-w-full flex-col items-stretch",
|
|
3699
|
+
"md:inset-auto md:bottom-24 md:right-6 md:items-end md:gap-4"
|
|
3700
|
+
),
|
|
3701
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
3702
|
+
"div",
|
|
3703
|
+
{
|
|
3704
|
+
ref: containerRef,
|
|
3705
|
+
tabIndex: -1,
|
|
3706
|
+
role: "dialog",
|
|
3707
|
+
"aria-label": labels.modalHeaderTitle,
|
|
3708
|
+
"data-copilot-popup": true,
|
|
3709
|
+
className: cn(
|
|
3710
|
+
"relative flex h-full w-full flex-col overflow-hidden bg-background text-foreground",
|
|
3711
|
+
"origin-bottom focus:outline-none transform-gpu transition-transform transition-opacity duration-200 ease-out",
|
|
3712
|
+
"md:transition-transform md:transition-opacity",
|
|
3713
|
+
"rounded-none border border-border/0 shadow-none ring-0",
|
|
3714
|
+
"md:h-[var(--copilot-popup-height)] md:w-[var(--copilot-popup-width)]",
|
|
3715
|
+
"md:max-h-[var(--copilot-popup-max-height)] md:max-w-[var(--copilot-popup-max-width)]",
|
|
3716
|
+
"md:origin-bottom-right md:rounded-2xl md:border-border md:shadow-xl md:ring-1 md:ring-border/40",
|
|
3717
|
+
popupAnimationClass
|
|
3718
|
+
),
|
|
3719
|
+
style: popupStyle,
|
|
3720
|
+
children: [
|
|
3721
|
+
headerElement,
|
|
3722
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "flex-1 overflow-hidden", "data-popup-chat": true, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3723
|
+
CopilotChatView_default,
|
|
3724
|
+
{
|
|
3725
|
+
...restProps,
|
|
3726
|
+
className: cn("h-full min-h-0", className)
|
|
3727
|
+
}
|
|
3728
|
+
) })
|
|
3729
|
+
]
|
|
3730
|
+
}
|
|
3731
|
+
)
|
|
3732
|
+
}
|
|
3733
|
+
) : null;
|
|
3734
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
3735
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CopilotChatToggleButton_default, {}),
|
|
3736
|
+
popupContent
|
|
3737
|
+
] });
|
|
3738
|
+
}
|
|
3739
|
+
CopilotPopupView.displayName = "CopilotPopupView";
|
|
3740
|
+
|
|
3741
|
+
// src/components/chat/CopilotSidebar.tsx
|
|
3742
|
+
var import_react27 = require("react");
|
|
3743
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3094
3744
|
function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
3095
|
-
const SidebarViewOverride = (0,
|
|
3745
|
+
const SidebarViewOverride = (0, import_react27.useMemo)(() => {
|
|
3096
3746
|
const Component = (viewProps) => {
|
|
3097
3747
|
const { header: viewHeader, width: viewWidth, ...restProps } = viewProps;
|
|
3098
|
-
return /* @__PURE__ */ (0,
|
|
3748
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3099
3749
|
CopilotSidebarView,
|
|
3100
3750
|
{
|
|
3101
3751
|
...restProps,
|
|
@@ -3106,7 +3756,7 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
|
3106
3756
|
};
|
|
3107
3757
|
return Object.assign(Component, CopilotChatView_default);
|
|
3108
3758
|
}, [header, width]);
|
|
3109
|
-
return /* @__PURE__ */ (0,
|
|
3759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3110
3760
|
CopilotChat,
|
|
3111
3761
|
{
|
|
3112
3762
|
...chatProps,
|
|
@@ -3117,6 +3767,50 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
|
3117
3767
|
}
|
|
3118
3768
|
CopilotSidebar.displayName = "CopilotSidebar";
|
|
3119
3769
|
|
|
3770
|
+
// src/components/chat/CopilotPopup.tsx
|
|
3771
|
+
var import_react28 = require("react");
|
|
3772
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3773
|
+
function CopilotPopup({
|
|
3774
|
+
header,
|
|
3775
|
+
defaultOpen,
|
|
3776
|
+
width,
|
|
3777
|
+
height,
|
|
3778
|
+
clickOutsideToClose,
|
|
3779
|
+
...chatProps
|
|
3780
|
+
}) {
|
|
3781
|
+
const PopupViewOverride = (0, import_react28.useMemo)(() => {
|
|
3782
|
+
const Component = (viewProps) => {
|
|
3783
|
+
const {
|
|
3784
|
+
header: viewHeader,
|
|
3785
|
+
width: viewWidth,
|
|
3786
|
+
height: viewHeight,
|
|
3787
|
+
clickOutsideToClose: viewClickOutsideToClose,
|
|
3788
|
+
...restProps
|
|
3789
|
+
} = viewProps;
|
|
3790
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3791
|
+
CopilotPopupView,
|
|
3792
|
+
{
|
|
3793
|
+
...restProps,
|
|
3794
|
+
header: header ?? viewHeader,
|
|
3795
|
+
width: width ?? viewWidth,
|
|
3796
|
+
height: height ?? viewHeight,
|
|
3797
|
+
clickOutsideToClose: clickOutsideToClose ?? viewClickOutsideToClose
|
|
3798
|
+
}
|
|
3799
|
+
);
|
|
3800
|
+
};
|
|
3801
|
+
return Object.assign(Component, CopilotChatView_default);
|
|
3802
|
+
}, [clickOutsideToClose, header, height, width]);
|
|
3803
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3804
|
+
CopilotChat,
|
|
3805
|
+
{
|
|
3806
|
+
...chatProps,
|
|
3807
|
+
chatView: PopupViewOverride,
|
|
3808
|
+
isModalDefaultOpen: defaultOpen
|
|
3809
|
+
}
|
|
3810
|
+
);
|
|
3811
|
+
}
|
|
3812
|
+
CopilotPopup.displayName = "CopilotPopup";
|
|
3813
|
+
|
|
3120
3814
|
// src/types/defineToolCallRenderer.ts
|
|
3121
3815
|
var import_zod2 = require("zod");
|
|
3122
3816
|
function defineToolCallRenderer(def) {
|
|
@@ -3130,25 +3824,25 @@ function defineToolCallRenderer(def) {
|
|
|
3130
3824
|
}
|
|
3131
3825
|
|
|
3132
3826
|
// src/components/WildcardToolCallRender.tsx
|
|
3133
|
-
var
|
|
3134
|
-
var
|
|
3827
|
+
var import_react29 = require("react");
|
|
3828
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
3135
3829
|
var WildcardToolCallRender = defineToolCallRenderer({
|
|
3136
3830
|
name: "*",
|
|
3137
3831
|
render: ({ args, result, name, status }) => {
|
|
3138
|
-
const [isExpanded, setIsExpanded] = (0,
|
|
3832
|
+
const [isExpanded, setIsExpanded] = (0, import_react29.useState)(false);
|
|
3139
3833
|
const statusString = String(status);
|
|
3140
3834
|
const isActive = statusString === "inProgress" || statusString === "executing";
|
|
3141
3835
|
const isComplete = statusString === "complete";
|
|
3142
3836
|
const statusStyles = isActive ? "bg-amber-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-400" : isComplete ? "bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-400" : "bg-zinc-100 text-zinc-800 dark:bg-zinc-700/40 dark:text-zinc-300";
|
|
3143
|
-
return /* @__PURE__ */ (0,
|
|
3144
|
-
/* @__PURE__ */ (0,
|
|
3837
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "mt-2 pb-2", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "rounded-xl border border-zinc-200/60 dark:border-zinc-800/60 bg-white/70 dark:bg-zinc-900/50 shadow-sm backdrop-blur p-4", children: [
|
|
3838
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
3145
3839
|
"div",
|
|
3146
3840
|
{
|
|
3147
3841
|
className: "flex items-center justify-between gap-3 cursor-pointer",
|
|
3148
3842
|
onClick: () => setIsExpanded(!isExpanded),
|
|
3149
3843
|
children: [
|
|
3150
|
-
/* @__PURE__ */ (0,
|
|
3151
|
-
/* @__PURE__ */ (0,
|
|
3844
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center gap-2 min-w-0", children: [
|
|
3845
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3152
3846
|
"svg",
|
|
3153
3847
|
{
|
|
3154
3848
|
className: `h-4 w-4 text-zinc-500 dark:text-zinc-400 transition-transform ${isExpanded ? "rotate-90" : ""}`,
|
|
@@ -3156,7 +3850,7 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3156
3850
|
viewBox: "0 0 24 24",
|
|
3157
3851
|
strokeWidth: 2,
|
|
3158
3852
|
stroke: "currentColor",
|
|
3159
|
-
children: /* @__PURE__ */ (0,
|
|
3853
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3160
3854
|
"path",
|
|
3161
3855
|
{
|
|
3162
3856
|
strokeLinecap: "round",
|
|
@@ -3166,10 +3860,10 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3166
3860
|
)
|
|
3167
3861
|
}
|
|
3168
3862
|
),
|
|
3169
|
-
/* @__PURE__ */ (0,
|
|
3170
|
-
/* @__PURE__ */ (0,
|
|
3863
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-blue-500" }),
|
|
3864
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "truncate text-sm font-medium text-zinc-900 dark:text-zinc-100", children: name })
|
|
3171
3865
|
] }),
|
|
3172
|
-
/* @__PURE__ */ (0,
|
|
3866
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3173
3867
|
"span",
|
|
3174
3868
|
{
|
|
3175
3869
|
className: `inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${statusStyles}`,
|
|
@@ -3179,14 +3873,14 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3179
3873
|
]
|
|
3180
3874
|
}
|
|
3181
3875
|
),
|
|
3182
|
-
isExpanded && /* @__PURE__ */ (0,
|
|
3183
|
-
/* @__PURE__ */ (0,
|
|
3184
|
-
/* @__PURE__ */ (0,
|
|
3185
|
-
/* @__PURE__ */ (0,
|
|
3876
|
+
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "mt-3 grid gap-4", children: [
|
|
3877
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { children: [
|
|
3878
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Arguments" }),
|
|
3879
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: JSON.stringify(args ?? {}, null, 2) })
|
|
3186
3880
|
] }),
|
|
3187
|
-
result !== void 0 && /* @__PURE__ */ (0,
|
|
3188
|
-
/* @__PURE__ */ (0,
|
|
3189
|
-
/* @__PURE__ */ (0,
|
|
3881
|
+
result !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { children: [
|
|
3882
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Result" }),
|
|
3883
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: typeof result === "string" ? result : JSON.stringify(result, null, 2) })
|
|
3190
3884
|
] })
|
|
3191
3885
|
] })
|
|
3192
3886
|
] }) });
|
|
@@ -3213,6 +3907,8 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
3213
3907
|
CopilotKitInspector,
|
|
3214
3908
|
CopilotKitProvider,
|
|
3215
3909
|
CopilotModalHeader,
|
|
3910
|
+
CopilotPopup,
|
|
3911
|
+
CopilotPopupView,
|
|
3216
3912
|
CopilotSidebar,
|
|
3217
3913
|
CopilotSidebarView,
|
|
3218
3914
|
WildcardToolCallRender,
|