@assistant-ui/react 0.7.38 → 0.7.40
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/primitives/actionBar/ActionBarRoot.d.ts +2 -2
- package/dist/primitives/actionBar/ActionBarRoot.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.mjs.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalAnchor.d.ts +2 -2
- package/dist/primitives/assistantModal/AssistantModalAnchor.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalAnchor.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalAnchor.mjs.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.d.ts +2 -2
- package/dist/primitives/assistantModal/AssistantModalContent.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.mjs.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.d.ts +2 -2
- package/dist/primitives/assistantModal/AssistantModalTrigger.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.mjs.map +1 -1
- package/dist/primitives/assistantModal/scope.d.ts +3 -3
- package/dist/primitives/assistantModal/scope.d.ts.map +1 -1
- package/dist/primitives/assistantModal/scope.js.map +1 -1
- package/dist/primitives/assistantModal/scope.mjs.map +1 -1
- package/dist/primitives/attachment/AttachmentRoot.d.ts +2 -2
- package/dist/primitives/attachment/AttachmentRoot.d.ts.map +1 -1
- package/dist/primitives/attachment/AttachmentRoot.js.map +1 -1
- package/dist/primitives/attachment/AttachmentRoot.mjs.map +1 -1
- package/dist/primitives/attachment/AttachmentThumb.d.ts +2 -2
- package/dist/primitives/attachment/AttachmentThumb.d.ts.map +1 -1
- package/dist/primitives/attachment/AttachmentThumb.js.map +1 -1
- package/dist/primitives/attachment/AttachmentThumb.mjs.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.d.ts +2 -2
- package/dist/primitives/branchPicker/BranchPickerRoot.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.mjs.map +1 -1
- package/dist/primitives/composer/ComposerRoot.d.ts +2 -2
- package/dist/primitives/composer/ComposerRoot.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerRoot.js.map +1 -1
- package/dist/primitives/composer/ComposerRoot.mjs.map +1 -1
- package/dist/primitives/contentPart/ContentPartImage.d.ts +2 -2
- package/dist/primitives/contentPart/ContentPartImage.d.ts.map +1 -1
- package/dist/primitives/contentPart/ContentPartImage.js.map +1 -1
- package/dist/primitives/contentPart/ContentPartImage.mjs.map +1 -1
- package/dist/primitives/contentPart/ContentPartText.d.ts +2 -2
- package/dist/primitives/contentPart/ContentPartText.d.ts.map +1 -1
- package/dist/primitives/contentPart/ContentPartText.js.map +1 -1
- package/dist/primitives/contentPart/ContentPartText.mjs.map +1 -1
- package/dist/primitives/message/MessageRoot.d.ts +2 -2
- package/dist/primitives/message/MessageRoot.d.ts.map +1 -1
- package/dist/primitives/message/MessageRoot.js.map +1 -1
- package/dist/primitives/message/MessageRoot.mjs.map +1 -1
- package/dist/primitives/thread/ThreadRoot.d.ts +2 -2
- package/dist/primitives/thread/ThreadRoot.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadRoot.js.map +1 -1
- package/dist/primitives/thread/ThreadRoot.mjs.map +1 -1
- package/dist/primitives/thread/ThreadViewport.d.ts +2 -2
- package/dist/primitives/thread/ThreadViewport.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadViewport.js.map +1 -1
- package/dist/primitives/thread/ThreadViewport.mjs.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.d.ts +2 -2
- package/dist/primitives/threadListItem/ThreadListItemRoot.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.mjs.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js +2 -2
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs +2 -2
- package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts +7 -3
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js +17 -14
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs +24 -15
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +3 -2
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +94 -64
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs +95 -65
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.d.ts +2 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.js +3 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.js.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.mjs +3 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.d.ts +10 -6
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.js +25 -8
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.js.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.mjs +25 -8
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.d.ts +2 -2
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.js +7 -8
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.js.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.mjs +7 -8
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudRuns.d.ts +15 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudRuns.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/{CloudContext.js → AssistantCloudRuns.js} +23 -9
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudRuns.js.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudRuns.mjs +21 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudRuns.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.d.ts +22 -0
- package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.js +85 -0
- package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.js.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.mjs +60 -0
- package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/index.d.ts +1 -1
- package/dist/runtimes/remote-thread-list/cloud/index.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/index.js +3 -3
- package/dist/runtimes/remote-thread-list/cloud/index.js.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/index.mjs +2 -2
- package/dist/runtimes/remote-thread-list/cloud/index.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.js +47 -19
- package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.js.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.mjs +54 -20
- package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/index.d.ts +2 -0
- package/dist/runtimes/remote-thread-list/index.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/index.js +9 -0
- package/dist/runtimes/remote-thread-list/index.js.map +1 -1
- package/dist/runtimes/remote-thread-list/index.mjs +4 -0
- package/dist/runtimes/remote-thread-list/index.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +11 -4
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/types.js.map +1 -1
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js +1 -0
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs +1 -0
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs.map +1 -1
- package/dist/styles/index.css.map +1 -1
- package/dist/ui/base/button.d.ts.map +1 -1
- package/dist/ui/base/button.js.map +1 -1
- package/dist/ui/base/button.mjs.map +1 -1
- package/dist/ui/base/dialog.js.map +1 -1
- package/dist/ui/base/dialog.mjs.map +1 -1
- package/dist/utils/createActionButton.d.ts +2 -2
- package/dist/utils/createActionButton.d.ts.map +1 -1
- package/dist/utils/createActionButton.js.map +1 -1
- package/dist/utils/createActionButton.mjs.map +1 -1
- package/package.json +9 -12
- package/src/primitives/actionBar/ActionBarRoot.tsx +2 -2
- package/src/primitives/assistantModal/AssistantModalAnchor.tsx +2 -2
- package/src/primitives/assistantModal/AssistantModalContent.tsx +2 -2
- package/src/primitives/assistantModal/AssistantModalTrigger.tsx +2 -2
- package/src/primitives/assistantModal/scope.tsx +1 -1
- package/src/primitives/attachment/AttachmentRoot.tsx +2 -2
- package/src/primitives/attachment/AttachmentThumb.tsx +2 -2
- package/src/primitives/branchPicker/BranchPickerRoot.tsx +2 -2
- package/src/primitives/composer/ComposerRoot.tsx +2 -2
- package/src/primitives/contentPart/ContentPartImage.tsx +2 -2
- package/src/primitives/contentPart/ContentPartText.tsx +2 -2
- package/src/primitives/message/MessageRoot.tsx +2 -2
- package/src/primitives/thread/ThreadRoot.tsx +2 -2
- package/src/primitives/thread/ThreadViewport.tsx +2 -2
- package/src/primitives/threadListItem/ThreadListItemRoot.tsx +2 -2
- package/src/runtimes/local/LocalThreadListRuntimeCore.tsx +2 -2
- package/src/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +43 -25
- package/src/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +119 -80
- package/src/runtimes/remote-thread-list/cloud/AssistantCloud.tsx +3 -0
- package/src/runtimes/remote-thread-list/cloud/AssistantCloudAPI.tsx +36 -16
- package/src/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.tsx +5 -6
- package/src/runtimes/remote-thread-list/cloud/AssistantCloudRuns.tsx +26 -0
- package/src/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.tsx +89 -0
- package/src/runtimes/remote-thread-list/cloud/index.ts +1 -1
- package/src/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.tsx +63 -28
- package/src/runtimes/remote-thread-list/index.ts +2 -1
- package/src/runtimes/remote-thread-list/types.tsx +18 -6
- package/src/runtimes/remote-thread-list/useRemoteThreadListRuntime.tsx +1 -0
- package/src/ui/base/button.tsx +2 -2
- package/src/ui/base/dialog.tsx +5 -5
- package/src/utils/createActionButton.tsx +2 -2
- package/dist/runtimes/remote-thread-list/cloud/CloudContext.d.ts +0 -10
- package/dist/runtimes/remote-thread-list/cloud/CloudContext.d.ts.map +0 -1
- package/dist/runtimes/remote-thread-list/cloud/CloudContext.js.map +0 -1
- package/dist/runtimes/remote-thread-list/cloud/CloudContext.mjs +0 -7
- package/dist/runtimes/remote-thread-list/cloud/CloudContext.mjs.map +0 -1
- package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.d.ts +0 -4
- package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.d.ts.map +0 -1
- package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.js +0 -46
- package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.js.map +0 -1
- package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.mjs +0 -22
- package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.mjs.map +0 -1
- package/src/runtimes/remote-thread-list/cloud/CloudContext.tsx +0 -12
- package/src/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.tsx +0 -19
package/package.json
CHANGED
@@ -29,7 +29,7 @@
|
|
29
29
|
"conversational-ui",
|
30
30
|
"conversational-ai"
|
31
31
|
],
|
32
|
-
"version": "0.7.
|
32
|
+
"version": "0.7.40",
|
33
33
|
"license": "MIT",
|
34
34
|
"exports": {
|
35
35
|
".": {
|
@@ -80,13 +80,14 @@
|
|
80
80
|
"class-variance-authority": "^0.7.1",
|
81
81
|
"classnames": "^2.5.1",
|
82
82
|
"json-schema": "^0.4.0",
|
83
|
-
"lucide-react": "^0.
|
83
|
+
"lucide-react": "^0.473.0",
|
84
84
|
"nanoid": "^5.0.9",
|
85
85
|
"react-textarea-autosize": "^8.5.7",
|
86
86
|
"secure-json-parse": "^3.0.2",
|
87
87
|
"zod": "^3.24.1",
|
88
88
|
"zod-to-json-schema": "^3.24.1",
|
89
|
-
"zustand": "^5.0.3"
|
89
|
+
"zustand": "^5.0.3",
|
90
|
+
"assistant-stream": "^0.0.18"
|
90
91
|
},
|
91
92
|
"peerDependencies": {
|
92
93
|
"@types/react": "*",
|
@@ -108,21 +109,17 @@
|
|
108
109
|
},
|
109
110
|
"devDependencies": {
|
110
111
|
"@types/json-schema": "^7.0.15",
|
111
|
-
"@types/node": "^22.10.
|
112
|
+
"@types/node": "^22.10.7",
|
112
113
|
"autoprefixer": "^10.4.20",
|
113
|
-
"esbuild-plugin-file-path-extensions": "^2.1.4",
|
114
114
|
"eslint": "^9",
|
115
|
-
"eslint-config-next": "15.1.
|
116
|
-
"postcss": "^8.
|
117
|
-
"postcss-js": "^4.0.1",
|
118
|
-
"postcss-nested": "^7.0.2",
|
115
|
+
"eslint-config-next": "15.1.5",
|
116
|
+
"postcss": "^8.5.1",
|
119
117
|
"tailwindcss": "^3.4.17",
|
120
118
|
"tailwindcss-animate": "^1.0.7",
|
121
|
-
"tsup": "8.3.5",
|
122
119
|
"tsx": "^4.19.2",
|
123
|
-
"@assistant-ui/tailwindcss-transformer": "0.1.0",
|
124
120
|
"@assistant-ui/tsbuildutils": "^0.0.1",
|
125
|
-
"@assistant-ui/tsconfig": "0.0.0"
|
121
|
+
"@assistant-ui/tsconfig": "0.0.0",
|
122
|
+
"@assistant-ui/tailwindcss-transformer": "0.1.0"
|
126
123
|
},
|
127
124
|
"publishConfig": {
|
128
125
|
"access": "public",
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client";
|
2
2
|
|
3
3
|
import { Primitive } from "@radix-ui/react-primitive";
|
4
|
-
import { type
|
4
|
+
import { type ComponentRef, forwardRef, ComponentPropsWithoutRef } from "react";
|
5
5
|
import {
|
6
6
|
useActionBarFloatStatus,
|
7
7
|
HideAndFloatStatus,
|
@@ -11,7 +11,7 @@ import {
|
|
11
11
|
type PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;
|
12
12
|
|
13
13
|
export namespace ActionBarPrimitiveRoot {
|
14
|
-
export type Element =
|
14
|
+
export type Element = ComponentRef<typeof Primitive.div>;
|
15
15
|
export type Props = PrimitiveDivProps & UseActionBarFloatStatusProps;
|
16
16
|
}
|
17
17
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
"use client";
|
2
2
|
|
3
|
-
import { ComponentPropsWithoutRef,
|
3
|
+
import { ComponentPropsWithoutRef, ComponentRef, forwardRef } from "react";
|
4
4
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
5
5
|
import { ScopedProps, usePopoverScope } from "./scope";
|
6
6
|
|
7
7
|
export namespace AssistantModalPrimitiveAnchor {
|
8
|
-
export type Element =
|
8
|
+
export type Element = ComponentRef<typeof PopoverPrimitive.Anchor>;
|
9
9
|
export type Props = ComponentPropsWithoutRef<typeof PopoverPrimitive.Anchor>;
|
10
10
|
}
|
11
11
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
"use client";
|
2
2
|
|
3
|
-
import { ComponentPropsWithoutRef,
|
3
|
+
import { ComponentPropsWithoutRef, ComponentRef, forwardRef } from "react";
|
4
4
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
5
5
|
import { ScopedProps, usePopoverScope } from "./scope";
|
6
6
|
import { composeEventHandlers } from "@radix-ui/primitive";
|
7
7
|
|
8
8
|
export namespace AssistantModalPrimitiveContent {
|
9
|
-
export type Element =
|
9
|
+
export type Element = ComponentRef<typeof PopoverPrimitive.Content>;
|
10
10
|
export type Props = ComponentPropsWithoutRef<
|
11
11
|
typeof PopoverPrimitive.Content
|
12
12
|
> & {
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { ComponentPropsWithoutRef,
|
1
|
+
import { ComponentPropsWithoutRef, ComponentRef, forwardRef } from "react";
|
2
2
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
3
3
|
import { ScopedProps, usePopoverScope } from "./scope";
|
4
4
|
|
5
5
|
export namespace AssistantModalPrimitiveTrigger {
|
6
|
-
export type Element =
|
6
|
+
export type Element = ComponentRef<typeof PopoverPrimitive.Trigger>;
|
7
7
|
export type Props = ComponentPropsWithoutRef<typeof PopoverPrimitive.Trigger>;
|
8
8
|
}
|
9
9
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
2
2
|
import type { Scope } from "@radix-ui/react-context";
|
3
3
|
|
4
|
-
export type ScopedProps<P> = P & { __scopeAssistantModal?: Scope };
|
5
4
|
export const usePopoverScope = PopoverPrimitive.createPopoverScope();
|
5
|
+
export type ScopedProps<P> = P & { __scopeAssistantModal?: Scope };
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { Primitive } from "@radix-ui/react-primitive";
|
2
|
-
import { ComponentPropsWithoutRef,
|
2
|
+
import { ComponentPropsWithoutRef, ComponentRef, forwardRef } from "react";
|
3
3
|
|
4
4
|
type PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;
|
5
5
|
|
6
6
|
export namespace AttachmentPrimitiveRoot {
|
7
|
-
export type Element =
|
7
|
+
export type Element = ComponentRef<typeof Primitive.div>;
|
8
8
|
export type Props = PrimitiveDivProps;
|
9
9
|
}
|
10
10
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
"use client";
|
2
2
|
|
3
|
-
import { ComponentPropsWithoutRef, forwardRef, type
|
3
|
+
import { ComponentPropsWithoutRef, forwardRef, type ComponentRef } from "react";
|
4
4
|
import { useAttachment } from "../../context/react/AttachmentContext";
|
5
5
|
import { Primitive } from "@radix-ui/react-primitive";
|
6
6
|
|
7
7
|
type PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;
|
8
8
|
|
9
9
|
export namespace AttachmentPrimitiveThumb {
|
10
|
-
export type Element =
|
10
|
+
export type Element = ComponentRef<typeof Primitive.div>;
|
11
11
|
export type Props = PrimitiveDivProps;
|
12
12
|
}
|
13
13
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { Primitive } from "@radix-ui/react-primitive";
|
2
|
-
import { type
|
2
|
+
import { type ComponentRef, forwardRef, ComponentPropsWithoutRef } from "react";
|
3
3
|
import { If } from "../message";
|
4
4
|
|
5
5
|
export namespace BranchPickerPrimitiveRoot {
|
6
|
-
export type Element =
|
6
|
+
export type Element = ComponentRef<typeof Primitive.div>;
|
7
7
|
export type Props = ComponentPropsWithoutRef<typeof Primitive.div> & {
|
8
8
|
hideWhenSingleBranch?: boolean | undefined;
|
9
9
|
};
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import { composeEventHandlers } from "@radix-ui/primitive";
|
4
4
|
import { Primitive } from "@radix-ui/react-primitive";
|
5
5
|
import {
|
6
|
-
type
|
6
|
+
type ComponentRef,
|
7
7
|
type FormEvent,
|
8
8
|
forwardRef,
|
9
9
|
ComponentPropsWithoutRef,
|
@@ -11,7 +11,7 @@ import {
|
|
11
11
|
import { useComposerSend } from "../../primitive-hooks/composer/useComposerSend";
|
12
12
|
|
13
13
|
export namespace ComposerPrimitiveRoot {
|
14
|
-
export type Element =
|
14
|
+
export type Element = ComponentRef<typeof Primitive.form>;
|
15
15
|
export type Props = ComponentPropsWithoutRef<typeof Primitive.form>;
|
16
16
|
}
|
17
17
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
"use client";
|
2
2
|
|
3
3
|
import { Primitive } from "@radix-ui/react-primitive";
|
4
|
-
import { type
|
4
|
+
import { type ComponentRef, forwardRef, ComponentPropsWithoutRef } from "react";
|
5
5
|
import { useContentPartImage } from "../../primitive-hooks/contentPart/useContentPartImage";
|
6
6
|
|
7
7
|
export namespace ContentPartPrimitiveImage {
|
8
|
-
export type Element =
|
8
|
+
export type Element = ComponentRef<typeof Primitive.img>;
|
9
9
|
export type Props = ComponentPropsWithoutRef<typeof Primitive.img>;
|
10
10
|
}
|
11
11
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
import { Primitive } from "@radix-ui/react-primitive";
|
4
4
|
import {
|
5
|
-
type
|
5
|
+
type ComponentRef,
|
6
6
|
forwardRef,
|
7
7
|
ComponentPropsWithoutRef,
|
8
8
|
ElementType,
|
@@ -11,7 +11,7 @@ import { useContentPartText } from "../../primitive-hooks/contentPart/useContent
|
|
11
11
|
import { useSmooth } from "../../utils/smooth/useSmooth";
|
12
12
|
|
13
13
|
export namespace ContentPartPrimitiveText {
|
14
|
-
export type Element =
|
14
|
+
export type Element = ComponentRef<typeof Primitive.span>;
|
15
15
|
export type Props = Omit<
|
16
16
|
ComponentPropsWithoutRef<typeof Primitive.span>,
|
17
17
|
"children" | "asChild"
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
import { Primitive } from "@radix-ui/react-primitive";
|
4
4
|
import {
|
5
|
-
type
|
5
|
+
type ComponentRef,
|
6
6
|
forwardRef,
|
7
7
|
ComponentPropsWithoutRef,
|
8
8
|
useCallback,
|
@@ -40,7 +40,7 @@ const useIsHoveringRef = () => {
|
|
40
40
|
};
|
41
41
|
|
42
42
|
export namespace MessagePrimitiveRoot {
|
43
|
-
export type Element =
|
43
|
+
export type Element = ComponentRef<typeof Primitive.div>;
|
44
44
|
export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;
|
45
45
|
}
|
46
46
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Primitive } from "@radix-ui/react-primitive";
|
2
|
-
import { type
|
2
|
+
import { type ComponentRef, forwardRef, ComponentPropsWithoutRef } from "react";
|
3
3
|
|
4
4
|
export namespace ThreadPrimitiveRoot {
|
5
|
-
export type Element =
|
5
|
+
export type Element = ComponentRef<typeof Primitive.div>;
|
6
6
|
export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;
|
7
7
|
}
|
8
8
|
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
4
4
|
import { Primitive } from "@radix-ui/react-primitive";
|
5
|
-
import { type
|
5
|
+
import { type ComponentRef, forwardRef, ComponentPropsWithoutRef } from "react";
|
6
6
|
import { useThreadViewportAutoScroll } from "../../primitive-hooks/thread/useThreadViewportAutoScroll";
|
7
7
|
|
8
8
|
export namespace ThreadPrimitiveViewport {
|
9
|
-
export type Element =
|
9
|
+
export type Element = ComponentRef<typeof Primitive.div>;
|
10
10
|
export type Props = ComponentPropsWithoutRef<typeof Primitive.div> &
|
11
11
|
useThreadViewportAutoScroll.Options;
|
12
12
|
}
|
@@ -1,13 +1,13 @@
|
|
1
1
|
"use client";
|
2
2
|
|
3
3
|
import { Primitive } from "@radix-ui/react-primitive";
|
4
|
-
import { type
|
4
|
+
import { type ComponentRef, forwardRef, ComponentPropsWithoutRef } from "react";
|
5
5
|
import { useThreadListItem } from "../../context/react/ThreadListItemContext";
|
6
6
|
|
7
7
|
type PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;
|
8
8
|
|
9
9
|
export namespace ThreadListItemPrimitiveRoot {
|
10
|
-
export type Element =
|
10
|
+
export type Element = ComponentRef<typeof Primitive.div>;
|
11
11
|
export type Props = PrimitiveDivProps;
|
12
12
|
}
|
13
13
|
|
@@ -132,11 +132,11 @@ export class LocalThreadListRuntimeCore implements ThreadListRuntimeCore {
|
|
132
132
|
// newState
|
133
133
|
switch (newState) {
|
134
134
|
case "regular":
|
135
|
-
this._threadIds = [...this._threadIds
|
135
|
+
this._threadIds = [data.threadId, ...this._threadIds];
|
136
136
|
break;
|
137
137
|
|
138
138
|
case "archived":
|
139
|
-
this._archivedThreadIds = [...this._archivedThreadIds
|
139
|
+
this._archivedThreadIds = [data.threadId, ...this._archivedThreadIds];
|
140
140
|
break;
|
141
141
|
|
142
142
|
case "deleted":
|
@@ -1,13 +1,24 @@
|
|
1
1
|
"use client";
|
2
2
|
|
3
|
-
import {
|
3
|
+
import {
|
4
|
+
FC,
|
5
|
+
useCallback,
|
6
|
+
useRef,
|
7
|
+
useEffect,
|
8
|
+
memo,
|
9
|
+
useMemo,
|
10
|
+
PropsWithChildren,
|
11
|
+
ComponentType,
|
12
|
+
} from "react";
|
4
13
|
import { UseBoundStore, StoreApi, create } from "zustand";
|
5
14
|
import { useAssistantRuntime } from "../../context";
|
6
15
|
import { ThreadListItemRuntimeProvider } from "../../context/providers/ThreadListItemRuntimeProvider";
|
7
16
|
import { useThreadListItem } from "../../context/react/ThreadListItemContext";
|
8
17
|
import { ThreadRuntimeCore, ThreadRuntimeImpl } from "../../internal";
|
9
18
|
import { BaseSubscribable } from "./BaseSubscribable";
|
10
|
-
import {
|
19
|
+
import { AssistantRuntime } from "../../api";
|
20
|
+
|
21
|
+
type RemoteThreadListHook = () => AssistantRuntime;
|
11
22
|
|
12
23
|
type RemoteThreadListHookInstance = {
|
13
24
|
runtime?: ThreadRuntimeCore;
|
@@ -104,31 +115,38 @@ export class RemoteThreadListHookInstanceManager extends BaseSubscribable {
|
|
104
115
|
return null;
|
105
116
|
};
|
106
117
|
|
107
|
-
private _OuterActiveThreadProvider: FC<{
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
)
|
114
|
-
|
115
|
-
|
116
|
-
|
118
|
+
private _OuterActiveThreadProvider: FC<{
|
119
|
+
threadId: string;
|
120
|
+
provider: ComponentType<PropsWithChildren>;
|
121
|
+
}> = memo(({ threadId, provider: Provider }) => {
|
122
|
+
const assistantRuntime = useAssistantRuntime();
|
123
|
+
const threadListItemRuntime = useMemo(
|
124
|
+
() => assistantRuntime.threadList.getItemById(threadId),
|
125
|
+
[assistantRuntime, threadId],
|
126
|
+
);
|
127
|
+
|
128
|
+
return (
|
129
|
+
<ThreadListItemRuntimeProvider runtime={threadListItemRuntime}>
|
130
|
+
<Provider>
|
117
131
|
<this._InnerActiveThreadProvider />
|
118
|
-
</
|
119
|
-
|
120
|
-
|
121
|
-
);
|
122
|
-
|
123
|
-
public __internal_RenderThreadRuntimes: FC
|
132
|
+
</Provider>
|
133
|
+
</ThreadListItemRuntimeProvider>
|
134
|
+
);
|
135
|
+
});
|
136
|
+
|
137
|
+
public __internal_RenderThreadRuntimes: FC<{
|
138
|
+
provider: ComponentType<PropsWithChildren>;
|
139
|
+
}> = ({ provider }) => {
|
124
140
|
this.useAliveThreadsKeysChanged(); // trigger re-render on alive threads change
|
125
141
|
|
126
|
-
return
|
127
|
-
|
128
|
-
|
129
|
-
.
|
130
|
-
|
131
|
-
|
132
|
-
|
142
|
+
return this.instances
|
143
|
+
.keys()
|
144
|
+
.map((threadId) => (
|
145
|
+
<this._OuterActiveThreadProvider
|
146
|
+
key={threadId}
|
147
|
+
threadId={threadId}
|
148
|
+
provider={provider}
|
149
|
+
/>
|
150
|
+
));
|
133
151
|
};
|
134
152
|
}
|
@@ -2,14 +2,17 @@
|
|
2
2
|
|
3
3
|
import { ThreadListRuntimeCore } from "../core/ThreadListRuntimeCore";
|
4
4
|
import { generateId } from "../../internal";
|
5
|
-
import {
|
5
|
+
import {
|
6
|
+
RemoteThreadInitializeResponse,
|
7
|
+
RemoteThreadListAdapter,
|
8
|
+
} from "./types";
|
6
9
|
import { RemoteThreadListHookInstanceManager } from "./RemoteThreadListHookInstanceManager";
|
7
10
|
import { BaseSubscribable } from "./BaseSubscribable";
|
8
11
|
import { EMPTY_THREAD_CORE } from "./EMPTY_THREAD_CORE";
|
9
12
|
import { OptimisticState } from "./OptimisticState";
|
10
13
|
import { FC, Fragment, useEffect, useId } from "react";
|
11
14
|
import { create } from "zustand";
|
12
|
-
import {
|
15
|
+
import { AssistantStream, AssistantMessageStream } from "assistant-stream";
|
13
16
|
|
14
17
|
type RemoteThreadData =
|
15
18
|
| {
|
@@ -128,10 +131,9 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
128
131
|
implements ThreadListRuntimeCore
|
129
132
|
{
|
130
133
|
private _adapter!: RemoteThreadListAdapter;
|
131
|
-
private _disposeOldAdapter?: () => void;
|
132
134
|
private readonly _hookManager: RemoteThreadListHookInstanceManager;
|
133
135
|
|
134
|
-
private
|
136
|
+
private _loadThreadsPromise: Promise<void> | undefined;
|
135
137
|
|
136
138
|
private _mainThreadId!: string;
|
137
139
|
private readonly _state = new OptimisticState<RemoteThreadState>({
|
@@ -144,6 +146,69 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
144
146
|
});
|
145
147
|
|
146
148
|
public getLoadThreadsPromise() {
|
149
|
+
// TODO this needs to be cached in case this promise is loaded during suspense
|
150
|
+
if (!this._loadThreadsPromise) {
|
151
|
+
this._loadThreadsPromise = this._state
|
152
|
+
.optimisticUpdate({
|
153
|
+
execute: () => this._adapter.list(),
|
154
|
+
loading: (state) => {
|
155
|
+
return {
|
156
|
+
...state,
|
157
|
+
isLoading: true,
|
158
|
+
};
|
159
|
+
},
|
160
|
+
then: (state, l) => {
|
161
|
+
const newThreadIds = [];
|
162
|
+
const newArchivedThreadIds = [];
|
163
|
+
const newThreadIdMap = {} as Record<string, THREAD_MAPPING_ID>;
|
164
|
+
const newThreadData = {} as Record<
|
165
|
+
THREAD_MAPPING_ID,
|
166
|
+
RemoteThreadData
|
167
|
+
>;
|
168
|
+
|
169
|
+
for (const thread of l.threads) {
|
170
|
+
switch (thread.status) {
|
171
|
+
case "regular":
|
172
|
+
newThreadIds.push(thread.remoteId);
|
173
|
+
break;
|
174
|
+
case "archived":
|
175
|
+
newArchivedThreadIds.push(thread.remoteId);
|
176
|
+
break;
|
177
|
+
default: {
|
178
|
+
const _exhaustiveCheck: never = thread.status;
|
179
|
+
throw new Error(`Unsupported state: ${_exhaustiveCheck}`);
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
const mappingId = createThreadMappingId(thread.remoteId);
|
184
|
+
newThreadIdMap[thread.remoteId] = mappingId;
|
185
|
+
newThreadData[mappingId] = {
|
186
|
+
threadId: thread.remoteId,
|
187
|
+
remoteId: thread.remoteId,
|
188
|
+
externalId: thread.externalId,
|
189
|
+
status: thread.status,
|
190
|
+
title: thread.title,
|
191
|
+
};
|
192
|
+
}
|
193
|
+
|
194
|
+
return {
|
195
|
+
...state,
|
196
|
+
threadIds: newThreadIds,
|
197
|
+
archivedThreadIds: newArchivedThreadIds,
|
198
|
+
threadIdMap: {
|
199
|
+
...state.threadIdMap,
|
200
|
+
...newThreadIdMap,
|
201
|
+
},
|
202
|
+
threadData: {
|
203
|
+
...state.threadData,
|
204
|
+
...newThreadData,
|
205
|
+
},
|
206
|
+
};
|
207
|
+
},
|
208
|
+
})
|
209
|
+
.then(() => {});
|
210
|
+
}
|
211
|
+
|
147
212
|
return this._loadThreadsPromise;
|
148
213
|
}
|
149
214
|
|
@@ -159,66 +224,6 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
159
224
|
}));
|
160
225
|
this.__internal_setAdapter(adapter);
|
161
226
|
|
162
|
-
this._loadThreadsPromise = this._state
|
163
|
-
.optimisticUpdate({
|
164
|
-
execute: () => adapter.list(),
|
165
|
-
loading: (state) => {
|
166
|
-
return {
|
167
|
-
...state,
|
168
|
-
isLoading: true,
|
169
|
-
};
|
170
|
-
},
|
171
|
-
then: (state, l) => {
|
172
|
-
const newThreadIds = [];
|
173
|
-
const newArchivedThreadIds = [];
|
174
|
-
const newThreadIdMap = {} as Record<string, THREAD_MAPPING_ID>;
|
175
|
-
const newThreadData = {} as Record<
|
176
|
-
THREAD_MAPPING_ID,
|
177
|
-
RemoteThreadData
|
178
|
-
>;
|
179
|
-
|
180
|
-
for (const thread of l.threads) {
|
181
|
-
switch (thread.status) {
|
182
|
-
case "regular":
|
183
|
-
newThreadIds.push(thread.remoteId);
|
184
|
-
break;
|
185
|
-
case "archived":
|
186
|
-
newArchivedThreadIds.push(thread.remoteId);
|
187
|
-
break;
|
188
|
-
default: {
|
189
|
-
const _exhaustiveCheck: never = thread.status;
|
190
|
-
throw new Error(`Unsupported state: ${_exhaustiveCheck}`);
|
191
|
-
}
|
192
|
-
}
|
193
|
-
|
194
|
-
const mappingId = createThreadMappingId(thread.remoteId);
|
195
|
-
newThreadIdMap[thread.remoteId] = mappingId;
|
196
|
-
newThreadData[mappingId] = {
|
197
|
-
threadId: thread.remoteId,
|
198
|
-
remoteId: thread.remoteId,
|
199
|
-
externalId: thread.externalId,
|
200
|
-
status: thread.status,
|
201
|
-
title: thread.title,
|
202
|
-
};
|
203
|
-
}
|
204
|
-
|
205
|
-
return {
|
206
|
-
...state,
|
207
|
-
threadIds: newThreadIds,
|
208
|
-
archivedThreadIds: newArchivedThreadIds,
|
209
|
-
threadIdMap: {
|
210
|
-
...state.threadIdMap,
|
211
|
-
...newThreadIdMap,
|
212
|
-
},
|
213
|
-
threadData: {
|
214
|
-
...state.threadData,
|
215
|
-
...newThreadData,
|
216
|
-
},
|
217
|
-
};
|
218
|
-
},
|
219
|
-
})
|
220
|
-
.then(() => {});
|
221
|
-
|
222
227
|
this.switchToNewThread();
|
223
228
|
}
|
224
229
|
|
@@ -228,8 +233,6 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
228
233
|
if (this._adapter === adapter) return;
|
229
234
|
|
230
235
|
this._adapter = adapter;
|
231
|
-
this._disposeOldAdapter?.();
|
232
|
-
this._disposeOldAdapter = this._adapter.onInitialize(this._onInitialize);
|
233
236
|
|
234
237
|
const Provider = adapter.unstable_Provider ?? Fragment;
|
235
238
|
if (Provider !== this.useProvider.getState().Provider) {
|
@@ -239,6 +242,14 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
239
242
|
this._hookManager.setRuntimeHook(adapter.runtimeHook);
|
240
243
|
}
|
241
244
|
|
245
|
+
public __internal_bindAdapter() {
|
246
|
+
this.getLoadThreadsPromise(); // begin loading on initial bind
|
247
|
+
return this._adapter.subscribe({
|
248
|
+
onInitialize: this._onInitialize,
|
249
|
+
onGenerateTitle: this._onGenerateTitle,
|
250
|
+
});
|
251
|
+
}
|
252
|
+
|
242
253
|
public get threadIds() {
|
243
254
|
return this._state.value.threadIds;
|
244
255
|
}
|
@@ -321,16 +332,16 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
321
332
|
return this.switchToThread(threadId);
|
322
333
|
}
|
323
334
|
|
324
|
-
private _onInitialize = async (
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
);
|
335
|
+
private _onInitialize = async (
|
336
|
+
threadId: string,
|
337
|
+
begin: () => Promise<RemoteThreadInitializeResponse>,
|
338
|
+
) => {
|
339
|
+
if (this._state.value.newThreadId !== threadId)
|
340
|
+
throw new Error("The provided thread is already initialized");
|
330
341
|
|
331
342
|
await this._state.optimisticUpdate({
|
332
343
|
execute: () => {
|
333
|
-
return
|
344
|
+
return begin();
|
334
345
|
},
|
335
346
|
optimistic: (state) => {
|
336
347
|
return updateStatusReducer(state, threadId, "regular");
|
@@ -339,7 +350,7 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
339
350
|
const data = getThreadData(state, threadId);
|
340
351
|
if (!data) return state;
|
341
352
|
|
342
|
-
const mappingId = createThreadMappingId(
|
353
|
+
const mappingId = createThreadMappingId(threadId);
|
343
354
|
return {
|
344
355
|
...state,
|
345
356
|
threadIdMap: {
|
@@ -359,6 +370,34 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
359
370
|
});
|
360
371
|
};
|
361
372
|
|
373
|
+
private _onGenerateTitle = async (
|
374
|
+
remoteId: string,
|
375
|
+
begin: () => Promise<AssistantStream>,
|
376
|
+
) => {
|
377
|
+
const data = this.getItemById(remoteId);
|
378
|
+
if (!data) throw new Error("Thread not found");
|
379
|
+
if (data.status === "new") throw new Error("Thread is not yet initialized");
|
380
|
+
|
381
|
+
const stream = await begin();
|
382
|
+
const messageStream = AssistantMessageStream.fromAssistantStream(stream);
|
383
|
+
for await (const result of messageStream) {
|
384
|
+
const newTitle =
|
385
|
+
result.content.filter((c) => c.type === "text")[0]?.text ??
|
386
|
+
"New Thread";
|
387
|
+
const state = this._state.baseValue;
|
388
|
+
this._state.update({
|
389
|
+
...state,
|
390
|
+
threadData: {
|
391
|
+
...state.threadData,
|
392
|
+
[data.threadId]: {
|
393
|
+
...data,
|
394
|
+
title: newTitle,
|
395
|
+
},
|
396
|
+
},
|
397
|
+
});
|
398
|
+
}
|
399
|
+
};
|
400
|
+
|
362
401
|
public rename(threadIdOrRemoteId: string, newTitle: string): Promise<void> {
|
363
402
|
const data = this.getItemById(threadIdOrRemoteId);
|
364
403
|
if (!data) throw new Error("Thread not found");
|
@@ -467,12 +506,12 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
467
506
|
const { Provider } = this.useProvider();
|
468
507
|
|
469
508
|
return (
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
509
|
+
(boundIds.length === 0 || boundIds[0] === id) && (
|
510
|
+
// only render if the component is the first one mounted
|
511
|
+
<this._hookManager.__internal_RenderThreadRuntimes
|
512
|
+
provider={Provider}
|
513
|
+
/>
|
514
|
+
)
|
476
515
|
);
|
477
516
|
};
|
478
517
|
}
|