@assistant-ui/react 0.5.76 → 0.5.78
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +73 -69
- package/dist/index.d.ts +73 -69
- package/dist/index.js +362 -292
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +358 -288
- package/dist/index.mjs.map +1 -1
- package/dist/styles/index.css +106 -3
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/tailwindcss/base-components.css +19 -3
- package/dist/styles/tailwindcss/thread.css +8 -4
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
@@ -412,15 +412,11 @@ function useComposerRuntime(options) {
|
|
412
412
|
import { useCallback } from "react";
|
413
413
|
var useAppendMessage = () => {
|
414
414
|
const threadRuntime = useThreadRuntime();
|
415
|
-
const threadViewportStore = useThreadViewportStore();
|
416
|
-
const threadComposerStore = useThreadComposerStore();
|
417
415
|
const append = useCallback(
|
418
416
|
(message) => {
|
419
417
|
threadRuntime.append(message);
|
420
|
-
threadViewportStore.getState().scrollToBottom();
|
421
|
-
threadComposerStore.getState().focus();
|
422
418
|
},
|
423
|
-
[threadRuntime
|
419
|
+
[threadRuntime]
|
424
420
|
);
|
425
421
|
return append;
|
426
422
|
};
|
@@ -429,11 +425,9 @@ var useAppendMessage = () => {
|
|
429
425
|
import { useCallback as useCallback2 } from "react";
|
430
426
|
var useSwitchToNewThread = () => {
|
431
427
|
const assistantRuntime = useAssistantRuntime();
|
432
|
-
const threadComposerStore = useThreadComposerStore();
|
433
428
|
const switchToNewThread = useCallback2(() => {
|
434
429
|
assistantRuntime.switchToNewThread();
|
435
|
-
|
436
|
-
}, [assistantRuntime, threadComposerStore]);
|
430
|
+
}, [assistantRuntime]);
|
437
431
|
return switchToNewThread;
|
438
432
|
};
|
439
433
|
|
@@ -546,25 +540,25 @@ var getThreadMessageText = (message) => {
|
|
546
540
|
var useActionBarCopy = ({
|
547
541
|
copiedDuration = 3e3
|
548
542
|
} = {}) => {
|
549
|
-
const
|
543
|
+
const messageRuntime = useMessageRuntime();
|
544
|
+
const composerRuntime = useComposerRuntime();
|
550
545
|
const messageUtilsStore = useMessageUtilsStore();
|
551
|
-
const editComposerStore = useEditComposerStore();
|
552
546
|
const hasCopyableContent = useCombinedStore(
|
553
|
-
[
|
547
|
+
[messageRuntime, composerRuntime],
|
554
548
|
(message, c) => {
|
555
549
|
return !c.isEditing && (message.role !== "assistant" || message.status.type !== "running") && message.content.some((c2) => c2.type === "text" && c2.text.length > 0);
|
556
550
|
}
|
557
551
|
);
|
558
552
|
const callback = useCallback3(() => {
|
559
|
-
const message =
|
553
|
+
const message = messageRuntime.getState();
|
560
554
|
const { setIsCopied } = messageUtilsStore.getState();
|
561
|
-
const { isEditing, text: composerValue } =
|
555
|
+
const { isEditing, text: composerValue } = composerRuntime.getState();
|
562
556
|
const valueToCopy = isEditing ? composerValue : getThreadMessageText(message);
|
563
557
|
navigator.clipboard.writeText(valueToCopy).then(() => {
|
564
558
|
setIsCopied(true);
|
565
559
|
setTimeout(() => setIsCopied(false), copiedDuration);
|
566
560
|
});
|
567
|
-
}, [
|
561
|
+
}, [messageRuntime, messageUtilsStore, composerRuntime, copiedDuration]);
|
568
562
|
if (!hasCopyableContent) return null;
|
569
563
|
return callback;
|
570
564
|
};
|
@@ -584,20 +578,15 @@ var useActionBarEdit = () => {
|
|
584
578
|
// src/primitive-hooks/actionBar/useActionBarReload.tsx
|
585
579
|
import { useCallback as useCallback5 } from "react";
|
586
580
|
var useActionBarReload = () => {
|
587
|
-
const messageStore = useMessageStore();
|
588
|
-
const threadStore = useThreadStore();
|
589
581
|
const messageRuntime = useMessageRuntime();
|
590
|
-
const
|
591
|
-
const threadViewportStore = useThreadViewportStore();
|
582
|
+
const threadRuntime = useThreadRuntime();
|
592
583
|
const disabled = useCombinedStore(
|
593
|
-
[
|
584
|
+
[threadRuntime, messageRuntime],
|
594
585
|
(t, m) => t.isRunning || t.isDisabled || m.role !== "assistant"
|
595
586
|
);
|
596
587
|
const callback = useCallback5(() => {
|
597
588
|
messageRuntime.reload();
|
598
|
-
|
599
|
-
threadComposerStore.getState().focus();
|
600
|
-
}, [messageRuntime, threadComposerStore, threadViewportStore]);
|
589
|
+
}, [messageRuntime]);
|
601
590
|
if (disabled) return null;
|
602
591
|
return callback;
|
603
592
|
};
|
@@ -687,12 +676,11 @@ var useBranchPickerPrevious = () => {
|
|
687
676
|
// src/primitive-hooks/composer/useComposerCancel.tsx
|
688
677
|
import { useCallback as useCallback12 } from "react";
|
689
678
|
var useComposerCancel = () => {
|
690
|
-
const
|
679
|
+
const composerRuntime = useComposerRuntime();
|
691
680
|
const disabled = useComposer((c) => !c.canCancel);
|
692
681
|
const callback = useCallback12(() => {
|
693
|
-
|
694
|
-
|
695
|
-
}, [composerStore]);
|
682
|
+
composerRuntime.cancel();
|
683
|
+
}, [composerRuntime]);
|
696
684
|
if (disabled) return null;
|
697
685
|
return callback;
|
698
686
|
};
|
@@ -709,21 +697,16 @@ var useComposerIf = (props) => {
|
|
709
697
|
// src/primitive-hooks/composer/useComposerSend.tsx
|
710
698
|
import { useCallback as useCallback13 } from "react";
|
711
699
|
var useComposerSend = () => {
|
712
|
-
const
|
713
|
-
const
|
714
|
-
const composerStore = useComposerStore();
|
715
|
-
const threadComposerStore = useThreadComposerStore();
|
700
|
+
const composerRuntime = useComposerRuntime();
|
701
|
+
const threadRuntime = useThreadRuntime();
|
716
702
|
const disabled = useCombinedStore(
|
717
|
-
[
|
703
|
+
[threadRuntime, composerRuntime],
|
718
704
|
(t, c) => t.isRunning || !c.isEditing || c.isEmpty
|
719
705
|
);
|
720
706
|
const callback = useCallback13(() => {
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
threadViewportStore.getState().scrollToBottom();
|
725
|
-
threadComposerStore.getState().focus();
|
726
|
-
}, [threadComposerStore, composerStore, threadViewportStore]);
|
707
|
+
if (!composerRuntime.getState().isEditing) return;
|
708
|
+
composerRuntime.send();
|
709
|
+
}, [threadRuntime]);
|
727
710
|
if (disabled) return null;
|
728
711
|
return callback;
|
729
712
|
};
|
@@ -789,10 +772,10 @@ var useContentPartText = () => {
|
|
789
772
|
|
790
773
|
// src/primitive-hooks/message/useMessageIf.tsx
|
791
774
|
var useMessageIf = (props) => {
|
792
|
-
const
|
775
|
+
const messageRuntime = useMessageRuntime();
|
793
776
|
const messageUtilsStore = useMessageUtilsStore();
|
794
777
|
return useCombinedStore(
|
795
|
-
[
|
778
|
+
[messageRuntime, messageUtilsStore],
|
796
779
|
({
|
797
780
|
role,
|
798
781
|
attachments,
|
@@ -847,11 +830,9 @@ import { useCallback as useCallback15 } from "react";
|
|
847
830
|
var useThreadScrollToBottom = () => {
|
848
831
|
const isAtBottom = useThreadViewport((s) => s.isAtBottom);
|
849
832
|
const threadViewportStore = useThreadViewportStore();
|
850
|
-
const threadComposerStore = useThreadComposerStore();
|
851
833
|
const handleScrollToBottom = useCallback15(() => {
|
852
834
|
threadViewportStore.getState().scrollToBottom();
|
853
|
-
|
854
|
-
}, [threadViewportStore, threadComposerStore]);
|
835
|
+
}, [threadViewportStore]);
|
855
836
|
if (isAtBottom) return null;
|
856
837
|
return handleScrollToBottom;
|
857
838
|
};
|
@@ -862,20 +843,16 @@ var useThreadSuggestion = ({
|
|
862
843
|
prompt,
|
863
844
|
autoSend
|
864
845
|
}) => {
|
865
|
-
const
|
866
|
-
const composerStore = useThreadComposerStore();
|
867
|
-
const append = useAppendMessage();
|
846
|
+
const threadRuntime = useThreadRuntime();
|
868
847
|
const disabled = useThread((t) => t.isDisabled);
|
869
848
|
const callback = useCallback16(() => {
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
append(prompt);
|
874
|
-
composer.setText("");
|
849
|
+
if (autoSend && !threadRuntime.getState().isRunning) {
|
850
|
+
threadRuntime.append(prompt);
|
851
|
+
threadRuntime.composer.setText("");
|
875
852
|
} else {
|
876
|
-
composer.setText(prompt);
|
853
|
+
threadRuntime.composer.setText(prompt);
|
877
854
|
}
|
878
|
-
}, [
|
855
|
+
}, [threadRuntime, autoSend, prompt]);
|
879
856
|
if (disabled) return null;
|
880
857
|
return callback;
|
881
858
|
};
|
@@ -903,11 +880,11 @@ var useActionBarFloatStatus = ({
|
|
903
880
|
autohide,
|
904
881
|
autohideFloat
|
905
882
|
}) => {
|
906
|
-
const
|
907
|
-
const
|
883
|
+
const threadRuntime = useThreadRuntime();
|
884
|
+
const messageRuntime = useMessageRuntime();
|
908
885
|
const messageUtilsStore = useMessageUtilsStore();
|
909
886
|
return useCombinedStore(
|
910
|
-
[
|
887
|
+
[threadRuntime, messageRuntime, messageUtilsStore],
|
911
888
|
(t, m, mu) => {
|
912
889
|
if (hideWhenRunning && t.isRunning) return "hidden" /* Hidden */;
|
913
890
|
const autohideEnabled = autohide === "always" || autohide === "not-last" && !m.isLast;
|
@@ -1107,46 +1084,44 @@ __export(assistantModal_exports, {
|
|
1107
1084
|
});
|
1108
1085
|
|
1109
1086
|
// src/primitives/assistantModal/AssistantModalRoot.tsx
|
1110
|
-
import { useState as useState4 } from "react";
|
1087
|
+
import { useEffect as useEffect7, useState as useState4 } from "react";
|
1111
1088
|
import * as PopoverPrimitive2 from "@radix-ui/react-popover";
|
1112
1089
|
import { composeEventHandlers as composeEventHandlers6 } from "@radix-ui/primitive";
|
1113
1090
|
|
1114
|
-
// src/utils/hooks/useOnComposerFocus.tsx
|
1115
|
-
import { useCallbackRef } from "@radix-ui/react-use-callback-ref";
|
1116
|
-
import { useEffect as useEffect7 } from "react";
|
1117
|
-
var useOnComposerFocus = (callback) => {
|
1118
|
-
const callbackRef = useCallbackRef(callback);
|
1119
|
-
const threadComposerStore = useThreadComposerStore();
|
1120
|
-
useEffect7(() => {
|
1121
|
-
return threadComposerStore.getState().onFocus(() => {
|
1122
|
-
callbackRef();
|
1123
|
-
});
|
1124
|
-
}, [threadComposerStore, callbackRef]);
|
1125
|
-
};
|
1126
|
-
|
1127
1091
|
// src/primitives/assistantModal/scope.tsx
|
1128
1092
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
1129
1093
|
var usePopoverScope = PopoverPrimitive.createPopoverScope();
|
1130
1094
|
|
1131
1095
|
// src/primitives/assistantModal/AssistantModalRoot.tsx
|
1132
1096
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
1133
|
-
var useAssistantModalOpenState = (
|
1097
|
+
var useAssistantModalOpenState = ({
|
1098
|
+
defaultOpen = false,
|
1099
|
+
unstable_openOnRunStart = true
|
1100
|
+
}) => {
|
1134
1101
|
const state = useState4(defaultOpen);
|
1135
1102
|
const [, setOpen] = state;
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1103
|
+
const threadRuntime = useThreadRuntime();
|
1104
|
+
useEffect7(() => {
|
1105
|
+
if (!unstable_openOnRunStart) return void 0;
|
1106
|
+
return threadRuntime.unstable_on("run-start", () => {
|
1107
|
+
setOpen(true);
|
1108
|
+
});
|
1109
|
+
}, [unstable_openOnRunStart]);
|
1139
1110
|
return state;
|
1140
1111
|
};
|
1141
1112
|
var AssistantModalPrimitiveRoot = ({
|
1142
1113
|
__scopeAssistantModal,
|
1143
1114
|
defaultOpen,
|
1115
|
+
unstable_openOnRunStart,
|
1144
1116
|
open,
|
1145
1117
|
onOpenChange,
|
1146
1118
|
...rest
|
1147
1119
|
}) => {
|
1148
1120
|
const scope = usePopoverScope(__scopeAssistantModal);
|
1149
|
-
const [modalOpen, setOpen] = useAssistantModalOpenState(
|
1121
|
+
const [modalOpen, setOpen] = useAssistantModalOpenState({
|
1122
|
+
defaultOpen,
|
1123
|
+
unstable_openOnRunStart
|
1124
|
+
});
|
1150
1125
|
return /* @__PURE__ */ jsx10(
|
1151
1126
|
PopoverPrimitive2.Root,
|
1152
1127
|
{
|
@@ -1438,9 +1413,9 @@ var useIsHoveringRef = () => {
|
|
1438
1413
|
);
|
1439
1414
|
return useManagedRef(callbackRef);
|
1440
1415
|
};
|
1441
|
-
var MessagePrimitiveRoot = forwardRef12((props,
|
1416
|
+
var MessagePrimitiveRoot = forwardRef12((props, forwardRef36) => {
|
1442
1417
|
const isHoveringRef = useIsHoveringRef();
|
1443
|
-
const ref = useComposedRefs(
|
1418
|
+
const ref = useComposedRefs(forwardRef36, isHoveringRef);
|
1444
1419
|
return /* @__PURE__ */ jsx18(Primitive9.div, { ...props, ref });
|
1445
1420
|
});
|
1446
1421
|
MessagePrimitiveRoot.displayName = "MessagePrimitive.Root";
|
@@ -1497,7 +1472,7 @@ import {
|
|
1497
1472
|
|
1498
1473
|
// src/utils/smooth/useSmooth.tsx
|
1499
1474
|
import { useEffect as useEffect9, useMemo as useMemo5, useRef as useRef2, useState as useState7 } from "react";
|
1500
|
-
import { useCallbackRef
|
1475
|
+
import { useCallbackRef } from "@radix-ui/react-use-callback-ref";
|
1501
1476
|
|
1502
1477
|
// src/utils/smooth/SmoothContext.tsx
|
1503
1478
|
import {
|
@@ -1599,7 +1574,7 @@ var useSmooth = (state, smooth = false) => {
|
|
1599
1574
|
const idRef = useRef2(id);
|
1600
1575
|
const [displayedText, setDisplayedText] = useState7(text);
|
1601
1576
|
const smoothStatusStore = useSmoothStatusStore({ optional: true });
|
1602
|
-
const setText =
|
1577
|
+
const setText = useCallbackRef((text2) => {
|
1603
1578
|
setDisplayedText(text2);
|
1604
1579
|
if (smoothStatusStore) {
|
1605
1580
|
writableStore(smoothStatusStore).setState(
|
@@ -1837,7 +1812,7 @@ var METHOD_NOT_SUPPORTED = () => {
|
|
1837
1812
|
throw new Error("Composer is not available");
|
1838
1813
|
};
|
1839
1814
|
var EMPTY_ARRAY = Object.freeze([]);
|
1840
|
-
var getThreadComposerState = (runtime
|
1815
|
+
var getThreadComposerState = (runtime) => {
|
1841
1816
|
return Object.freeze({
|
1842
1817
|
type: "thread",
|
1843
1818
|
isEditing: runtime?.isEditing ?? false,
|
@@ -1851,8 +1826,6 @@ var getThreadComposerState = (runtime, focus, onFocus) => {
|
|
1851
1826
|
// edit: beginEdit,
|
1852
1827
|
send: runtime?.send.bind(runtime) ?? METHOD_NOT_SUPPORTED,
|
1853
1828
|
cancel: runtime?.cancel.bind(runtime) ?? METHOD_NOT_SUPPORTED,
|
1854
|
-
focus,
|
1855
|
-
onFocus,
|
1856
1829
|
reset: runtime?.reset.bind(runtime) ?? METHOD_NOT_SUPPORTED,
|
1857
1830
|
addAttachment: runtime?.addAttachment.bind(runtime) ?? METHOD_NOT_SUPPORTED,
|
1858
1831
|
removeAttachment: runtime?.removeAttachment.bind(runtime) ?? METHOD_NOT_SUPPORTED
|
@@ -1969,11 +1942,7 @@ var ThreadComposerRuntimeImpl = class extends ComposerRuntimeImpl {
|
|
1969
1942
|
_getState;
|
1970
1943
|
constructor(core) {
|
1971
1944
|
const stateBinding = new LazyMemoizeSubject({
|
1972
|
-
getState: () => getThreadComposerState(
|
1973
|
-
core.getState(),
|
1974
|
-
this.focus.bind(this),
|
1975
|
-
this.onFocus.bind(this)
|
1976
|
-
),
|
1945
|
+
getState: () => getThreadComposerState(core.getState()),
|
1977
1946
|
subscribe: (callback) => core.subscribe(callback)
|
1978
1947
|
});
|
1979
1948
|
super({
|
@@ -1988,21 +1957,6 @@ var ThreadComposerRuntimeImpl = class extends ComposerRuntimeImpl {
|
|
1988
1957
|
getState() {
|
1989
1958
|
return this._getState();
|
1990
1959
|
}
|
1991
|
-
// TODO replace with events
|
1992
|
-
_focusListeners = /* @__PURE__ */ new Set();
|
1993
|
-
/**
|
1994
|
-
* @deprecated This feature is being removed in 0.6.0. Submit feedback if you need it.
|
1995
|
-
*/
|
1996
|
-
focus() {
|
1997
|
-
this._focusListeners.forEach((callback) => callback());
|
1998
|
-
}
|
1999
|
-
/**
|
2000
|
-
* @deprecated This feature is being removed in 0.6.0. Submit feedback if you need it.
|
2001
|
-
*/
|
2002
|
-
onFocus(callback) {
|
2003
|
-
this._focusListeners.add(callback);
|
2004
|
-
return () => this._focusListeners.delete(callback);
|
2005
|
-
}
|
2006
1960
|
getAttachmentByIndex(idx) {
|
2007
1961
|
return new ThreadComposerAttachmentRuntimeImpl(
|
2008
1962
|
new ShallowMemoizeSubject({
|
@@ -2080,6 +2034,9 @@ var NestedSubscriptionSubject = class extends BaseSubject {
|
|
2080
2034
|
getState() {
|
2081
2035
|
return this.binding.getState();
|
2082
2036
|
}
|
2037
|
+
outerSubscribe(callback) {
|
2038
|
+
return this.binding.subscribe(callback);
|
2039
|
+
}
|
2083
2040
|
_connect() {
|
2084
2041
|
const callback = () => {
|
2085
2042
|
this.notifySubscribers();
|
@@ -2094,7 +2051,7 @@ var NestedSubscriptionSubject = class extends BaseSubject {
|
|
2094
2051
|
innerUnsubscribe = this.binding.getState()?.subscribe(callback);
|
2095
2052
|
callback();
|
2096
2053
|
};
|
2097
|
-
const outerUnsubscribe = this.
|
2054
|
+
const outerUnsubscribe = this.outerSubscribe(onRuntimeUpdate);
|
2098
2055
|
return () => {
|
2099
2056
|
outerUnsubscribe?.();
|
2100
2057
|
innerUnsubscribe?.();
|
@@ -2265,8 +2222,7 @@ var MessageContentPartComponent = ({
|
|
2265
2222
|
tools: { by_name = {}, Fallback: Fallback2 = void 0 } = {}
|
2266
2223
|
} = {}
|
2267
2224
|
}) => {
|
2268
|
-
const
|
2269
|
-
const threadRuntime = useThreadRuntime();
|
2225
|
+
const contentPartRuntime = useContentPartRuntime();
|
2270
2226
|
const part = useContentPart();
|
2271
2227
|
const type = part.type;
|
2272
2228
|
switch (type) {
|
@@ -2287,12 +2243,7 @@ var MessageContentPartComponent = ({
|
|
2287
2243
|
return /* @__PURE__ */ jsx23(UI, { ...part, part });
|
2288
2244
|
case "tool-call": {
|
2289
2245
|
const Tool = by_name[part.toolName] || Fallback2;
|
2290
|
-
const addResult = (result) =>
|
2291
|
-
messageId: messageStore.getState().id,
|
2292
|
-
toolName: part.toolName,
|
2293
|
-
toolCallId: part.toolCallId,
|
2294
|
-
result
|
2295
|
-
});
|
2246
|
+
const addResult = (result) => contentPartRuntime.addToolResult(result);
|
2296
2247
|
return /* @__PURE__ */ jsx23(ToolUIDisplay, { ...part, part, UI: Tool, addResult });
|
2297
2248
|
}
|
2298
2249
|
default:
|
@@ -2475,11 +2426,24 @@ import { Slot } from "@radix-ui/react-slot";
|
|
2475
2426
|
import {
|
2476
2427
|
forwardRef as forwardRef18,
|
2477
2428
|
useCallback as useCallback20,
|
2478
|
-
useEffect as
|
2429
|
+
useEffect as useEffect12,
|
2479
2430
|
useRef as useRef3
|
2480
2431
|
} from "react";
|
2481
2432
|
import TextareaAutosize from "react-textarea-autosize";
|
2482
2433
|
import { useEscapeKeydown as useEscapeKeydown2 } from "@radix-ui/react-use-escape-keydown";
|
2434
|
+
|
2435
|
+
// src/utils/hooks/useOnScrollToBottom.tsx
|
2436
|
+
import { useCallbackRef as useCallbackRef2 } from "@radix-ui/react-use-callback-ref";
|
2437
|
+
import { useEffect as useEffect11 } from "react";
|
2438
|
+
var useOnScrollToBottom = (callback) => {
|
2439
|
+
const callbackRef = useCallbackRef2(callback);
|
2440
|
+
const onScrollToBottom = useThreadViewport((vp) => vp.onScrollToBottom);
|
2441
|
+
useEffect11(() => {
|
2442
|
+
return onScrollToBottom(callbackRef);
|
2443
|
+
}, [onScrollToBottom, callbackRef]);
|
2444
|
+
};
|
2445
|
+
|
2446
|
+
// src/primitives/composer/ComposerInput.tsx
|
2483
2447
|
import { jsx as jsx28 } from "react/jsx-runtime";
|
2484
2448
|
var ComposerPrimitiveInput = forwardRef18(
|
2485
2449
|
({
|
@@ -2490,10 +2454,13 @@ var ComposerPrimitiveInput = forwardRef18(
|
|
2490
2454
|
onKeyDown,
|
2491
2455
|
submitOnEnter = true,
|
2492
2456
|
cancelOnEscape = true,
|
2457
|
+
unstable_focusOnRunStart = true,
|
2458
|
+
unstable_focusOnScrollToBottom = true,
|
2459
|
+
unstable_focusOnThreadSwitched = true,
|
2493
2460
|
...rest
|
2494
2461
|
}, forwardedRef) => {
|
2495
|
-
const
|
2496
|
-
const
|
2462
|
+
const threadRuntime = useThreadRuntime();
|
2463
|
+
const composerRuntime = useComposerRuntime();
|
2497
2464
|
const value = useComposer((c) => {
|
2498
2465
|
if (!c.isEditing) return "";
|
2499
2466
|
return c.text;
|
@@ -2504,9 +2471,8 @@ var ComposerPrimitiveInput = forwardRef18(
|
|
2504
2471
|
const ref = useComposedRefs2(forwardedRef, textareaRef);
|
2505
2472
|
useEscapeKeydown2((e) => {
|
2506
2473
|
if (!cancelOnEscape) return;
|
2507
|
-
|
2508
|
-
|
2509
|
-
composer.cancel();
|
2474
|
+
if (composerRuntime.getState().canCancel) {
|
2475
|
+
composerRuntime.cancel();
|
2510
2476
|
e.preventDefault();
|
2511
2477
|
}
|
2512
2478
|
});
|
@@ -2514,7 +2480,7 @@ var ComposerPrimitiveInput = forwardRef18(
|
|
2514
2480
|
if (isDisabled || !submitOnEnter) return;
|
2515
2481
|
if (e.nativeEvent.isComposing) return;
|
2516
2482
|
if (e.key === "Enter" && e.shiftKey === false) {
|
2517
|
-
const { isRunning } =
|
2483
|
+
const { isRunning } = threadRuntime.getState();
|
2518
2484
|
if (!isRunning) {
|
2519
2485
|
e.preventDefault();
|
2520
2486
|
textareaRef.current?.closest("form")?.requestSubmit();
|
@@ -2522,7 +2488,7 @@ var ComposerPrimitiveInput = forwardRef18(
|
|
2522
2488
|
}
|
2523
2489
|
};
|
2524
2490
|
const autoFocusEnabled = autoFocus && !isDisabled;
|
2525
|
-
const
|
2491
|
+
const focus2 = useCallback20(() => {
|
2526
2492
|
const textarea = textareaRef.current;
|
2527
2493
|
if (!textarea || !autoFocusEnabled) return;
|
2528
2494
|
textarea.focus({ preventScroll: true });
|
@@ -2531,12 +2497,22 @@ var ComposerPrimitiveInput = forwardRef18(
|
|
2531
2497
|
textareaRef.current.value.length
|
2532
2498
|
);
|
2533
2499
|
}, [autoFocusEnabled]);
|
2534
|
-
|
2535
|
-
|
2536
|
-
if (
|
2537
|
-
|
2500
|
+
useEffect12(() => focus2(), [focus2]);
|
2501
|
+
useOnScrollToBottom(() => {
|
2502
|
+
if (composerRuntime.type === "thread" && unstable_focusOnScrollToBottom) {
|
2503
|
+
focus2();
|
2538
2504
|
}
|
2539
2505
|
});
|
2506
|
+
useEffect12(() => {
|
2507
|
+
if (composerRuntime.type !== "thread" || !unstable_focusOnRunStart)
|
2508
|
+
return void 0;
|
2509
|
+
return threadRuntime.unstable_on("run-start", focus2);
|
2510
|
+
}, [unstable_focusOnRunStart]);
|
2511
|
+
useEffect12(() => {
|
2512
|
+
if (composerRuntime.type !== "thread" || !unstable_focusOnThreadSwitched)
|
2513
|
+
return void 0;
|
2514
|
+
return threadRuntime.unstable_on("switched-to", focus2);
|
2515
|
+
}, [unstable_focusOnThreadSwitched]);
|
2540
2516
|
return /* @__PURE__ */ jsx28(
|
2541
2517
|
Component,
|
2542
2518
|
{
|
@@ -2546,9 +2522,8 @@ var ComposerPrimitiveInput = forwardRef18(
|
|
2546
2522
|
ref,
|
2547
2523
|
disabled: isDisabled,
|
2548
2524
|
onChange: composeEventHandlers9(onChange, (e) => {
|
2549
|
-
|
2550
|
-
|
2551
|
-
return composerState.setText(e.target.value);
|
2525
|
+
if (!composerRuntime.getState().isEditing) return;
|
2526
|
+
return composerRuntime.setText(e.target.value);
|
2552
2527
|
}),
|
2553
2528
|
onKeyDown: composeEventHandlers9(onKeyDown, handleKeyPress)
|
2554
2529
|
}
|
@@ -2690,7 +2665,7 @@ import { forwardRef as forwardRef20 } from "react";
|
|
2690
2665
|
|
2691
2666
|
// src/primitive-hooks/thread/useThreadViewportAutoScroll.tsx
|
2692
2667
|
import { useComposedRefs as useComposedRefs3 } from "@radix-ui/react-compose-refs";
|
2693
|
-
import { useRef as useRef4 } from "react";
|
2668
|
+
import { useEffect as useEffect13, useRef as useRef4 } from "react";
|
2694
2669
|
|
2695
2670
|
// src/utils/hooks/useOnResizeContent.tsx
|
2696
2671
|
import { useCallbackRef as useCallbackRef3 } from "@radix-ui/react-use-callback-ref";
|
@@ -2732,22 +2707,10 @@ var useOnResizeContent = (callback) => {
|
|
2732
2707
|
return useManagedRef(refCallback);
|
2733
2708
|
};
|
2734
2709
|
|
2735
|
-
// src/utils/hooks/useOnScrollToBottom.tsx
|
2736
|
-
import { useCallbackRef as useCallbackRef4 } from "@radix-ui/react-use-callback-ref";
|
2737
|
-
import { useEffect as useEffect12 } from "react";
|
2738
|
-
var useOnScrollToBottom = (callback) => {
|
2739
|
-
const callbackRef = useCallbackRef4(callback);
|
2740
|
-
const threadViewportStore = useThreadViewportStore();
|
2741
|
-
useEffect12(() => {
|
2742
|
-
return threadViewportStore.getState().onScrollToBottom(() => {
|
2743
|
-
callbackRef();
|
2744
|
-
});
|
2745
|
-
}, [threadViewportStore, callbackRef]);
|
2746
|
-
};
|
2747
|
-
|
2748
2710
|
// src/primitive-hooks/thread/useThreadViewportAutoScroll.tsx
|
2749
2711
|
var useThreadViewportAutoScroll = ({
|
2750
|
-
autoScroll = true
|
2712
|
+
autoScroll = true,
|
2713
|
+
unstable_scrollToBottomOnRunStart = true
|
2751
2714
|
}) => {
|
2752
2715
|
const divRef = useRef4(null);
|
2753
2716
|
const threadViewportStore = useThreadViewportStore();
|
@@ -2793,6 +2756,11 @@ var useThreadViewportAutoScroll = ({
|
|
2793
2756
|
useOnScrollToBottom(() => {
|
2794
2757
|
scrollToBottom("auto");
|
2795
2758
|
});
|
2759
|
+
const threadRuntime = useThreadRuntime();
|
2760
|
+
useEffect13(() => {
|
2761
|
+
if (!unstable_scrollToBottomOnRunStart) return void 0;
|
2762
|
+
return threadRuntime.unstable_on("run-start", focus);
|
2763
|
+
}, [unstable_scrollToBottomOnRunStart]);
|
2796
2764
|
return autoScrollRef;
|
2797
2765
|
};
|
2798
2766
|
|
@@ -2811,7 +2779,7 @@ ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
|
|
2811
2779
|
import { memo as memo5, useMemo as useMemo10 } from "react";
|
2812
2780
|
|
2813
2781
|
// src/context/providers/MessageRuntimeProvider.tsx
|
2814
|
-
import { useEffect as
|
2782
|
+
import { useEffect as useEffect14, useState as useState9 } from "react";
|
2815
2783
|
import { create as create10 } from "zustand";
|
2816
2784
|
|
2817
2785
|
// src/context/stores/MessageUtils.ts
|
@@ -2833,14 +2801,14 @@ var makeMessageUtilsStore = () => create9((set) => {
|
|
2833
2801
|
import { jsx as jsx32 } from "react/jsx-runtime";
|
2834
2802
|
var useMessageRuntimeStore = (runtime) => {
|
2835
2803
|
const [store] = useState9(() => create10(() => runtime));
|
2836
|
-
|
2804
|
+
useEffect14(() => {
|
2837
2805
|
writableStore(store).setState(runtime, true);
|
2838
2806
|
}, [runtime, store]);
|
2839
2807
|
return store;
|
2840
2808
|
};
|
2841
2809
|
var useMessageStore2 = (runtime) => {
|
2842
2810
|
const [store] = useState9(() => create10(() => runtime.getState()));
|
2843
|
-
|
2811
|
+
useEffect14(() => {
|
2844
2812
|
const updateState = () => writableStore(store).setState(runtime.getState(), true);
|
2845
2813
|
updateState();
|
2846
2814
|
return runtime.subscribe(updateState);
|
@@ -2854,7 +2822,7 @@ var useMessageUtilsStore2 = () => {
|
|
2854
2822
|
var useEditComposerStore2 = (useMessageRuntime2) => {
|
2855
2823
|
const runtime = useMessageRuntime2.getState().composer;
|
2856
2824
|
const [store] = useState9(() => create10(() => runtime.getState()));
|
2857
|
-
|
2825
|
+
useEffect14(() => {
|
2858
2826
|
const updateState = () => writableStore(store).setState(runtime.getState());
|
2859
2827
|
updateState();
|
2860
2828
|
return runtime.subscribe(updateState);
|
@@ -3588,6 +3556,7 @@ var ThreadRuntimeImpl = class {
|
|
3588
3556
|
this._threadBinding = {
|
3589
3557
|
getState: () => threadBinding.getState(),
|
3590
3558
|
getStateState: () => stateBinding.getState(),
|
3559
|
+
outerSubscribe: (callback) => threadBinding.outerSubscribe(callback),
|
3591
3560
|
subscribe: (callback) => threadBinding.subscribe(callback)
|
3592
3561
|
};
|
3593
3562
|
}
|
@@ -3700,6 +3669,20 @@ var ThreadRuntimeImpl = class {
|
|
3700
3669
|
this._threadBinding
|
3701
3670
|
);
|
3702
3671
|
}
|
3672
|
+
_eventListenerNestedSubscriptions = /* @__PURE__ */ new Map();
|
3673
|
+
unstable_on(event, callback) {
|
3674
|
+
let subject = this._eventListenerNestedSubscriptions.get(event);
|
3675
|
+
if (!subject) {
|
3676
|
+
subject = new NestedSubscriptionSubject({
|
3677
|
+
getState: () => ({
|
3678
|
+
subscribe: (callback2) => this._threadBinding.getState().unstable_on(event, callback2)
|
3679
|
+
}),
|
3680
|
+
subscribe: (callback2) => this._threadBinding.outerSubscribe(callback2)
|
3681
|
+
});
|
3682
|
+
this._eventListenerNestedSubscriptions.set(event, subject);
|
3683
|
+
}
|
3684
|
+
return subject.subscribe(callback);
|
3685
|
+
}
|
3703
3686
|
};
|
3704
3687
|
|
3705
3688
|
// src/api/AssistantRuntime.ts
|
@@ -4163,18 +4146,23 @@ var BaseThreadRuntimeCore = class {
|
|
4163
4146
|
this.repository.getMessage(messageId)
|
4164
4147
|
)
|
4165
4148
|
);
|
4166
|
-
this.
|
4149
|
+
this._notifySubscribers();
|
4167
4150
|
}
|
4168
4151
|
getBranches(messageId) {
|
4169
4152
|
return this.repository.getBranches(messageId);
|
4170
4153
|
}
|
4171
4154
|
switchToBranch(branchId) {
|
4172
4155
|
this.repository.switchToBranch(branchId);
|
4173
|
-
this.
|
4156
|
+
this._notifySubscribers();
|
4174
4157
|
}
|
4175
|
-
|
4158
|
+
_notifySubscribers() {
|
4176
4159
|
for (const callback of this._subscriptions) callback();
|
4177
4160
|
}
|
4161
|
+
_notifyEventSubscribers(event) {
|
4162
|
+
const subscribers = this._eventSubscribers.get(event);
|
4163
|
+
if (!subscribers) return;
|
4164
|
+
for (const callback of subscribers) callback();
|
4165
|
+
}
|
4178
4166
|
subscribe(callback) {
|
4179
4167
|
this._subscriptions.add(callback);
|
4180
4168
|
return () => this._subscriptions.delete(callback);
|
@@ -4189,7 +4177,7 @@ var BaseThreadRuntimeCore = class {
|
|
4189
4177
|
const { message } = this.repository.getMessage(messageId);
|
4190
4178
|
adapter.submit({ message, type });
|
4191
4179
|
this._submittedFeedback[messageId] = { type };
|
4192
|
-
this.
|
4180
|
+
this._notifySubscribers();
|
4193
4181
|
}
|
4194
4182
|
_stopSpeaking;
|
4195
4183
|
speech;
|
@@ -4206,10 +4194,10 @@ var BaseThreadRuntimeCore = class {
|
|
4206
4194
|
} else {
|
4207
4195
|
this.speech = { messageId, status: utterance.status };
|
4208
4196
|
}
|
4209
|
-
this.
|
4197
|
+
this._notifySubscribers();
|
4210
4198
|
});
|
4211
4199
|
this.speech = { messageId, status: utterance.status };
|
4212
|
-
this.
|
4200
|
+
this._notifySubscribers();
|
4213
4201
|
this._stopSpeaking = () => {
|
4214
4202
|
utterance.cancel();
|
4215
4203
|
unsub();
|
@@ -4220,14 +4208,27 @@ var BaseThreadRuntimeCore = class {
|
|
4220
4208
|
stopSpeaking() {
|
4221
4209
|
if (!this._stopSpeaking) throw new Error("No message is being spoken");
|
4222
4210
|
this._stopSpeaking();
|
4223
|
-
this.
|
4211
|
+
this._notifySubscribers();
|
4224
4212
|
}
|
4225
4213
|
export() {
|
4226
4214
|
return this.repository.export();
|
4227
4215
|
}
|
4228
4216
|
import(data) {
|
4229
4217
|
this.repository.import(data);
|
4230
|
-
this.
|
4218
|
+
this._notifySubscribers();
|
4219
|
+
}
|
4220
|
+
_eventSubscribers = /* @__PURE__ */ new Map();
|
4221
|
+
unstable_on(event, callback) {
|
4222
|
+
const subscribers = this._eventSubscribers.get(event);
|
4223
|
+
if (!subscribers) {
|
4224
|
+
this._eventSubscribers.set(event, /* @__PURE__ */ new Set([callback]));
|
4225
|
+
} else {
|
4226
|
+
subscribers.add(callback);
|
4227
|
+
}
|
4228
|
+
return () => {
|
4229
|
+
const subscribers2 = this._eventSubscribers.get(event);
|
4230
|
+
subscribers2.delete(callback);
|
4231
|
+
};
|
4231
4232
|
}
|
4232
4233
|
};
|
4233
4234
|
|
@@ -4289,7 +4290,7 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
4289
4290
|
this.capabilities.feedback = canFeedback;
|
4290
4291
|
hasUpdates = true;
|
4291
4292
|
}
|
4292
|
-
if (hasUpdates) this.
|
4293
|
+
if (hasUpdates) this._notifySubscribers();
|
4293
4294
|
}
|
4294
4295
|
async append(message) {
|
4295
4296
|
const newMessage = fromCoreMessage(message, {
|
@@ -4300,7 +4301,7 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
4300
4301
|
await this.startRun(newMessage.id);
|
4301
4302
|
} else {
|
4302
4303
|
this.repository.resetHead(newMessage.id);
|
4303
|
-
this.
|
4304
|
+
this._notifySubscribers();
|
4304
4305
|
}
|
4305
4306
|
}
|
4306
4307
|
async startRun(parentId) {
|
@@ -4313,6 +4314,7 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
4313
4314
|
content: [],
|
4314
4315
|
createdAt: /* @__PURE__ */ new Date()
|
4315
4316
|
};
|
4317
|
+
this._notifyEventSubscribers("run-start");
|
4316
4318
|
do {
|
4317
4319
|
message = await this.performRoundtrip(parentId, message);
|
4318
4320
|
} while (shouldContinue(message));
|
@@ -4344,7 +4346,7 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
4344
4346
|
} : void 0
|
4345
4347
|
};
|
4346
4348
|
this.repository.addOrUpdateMessage(parentId, message);
|
4347
|
-
this.
|
4349
|
+
this._notifySubscribers();
|
4348
4350
|
};
|
4349
4351
|
const maxSteps = this.options.maxSteps ? this.options.maxSteps : (this.options.maxToolRoundtrips ?? 1) + 1;
|
4350
4352
|
const steps = message.metadata?.steps?.length ?? 0;
|
@@ -4455,6 +4457,7 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
4455
4457
|
this.thread.adapter,
|
4456
4458
|
options
|
4457
4459
|
);
|
4460
|
+
this.thread._notifyEventSubscribers("switched-to");
|
4458
4461
|
}
|
4459
4462
|
switchToThread(threadId) {
|
4460
4463
|
if (threadId !== null) {
|
@@ -4503,7 +4506,7 @@ var useLocalRuntime = (adapter, options = {}) => {
|
|
4503
4506
|
};
|
4504
4507
|
|
4505
4508
|
// src/runtimes/external-store/useExternalStoreRuntime.tsx
|
4506
|
-
import { useEffect as
|
4509
|
+
import { useEffect as useEffect15, useMemo as useMemo12, useState as useState12 } from "react";
|
4507
4510
|
|
4508
4511
|
// src/runtimes/external-store/getExternalStoreMessage.tsx
|
4509
4512
|
var symbolInnerMessage = Symbol("innerMessage");
|
@@ -4676,7 +4679,7 @@ var ExternalStoreThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
4676
4679
|
if (oldStore.convertMessage !== store.convertMessage) {
|
4677
4680
|
this._converter = new ThreadMessageConverter();
|
4678
4681
|
} else if (oldStore.isRunning === store.isRunning && oldStore.messages === store.messages) {
|
4679
|
-
this.
|
4682
|
+
this._notifySubscribers();
|
4680
4683
|
return;
|
4681
4684
|
}
|
4682
4685
|
}
|
@@ -4716,7 +4719,7 @@ var ExternalStoreThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
4716
4719
|
this.assistantOptimisticId ?? messages2.at(-1)?.id ?? null
|
4717
4720
|
);
|
4718
4721
|
this._messages = this.repository.getMessages();
|
4719
|
-
this.
|
4722
|
+
this._notifySubscribers();
|
4720
4723
|
}
|
4721
4724
|
switchToBranch(branchId) {
|
4722
4725
|
if (!this._store.setMessages)
|
@@ -4755,7 +4758,7 @@ var ExternalStoreThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
4755
4758
|
}
|
4756
4759
|
messages2 = this.repository.getMessages();
|
4757
4760
|
} else {
|
4758
|
-
this.
|
4761
|
+
this._notifySubscribers();
|
4759
4762
|
}
|
4760
4763
|
setTimeout(() => {
|
4761
4764
|
this.updateMessages(messages2);
|
@@ -4798,6 +4801,7 @@ var ExternalStoreRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
4798
4801
|
}
|
4799
4802
|
);
|
4800
4803
|
await this.thread.store.onSwitchToNewThread();
|
4804
|
+
this.thread._notifyEventSubscribers("switched-to");
|
4801
4805
|
}
|
4802
4806
|
async switchToThread(threadId) {
|
4803
4807
|
if (threadId !== null) {
|
@@ -4811,7 +4815,8 @@ var ExternalStoreRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
4811
4815
|
// ignore messages until rerender
|
4812
4816
|
}
|
4813
4817
|
);
|
4814
|
-
this.thread.store.onSwitchToThread(threadId);
|
4818
|
+
await this.thread.store.onSwitchToThread(threadId);
|
4819
|
+
this.thread._notifyEventSubscribers("switched-to");
|
4815
4820
|
} else {
|
4816
4821
|
this.switchToNewThread();
|
4817
4822
|
}
|
@@ -4821,7 +4826,7 @@ var ExternalStoreRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
4821
4826
|
// src/runtimes/external-store/useExternalStoreRuntime.tsx
|
4822
4827
|
var useExternalStoreRuntime = (store) => {
|
4823
4828
|
const [runtime] = useState12(() => new ExternalStoreRuntimeCore(store));
|
4824
|
-
|
4829
|
+
useEffect15(() => {
|
4825
4830
|
runtime.thread.store = store;
|
4826
4831
|
});
|
4827
4832
|
return useMemo12(
|
@@ -5562,15 +5567,15 @@ var assistant_message_default = Object.assign(
|
|
5562
5567
|
);
|
5563
5568
|
|
5564
5569
|
// src/ui/assistant-modal.tsx
|
5565
|
-
import { forwardRef as
|
5570
|
+
import { forwardRef as forwardRef35 } from "react";
|
5566
5571
|
import { BotIcon, ChevronDownIcon } from "lucide-react";
|
5567
5572
|
|
5568
5573
|
// src/ui/thread.tsx
|
5569
|
-
import { forwardRef as
|
5574
|
+
import { forwardRef as forwardRef34 } from "react";
|
5570
5575
|
import { ArrowDownIcon } from "lucide-react";
|
5571
5576
|
|
5572
5577
|
// src/ui/composer.tsx
|
5573
|
-
import { forwardRef as
|
5578
|
+
import { forwardRef as forwardRef29 } from "react";
|
5574
5579
|
import { PaperclipIcon, SendHorizontalIcon } from "lucide-react";
|
5575
5580
|
|
5576
5581
|
// src/ui/base/CircleStopIcon.tsx
|
@@ -5590,15 +5595,117 @@ var CircleStopIcon = () => {
|
|
5590
5595
|
};
|
5591
5596
|
CircleStopIcon.displayName = "CircleStopIcon";
|
5592
5597
|
|
5593
|
-
// src/ui/
|
5594
|
-
import {
|
5595
|
-
|
5598
|
+
// src/ui/attachment.tsx
|
5599
|
+
import {
|
5600
|
+
forwardRef as forwardRef28,
|
5601
|
+
useEffect as useEffect16,
|
5602
|
+
useState as useState14
|
5603
|
+
} from "react";
|
5604
|
+
import { CircleXIcon, FileIcon } from "lucide-react";
|
5605
|
+
|
5606
|
+
// src/ui/base/dialog.tsx
|
5607
|
+
import * as React from "react";
|
5608
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
5609
|
+
import classNames3 from "classnames";
|
5596
5610
|
import { jsx as jsx45, jsxs as jsxs8 } from "react/jsx-runtime";
|
5597
|
-
var
|
5611
|
+
var Dialog = DialogPrimitive.Root;
|
5612
|
+
var DialogTrigger = DialogPrimitive.Trigger;
|
5613
|
+
var DialogPortal = DialogPrimitive.Portal;
|
5614
|
+
var DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx45(
|
5615
|
+
DialogPrimitive.Overlay,
|
5616
|
+
{
|
5617
|
+
ref,
|
5618
|
+
className: classNames3("aui-dialog-overlay", className),
|
5619
|
+
...props
|
5620
|
+
}
|
5621
|
+
));
|
5622
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
5623
|
+
var DialogContent = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs8(DialogPortal, { children: [
|
5624
|
+
/* @__PURE__ */ jsx45(DialogOverlay, {}),
|
5625
|
+
/* @__PURE__ */ jsx45(
|
5626
|
+
DialogPrimitive.Content,
|
5627
|
+
{
|
5628
|
+
ref,
|
5629
|
+
className: classNames3("aui-dialog-content", className),
|
5630
|
+
...props,
|
5631
|
+
children
|
5632
|
+
}
|
5633
|
+
)
|
5634
|
+
] }));
|
5635
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
5636
|
+
|
5637
|
+
// src/ui/attachment.tsx
|
5638
|
+
import { AvatarFallback as AvatarFallback2 } from "@radix-ui/react-avatar";
|
5639
|
+
import { jsx as jsx46, jsxs as jsxs9 } from "react/jsx-runtime";
|
5640
|
+
var AttachmentRoot = withDefaults(attachment_exports.Root, {
|
5598
5641
|
className: "aui-attachment-root"
|
5599
5642
|
});
|
5600
|
-
|
5601
|
-
var
|
5643
|
+
AttachmentRoot.displayName = "AttachmentRoot";
|
5644
|
+
var useFileSrc = (file) => {
|
5645
|
+
const [src, setSrc] = useState14(void 0);
|
5646
|
+
useEffect16(() => {
|
5647
|
+
if (!file) {
|
5648
|
+
setSrc(void 0);
|
5649
|
+
return;
|
5650
|
+
}
|
5651
|
+
const objectUrl = URL.createObjectURL(file);
|
5652
|
+
setSrc(objectUrl);
|
5653
|
+
return () => {
|
5654
|
+
URL.revokeObjectURL(objectUrl);
|
5655
|
+
};
|
5656
|
+
}, [file]);
|
5657
|
+
return src;
|
5658
|
+
};
|
5659
|
+
var useAttachmentSrc = () => {
|
5660
|
+
const { file, src } = useAttachment((a) => {
|
5661
|
+
if (a.type !== "image") return {};
|
5662
|
+
if (a.file) return { file: a.file };
|
5663
|
+
const src2 = a.content?.filter((c) => c.type === "image")[0]?.image;
|
5664
|
+
if (!src2) return {};
|
5665
|
+
return { src: src2 };
|
5666
|
+
});
|
5667
|
+
return useFileSrc(file) ?? src;
|
5668
|
+
};
|
5669
|
+
var AttachmentPreview = ({ src }) => {
|
5670
|
+
const [isLoaded, setIsLoaded] = useState14(false);
|
5671
|
+
return (
|
5672
|
+
// eslint-disable-next-line @next/next/no-img-element
|
5673
|
+
/* @__PURE__ */ jsx46(
|
5674
|
+
"img",
|
5675
|
+
{
|
5676
|
+
src,
|
5677
|
+
style: {
|
5678
|
+
width: "auto",
|
5679
|
+
height: "auto",
|
5680
|
+
maxWidth: "75dvh",
|
5681
|
+
maxHeight: "75dvh",
|
5682
|
+
display: isLoaded ? "block" : "none",
|
5683
|
+
overflow: "clip"
|
5684
|
+
},
|
5685
|
+
onLoad: () => setIsLoaded(true),
|
5686
|
+
alt: "Image Preview"
|
5687
|
+
}
|
5688
|
+
)
|
5689
|
+
);
|
5690
|
+
};
|
5691
|
+
var AttachmentPreviewDialog = ({ children }) => {
|
5692
|
+
const src = useAttachmentSrc();
|
5693
|
+
if (!src) return children;
|
5694
|
+
return /* @__PURE__ */ jsxs9(Dialog, { children: [
|
5695
|
+
/* @__PURE__ */ jsx46(DialogTrigger, { className: "aui-attachment-preview-trigger", asChild: true, children }),
|
5696
|
+
/* @__PURE__ */ jsx46(DialogContent, { children: /* @__PURE__ */ jsx46(AttachmentPreview, { src }) })
|
5697
|
+
] });
|
5698
|
+
};
|
5699
|
+
var AttachmentThumb = () => {
|
5700
|
+
const isImage = useAttachment((a) => a.type === "image");
|
5701
|
+
const src = useAttachmentSrc();
|
5702
|
+
return /* @__PURE__ */ jsxs9(AvatarRoot, { className: "aui-attachment-thumb", children: [
|
5703
|
+
/* @__PURE__ */ jsx46(AvatarFallback2, { delayMs: isImage ? 200 : 0, children: /* @__PURE__ */ jsx46(FileIcon, {}) }),
|
5704
|
+
/* @__PURE__ */ jsx46(AvatarImage, { src })
|
5705
|
+
] });
|
5706
|
+
};
|
5707
|
+
var Attachment = () => {
|
5708
|
+
const canRemove = useAttachment((a) => a.source !== "message");
|
5602
5709
|
const typeLabel = useAttachment((a) => {
|
5603
5710
|
const type = a.type;
|
5604
5711
|
switch (type) {
|
@@ -5613,46 +5720,46 @@ var ComposerAttachment2 = () => {
|
|
5613
5720
|
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
5614
5721
|
}
|
5615
5722
|
});
|
5616
|
-
return /* @__PURE__ */
|
5617
|
-
/* @__PURE__ */
|
5618
|
-
|
5619
|
-
/* @__PURE__ */
|
5620
|
-
|
5621
|
-
|
5622
|
-
|
5723
|
+
return /* @__PURE__ */ jsxs9(Tooltip, { children: [
|
5724
|
+
/* @__PURE__ */ jsx46(AttachmentPreviewDialog, { children: /* @__PURE__ */ jsx46(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs9(AttachmentRoot, { children: [
|
5725
|
+
/* @__PURE__ */ jsx46(AttachmentThumb, {}),
|
5726
|
+
/* @__PURE__ */ jsxs9("div", { className: "aui-attachment-text", children: [
|
5727
|
+
/* @__PURE__ */ jsx46("p", { className: "aui-attachment-name", children: /* @__PURE__ */ jsx46(attachment_exports.Name, {}) }),
|
5728
|
+
/* @__PURE__ */ jsx46("p", { className: "aui-attachment-type", children: typeLabel })
|
5729
|
+
] }),
|
5730
|
+
canRemove && /* @__PURE__ */ jsx46(AttachmentRemove, {})
|
5731
|
+
] }) }) }),
|
5732
|
+
/* @__PURE__ */ jsx46(TooltipContent, { side: "top", children: /* @__PURE__ */ jsx46(attachment_exports.Name, {}) })
|
5623
5733
|
] });
|
5624
5734
|
};
|
5625
|
-
|
5626
|
-
var
|
5735
|
+
Attachment.displayName = "Attachment";
|
5736
|
+
var AttachmentRemove = forwardRef28((props, ref) => {
|
5627
5737
|
const {
|
5628
5738
|
strings: {
|
5629
5739
|
composer: { removeAttachment: { tooltip = "Remove file" } = {} } = {}
|
5630
5740
|
} = {}
|
5631
5741
|
} = useThreadConfig();
|
5632
|
-
return /* @__PURE__ */
|
5742
|
+
return /* @__PURE__ */ jsx46(attachment_exports.Remove, { asChild: true, children: /* @__PURE__ */ jsx46(
|
5633
5743
|
TooltipIconButton,
|
5634
5744
|
{
|
5635
5745
|
tooltip,
|
5636
|
-
className: "aui-
|
5746
|
+
className: "aui-attachment-remove",
|
5637
5747
|
side: "top",
|
5638
5748
|
...props,
|
5639
5749
|
ref,
|
5640
|
-
children: props.children ?? /* @__PURE__ */
|
5750
|
+
children: props.children ?? /* @__PURE__ */ jsx46(CircleXIcon, {})
|
5641
5751
|
}
|
5642
5752
|
) });
|
5643
5753
|
});
|
5644
|
-
|
5754
|
+
AttachmentRemove.displayName = "AttachmentRemove";
|
5645
5755
|
var exports5 = {
|
5646
|
-
Root:
|
5647
|
-
Remove:
|
5756
|
+
Root: AttachmentRoot,
|
5757
|
+
Remove: AttachmentRemove
|
5648
5758
|
};
|
5649
|
-
var
|
5650
|
-
ComposerAttachment2,
|
5651
|
-
exports5
|
5652
|
-
);
|
5759
|
+
var attachment_default = Object.assign(Attachment, exports5);
|
5653
5760
|
|
5654
5761
|
// src/ui/composer.tsx
|
5655
|
-
import { Fragment as Fragment6, jsx as
|
5762
|
+
import { Fragment as Fragment6, jsx as jsx47, jsxs as jsxs10 } from "react/jsx-runtime";
|
5656
5763
|
var useAllowAttachments = (ensureCapability = false) => {
|
5657
5764
|
const { composer: { allowAttachments = true } = {} } = useThreadConfig();
|
5658
5765
|
const attachmentsSupported = useThread((t) => t.capabilities.attachments);
|
@@ -5660,11 +5767,11 @@ var useAllowAttachments = (ensureCapability = false) => {
|
|
5660
5767
|
};
|
5661
5768
|
var Composer = () => {
|
5662
5769
|
const allowAttachments = useAllowAttachments(true);
|
5663
|
-
return /* @__PURE__ */
|
5664
|
-
allowAttachments && /* @__PURE__ */
|
5665
|
-
allowAttachments && /* @__PURE__ */
|
5666
|
-
/* @__PURE__ */
|
5667
|
-
/* @__PURE__ */
|
5770
|
+
return /* @__PURE__ */ jsxs10(ComposerRoot, { children: [
|
5771
|
+
allowAttachments && /* @__PURE__ */ jsx47(ComposerAttachments, {}),
|
5772
|
+
allowAttachments && /* @__PURE__ */ jsx47(ComposerAddAttachment, {}),
|
5773
|
+
/* @__PURE__ */ jsx47(ComposerInput, { autoFocus: true }),
|
5774
|
+
/* @__PURE__ */ jsx47(ComposerAction, {})
|
5668
5775
|
] });
|
5669
5776
|
};
|
5670
5777
|
Composer.displayName = "Composer";
|
@@ -5677,14 +5784,14 @@ var ComposerInputStyled = withDefaults(composer_exports.Input, {
|
|
5677
5784
|
autoFocus: true,
|
5678
5785
|
className: "aui-composer-input"
|
5679
5786
|
});
|
5680
|
-
var ComposerInput =
|
5787
|
+
var ComposerInput = forwardRef29(
|
5681
5788
|
(props, ref) => {
|
5682
5789
|
const {
|
5683
5790
|
strings: {
|
5684
5791
|
composer: { input: { placeholder = "Write a message..." } = {} } = {}
|
5685
5792
|
} = {}
|
5686
5793
|
} = useThreadConfig();
|
5687
|
-
return /* @__PURE__ */
|
5794
|
+
return /* @__PURE__ */ jsx47(ComposerInputStyled, { placeholder, ...props, ref });
|
5688
5795
|
}
|
5689
5796
|
);
|
5690
5797
|
ComposerInput.displayName = "ComposerInput";
|
@@ -5692,12 +5799,12 @@ var ComposerAttachmentsContainer = withDefaults("div", {
|
|
5692
5799
|
className: "aui-composer-attachments"
|
5693
5800
|
});
|
5694
5801
|
var ComposerAttachments = ({ components }) => {
|
5695
|
-
return /* @__PURE__ */
|
5802
|
+
return /* @__PURE__ */ jsx47(ComposerAttachmentsContainer, { children: /* @__PURE__ */ jsx47(
|
5696
5803
|
composer_exports.Attachments,
|
5697
5804
|
{
|
5698
5805
|
components: {
|
5699
5806
|
...components,
|
5700
|
-
Attachment: components?.Attachment ??
|
5807
|
+
Attachment: components?.Attachment ?? attachment_default
|
5701
5808
|
}
|
5702
5809
|
}
|
5703
5810
|
) });
|
@@ -5706,21 +5813,21 @@ var ComposerAttachButton = withDefaults(TooltipIconButton, {
|
|
5706
5813
|
variant: "default",
|
5707
5814
|
className: "aui-composer-attach"
|
5708
5815
|
});
|
5709
|
-
var ComposerAddAttachment =
|
5816
|
+
var ComposerAddAttachment = forwardRef29((props, ref) => {
|
5710
5817
|
const {
|
5711
5818
|
strings: {
|
5712
5819
|
composer: { addAttachment: { tooltip = "Attach file" } = {} } = {}
|
5713
5820
|
} = {}
|
5714
5821
|
} = useThreadConfig();
|
5715
5822
|
const allowAttachments = useAllowAttachments();
|
5716
|
-
return /* @__PURE__ */
|
5823
|
+
return /* @__PURE__ */ jsx47(composer_exports.AddAttachment, { disabled: !allowAttachments, asChild: true, children: /* @__PURE__ */ jsx47(
|
5717
5824
|
ComposerAttachButton,
|
5718
5825
|
{
|
5719
5826
|
tooltip,
|
5720
5827
|
variant: "ghost",
|
5721
5828
|
...props,
|
5722
5829
|
ref,
|
5723
|
-
children: props.children ?? /* @__PURE__ */
|
5830
|
+
children: props.children ?? /* @__PURE__ */ jsx47(PaperclipIcon, {})
|
5724
5831
|
}
|
5725
5832
|
) });
|
5726
5833
|
});
|
@@ -5731,10 +5838,10 @@ var useAllowCancel = () => {
|
|
5731
5838
|
};
|
5732
5839
|
var ComposerAction = () => {
|
5733
5840
|
const allowCancel = useAllowCancel();
|
5734
|
-
if (!allowCancel) return /* @__PURE__ */
|
5735
|
-
return /* @__PURE__ */
|
5736
|
-
/* @__PURE__ */
|
5737
|
-
/* @__PURE__ */
|
5841
|
+
if (!allowCancel) return /* @__PURE__ */ jsx47(ComposerSend, {});
|
5842
|
+
return /* @__PURE__ */ jsxs10(Fragment6, { children: [
|
5843
|
+
/* @__PURE__ */ jsx47(thread_exports.If, { running: false, children: /* @__PURE__ */ jsx47(ComposerSend, {}) }),
|
5844
|
+
/* @__PURE__ */ jsx47(thread_exports.If, { running: true, children: /* @__PURE__ */ jsx47(ComposerCancel, {}) })
|
5738
5845
|
] });
|
5739
5846
|
};
|
5740
5847
|
ComposerAction.displayName = "ComposerAction";
|
@@ -5742,12 +5849,12 @@ var ComposerSendButton = withDefaults(TooltipIconButton, {
|
|
5742
5849
|
variant: "default",
|
5743
5850
|
className: "aui-composer-send"
|
5744
5851
|
});
|
5745
|
-
var ComposerSend =
|
5852
|
+
var ComposerSend = forwardRef29(
|
5746
5853
|
(props, ref) => {
|
5747
5854
|
const {
|
5748
5855
|
strings: { composer: { send: { tooltip = "Send" } = {} } = {} } = {}
|
5749
5856
|
} = useThreadConfig();
|
5750
|
-
return /* @__PURE__ */
|
5857
|
+
return /* @__PURE__ */ jsx47(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx47(ComposerSendButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx47(SendHorizontalIcon, {}) }) });
|
5751
5858
|
}
|
5752
5859
|
);
|
5753
5860
|
ComposerSend.displayName = "ComposerSend";
|
@@ -5755,12 +5862,12 @@ var ComposerCancelButton = withDefaults(TooltipIconButton, {
|
|
5755
5862
|
variant: "default",
|
5756
5863
|
className: "aui-composer-cancel"
|
5757
5864
|
});
|
5758
|
-
var ComposerCancel =
|
5865
|
+
var ComposerCancel = forwardRef29(
|
5759
5866
|
(props, ref) => {
|
5760
5867
|
const {
|
5761
5868
|
strings: { composer: { cancel: { tooltip = "Cancel" } = {} } = {} } = {}
|
5762
5869
|
} = useThreadConfig();
|
5763
|
-
return /* @__PURE__ */
|
5870
|
+
return /* @__PURE__ */ jsx47(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx47(ComposerCancelButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx47(CircleStopIcon, {}) }) });
|
5764
5871
|
}
|
5765
5872
|
);
|
5766
5873
|
ComposerCancel.displayName = "ComposerCancel";
|
@@ -5776,15 +5883,15 @@ var exports6 = {
|
|
5776
5883
|
var composer_default = Object.assign(Composer, exports6);
|
5777
5884
|
|
5778
5885
|
// src/ui/thread-welcome.tsx
|
5779
|
-
import { forwardRef as
|
5780
|
-
import { jsx as
|
5886
|
+
import { forwardRef as forwardRef30 } from "react";
|
5887
|
+
import { jsx as jsx48, jsxs as jsxs11 } from "react/jsx-runtime";
|
5781
5888
|
var ThreadWelcome = () => {
|
5782
|
-
return /* @__PURE__ */
|
5783
|
-
/* @__PURE__ */
|
5784
|
-
/* @__PURE__ */
|
5785
|
-
/* @__PURE__ */
|
5889
|
+
return /* @__PURE__ */ jsxs11(ThreadWelcomeRoot, { children: [
|
5890
|
+
/* @__PURE__ */ jsxs11(ThreadWelcomeCenter, { children: [
|
5891
|
+
/* @__PURE__ */ jsx48(ThreadWelcomeAvatar, {}),
|
5892
|
+
/* @__PURE__ */ jsx48(ThreadWelcomeMessage, {})
|
5786
5893
|
] }),
|
5787
|
-
/* @__PURE__ */
|
5894
|
+
/* @__PURE__ */ jsx48(ThreadWelcomeSuggestions, {})
|
5788
5895
|
] });
|
5789
5896
|
};
|
5790
5897
|
ThreadWelcome.displayName = "ThreadWelcome";
|
@@ -5794,20 +5901,20 @@ var ThreadWelcomeRootStyled = withDefaults("div", {
|
|
5794
5901
|
var ThreadWelcomeCenter = withDefaults("div", {
|
5795
5902
|
className: "aui-thread-welcome-center"
|
5796
5903
|
});
|
5797
|
-
var ThreadWelcomeRoot =
|
5798
|
-
return /* @__PURE__ */
|
5904
|
+
var ThreadWelcomeRoot = forwardRef30((props, ref) => {
|
5905
|
+
return /* @__PURE__ */ jsx48(thread_exports.Empty, { children: /* @__PURE__ */ jsx48(ThreadWelcomeRootStyled, { ...props, ref }) });
|
5799
5906
|
});
|
5800
5907
|
ThreadWelcomeRoot.displayName = "ThreadWelcomeRoot";
|
5801
5908
|
var ThreadWelcomeAvatar = () => {
|
5802
5909
|
const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
|
5803
|
-
return /* @__PURE__ */
|
5910
|
+
return /* @__PURE__ */ jsx48(Avatar, { ...avatar });
|
5804
5911
|
};
|
5805
5912
|
var ThreadWelcomeMessageStyled = withDefaults("p", {
|
5806
5913
|
className: "aui-thread-welcome-message"
|
5807
5914
|
});
|
5808
|
-
var ThreadWelcomeMessage =
|
5915
|
+
var ThreadWelcomeMessage = forwardRef30(({ message: messageProp, ...rest }, ref) => {
|
5809
5916
|
const { welcome: { message = "How can I help you today?" } = {} } = useThreadConfig();
|
5810
|
-
return /* @__PURE__ */
|
5917
|
+
return /* @__PURE__ */ jsx48(ThreadWelcomeMessageStyled, { ...rest, ref, children: messageProp ?? message });
|
5811
5918
|
});
|
5812
5919
|
ThreadWelcomeMessage.displayName = "ThreadWelcomeMessage";
|
5813
5920
|
var ThreadWelcomeSuggestionContainer = withDefaults("div", {
|
@@ -5819,15 +5926,15 @@ var ThreadWelcomeSuggestionStyled = withDefaults(thread_exports.Suggestion, {
|
|
5819
5926
|
var ThreadWelcomeSuggestion = ({
|
5820
5927
|
suggestion: { text, prompt }
|
5821
5928
|
}) => {
|
5822
|
-
return /* @__PURE__ */
|
5929
|
+
return /* @__PURE__ */ jsx48(ThreadWelcomeSuggestionStyled, { prompt, method: "replace", autoSend: true, children: /* @__PURE__ */ jsx48("span", { className: "aui-thread-welcome-suggestion-text", children: text ?? prompt }) });
|
5823
5930
|
};
|
5824
5931
|
var ThreadWelcomeSuggestions = () => {
|
5825
5932
|
const suggestions2 = useThread((t) => t.suggestions);
|
5826
5933
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
5827
5934
|
const finalSuggestions = suggestions2.length ? suggestions2 : suggestions;
|
5828
|
-
return /* @__PURE__ */
|
5935
|
+
return /* @__PURE__ */ jsx48(ThreadWelcomeSuggestionContainer, { children: finalSuggestions?.map((suggestion, idx) => {
|
5829
5936
|
const key = `${suggestion.prompt}-${idx}`;
|
5830
|
-
return /* @__PURE__ */
|
5937
|
+
return /* @__PURE__ */ jsx48(ThreadWelcomeSuggestion, { suggestion }, key);
|
5831
5938
|
}) });
|
5832
5939
|
};
|
5833
5940
|
ThreadWelcomeSuggestions.displayName = "ThreadWelcomeSuggestions";
|
@@ -5842,12 +5949,12 @@ var exports7 = {
|
|
5842
5949
|
var thread_welcome_default = Object.assign(ThreadWelcome, exports7);
|
5843
5950
|
|
5844
5951
|
// src/ui/user-message.tsx
|
5845
|
-
import { forwardRef as
|
5952
|
+
import { forwardRef as forwardRef32 } from "react";
|
5846
5953
|
|
5847
5954
|
// src/ui/user-action-bar.tsx
|
5848
|
-
import { forwardRef as
|
5955
|
+
import { forwardRef as forwardRef31 } from "react";
|
5849
5956
|
import { PencilIcon } from "lucide-react";
|
5850
|
-
import { jsx as
|
5957
|
+
import { jsx as jsx49 } from "react/jsx-runtime";
|
5851
5958
|
var useAllowEdit = (ensureCapability = false) => {
|
5852
5959
|
const { userMessage: { allowEdit = true } = {} } = useThreadConfig();
|
5853
5960
|
const editSupported = useThread((t) => t.capabilities.edit);
|
@@ -5856,19 +5963,19 @@ var useAllowEdit = (ensureCapability = false) => {
|
|
5856
5963
|
var UserActionBar = () => {
|
5857
5964
|
const allowEdit = useAllowEdit(true);
|
5858
5965
|
if (!allowEdit) return null;
|
5859
|
-
return /* @__PURE__ */
|
5966
|
+
return /* @__PURE__ */ jsx49(UserActionBarRoot, { hideWhenRunning: true, autohide: "not-last", children: /* @__PURE__ */ jsx49(UserActionBarEdit, {}) });
|
5860
5967
|
};
|
5861
5968
|
UserActionBar.displayName = "UserActionBar";
|
5862
5969
|
var UserActionBarRoot = withDefaults(actionBar_exports.Root, {
|
5863
5970
|
className: "aui-user-action-bar-root"
|
5864
5971
|
});
|
5865
5972
|
UserActionBarRoot.displayName = "UserActionBarRoot";
|
5866
|
-
var UserActionBarEdit =
|
5973
|
+
var UserActionBarEdit = forwardRef31((props, ref) => {
|
5867
5974
|
const {
|
5868
5975
|
strings: { userMessage: { edit: { tooltip = "Edit" } = {} } = {} } = {}
|
5869
5976
|
} = useThreadConfig();
|
5870
5977
|
const allowEdit = useAllowEdit();
|
5871
|
-
return /* @__PURE__ */
|
5978
|
+
return /* @__PURE__ */ jsx49(actionBar_exports.Edit, { disabled: !allowEdit, asChild: true, children: /* @__PURE__ */ jsx49(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx49(PencilIcon, {}) }) });
|
5872
5979
|
});
|
5873
5980
|
UserActionBarEdit.displayName = "UserActionBarEdit";
|
5874
5981
|
var exports8 = {
|
@@ -5877,44 +5984,6 @@ var exports8 = {
|
|
5877
5984
|
};
|
5878
5985
|
var user_action_bar_default = Object.assign(UserActionBar, exports8);
|
5879
5986
|
|
5880
|
-
// src/ui/user-message-attachment.tsx
|
5881
|
-
import { jsx as jsx49, jsxs as jsxs11 } from "react/jsx-runtime";
|
5882
|
-
var UserMessageAttachmentRoot = withDefaults(attachment_exports.Root, {
|
5883
|
-
className: "aui-attachment-root"
|
5884
|
-
});
|
5885
|
-
UserMessageAttachmentRoot.displayName = "UserMessageAttachmentRoot";
|
5886
|
-
var UserMessageAttachment = () => {
|
5887
|
-
const typeLabel = useAttachment((a) => {
|
5888
|
-
const type = a.type;
|
5889
|
-
switch (type) {
|
5890
|
-
case "image":
|
5891
|
-
return "Image";
|
5892
|
-
case "document":
|
5893
|
-
return "Document";
|
5894
|
-
case "file":
|
5895
|
-
return "File";
|
5896
|
-
default:
|
5897
|
-
const _exhaustiveCheck = type;
|
5898
|
-
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
5899
|
-
}
|
5900
|
-
});
|
5901
|
-
return /* @__PURE__ */ jsxs11(UserMessageAttachmentRoot, { children: [
|
5902
|
-
/* @__PURE__ */ jsx49(attachment_exports.unstable_Thumb, { className: "aui-attachment-thumb" }),
|
5903
|
-
/* @__PURE__ */ jsxs11("div", { className: "aui-attachment-text", children: [
|
5904
|
-
/* @__PURE__ */ jsx49("p", { className: "aui-attachment-name", children: /* @__PURE__ */ jsx49(attachment_exports.Name, {}) }),
|
5905
|
-
/* @__PURE__ */ jsx49("p", { className: "aui-attachment-type", children: typeLabel })
|
5906
|
-
] })
|
5907
|
-
] });
|
5908
|
-
};
|
5909
|
-
UserMessageAttachment.displayName = "UserMessageAttachment";
|
5910
|
-
var exports9 = {
|
5911
|
-
Root: UserMessageAttachmentRoot
|
5912
|
-
};
|
5913
|
-
var user_message_attachment_default = Object.assign(
|
5914
|
-
UserMessageAttachment,
|
5915
|
-
exports9
|
5916
|
-
);
|
5917
|
-
|
5918
5987
|
// src/ui/user-message.tsx
|
5919
5988
|
import { jsx as jsx50, jsxs as jsxs12 } from "react/jsx-runtime";
|
5920
5989
|
var UserMessage = () => {
|
@@ -5935,7 +6004,7 @@ UserMessageRoot.displayName = "UserMessageRoot";
|
|
5935
6004
|
var UserMessageContentWrapper = withDefaults("div", {
|
5936
6005
|
className: "aui-user-message-content"
|
5937
6006
|
});
|
5938
|
-
var UserMessageContent =
|
6007
|
+
var UserMessageContent = forwardRef32(({ components, ...props }, ref) => {
|
5939
6008
|
return /* @__PURE__ */ jsx50(UserMessageContentWrapper, { ...props, ref, children: /* @__PURE__ */ jsx50(
|
5940
6009
|
message_exports.Content,
|
5941
6010
|
{
|
@@ -5958,20 +6027,20 @@ var UserMessageAttachments = ({
|
|
5958
6027
|
{
|
5959
6028
|
components: {
|
5960
6029
|
...components,
|
5961
|
-
Attachment: components?.Attachment ??
|
6030
|
+
Attachment: components?.Attachment ?? attachment_default
|
5962
6031
|
}
|
5963
6032
|
}
|
5964
6033
|
) }) });
|
5965
6034
|
};
|
5966
|
-
var
|
6035
|
+
var exports9 = {
|
5967
6036
|
Root: UserMessageRoot,
|
5968
6037
|
Content: UserMessageContent,
|
5969
6038
|
Attachments: UserMessageAttachments
|
5970
6039
|
};
|
5971
|
-
var user_message_default = Object.assign(UserMessage,
|
6040
|
+
var user_message_default = Object.assign(UserMessage, exports9);
|
5972
6041
|
|
5973
6042
|
// src/ui/edit-composer.tsx
|
5974
|
-
import { forwardRef as
|
6043
|
+
import { forwardRef as forwardRef33 } from "react";
|
5975
6044
|
import { jsx as jsx51, jsxs as jsxs13 } from "react/jsx-runtime";
|
5976
6045
|
var EditComposer = () => {
|
5977
6046
|
return /* @__PURE__ */ jsxs13(EditComposerRoot, { children: [
|
@@ -5995,28 +6064,28 @@ var EditComposerFooter = withDefaults("div", {
|
|
5995
6064
|
className: "aui-edit-composer-footer"
|
5996
6065
|
});
|
5997
6066
|
EditComposerFooter.displayName = "EditComposerFooter";
|
5998
|
-
var EditComposerCancel =
|
6067
|
+
var EditComposerCancel = forwardRef33((props, ref) => {
|
5999
6068
|
const {
|
6000
6069
|
strings: { editComposer: { cancel: { label = "Cancel" } = {} } = {} } = {}
|
6001
6070
|
} = useThreadConfig();
|
6002
6071
|
return /* @__PURE__ */ jsx51(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx51(Button, { variant: "ghost", ...props, ref, children: props.children ?? label }) });
|
6003
6072
|
});
|
6004
6073
|
EditComposerCancel.displayName = "EditComposerCancel";
|
6005
|
-
var EditComposerSend =
|
6074
|
+
var EditComposerSend = forwardRef33((props, ref) => {
|
6006
6075
|
const {
|
6007
6076
|
strings: { editComposer: { send: { label = "Send" } = {} } = {} } = {}
|
6008
6077
|
} = useThreadConfig();
|
6009
6078
|
return /* @__PURE__ */ jsx51(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx51(Button, { ...props, ref, children: props.children ?? label }) });
|
6010
6079
|
});
|
6011
6080
|
EditComposerSend.displayName = "EditComposerSend";
|
6012
|
-
var
|
6081
|
+
var exports10 = {
|
6013
6082
|
Root: EditComposerRoot,
|
6014
6083
|
Input: EditComposerInput,
|
6015
6084
|
Footer: EditComposerFooter,
|
6016
6085
|
Cancel: EditComposerCancel,
|
6017
6086
|
Send: EditComposerSend
|
6018
6087
|
};
|
6019
|
-
var edit_composer_default = Object.assign(EditComposer,
|
6088
|
+
var edit_composer_default = Object.assign(EditComposer, exports10);
|
6020
6089
|
|
6021
6090
|
// src/ui/thread.tsx
|
6022
6091
|
import { Fragment as Fragment7, jsx as jsx52, jsxs as jsxs14 } from "react/jsx-runtime";
|
@@ -6040,7 +6109,7 @@ var Thread = (config) => {
|
|
6040
6109
|
var ThreadRootStyled = withDefaults(thread_exports.Root, {
|
6041
6110
|
className: "aui-root aui-thread-root"
|
6042
6111
|
});
|
6043
|
-
var ThreadRoot =
|
6112
|
+
var ThreadRoot = forwardRef34(
|
6044
6113
|
({ config, ...props }, ref) => {
|
6045
6114
|
return /* @__PURE__ */ jsx52(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx52(ThreadRootStyled, { ...props, ref }) });
|
6046
6115
|
}
|
@@ -6091,7 +6160,7 @@ var ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {
|
|
6091
6160
|
variant: "outline",
|
6092
6161
|
className: "aui-thread-scroll-to-bottom"
|
6093
6162
|
});
|
6094
|
-
var ThreadScrollToBottom =
|
6163
|
+
var ThreadScrollToBottom = forwardRef34((props, ref) => {
|
6095
6164
|
const {
|
6096
6165
|
strings: {
|
6097
6166
|
thread: { scrollToBottom: { tooltip = "Scroll to bottom" } = {} } = {}
|
@@ -6100,7 +6169,7 @@ var ThreadScrollToBottom = forwardRef33((props, ref) => {
|
|
6100
6169
|
return /* @__PURE__ */ jsx52(thread_exports.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ jsx52(ThreadScrollToBottomIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx52(ArrowDownIcon, {}) }) });
|
6101
6170
|
});
|
6102
6171
|
ThreadScrollToBottom.displayName = "ThreadScrollToBottom";
|
6103
|
-
var
|
6172
|
+
var exports11 = {
|
6104
6173
|
Root: ThreadRoot,
|
6105
6174
|
Viewport: ThreadViewport,
|
6106
6175
|
Messages: ThreadMessages,
|
@@ -6108,7 +6177,7 @@ var exports12 = {
|
|
6108
6177
|
ScrollToBottom: ThreadScrollToBottom,
|
6109
6178
|
ViewportFooter: ThreadViewportFooter
|
6110
6179
|
};
|
6111
|
-
var thread_default = Object.assign(Thread,
|
6180
|
+
var thread_default = Object.assign(Thread, exports11);
|
6112
6181
|
|
6113
6182
|
// src/ui/assistant-modal.tsx
|
6114
6183
|
import { Fragment as Fragment8, jsx as jsx53, jsxs as jsxs15 } from "react/jsx-runtime";
|
@@ -6126,7 +6195,7 @@ var AssistantModalRoot = ({
|
|
6126
6195
|
return /* @__PURE__ */ jsx53(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx53(assistantModal_exports.Root, { ...props }) });
|
6127
6196
|
};
|
6128
6197
|
AssistantModalRoot.displayName = "AssistantModalRoot";
|
6129
|
-
var AssistantModalTrigger =
|
6198
|
+
var AssistantModalTrigger = forwardRef35((props, ref) => {
|
6130
6199
|
return /* @__PURE__ */ jsx53(AssistantModalAnchor, { children: /* @__PURE__ */ jsx53(assistantModal_exports.Trigger, { asChild: true, children: /* @__PURE__ */ jsx53(AssistantModalButton, { ...props, ref }) }) });
|
6131
6200
|
});
|
6132
6201
|
AssistantModalTrigger.displayName = "AssistantModalTrigger";
|
@@ -6138,7 +6207,7 @@ var ModalButtonStyled = withDefaults(TooltipIconButton, {
|
|
6138
6207
|
variant: "default",
|
6139
6208
|
className: "aui-modal-button"
|
6140
6209
|
});
|
6141
|
-
var AssistantModalButton =
|
6210
|
+
var AssistantModalButton = forwardRef35(({ "data-state": state, ...rest }, ref) => {
|
6142
6211
|
const {
|
6143
6212
|
strings: {
|
6144
6213
|
assistantModal: {
|
@@ -6185,14 +6254,14 @@ var AssistantModalContent = withDefaults(assistantModal_exports.Content, {
|
|
6185
6254
|
sideOffset: 16
|
6186
6255
|
});
|
6187
6256
|
AssistantModalContent.displayName = "AssistantModalContent";
|
6188
|
-
var
|
6257
|
+
var exports12 = {
|
6189
6258
|
Root: AssistantModalRoot,
|
6190
6259
|
Trigger: AssistantModalTrigger,
|
6191
6260
|
Content: AssistantModalContent,
|
6192
6261
|
Button: AssistantModalButton,
|
6193
6262
|
Anchor: AssistantModalAnchor
|
6194
6263
|
};
|
6195
|
-
var assistant_modal_default = Object.assign(AssistantModal,
|
6264
|
+
var assistant_modal_default = Object.assign(AssistantModal, exports12);
|
6196
6265
|
export {
|
6197
6266
|
actionBar_exports as ActionBarPrimitive,
|
6198
6267
|
assistant_action_bar_default as AssistantActionBar,
|
@@ -6201,10 +6270,11 @@ export {
|
|
6201
6270
|
assistantModal_exports as AssistantModalPrimitive,
|
6202
6271
|
AssistantRuntimeProvider,
|
6203
6272
|
attachment_exports as AttachmentPrimitive,
|
6273
|
+
attachment_default as AttachmentUI,
|
6204
6274
|
branch_picker_default as BranchPicker,
|
6205
6275
|
branchPicker_exports as BranchPickerPrimitive,
|
6206
6276
|
composer_default as Composer,
|
6207
|
-
|
6277
|
+
attachment_default as ComposerAttachment,
|
6208
6278
|
composer_exports as ComposerPrimitive,
|
6209
6279
|
CompositeAttachmentAdapter,
|
6210
6280
|
content_part_default as ContentPart,
|
@@ -6222,7 +6292,7 @@ export {
|
|
6222
6292
|
thread_welcome_default as ThreadWelcome,
|
6223
6293
|
user_action_bar_default as UserActionBar,
|
6224
6294
|
user_message_default as UserMessage,
|
6225
|
-
|
6295
|
+
attachment_default as UserMessageAttachment,
|
6226
6296
|
WebSpeechSynthesisAdapter,
|
6227
6297
|
fromCoreMessage,
|
6228
6298
|
fromCoreMessages,
|