@assistant-ui/react 0.12.16 → 0.12.17
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/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.d.ts +2 -26
- package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.js +1 -13
- package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts +1 -3
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.js +1 -51
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js +7 -20
- package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.js +3 -8
- package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +4 -7
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +5 -7
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.js +3 -10
- package/dist/primitives/actionBar/ActionBarReload.js.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +5 -4
- package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
- package/dist/primitives/composer/ComposerCancel.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerCancel.js +3 -8
- package/dist/primitives/composer/ComposerCancel.js.map +1 -1
- package/dist/primitives/composer/ComposerSend.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerSend.js +3 -8
- package/dist/primitives/composer/ComposerSend.js.map +1 -1
- package/package.json +2 -2
- package/src/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.ts +2 -35
- package/src/legacy-runtime/runtime-cores/local/useLocalRuntime.ts +1 -67
- package/src/primitives/actionBar/ActionBarCopy.tsx +7 -26
- package/src/primitives/actionBar/ActionBarEdit.ts +3 -10
- package/src/primitives/actionBar/ActionBarFeedbackNegative.tsx +4 -9
- package/src/primitives/actionBar/ActionBarFeedbackPositive.tsx +5 -9
- package/src/primitives/actionBar/ActionBarReload.ts +3 -16
- package/src/primitives/composer/ComposerAddAttachment.ts +5 -4
- package/src/primitives/composer/ComposerCancel.ts +3 -10
- package/src/primitives/composer/ComposerSend.ts +3 -13
|
@@ -1,28 +1,4 @@
|
|
|
1
1
|
export type { LocalRuntimeOptionsBase } from "@assistant-ui/core";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import type { AssistantCloud } from "assistant-cloud";
|
|
5
|
-
export type LocalRuntimeOptions = Omit<LocalRuntimeOptionsBase, "adapters"> & {
|
|
6
|
-
cloud?: AssistantCloud | undefined;
|
|
7
|
-
initialMessages?: readonly ThreadMessageLike[] | undefined;
|
|
8
|
-
adapters?: Omit<LocalRuntimeOptionsBase["adapters"], "chatModel"> | undefined;
|
|
9
|
-
};
|
|
10
|
-
export declare const splitLocalRuntimeOptions: <T extends LocalRuntimeOptions>(options: T) => {
|
|
11
|
-
localRuntimeOptions: {
|
|
12
|
-
cloud: AssistantCloud | undefined;
|
|
13
|
-
initialMessages: readonly ThreadMessageLike[] | undefined;
|
|
14
|
-
maxSteps: number | undefined;
|
|
15
|
-
adapters: Omit<{
|
|
16
|
-
chatModel: import("@assistant-ui/core").ChatModelAdapter;
|
|
17
|
-
history?: import("@assistant-ui/core").ThreadHistoryAdapter | undefined;
|
|
18
|
-
attachments?: import("@assistant-ui/core").AttachmentAdapter | undefined;
|
|
19
|
-
speech?: import("@assistant-ui/core").SpeechSynthesisAdapter | undefined;
|
|
20
|
-
dictation?: import("@assistant-ui/core").DictationAdapter | undefined;
|
|
21
|
-
feedback?: import("@assistant-ui/core").FeedbackAdapter | undefined;
|
|
22
|
-
suggestion?: import("@assistant-ui/core").SuggestionAdapter | undefined;
|
|
23
|
-
}, "chatModel"> | undefined;
|
|
24
|
-
unstable_humanToolNames: string[] | undefined;
|
|
25
|
-
};
|
|
26
|
-
otherOptions: Omit<T, "cloud" | "adapters" | "maxSteps" | "unstable_humanToolNames" | "initialMessages">;
|
|
27
|
-
};
|
|
2
|
+
export type { LocalRuntimeOptions } from "@assistant-ui/core/react";
|
|
3
|
+
export { splitLocalRuntimeOptions } from "@assistant-ui/core/react";
|
|
28
4
|
//# sourceMappingURL=LocalRuntimeOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalRuntimeOptions.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"LocalRuntimeOptions.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAClE,YAAY,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
const { cloud, initialMessages, maxSteps, adapters, unstable_humanToolNames, ...rest } = options;
|
|
3
|
-
return {
|
|
4
|
-
localRuntimeOptions: {
|
|
5
|
-
cloud,
|
|
6
|
-
initialMessages,
|
|
7
|
-
maxSteps,
|
|
8
|
-
adapters,
|
|
9
|
-
unstable_humanToolNames,
|
|
10
|
-
},
|
|
11
|
-
otherOptions: rest,
|
|
12
|
-
};
|
|
13
|
-
};
|
|
1
|
+
export { splitLocalRuntimeOptions } from "@assistant-ui/core/react";
|
|
14
2
|
//# sourceMappingURL=LocalRuntimeOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalRuntimeOptions.js","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LocalRuntimeOptions.js","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import type { LocalRuntimeOptions } from "./LocalRuntimeOptions.js";
|
|
3
|
-
export declare const useLocalRuntime: (adapter: ChatModelAdapter, { cloud, ...options }?: LocalRuntimeOptions) => import("@assistant-ui/core").AssistantRuntime;
|
|
1
|
+
export { useLocalRuntime } from "@assistant-ui/core/react";
|
|
4
2
|
//# sourceMappingURL=useLocalRuntime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalRuntime.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/local/useLocalRuntime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocalRuntime.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/local/useLocalRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,53 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
import { LocalRuntimeCore } from "./LocalRuntimeCore.js";
|
|
4
|
-
import { useRuntimeAdapters } from "../adapters/RuntimeAdapterProvider.js";
|
|
5
|
-
import { useRemoteThreadListRuntime } from "../remote-thread-list/useRemoteThreadListRuntime.js";
|
|
6
|
-
import { useCloudThreadListAdapter } from "../remote-thread-list/adapter/cloud.js";
|
|
7
|
-
import { AssistantRuntimeImpl } from "../../../internal.js";
|
|
8
|
-
import { useAuiState } from "@assistant-ui/store";
|
|
9
|
-
const useLocalThreadRuntime = (adapter, { initialMessages, ...options }) => {
|
|
10
|
-
const { modelContext, ...threadListAdapters } = useRuntimeAdapters() ?? {};
|
|
11
|
-
const opt = {
|
|
12
|
-
...options,
|
|
13
|
-
adapters: {
|
|
14
|
-
...threadListAdapters,
|
|
15
|
-
...options.adapters,
|
|
16
|
-
chatModel: adapter,
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));
|
|
20
|
-
const threadIdRef = useRef(undefined);
|
|
21
|
-
threadIdRef.current = useAuiState((s) => s.threadListItem.remoteId);
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
runtime.threads
|
|
24
|
-
.getMainThreadRuntimeCore()
|
|
25
|
-
.__internal_setGetThreadId(() => threadIdRef.current);
|
|
26
|
-
}, [runtime]);
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
return () => {
|
|
29
|
-
runtime.threads.getMainThreadRuntimeCore().detach();
|
|
30
|
-
};
|
|
31
|
-
}, [runtime]);
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
runtime.threads.getMainThreadRuntimeCore().__internal_setOptions(opt);
|
|
34
|
-
runtime.threads.getMainThreadRuntimeCore().__internal_load();
|
|
35
|
-
});
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (!modelContext)
|
|
38
|
-
return undefined;
|
|
39
|
-
return runtime.registerModelContextProvider(modelContext);
|
|
40
|
-
}, [modelContext, runtime]);
|
|
41
|
-
return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);
|
|
42
|
-
};
|
|
43
|
-
export const useLocalRuntime = (adapter, { cloud, ...options } = {}) => {
|
|
44
|
-
const cloudAdapter = useCloudThreadListAdapter({ cloud });
|
|
45
|
-
return useRemoteThreadListRuntime({
|
|
46
|
-
runtimeHook: function RuntimeHook() {
|
|
47
|
-
return useLocalThreadRuntime(adapter, options);
|
|
48
|
-
},
|
|
49
|
-
adapter: cloudAdapter,
|
|
50
|
-
allowNesting: true,
|
|
51
|
-
});
|
|
52
|
-
};
|
|
2
|
+
export { useLocalRuntime } from "@assistant-ui/core/react";
|
|
53
3
|
//# sourceMappingURL=useLocalRuntime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalRuntime.js","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/local/useLocalRuntime.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useLocalRuntime.js","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/local/useLocalRuntime.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarCopy.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarCopy.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,0CAAuC;AAMnE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,QAAA,MAAM,yBAAyB,GAAI,sBAEhC;IACD,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,
|
|
1
|
+
{"version":3,"file":"ActionBarCopy.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarCopy.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,0CAAuC;AAMnE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,QAAA,MAAM,yBAAyB,GAAI,sBAEhC;IACD,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,wBAOL,CAAC;AAEF,yBAAiB,sBAAsB,CAAC;IACtC,KAAY,OAAO,GAAG,iBAAiB,CAAC;IACxC;;;OAGG;IACH,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,yBAAyB,CAAC,CAAC;CACzE;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB;;;qBAjChB,MAAM,GAAG,SAAS;qDAmDnC,CAAC"}
|
|
@@ -3,8 +3,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
5
5
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
6
|
-
import {
|
|
7
|
-
import { useAuiState
|
|
6
|
+
import { useActionBarCopy } from "@assistant-ui/core/react";
|
|
7
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
8
8
|
/**
|
|
9
9
|
* Hook that provides copy functionality for action bar buttons.
|
|
10
10
|
*
|
|
@@ -30,26 +30,13 @@ import { useAuiState, useAui } from "@assistant-ui/store";
|
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
const useActionBarPrimitiveCopy = ({ copiedDuration = 3000, } = {}) => {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
s.message.status?.type !== "running") &&
|
|
37
|
-
s.message.parts.some((c) => c.type === "text" && c.text.length > 0));
|
|
33
|
+
const { copy, disabled } = useActionBarCopy({
|
|
34
|
+
copiedDuration,
|
|
35
|
+
copyToClipboard: (text) => navigator.clipboard.writeText(text),
|
|
38
36
|
});
|
|
39
|
-
|
|
40
|
-
const composerValue = useAuiState((s) => s.composer.text);
|
|
41
|
-
const callback = useCallback(() => {
|
|
42
|
-
const valueToCopy = isEditing ? composerValue : aui.message().getCopyText();
|
|
43
|
-
if (!valueToCopy)
|
|
44
|
-
return;
|
|
45
|
-
navigator.clipboard.writeText(valueToCopy).then(() => {
|
|
46
|
-
aui.message().setIsCopied(true);
|
|
47
|
-
setTimeout(() => aui.message().setIsCopied(false), copiedDuration);
|
|
48
|
-
});
|
|
49
|
-
}, [aui, isEditing, composerValue, copiedDuration]);
|
|
50
|
-
if (!hasCopyableContent)
|
|
37
|
+
if (disabled)
|
|
51
38
|
return null;
|
|
52
|
-
return
|
|
39
|
+
return copy;
|
|
53
40
|
};
|
|
54
41
|
/**
|
|
55
42
|
* A button component that copies message content to the clipboard.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarCopy.js","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarCopy.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ActionBarCopy.js","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarCopy.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,yBAAyB,GAAG,CAAC,EACjC,cAAc,GAAG,IAAI,MAGnB,EAAE,EAAE,EAAE;IACR,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,gBAAgB,CAAC;QAC1C,cAAc;QACd,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC;KAC/D,CAAC,CAAC;IACH,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1B,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAWF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAG9C,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY,EAAE,EAAE;IAClE,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,yBAAyB,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC;IAC/D,OAAO,CACL,KAAC,SAAS,CAAC,MAAM,IACf,IAAI,EAAC,QAAQ,KACT,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAC3C,KAAK,EACT,GAAG,EAAE,YAAY,EACjB,QAAQ,EAAE,QAAQ,IAAI,CAAC,QAAQ,EAC/B,OAAO,EAAE,oBAAoB,CAAC,OAAO,EAAE,GAAG,EAAE;YAC1C,QAAQ,EAAE,EAAE,CAAC;QACf,CAAC,CAAC,GACF,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,sBAAsB,CAAC,WAAW,GAAG,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarEdit.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarEdit.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,0CAAuC;
|
|
1
|
+
{"version":3,"file":"ActionBarEdit.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarEdit.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,0CAAuC;AAGxC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,gBAAgB,2BAIrB,CAAC;AAEF,yBAAiB,sBAAsB,CAAC;IACtC,KAAY,OAAO,GAAG,mBAAmB,CAAC;IAC1C;;;OAGG;IACH,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,gBAAgB,CAAC,CAAC;CAChE;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB;;6DAGlC,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createActionButton, } from "../../utils/createActionButton.js";
|
|
3
|
-
import {
|
|
4
|
-
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
3
|
+
import { useActionBarEdit as useActionBarEditBehavior } from "@assistant-ui/core/react";
|
|
5
4
|
/**
|
|
6
5
|
* Hook that provides edit functionality for action bar buttons.
|
|
7
6
|
*
|
|
@@ -24,14 +23,10 @@ import { useAuiState, useAui } from "@assistant-ui/store";
|
|
|
24
23
|
* ```
|
|
25
24
|
*/
|
|
26
25
|
const useActionBarEdit = () => {
|
|
27
|
-
const
|
|
28
|
-
const disabled = useAuiState((s) => s.composer.isEditing);
|
|
29
|
-
const callback = useCallback(() => {
|
|
30
|
-
aui.composer().beginEdit();
|
|
31
|
-
}, [aui]);
|
|
26
|
+
const { disabled, edit } = useActionBarEditBehavior();
|
|
32
27
|
if (disabled)
|
|
33
28
|
return null;
|
|
34
|
-
return
|
|
29
|
+
return edit;
|
|
35
30
|
};
|
|
36
31
|
/**
|
|
37
32
|
* A button component that starts editing the current message.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarEdit.js","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarEdit.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAGL,kBAAkB,GACnB,0CAAuC;AACxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ActionBarEdit.js","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarEdit.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAGL,kBAAkB,GACnB,0CAAuC;AACxC,OAAO,EAAE,gBAAgB,IAAI,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAExF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,gBAAgB,GAAG,GAAG,EAAE;IAC5B,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,wBAAwB,EAAE,CAAC;IACtD,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1B,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAWF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CACtD,yBAAyB,EACzB,gBAAgB,CACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarFeedbackNegative.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarFeedbackNegative.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,0CAAuC;AAMnE,QAAA,MAAM,4BAA4B,
|
|
1
|
+
{"version":3,"file":"ActionBarFeedbackNegative.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarFeedbackNegative.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,0CAAuC;AAMnE,QAAA,MAAM,4BAA4B,kBAGjC,CAAC;AAEF,yBAAiB,kCAAkC,CAAC;IAClD,KAAY,OAAO,GAAG,iBAAiB,CAAC;IACxC,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,4BAA4B,CAAC,CAAC;CAC5E;AAED,eAAO,MAAM,kCAAkC;;6DAoB7C,CAAC"}
|
|
@@ -3,14 +3,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
5
5
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
7
|
+
import { useActionBarFeedbackNegative as useActionBarFeedbackNegativeBehavior } from "@assistant-ui/core/react";
|
|
8
8
|
const useActionBarFeedbackNegative = () => {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
aui.message().submitFeedback({ type: "negative" });
|
|
12
|
-
}, [aui]);
|
|
13
|
-
return callback;
|
|
9
|
+
const { submit } = useActionBarFeedbackNegativeBehavior();
|
|
10
|
+
return submit;
|
|
14
11
|
};
|
|
15
12
|
export const ActionBarPrimitiveFeedbackNegative = forwardRef(({ onClick, disabled, ...props }, forwardedRef) => {
|
|
16
13
|
const isSubmitted = useAuiState((s) => s.message.metadata.submittedFeedback?.type === "negative");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarFeedbackNegative.js","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarFeedbackNegative.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ActionBarFeedbackNegative.js","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarFeedbackNegative.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,4BAA4B,IAAI,oCAAoC,EAAE,MAAM,0BAA0B,CAAC;AAEhH,MAAM,4BAA4B,GAAG,GAAG,EAAE;IACxC,MAAM,EAAE,MAAM,EAAE,GAAG,oCAAoC,EAAE,CAAC;IAC1D,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAOF,MAAM,CAAC,MAAM,kCAAkC,GAAG,UAAU,CAG1D,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY,EAAE,EAAE;IAClD,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,EAAE,IAAI,KAAK,UAAU,CACjE,CAAC;IACF,MAAM,QAAQ,GAAG,4BAA4B,EAAE,CAAC;IAChD,OAAO,CACL,KAAC,SAAS,CAAC,MAAM,IACf,IAAI,EAAC,QAAQ,KACT,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KACjD,KAAK,EACT,GAAG,EAAE,YAAY,EACjB,QAAQ,EAAE,QAAQ,IAAI,CAAC,QAAQ,EAC/B,OAAO,EAAE,oBAAoB,CAAC,OAAO,EAAE,GAAG,EAAE;YAC1C,QAAQ,EAAE,EAAE,CAAC;QACf,CAAC,CAAC,GACF,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,kCAAkC,CAAC,WAAW;IAC5C,qCAAqC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarFeedbackPositive.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarFeedbackPositive.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,0CAAuC;
|
|
1
|
+
{"version":3,"file":"ActionBarFeedbackPositive.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarFeedbackPositive.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,0CAAuC;AAMnE,QAAA,MAAM,4BAA4B,kBAGjC,CAAC;AAEF,yBAAiB,kCAAkC,CAAC;IAClD,KAAY,OAAO,GAAG,iBAAiB,CAAC;IACxC,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,4BAA4B,CAAC,CAAC;CAC5E;AAED,eAAO,MAAM,kCAAkC;;6DAoB7C,CAAC"}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
4
|
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
5
|
-
import { useAuiState
|
|
5
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
6
6
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
7
|
+
import { useActionBarFeedbackPositive as useActionBarFeedbackPositiveBehavior } from "@assistant-ui/core/react";
|
|
7
8
|
const useActionBarFeedbackPositive = () => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
aui.message().submitFeedback({ type: "positive" });
|
|
11
|
-
}, [aui]);
|
|
12
|
-
return callback;
|
|
9
|
+
const { submit } = useActionBarFeedbackPositiveBehavior();
|
|
10
|
+
return submit;
|
|
13
11
|
};
|
|
14
12
|
export const ActionBarPrimitiveFeedbackPositive = forwardRef(({ onClick, disabled, ...props }, forwardedRef) => {
|
|
15
13
|
const isSubmitted = useAuiState((s) => s.message.metadata.submittedFeedback?.type === "positive");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarFeedbackPositive.js","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarFeedbackPositive.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"ActionBarFeedbackPositive.js","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarFeedbackPositive.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,4BAA4B,IAAI,oCAAoC,EAAE,MAAM,0BAA0B,CAAC;AAEhH,MAAM,4BAA4B,GAAG,GAAG,EAAE;IACxC,MAAM,EAAE,MAAM,EAAE,GAAG,oCAAoC,EAAE,CAAC;IAC1D,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAOF,MAAM,CAAC,MAAM,kCAAkC,GAAG,UAAU,CAG1D,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY,EAAE,EAAE;IAClD,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,EAAE,IAAI,KAAK,UAAU,CACjE,CAAC;IACF,MAAM,QAAQ,GAAG,4BAA4B,EAAE,CAAC;IAChD,OAAO,CACL,KAAC,SAAS,CAAC,MAAM,IACf,IAAI,EAAC,QAAQ,KACT,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KACjD,KAAK,EACT,GAAG,EAAE,YAAY,EACjB,QAAQ,EAAE,QAAQ,IAAI,CAAC,QAAQ,EAC/B,OAAO,EAAE,oBAAoB,CAAC,OAAO,EAAE,GAAG,EAAE;YAC1C,QAAQ,EAAE,EAAE,CAAC;QACf,CAAC,CAAC,GACF,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,kCAAkC,CAAC,WAAW;IAC5C,qCAAqC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarReload.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarReload.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,0CAAuC;
|
|
1
|
+
{"version":3,"file":"ActionBarReload.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarReload.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,0CAAuC;AAGxC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,kBAAkB,2BAIvB,CAAC;AAEF,yBAAiB,wBAAwB,CAAC;IACxC,KAAY,OAAO,GAAG,mBAAmB,CAAC;IAC1C;;;OAGG;IACH,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,kBAAkB,CAAC,CAAC;CAClE;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB;;6DAGpC,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createActionButton, } from "../../utils/createActionButton.js";
|
|
3
|
-
import {
|
|
4
|
-
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
3
|
+
import { useActionBarReload as useActionBarReloadBehavior } from "@assistant-ui/core/react";
|
|
5
4
|
/**
|
|
6
5
|
* Hook that provides reload functionality for action bar buttons.
|
|
7
6
|
*
|
|
@@ -24,16 +23,10 @@ import { useAuiState, useAui } from "@assistant-ui/store";
|
|
|
24
23
|
* ```
|
|
25
24
|
*/
|
|
26
25
|
const useActionBarReload = () => {
|
|
27
|
-
const
|
|
28
|
-
const disabled = useAuiState((s) => s.thread.isRunning ||
|
|
29
|
-
s.thread.isDisabled ||
|
|
30
|
-
s.message.role !== "assistant");
|
|
31
|
-
const callback = useCallback(() => {
|
|
32
|
-
aui.message().reload();
|
|
33
|
-
}, [aui]);
|
|
26
|
+
const { disabled, reload } = useActionBarReloadBehavior();
|
|
34
27
|
if (disabled)
|
|
35
28
|
return null;
|
|
36
|
-
return
|
|
29
|
+
return reload;
|
|
37
30
|
};
|
|
38
31
|
/**
|
|
39
32
|
* A button component that reloads/regenerates the current assistant message.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarReload.js","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarReload.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAGL,kBAAkB,GACnB,0CAAuC;AACxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ActionBarReload.js","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarReload.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAGL,kBAAkB,GACnB,0CAAuC;AACxC,OAAO,EAAE,kBAAkB,IAAI,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,kBAAkB,GAAG,GAAG,EAAE;IAC9B,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,0BAA0B,EAAE,CAAC;IAC1D,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1B,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAWF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,kBAAkB,CACxD,2BAA2B,EAC3B,kBAAkB,CACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerAddAttachment.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerAddAttachment.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,0CAAuC;
|
|
1
|
+
{"version":3,"file":"ComposerAddAttachment.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerAddAttachment.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,0CAAuC;AAKxC,QAAA,MAAM,wBAAwB,GAAI,gBAE/B;IACD,qCAAqC;IACrC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC3B,wBAsCL,CAAC;AAEF,yBAAiB,8BAA8B,CAAC;IAC9C,KAAY,OAAO,GAAG,mBAAmB,CAAC;IAC1C,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,wBAAwB,CAAC,CAAC;CACxE;AAED,eAAO,MAAM,8BAA8B;;;IA/CzC,qCAAqC;eAC1B,OAAO,GAAG,SAAS;qDAkD/B,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createActionButton, } from "../../utils/createActionButton.js";
|
|
3
3
|
import { useCallback } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useAui } from "@assistant-ui/store";
|
|
5
|
+
import { useComposerAddAttachment as useComposerAddAttachmentBehavior } from "@assistant-ui/core/react";
|
|
5
6
|
const useComposerAddAttachment = ({ multiple = true, } = {}) => {
|
|
6
|
-
const disabled =
|
|
7
|
+
const { disabled, addAttachment } = useComposerAddAttachmentBehavior();
|
|
7
8
|
const aui = useAui();
|
|
8
9
|
const callback = useCallback(() => {
|
|
9
10
|
const input = document.createElement("input");
|
|
@@ -20,7 +21,7 @@ const useComposerAddAttachment = ({ multiple = true, } = {}) => {
|
|
|
20
21
|
if (!fileList)
|
|
21
22
|
return;
|
|
22
23
|
for (const file of fileList) {
|
|
23
|
-
|
|
24
|
+
addAttachment(file);
|
|
24
25
|
}
|
|
25
26
|
document.body.removeChild(input);
|
|
26
27
|
};
|
|
@@ -30,7 +31,7 @@ const useComposerAddAttachment = ({ multiple = true, } = {}) => {
|
|
|
30
31
|
}
|
|
31
32
|
};
|
|
32
33
|
input.click();
|
|
33
|
-
}, [aui, multiple]);
|
|
34
|
+
}, [aui, multiple, addAttachment]);
|
|
34
35
|
if (disabled)
|
|
35
36
|
return null;
|
|
36
37
|
return callback;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerAddAttachment.js","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerAddAttachment.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAGL,kBAAkB,GACnB,0CAAuC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ComposerAddAttachment.js","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerAddAttachment.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAGL,kBAAkB,GACnB,0CAAuC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,wBAAwB,IAAI,gCAAgC,EAAE,MAAM,0BAA0B,CAAC;AAExG,MAAM,wBAAwB,GAAG,CAAC,EAChC,QAAQ,GAAG,IAAI,MAIb,EAAE,EAAE,EAAE;IACR,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,gCAAgC,EAAE,CAAC;IACvE,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IAErB,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;QAChC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC9C,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC;QACpB,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC1B,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;QAEpB,MAAM,gBAAgB,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,gBAAgB,CAAC;QACpE,IAAI,gBAAgB,KAAK,GAAG,EAAE,CAAC;YAC7B,KAAK,CAAC,MAAM,GAAG,gBAAgB,CAAC;QAClC,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAEjC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,EAAE,EAAE;YACrB,MAAM,QAAQ,GAAI,CAAC,CAAC,MAA2B,CAAC,KAAK,CAAC;YACtD,IAAI,CAAC,QAAQ;gBAAE,OAAO;YACtB,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;gBAC5B,aAAa,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;YAED,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC,CAAC;QAEF,KAAK,CAAC,QAAQ,GAAG,GAAG,EAAE;YACpB,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC7C,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YACnC,CAAC;QACH,CAAC,CAAC;QAEF,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;IAEnC,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1B,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAOF,MAAM,CAAC,MAAM,8BAA8B,GAAG,kBAAkB,CAC9D,iCAAiC,EACjC,wBAAwB,EACxB,CAAC,UAAU,CAAC,CACb,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerCancel.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerCancel.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,0CAAuC;
|
|
1
|
+
{"version":3,"file":"ComposerCancel.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerCancel.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,0CAAuC;AAGxC,QAAA,MAAM,iBAAiB,2BAItB,CAAC;AAEF,yBAAiB,uBAAuB,CAAC;IACvC,KAAY,OAAO,GAAG,mBAAmB,CAAC;IAC1C;;;OAGG;IACH,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,iBAAiB,CAAC,CAAC;CACjE;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB;;6DAGnC,CAAC"}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createActionButton, } from "../../utils/createActionButton.js";
|
|
3
|
-
import {
|
|
4
|
-
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
3
|
+
import { useComposerCancel as useComposerCancelBehavior } from "@assistant-ui/core/react";
|
|
5
4
|
const useComposerCancel = () => {
|
|
6
|
-
const
|
|
7
|
-
const disabled = useAuiState((s) => !s.composer.canCancel);
|
|
8
|
-
const callback = useCallback(() => {
|
|
9
|
-
aui.composer().cancel();
|
|
10
|
-
}, [aui]);
|
|
5
|
+
const { disabled, cancel } = useComposerCancelBehavior();
|
|
11
6
|
if (disabled)
|
|
12
7
|
return null;
|
|
13
|
-
return
|
|
8
|
+
return cancel;
|
|
14
9
|
};
|
|
15
10
|
/**
|
|
16
11
|
* A button component that cancels the current message composition.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerCancel.js","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerCancel.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAGL,kBAAkB,GACnB,0CAAuC;AACxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ComposerCancel.js","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerCancel.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAGL,kBAAkB,GACnB,0CAAuC;AACxC,OAAO,EAAE,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAE1F,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,yBAAyB,EAAE,CAAC;IACzD,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1B,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAWF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CACvD,0BAA0B,EAC1B,iBAAiB,CAClB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerSend.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerSend.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,0CAAuC;
|
|
1
|
+
{"version":3,"file":"ComposerSend.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerSend.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,0CAAuC;AAGxC,eAAO,MAAM,eAAe,2BAI3B,CAAC;AAEF,yBAAiB,qBAAqB,CAAC;IACrC,KAAY,OAAO,GAAG,mBAAmB,CAAC;IAC1C;;;OAGG;IACH,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,eAAe,CAAC,CAAC;CAC/D;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB;;6DAGjC,CAAC"}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createActionButton, } from "../../utils/createActionButton.js";
|
|
3
|
-
import {
|
|
4
|
-
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
3
|
+
import { useComposerSend as useComposerSendBehavior } from "@assistant-ui/core/react";
|
|
5
4
|
export const useComposerSend = () => {
|
|
6
|
-
const
|
|
7
|
-
const disabled = useAuiState((s) => s.thread.isRunning || !s.composer.isEditing || s.composer.isEmpty);
|
|
8
|
-
const callback = useCallback(() => {
|
|
9
|
-
aui.composer().send();
|
|
10
|
-
}, [aui]);
|
|
5
|
+
const { disabled, send } = useComposerSendBehavior();
|
|
11
6
|
if (disabled)
|
|
12
7
|
return null;
|
|
13
|
-
return
|
|
8
|
+
return send;
|
|
14
9
|
};
|
|
15
10
|
/**
|
|
16
11
|
* A button component that sends the current message in the composer.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerSend.js","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerSend.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAGL,kBAAkB,GACnB,0CAAuC;AACxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ComposerSend.js","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerSend.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAGL,kBAAkB,GACnB,0CAAuC;AACxC,OAAO,EAAE,eAAe,IAAI,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEtF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,uBAAuB,EAAE,CAAC;IACrD,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1B,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAWF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CACrD,wBAAwB,EACxB,eAAe,CAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/react",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.17",
|
|
4
4
|
"description": "TypeScript/React library for AI Chat",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"radix-ui",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
],
|
|
50
50
|
"sideEffects": false,
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@assistant-ui/core": "^0.1.
|
|
52
|
+
"@assistant-ui/core": "^0.1.5",
|
|
53
53
|
"@assistant-ui/store": "^0.2.2",
|
|
54
54
|
"@assistant-ui/tap": "^0.5.2",
|
|
55
55
|
"@radix-ui/primitive": "^1.1.3",
|
|
@@ -1,36 +1,3 @@
|
|
|
1
1
|
export type { LocalRuntimeOptionsBase } from "@assistant-ui/core";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import type { ThreadMessageLike } from "@assistant-ui/core";
|
|
5
|
-
import type { AssistantCloud } from "assistant-cloud";
|
|
6
|
-
|
|
7
|
-
// TODO align LocalRuntimeOptions with LocalRuntimeOptionsBase
|
|
8
|
-
export type LocalRuntimeOptions = Omit<LocalRuntimeOptionsBase, "adapters"> & {
|
|
9
|
-
cloud?: AssistantCloud | undefined;
|
|
10
|
-
initialMessages?: readonly ThreadMessageLike[] | undefined;
|
|
11
|
-
adapters?: Omit<LocalRuntimeOptionsBase["adapters"], "chatModel"> | undefined;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const splitLocalRuntimeOptions = <T extends LocalRuntimeOptions>(
|
|
15
|
-
options: T,
|
|
16
|
-
) => {
|
|
17
|
-
const {
|
|
18
|
-
cloud,
|
|
19
|
-
initialMessages,
|
|
20
|
-
maxSteps,
|
|
21
|
-
adapters,
|
|
22
|
-
unstable_humanToolNames,
|
|
23
|
-
...rest
|
|
24
|
-
} = options;
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
localRuntimeOptions: {
|
|
28
|
-
cloud,
|
|
29
|
-
initialMessages,
|
|
30
|
-
maxSteps,
|
|
31
|
-
adapters,
|
|
32
|
-
unstable_humanToolNames,
|
|
33
|
-
},
|
|
34
|
-
otherOptions: rest,
|
|
35
|
-
};
|
|
36
|
-
};
|
|
2
|
+
export type { LocalRuntimeOptions } from "@assistant-ui/core/react";
|
|
3
|
+
export { splitLocalRuntimeOptions } from "@assistant-ui/core/react";
|
|
@@ -1,69 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import type { ChatModelAdapter } from "./ChatModelAdapter";
|
|
5
|
-
import { LocalRuntimeCore } from "./LocalRuntimeCore";
|
|
6
|
-
import type { LocalRuntimeOptions } from "./LocalRuntimeOptions";
|
|
7
|
-
import { useRuntimeAdapters } from "../adapters/RuntimeAdapterProvider";
|
|
8
|
-
import { useRemoteThreadListRuntime } from "../remote-thread-list/useRemoteThreadListRuntime";
|
|
9
|
-
import { useCloudThreadListAdapter } from "../remote-thread-list/adapter/cloud";
|
|
10
|
-
import { AssistantRuntimeImpl } from "../../../internal";
|
|
11
|
-
import { useAuiState } from "@assistant-ui/store";
|
|
12
|
-
|
|
13
|
-
const useLocalThreadRuntime = (
|
|
14
|
-
adapter: ChatModelAdapter,
|
|
15
|
-
{ initialMessages, ...options }: LocalRuntimeOptions,
|
|
16
|
-
) => {
|
|
17
|
-
const { modelContext, ...threadListAdapters } = useRuntimeAdapters() ?? {};
|
|
18
|
-
const opt = {
|
|
19
|
-
...options,
|
|
20
|
-
adapters: {
|
|
21
|
-
...threadListAdapters,
|
|
22
|
-
...options.adapters,
|
|
23
|
-
chatModel: adapter,
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));
|
|
28
|
-
|
|
29
|
-
const threadIdRef = useRef<string | undefined>(undefined);
|
|
30
|
-
threadIdRef.current = useAuiState((s) => s.threadListItem.remoteId);
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
runtime.threads
|
|
34
|
-
.getMainThreadRuntimeCore()
|
|
35
|
-
.__internal_setGetThreadId(() => threadIdRef.current);
|
|
36
|
-
}, [runtime]);
|
|
37
|
-
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
return () => {
|
|
40
|
-
runtime.threads.getMainThreadRuntimeCore().detach();
|
|
41
|
-
};
|
|
42
|
-
}, [runtime]);
|
|
43
|
-
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
runtime.threads.getMainThreadRuntimeCore().__internal_setOptions(opt);
|
|
46
|
-
runtime.threads.getMainThreadRuntimeCore().__internal_load();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
if (!modelContext) return undefined;
|
|
51
|
-
return runtime.registerModelContextProvider(modelContext);
|
|
52
|
-
}, [modelContext, runtime]);
|
|
53
|
-
|
|
54
|
-
return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const useLocalRuntime = (
|
|
58
|
-
adapter: ChatModelAdapter,
|
|
59
|
-
{ cloud, ...options }: LocalRuntimeOptions = {},
|
|
60
|
-
) => {
|
|
61
|
-
const cloudAdapter = useCloudThreadListAdapter({ cloud });
|
|
62
|
-
return useRemoteThreadListRuntime({
|
|
63
|
-
runtimeHook: function RuntimeHook() {
|
|
64
|
-
return useLocalThreadRuntime(adapter, options);
|
|
65
|
-
},
|
|
66
|
-
adapter: cloudAdapter,
|
|
67
|
-
allowNesting: true,
|
|
68
|
-
});
|
|
69
|
-
};
|
|
3
|
+
export { useLocalRuntime } from "@assistant-ui/core/react";
|
|
@@ -4,8 +4,8 @@ import { forwardRef } from "react";
|
|
|
4
4
|
import { ActionButtonProps } from "../../utils/createActionButton";
|
|
5
5
|
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
6
6
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
7
|
-
import {
|
|
8
|
-
import { useAuiState
|
|
7
|
+
import { useActionBarCopy } from "@assistant-ui/core/react";
|
|
8
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Hook that provides copy functionality for action bar buttons.
|
|
@@ -36,31 +36,12 @@ const useActionBarPrimitiveCopy = ({
|
|
|
36
36
|
}: {
|
|
37
37
|
copiedDuration?: number | undefined;
|
|
38
38
|
} = {}) => {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
(s.message.role !== "assistant" ||
|
|
43
|
-
s.message.status?.type !== "running") &&
|
|
44
|
-
s.message.parts.some((c) => c.type === "text" && c.text.length > 0)
|
|
45
|
-
);
|
|
39
|
+
const { copy, disabled } = useActionBarCopy({
|
|
40
|
+
copiedDuration,
|
|
41
|
+
copyToClipboard: (text) => navigator.clipboard.writeText(text),
|
|
46
42
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const composerValue = useAuiState((s) => s.composer.text);
|
|
50
|
-
|
|
51
|
-
const callback = useCallback(() => {
|
|
52
|
-
const valueToCopy = isEditing ? composerValue : aui.message().getCopyText();
|
|
53
|
-
|
|
54
|
-
if (!valueToCopy) return;
|
|
55
|
-
|
|
56
|
-
navigator.clipboard.writeText(valueToCopy).then(() => {
|
|
57
|
-
aui.message().setIsCopied(true);
|
|
58
|
-
setTimeout(() => aui.message().setIsCopied(false), copiedDuration);
|
|
59
|
-
});
|
|
60
|
-
}, [aui, isEditing, composerValue, copiedDuration]);
|
|
61
|
-
|
|
62
|
-
if (!hasCopyableContent) return null;
|
|
63
|
-
return callback;
|
|
43
|
+
if (disabled) return null;
|
|
44
|
+
return copy;
|
|
64
45
|
};
|
|
65
46
|
|
|
66
47
|
export namespace ActionBarPrimitiveCopy {
|
|
@@ -5,8 +5,7 @@ import {
|
|
|
5
5
|
ActionButtonProps,
|
|
6
6
|
createActionButton,
|
|
7
7
|
} from "../../utils/createActionButton";
|
|
8
|
-
import {
|
|
9
|
-
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
8
|
+
import { useActionBarEdit as useActionBarEditBehavior } from "@assistant-ui/core/react";
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Hook that provides edit functionality for action bar buttons.
|
|
@@ -30,15 +29,9 @@ import { useAuiState, useAui } from "@assistant-ui/store";
|
|
|
30
29
|
* ```
|
|
31
30
|
*/
|
|
32
31
|
const useActionBarEdit = () => {
|
|
33
|
-
const
|
|
34
|
-
const disabled = useAuiState((s) => s.composer.isEditing);
|
|
35
|
-
|
|
36
|
-
const callback = useCallback(() => {
|
|
37
|
-
aui.composer().beginEdit();
|
|
38
|
-
}, [aui]);
|
|
39
|
-
|
|
32
|
+
const { disabled, edit } = useActionBarEditBehavior();
|
|
40
33
|
if (disabled) return null;
|
|
41
|
-
return
|
|
34
|
+
return edit;
|
|
42
35
|
};
|
|
43
36
|
|
|
44
37
|
export namespace ActionBarPrimitiveEdit {
|
|
@@ -4,17 +4,12 @@ import { forwardRef } from "react";
|
|
|
4
4
|
import { ActionButtonProps } from "../../utils/createActionButton";
|
|
5
5
|
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
6
6
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
8
|
+
import { useActionBarFeedbackNegative as useActionBarFeedbackNegativeBehavior } from "@assistant-ui/core/react";
|
|
9
9
|
|
|
10
10
|
const useActionBarFeedbackNegative = () => {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const callback = useCallback(() => {
|
|
14
|
-
aui.message().submitFeedback({ type: "negative" });
|
|
15
|
-
}, [aui]);
|
|
16
|
-
|
|
17
|
-
return callback;
|
|
11
|
+
const { submit } = useActionBarFeedbackNegativeBehavior();
|
|
12
|
+
return submit;
|
|
18
13
|
};
|
|
19
14
|
|
|
20
15
|
export namespace ActionBarPrimitiveFeedbackNegative {
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { forwardRef
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
4
|
import { ActionButtonProps } from "../../utils/createActionButton";
|
|
5
5
|
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
6
|
-
import { useAuiState
|
|
6
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
7
7
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
8
|
+
import { useActionBarFeedbackPositive as useActionBarFeedbackPositiveBehavior } from "@assistant-ui/core/react";
|
|
8
9
|
|
|
9
10
|
const useActionBarFeedbackPositive = () => {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const callback = useCallback(() => {
|
|
13
|
-
aui.message().submitFeedback({ type: "positive" });
|
|
14
|
-
}, [aui]);
|
|
15
|
-
|
|
16
|
-
return callback;
|
|
11
|
+
const { submit } = useActionBarFeedbackPositiveBehavior();
|
|
12
|
+
return submit;
|
|
17
13
|
};
|
|
18
14
|
|
|
19
15
|
export namespace ActionBarPrimitiveFeedbackPositive {
|
|
@@ -5,8 +5,7 @@ import {
|
|
|
5
5
|
ActionButtonProps,
|
|
6
6
|
createActionButton,
|
|
7
7
|
} from "../../utils/createActionButton";
|
|
8
|
-
import {
|
|
9
|
-
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
8
|
+
import { useActionBarReload as useActionBarReloadBehavior } from "@assistant-ui/core/react";
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Hook that provides reload functionality for action bar buttons.
|
|
@@ -30,21 +29,9 @@ import { useAuiState, useAui } from "@assistant-ui/store";
|
|
|
30
29
|
* ```
|
|
31
30
|
*/
|
|
32
31
|
const useActionBarReload = () => {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
const disabled = useAuiState(
|
|
36
|
-
(s) =>
|
|
37
|
-
s.thread.isRunning ||
|
|
38
|
-
s.thread.isDisabled ||
|
|
39
|
-
s.message.role !== "assistant",
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const callback = useCallback(() => {
|
|
43
|
-
aui.message().reload();
|
|
44
|
-
}, [aui]);
|
|
45
|
-
|
|
32
|
+
const { disabled, reload } = useActionBarReloadBehavior();
|
|
46
33
|
if (disabled) return null;
|
|
47
|
-
return
|
|
34
|
+
return reload;
|
|
48
35
|
};
|
|
49
36
|
|
|
50
37
|
export namespace ActionBarPrimitiveReload {
|
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
createActionButton,
|
|
7
7
|
} from "../../utils/createActionButton";
|
|
8
8
|
import { useCallback } from "react";
|
|
9
|
-
import {
|
|
9
|
+
import { useAui } from "@assistant-ui/store";
|
|
10
|
+
import { useComposerAddAttachment as useComposerAddAttachmentBehavior } from "@assistant-ui/core/react";
|
|
10
11
|
|
|
11
12
|
const useComposerAddAttachment = ({
|
|
12
13
|
multiple = true,
|
|
@@ -14,7 +15,7 @@ const useComposerAddAttachment = ({
|
|
|
14
15
|
/** allow selecting multiple files */
|
|
15
16
|
multiple?: boolean | undefined;
|
|
16
17
|
} = {}) => {
|
|
17
|
-
const disabled =
|
|
18
|
+
const { disabled, addAttachment } = useComposerAddAttachmentBehavior();
|
|
18
19
|
const aui = useAui();
|
|
19
20
|
|
|
20
21
|
const callback = useCallback(() => {
|
|
@@ -34,7 +35,7 @@ const useComposerAddAttachment = ({
|
|
|
34
35
|
const fileList = (e.target as HTMLInputElement).files;
|
|
35
36
|
if (!fileList) return;
|
|
36
37
|
for (const file of fileList) {
|
|
37
|
-
|
|
38
|
+
addAttachment(file);
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
document.body.removeChild(input);
|
|
@@ -47,7 +48,7 @@ const useComposerAddAttachment = ({
|
|
|
47
48
|
};
|
|
48
49
|
|
|
49
50
|
input.click();
|
|
50
|
-
}, [aui, multiple]);
|
|
51
|
+
}, [aui, multiple, addAttachment]);
|
|
51
52
|
|
|
52
53
|
if (disabled) return null;
|
|
53
54
|
return callback;
|
|
@@ -5,19 +5,12 @@ import {
|
|
|
5
5
|
ActionButtonProps,
|
|
6
6
|
createActionButton,
|
|
7
7
|
} from "../../utils/createActionButton";
|
|
8
|
-
import {
|
|
9
|
-
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
8
|
+
import { useComposerCancel as useComposerCancelBehavior } from "@assistant-ui/core/react";
|
|
10
9
|
|
|
11
10
|
const useComposerCancel = () => {
|
|
12
|
-
const
|
|
13
|
-
const disabled = useAuiState((s) => !s.composer.canCancel);
|
|
14
|
-
|
|
15
|
-
const callback = useCallback(() => {
|
|
16
|
-
aui.composer().cancel();
|
|
17
|
-
}, [aui]);
|
|
18
|
-
|
|
11
|
+
const { disabled, cancel } = useComposerCancelBehavior();
|
|
19
12
|
if (disabled) return null;
|
|
20
|
-
return
|
|
13
|
+
return cancel;
|
|
21
14
|
};
|
|
22
15
|
|
|
23
16
|
export namespace ComposerPrimitiveCancel {
|
|
@@ -5,22 +5,12 @@ import {
|
|
|
5
5
|
ActionButtonProps,
|
|
6
6
|
createActionButton,
|
|
7
7
|
} from "../../utils/createActionButton";
|
|
8
|
-
import {
|
|
9
|
-
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
8
|
+
import { useComposerSend as useComposerSendBehavior } from "@assistant-ui/core/react";
|
|
10
9
|
|
|
11
10
|
export const useComposerSend = () => {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const disabled = useAuiState(
|
|
15
|
-
(s) => s.thread.isRunning || !s.composer.isEditing || s.composer.isEmpty,
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const callback = useCallback(() => {
|
|
19
|
-
aui.composer().send();
|
|
20
|
-
}, [aui]);
|
|
21
|
-
|
|
11
|
+
const { disabled, send } = useComposerSendBehavior();
|
|
22
12
|
if (disabled) return null;
|
|
23
|
-
return
|
|
13
|
+
return send;
|
|
24
14
|
};
|
|
25
15
|
|
|
26
16
|
export namespace ComposerPrimitiveSend {
|