@assistant-ui/react 0.5.98 → 0.5.100
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/api/AssistantRuntime.d.ts +4 -4
- package/dist/api/AssistantRuntime.d.ts.map +1 -1
- package/dist/api/AssistantRuntime.js +7 -7
- package/dist/api/AssistantRuntime.js.map +1 -1
- package/dist/api/AssistantRuntime.mjs +7 -9
- package/dist/api/AssistantRuntime.mjs.map +1 -1
- package/dist/api/ComposerRuntime.d.ts +7 -0
- package/dist/api/ComposerRuntime.d.ts.map +1 -1
- package/dist/api/ComposerRuntime.js +13 -0
- package/dist/api/ComposerRuntime.js.map +1 -1
- package/dist/api/ComposerRuntime.mjs +13 -0
- package/dist/api/ComposerRuntime.mjs.map +1 -1
- package/dist/api/MessageRuntime.d.ts.map +1 -1
- package/dist/api/MessageRuntime.js +0 -5
- package/dist/api/MessageRuntime.js.map +1 -1
- package/dist/api/MessageRuntime.mjs +0 -5
- package/dist/api/MessageRuntime.mjs.map +1 -1
- package/dist/api/RuntimePathTypes.d.ts +16 -1
- package/dist/api/RuntimePathTypes.d.ts.map +1 -1
- package/dist/api/RuntimePathTypes.js.map +1 -1
- package/dist/api/ThreadListItemRuntime.d.ts +29 -0
- package/dist/api/ThreadListItemRuntime.d.ts.map +1 -0
- package/dist/api/ThreadListItemRuntime.js +61 -0
- package/dist/api/ThreadListItemRuntime.js.map +1 -0
- package/dist/api/ThreadListItemRuntime.mjs +36 -0
- package/dist/api/ThreadListItemRuntime.mjs.map +1 -0
- package/dist/api/ThreadListRuntime.d.ts +51 -0
- package/dist/api/ThreadListRuntime.d.ts.map +1 -0
- package/dist/api/ThreadListRuntime.js +128 -0
- package/dist/api/ThreadListRuntime.js.map +1 -0
- package/dist/api/ThreadListRuntime.mjs +105 -0
- package/dist/api/ThreadListRuntime.mjs.map +1 -0
- package/dist/api/ThreadRuntime.d.ts +3 -0
- package/dist/api/ThreadRuntime.d.ts.map +1 -1
- package/dist/api/ThreadRuntime.js +1 -1
- package/dist/api/ThreadRuntime.js.map +1 -1
- package/dist/api/ThreadRuntime.mjs +1 -1
- package/dist/api/ThreadRuntime.mjs.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.js +7 -9
- package/dist/context/providers/AssistantRuntimeProvider.js.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.mjs +7 -9
- package/dist/context/providers/AssistantRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/AttachmentRuntimeProvider.d.ts +6 -5
- package/dist/context/providers/AttachmentRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/AttachmentRuntimeProvider.js.map +1 -1
- package/dist/context/providers/AttachmentRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/ContentPartRuntimeProvider.d.ts +6 -5
- package/dist/context/providers/ContentPartRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/ContentPartRuntimeProvider.js +1 -4
- package/dist/context/providers/ContentPartRuntimeProvider.js.map +1 -1
- package/dist/context/providers/ContentPartRuntimeProvider.mjs +1 -4
- package/dist/context/providers/ContentPartRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/MessageRuntimeProvider.d.ts +6 -5
- package/dist/context/providers/MessageRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/MessageRuntimeProvider.js.map +1 -1
- package/dist/context/providers/MessageRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/TextContentPartProvider.d.ts +7 -6
- package/dist/context/providers/TextContentPartProvider.d.ts.map +1 -1
- package/dist/context/providers/TextContentPartProvider.js +5 -1
- package/dist/context/providers/TextContentPartProvider.js.map +1 -1
- package/dist/context/providers/TextContentPartProvider.mjs +5 -1
- package/dist/context/providers/TextContentPartProvider.mjs.map +1 -1
- package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts +13 -0
- package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -0
- package/dist/context/providers/ThreadListItemRuntimeProvider.js +62 -0
- package/dist/context/providers/ThreadListItemRuntimeProvider.js.map +1 -0
- package/dist/context/providers/ThreadListItemRuntimeProvider.mjs +39 -0
- package/dist/context/providers/ThreadListItemRuntimeProvider.mjs.map +1 -0
- package/dist/context/react/AssistantContext.d.ts +35 -11
- package/dist/context/react/AssistantContext.d.ts.map +1 -1
- package/dist/context/react/AssistantContext.js +4 -4
- package/dist/context/react/AssistantContext.js.map +1 -1
- package/dist/context/react/AssistantContext.mjs +3 -3
- package/dist/context/react/AssistantContext.mjs.map +1 -1
- package/dist/context/react/ThreadListItemContext.d.ts +58 -0
- package/dist/context/react/ThreadListItemContext.d.ts.map +1 -0
- package/dist/context/react/ThreadListItemContext.js +53 -0
- package/dist/context/react/ThreadListItemContext.js.map +1 -0
- package/dist/context/react/ThreadListItemContext.mjs +25 -0
- package/dist/context/react/ThreadListItemContext.mjs.map +1 -0
- package/dist/context/react/index.d.ts +1 -1
- package/dist/context/react/index.d.ts.map +1 -1
- package/dist/context/react/index.js +2 -2
- package/dist/context/react/index.js.map +1 -1
- package/dist/context/react/index.mjs +2 -2
- package/dist/context/react/index.mjs.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs.map +1 -1
- package/dist/primitives/index.d.ts +2 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +6 -0
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/index.mjs +4 -0
- package/dist/primitives/index.mjs.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.d.ts +11 -0
- package/dist/primitives/threadList/ThreadListItems.d.ts.map +1 -0
- package/dist/primitives/threadList/ThreadListItems.js +72 -0
- package/dist/primitives/threadList/ThreadListItems.js.map +1 -0
- package/dist/primitives/threadList/ThreadListItems.mjs +48 -0
- package/dist/primitives/threadList/ThreadListItems.mjs.map +1 -0
- package/dist/primitives/threadList/ThreadListNew.d.ts +13 -0
- package/dist/primitives/threadList/ThreadListNew.d.ts.map +1 -0
- package/dist/primitives/threadList/ThreadListNew.js +43 -0
- package/dist/primitives/threadList/ThreadListNew.js.map +1 -0
- package/dist/primitives/threadList/ThreadListNew.mjs +21 -0
- package/dist/primitives/threadList/ThreadListNew.mjs.map +1 -0
- package/dist/primitives/threadList/index.d.ts +3 -0
- package/dist/primitives/threadList/index.d.ts.map +1 -0
- package/dist/primitives/threadList/index.js +34 -0
- package/dist/primitives/threadList/index.js.map +1 -0
- package/dist/primitives/threadList/index.mjs +8 -0
- package/dist/primitives/threadList/index.mjs.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts +13 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.js +43 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.js.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.mjs +21 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.mjs.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts +13 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.js +43 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.js.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.mjs +21 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.mjs.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts +13 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js +43 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.mjs +21 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.mjs.map +1 -0
- package/dist/primitives/threadListItem/index.d.ts +4 -0
- package/dist/primitives/threadListItem/index.d.ts.map +1 -0
- package/dist/primitives/threadListItem/index.js +37 -0
- package/dist/primitives/threadListItem/index.js.map +1 -0
- package/dist/primitives/threadListItem/index.mjs +10 -0
- package/dist/primitives/threadListItem/index.mjs.map +1 -0
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts +5 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js +14 -5
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs +14 -5
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js +2 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs +2 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/core/AssistantRuntimeCore.d.ts +2 -2
- package/dist/runtimes/core/AssistantRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/AssistantRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/BaseAssistantRuntimeCore.d.ts +2 -2
- package/dist/runtimes/core/BaseAssistantRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/BaseAssistantRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/BaseAssistantRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/core/ComposerRuntimeCore.d.ts +3 -0
- package/dist/runtimes/core/ComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/{ThreadManagerRuntimeCore.d.ts → ThreadListRuntimeCore.d.ts} +7 -6
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts.map +1 -0
- package/dist/runtimes/core/{ThreadManagerRuntimeCore.js → ThreadListRuntimeCore.js} +4 -4
- package/dist/runtimes/core/ThreadListRuntimeCore.js.map +1 -0
- package/dist/runtimes/core/ThreadListRuntimeCore.mjs +1 -0
- package/dist/runtimes/core/subscribeToMainThread.js +2 -2
- package/dist/runtimes/core/subscribeToMainThread.js.map +1 -1
- package/dist/runtimes/core/subscribeToMainThread.mjs +2 -2
- package/dist/runtimes/core/subscribeToMainThread.mjs.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts +8 -8
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreAdapter.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.d.ts +2 -2
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js +8 -8
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.mjs +8 -8
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts +35 -0
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts.map +1 -0
- package/dist/runtimes/external-store/{ExternalStoreThreadManagementAdapter.js → ExternalStoreThreadListRuntimeCore.js} +21 -9
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js.map +1 -0
- package/dist/runtimes/external-store/{ExternalStoreThreadManagementAdapter.mjs → ExternalStoreThreadListRuntimeCore.mjs} +17 -5
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs.map +1 -0
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js +8 -3
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs +8 -3
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.d.ts +2 -2
- package/dist/runtimes/local/LocalRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.js +7 -7
- package/dist/runtimes/local/LocalRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.mjs +7 -7
- package/dist/runtimes/local/LocalRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/{LocalThreadManagerRuntimeCore.d.ts → LocalThreadListRuntimeCore.d.ts} +16 -6
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts.map +1 -0
- package/dist/runtimes/local/{LocalThreadManagerRuntimeCore.js → LocalThreadListRuntimeCore.js} +11 -8
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -0
- package/dist/runtimes/local/{LocalThreadManagerRuntimeCore.mjs → LocalThreadListRuntimeCore.mjs} +7 -4
- package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs.map +1 -0
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js +2 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs +2 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs.map +1 -1
- package/dist/types/AssistantTypes.d.ts +2 -0
- package/dist/types/AssistantTypes.d.ts.map +1 -1
- package/dist/types/AssistantTypes.js.map +1 -1
- package/package.json +7 -7
- package/src/api/AssistantRuntime.ts +9 -12
- package/src/api/ComposerRuntime.ts +17 -0
- package/src/api/MessageRuntime.ts +0 -9
- package/src/api/RuntimePathTypes.ts +10 -1
- package/src/api/ThreadListItemRuntime.ts +67 -0
- package/src/api/ThreadListRuntime.ts +159 -0
- package/src/api/ThreadRuntime.ts +2 -1
- package/src/api/index.ts +1 -4
- package/src/context/providers/AssistantRuntimeProvider.tsx +7 -9
- package/src/context/providers/AttachmentRuntimeProvider.tsx +6 -4
- package/src/context/providers/ContentPartRuntimeProvider.tsx +8 -7
- package/src/context/providers/MessageRuntimeProvider.tsx +6 -4
- package/src/context/providers/TextContentPartProvider.tsx +11 -7
- package/src/context/providers/ThreadListItemRuntimeProvider.tsx +54 -0
- package/src/context/react/AssistantContext.ts +4 -4
- package/src/context/react/ThreadListItemContext.ts +39 -0
- package/src/context/react/index.ts +2 -2
- package/src/internal.ts +1 -1
- package/src/primitives/index.ts +2 -0
- package/src/primitives/threadList/ThreadListItems.tsx +73 -0
- package/src/primitives/threadList/ThreadListNew.ts +25 -0
- package/src/primitives/threadList/index.ts +2 -0
- package/src/primitives/threadListItem/ThreadListItemArchive.ts +25 -0
- package/src/primitives/threadListItem/ThreadListItemDelete.ts +25 -0
- package/src/primitives/threadListItem/ThreadListItemUnarchive.ts +25 -0
- package/src/primitives/threadListItem/index.ts +3 -0
- package/src/runtimes/composer/BaseComposerRuntimeCore.tsx +19 -5
- package/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx +3 -2
- package/src/runtimes/core/AssistantRuntimeCore.tsx +2 -2
- package/src/runtimes/core/BaseAssistantRuntimeCore.tsx +2 -2
- package/src/runtimes/core/ComposerRuntimeCore.tsx +4 -0
- package/src/runtimes/core/{ThreadManagerRuntimeCore.tsx → ThreadListRuntimeCore.tsx} +7 -5
- package/src/runtimes/core/subscribeToMainThread.ts +2 -2
- package/src/runtimes/external-store/ExternalStoreAdapter.tsx +8 -8
- package/src/runtimes/external-store/ExternalStoreRuntimeCore.tsx +8 -8
- package/src/runtimes/external-store/{ExternalStoreThreadManagementAdapter.tsx → ExternalStoreThreadListRuntimeCore.tsx} +24 -9
- package/src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx +8 -3
- package/src/runtimes/local/LocalRuntimeCore.tsx +7 -7
- package/src/runtimes/local/{LocalThreadManagerRuntimeCore.tsx → LocalThreadListRuntimeCore.tsx} +11 -7
- package/src/runtimes/local/LocalThreadRuntimeCore.tsx +2 -1
- package/src/types/AssistantTypes.ts +3 -0
- package/dist/api/ThreadManagerRuntime.d.ts +0 -32
- package/dist/api/ThreadManagerRuntime.d.ts.map +0 -1
- package/dist/api/ThreadManagerRuntime.js +0 -73
- package/dist/api/ThreadManagerRuntime.js.map +0 -1
- package/dist/api/ThreadManagerRuntime.mjs +0 -48
- package/dist/api/ThreadManagerRuntime.mjs.map +0 -1
- package/dist/runtimes/core/ThreadManagerRuntimeCore.d.ts.map +0 -1
- package/dist/runtimes/core/ThreadManagerRuntimeCore.js.map +0 -1
- package/dist/runtimes/core/ThreadManagerRuntimeCore.mjs +0 -1
- package/dist/runtimes/external-store/ExternalStoreThreadManagementAdapter.d.ts +0 -25
- package/dist/runtimes/external-store/ExternalStoreThreadManagementAdapter.d.ts.map +0 -1
- package/dist/runtimes/external-store/ExternalStoreThreadManagementAdapter.js.map +0 -1
- package/dist/runtimes/external-store/ExternalStoreThreadManagementAdapter.mjs.map +0 -1
- package/dist/runtimes/local/LocalThreadManagerRuntimeCore.d.ts.map +0 -1
- package/dist/runtimes/local/LocalThreadManagerRuntimeCore.js.map +0 -1
- package/dist/runtimes/local/LocalThreadManagerRuntimeCore.mjs.map +0 -1
- package/src/api/ThreadManagerRuntime.ts +0 -80
- /package/dist/runtimes/core/{ThreadManagerRuntimeCore.mjs.map → ThreadListRuntimeCore.mjs.map} +0 -0
@@ -0,0 +1,159 @@
|
|
1
|
+
import { LazyMemoizeSubject } from "./subscribable/LazyMemoizeSubject";
|
2
|
+
import {
|
3
|
+
ThreadListMetadata,
|
4
|
+
ThreadListRuntimeCore,
|
5
|
+
} from "../runtimes/core/ThreadListRuntimeCore";
|
6
|
+
import { Unsubscribe } from "../types";
|
7
|
+
import { ThreadListRuntimePath } from "./RuntimePathTypes";
|
8
|
+
import {
|
9
|
+
ThreadListItemRuntime,
|
10
|
+
ThreadListItemRuntimeImpl,
|
11
|
+
} from "./ThreadListItemRuntime";
|
12
|
+
import { SKIP_UPDATE } from "./subscribable/SKIP_UPDATE";
|
13
|
+
|
14
|
+
export type ThreadListState = Readonly<{
|
15
|
+
threads: readonly ThreadListMetadata[];
|
16
|
+
archivedThreads: readonly ThreadListMetadata[];
|
17
|
+
}>;
|
18
|
+
|
19
|
+
export type ThreadListRuntime = Readonly<{
|
20
|
+
path: ThreadListRuntimePath;
|
21
|
+
getState(): ThreadListState;
|
22
|
+
|
23
|
+
/**
|
24
|
+
* @deprecated Use `getThreadListItemById(idx).rename(newTitle)` instead. This will be removed in 0.6.0.
|
25
|
+
*/
|
26
|
+
rename(threadId: string, newTitle: string): Promise<void>;
|
27
|
+
/**
|
28
|
+
* @deprecated Use `getThreadListItemById(idx).archive()` instead. This will be removed in 0.6.0.
|
29
|
+
*/
|
30
|
+
archive(threadId: string): Promise<void>;
|
31
|
+
/**
|
32
|
+
* @deprecated Use `getThreadListItemById(idx).unarchive()` instead. This will be removed in 0.6.0.
|
33
|
+
*/
|
34
|
+
unarchive(threadId: string): Promise<void>;
|
35
|
+
/**
|
36
|
+
* @deprecated Use `getThreadListItemById(idx).delete()` instead. This will be removed in 0.6.0.
|
37
|
+
*/
|
38
|
+
delete(threadId: string): Promise<void>;
|
39
|
+
|
40
|
+
subscribe(callback: () => void): Unsubscribe;
|
41
|
+
|
42
|
+
getThreadListItemById(threadId: string): ThreadListItemRuntime;
|
43
|
+
getThreadListItemByIndex(idx: number): ThreadListItemRuntime;
|
44
|
+
getThreadListArchivedItemByIndex(idx: number): ThreadListItemRuntime;
|
45
|
+
}>;
|
46
|
+
|
47
|
+
const getThreadListState = (
|
48
|
+
threadList: ThreadListRuntimeCore,
|
49
|
+
): ThreadListState => {
|
50
|
+
return {
|
51
|
+
threads: threadList.threads,
|
52
|
+
archivedThreads: threadList.archivedThreads,
|
53
|
+
};
|
54
|
+
};
|
55
|
+
|
56
|
+
const THREAD_MANAGER_PATH = {
|
57
|
+
ref: "ThreadList",
|
58
|
+
};
|
59
|
+
|
60
|
+
export type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;
|
61
|
+
|
62
|
+
export class ThreadListRuntimeImpl implements ThreadListRuntime {
|
63
|
+
public get path() {
|
64
|
+
return THREAD_MANAGER_PATH;
|
65
|
+
}
|
66
|
+
|
67
|
+
private _getState;
|
68
|
+
constructor(private _core: ThreadListRuntimeCoreBinding) {
|
69
|
+
const stateBinding = new LazyMemoizeSubject({
|
70
|
+
path: THREAD_MANAGER_PATH,
|
71
|
+
getState: () => getThreadListState(_core),
|
72
|
+
subscribe: (callback) => _core.subscribe(callback),
|
73
|
+
});
|
74
|
+
|
75
|
+
this._getState = stateBinding.getState.bind(stateBinding);
|
76
|
+
}
|
77
|
+
|
78
|
+
public getState(): ThreadListState {
|
79
|
+
return this._getState();
|
80
|
+
}
|
81
|
+
|
82
|
+
public rename(threadId: string, newTitle: string): Promise<void> {
|
83
|
+
return this._core.rename(threadId, newTitle);
|
84
|
+
}
|
85
|
+
|
86
|
+
public archive(threadId: string): Promise<void> {
|
87
|
+
return this._core.archive(threadId);
|
88
|
+
}
|
89
|
+
|
90
|
+
public unarchive(threadId: string): Promise<void> {
|
91
|
+
return this._core.unarchive(threadId);
|
92
|
+
}
|
93
|
+
|
94
|
+
public delete(threadId: string): Promise<void> {
|
95
|
+
return this._core.delete(threadId);
|
96
|
+
}
|
97
|
+
|
98
|
+
public subscribe(callback: () => void): Unsubscribe {
|
99
|
+
return this._core.subscribe(callback);
|
100
|
+
}
|
101
|
+
|
102
|
+
public getThreadListItemByIndex(idx: number) {
|
103
|
+
return new ThreadListItemRuntimeImpl(
|
104
|
+
new LazyMemoizeSubject({
|
105
|
+
path: {
|
106
|
+
ref: this.path.ref + `${this.path.ref}.threadItems[${idx}]`,
|
107
|
+
threadSelector: { type: "index", index: idx },
|
108
|
+
},
|
109
|
+
getState: () => {
|
110
|
+
const threads = this._core.threads;
|
111
|
+
const thread = threads[idx];
|
112
|
+
if (!thread) return SKIP_UPDATE;
|
113
|
+
return thread;
|
114
|
+
},
|
115
|
+
subscribe: (callback) => this._core.subscribe(callback),
|
116
|
+
}),
|
117
|
+
this._core,
|
118
|
+
);
|
119
|
+
}
|
120
|
+
|
121
|
+
public getThreadListArchivedItemByIndex(idx: number) {
|
122
|
+
return new ThreadListItemRuntimeImpl(
|
123
|
+
new LazyMemoizeSubject({
|
124
|
+
path: {
|
125
|
+
ref: this.path.ref + `${this.path.ref}.archivedThreadItems[${idx}]`,
|
126
|
+
threadSelector: { type: "archiveIndex", index: idx },
|
127
|
+
},
|
128
|
+
getState: () => {
|
129
|
+
const threads = this._core.archivedThreads;
|
130
|
+
const thread = threads[idx];
|
131
|
+
if (!thread) return SKIP_UPDATE;
|
132
|
+
return thread;
|
133
|
+
},
|
134
|
+
subscribe: (callback) => this._core.subscribe(callback),
|
135
|
+
}),
|
136
|
+
this._core,
|
137
|
+
);
|
138
|
+
}
|
139
|
+
|
140
|
+
public getThreadListItemById(threadId: string) {
|
141
|
+
return new ThreadListItemRuntimeImpl(
|
142
|
+
new LazyMemoizeSubject({
|
143
|
+
path: {
|
144
|
+
ref:
|
145
|
+
this.path.ref +
|
146
|
+
`${this.path.ref}.threadItems[threadId=${threadId}]`,
|
147
|
+
threadSelector: { type: "threadId", threadId },
|
148
|
+
},
|
149
|
+
getState: () => {
|
150
|
+
const threadItem = this._core.getThreadMetadataById(threadId);
|
151
|
+
if (!threadItem) return SKIP_UPDATE;
|
152
|
+
return threadItem;
|
153
|
+
},
|
154
|
+
subscribe: (callback) => this._core.subscribe(callback),
|
155
|
+
}),
|
156
|
+
this._core,
|
157
|
+
);
|
158
|
+
}
|
159
|
+
}
|
package/src/api/ThreadRuntime.ts
CHANGED
@@ -42,6 +42,7 @@ export type CreateAppendMessage =
|
|
42
42
|
role?: AppendMessage["role"] | undefined;
|
43
43
|
content: AppendMessage["content"];
|
44
44
|
attachments?: AppendMessage["attachments"] | undefined;
|
45
|
+
startRun?: boolean | undefined;
|
45
46
|
};
|
46
47
|
|
47
48
|
const toAppendMessage = (
|
@@ -62,9 +63,9 @@ const toAppendMessage = (
|
|
62
63
|
}
|
63
64
|
|
64
65
|
return {
|
66
|
+
...message,
|
65
67
|
parentId: message.parentId ?? messages.at(-1)?.id ?? null,
|
66
68
|
role: message.role ?? "user",
|
67
|
-
content: message.content,
|
68
69
|
attachments: message.attachments ?? [],
|
69
70
|
} as AppendMessage;
|
70
71
|
};
|
package/src/api/index.ts
CHANGED
@@ -14,7 +14,4 @@ export type {
|
|
14
14
|
ComposerState,
|
15
15
|
} from "./ComposerRuntime";
|
16
16
|
export type { AttachmentRuntime, AttachmentState } from "./AttachmentRuntime";
|
17
|
-
export type {
|
18
|
-
ThreadManagerRuntime,
|
19
|
-
ThreadManagerState,
|
20
|
-
} from "./ThreadManagerRuntime";
|
17
|
+
export type { ThreadListRuntime, ThreadListState } from "./ThreadListRuntime";
|
@@ -32,16 +32,14 @@ const useAssistantToolUIsStore = () => {
|
|
32
32
|
return useMemo(() => makeAssistantToolUIsStore(), []);
|
33
33
|
};
|
34
34
|
|
35
|
-
const
|
36
|
-
const [store] = useState(() =>
|
37
|
-
create(() => runtime.threadManager.getState()),
|
38
|
-
);
|
35
|
+
const useThreadListStore = (runtime: AssistantRuntime) => {
|
36
|
+
const [store] = useState(() => create(() => runtime.threadList.getState()));
|
39
37
|
|
40
38
|
useEffect(() => {
|
41
39
|
const updateState = () =>
|
42
|
-
writableStore(store).setState(runtime.
|
40
|
+
writableStore(store).setState(runtime.threadList.getState(), true);
|
43
41
|
updateState();
|
44
|
-
return runtime.
|
42
|
+
return runtime.threadList.subscribe(updateState);
|
45
43
|
}, [runtime, store]);
|
46
44
|
|
47
45
|
return store;
|
@@ -52,15 +50,15 @@ export const AssistantRuntimeProviderImpl: FC<
|
|
52
50
|
> = ({ children, runtime }) => {
|
53
51
|
const useAssistantRuntime = useAssistantRuntimeStore(runtime);
|
54
52
|
const useToolUIs = useAssistantToolUIsStore();
|
55
|
-
const
|
53
|
+
const useThreadList = useThreadListStore(runtime);
|
56
54
|
const context = useMemo(() => {
|
57
55
|
return {
|
58
56
|
useToolUIs,
|
59
57
|
useAssistantRuntime,
|
60
58
|
useAssistantActions: useAssistantRuntime,
|
61
|
-
|
59
|
+
useThreadList,
|
62
60
|
};
|
63
|
-
}, [useAssistantRuntime, useToolUIs,
|
61
|
+
}, [useAssistantRuntime, useToolUIs, useThreadList]);
|
64
62
|
|
65
63
|
return (
|
66
64
|
<AssistantContext.Provider value={context}>
|
@@ -12,9 +12,11 @@ import { AttachmentContext } from "../react/AttachmentContext";
|
|
12
12
|
import { writableStore } from "../ReadonlyStore";
|
13
13
|
import { AttachmentRuntime } from "../../api/AttachmentRuntime";
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
export namespace AttachmentRuntimeProvider {
|
16
|
+
export type Props = PropsWithChildren<{
|
17
|
+
runtime: AttachmentRuntime;
|
18
|
+
}>;
|
19
|
+
}
|
18
20
|
|
19
21
|
const useAttachmentRuntimeStore = (runtime: AttachmentRuntime) => {
|
20
22
|
const [store] = useState(() => create(() => runtime));
|
@@ -37,7 +39,7 @@ const useAttachmentStore = (runtime: AttachmentRuntime) => {
|
|
37
39
|
return store;
|
38
40
|
};
|
39
41
|
|
40
|
-
export const AttachmentRuntimeProvider: FC<
|
42
|
+
export const AttachmentRuntimeProvider: FC<AttachmentRuntimeProvider.Props> = ({
|
41
43
|
runtime,
|
42
44
|
children,
|
43
45
|
}) => {
|
@@ -7,9 +7,11 @@ import type { ContentPartContextValue } from "../react/ContentPartContext";
|
|
7
7
|
import { writableStore } from "../ReadonlyStore";
|
8
8
|
import { ContentPartRuntime } from "../../api/ContentPartRuntime";
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
export namespace ContentPartRuntimeProvider {
|
11
|
+
export type Props = PropsWithChildren<{
|
12
|
+
runtime: ContentPartRuntime;
|
13
|
+
}>;
|
14
|
+
}
|
13
15
|
|
14
16
|
const useContentPartRuntimeStore = (runtime: ContentPartRuntime) => {
|
15
17
|
const [store] = useState(() => create(() => runtime));
|
@@ -33,10 +35,9 @@ export const useContentPartStore = (runtime: ContentPartRuntime) => {
|
|
33
35
|
return store;
|
34
36
|
};
|
35
37
|
|
36
|
-
export const ContentPartRuntimeProvider: FC<
|
37
|
-
|
38
|
-
|
39
|
-
}) => {
|
38
|
+
export const ContentPartRuntimeProvider: FC<
|
39
|
+
ContentPartRuntimeProvider.Props
|
40
|
+
> = ({ runtime, children }) => {
|
40
41
|
const useContentPartRuntime = useContentPartRuntimeStore(runtime);
|
41
42
|
const useContentPart = useContentPartStore(runtime);
|
42
43
|
const [context] = useState<ContentPartContextValue>(() => {
|
@@ -8,9 +8,11 @@ import { makeMessageUtilsStore } from "../stores/MessageUtils";
|
|
8
8
|
import { ReadonlyStore, writableStore } from "../ReadonlyStore";
|
9
9
|
import { MessageRuntime } from "../../api/MessageRuntime";
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
export namespace MessageRuntimeProvider {
|
12
|
+
export type Props = PropsWithChildren<{
|
13
|
+
runtime: MessageRuntime;
|
14
|
+
}>;
|
15
|
+
}
|
14
16
|
|
15
17
|
const useMessageRuntimeStore = (runtime: MessageRuntime) => {
|
16
18
|
const [store] = useState(() => create(() => runtime));
|
@@ -54,7 +56,7 @@ const useEditComposerStore = (
|
|
54
56
|
return store;
|
55
57
|
};
|
56
58
|
|
57
|
-
export const MessageRuntimeProvider: FC<
|
59
|
+
export const MessageRuntimeProvider: FC<MessageRuntimeProvider.Props> = ({
|
58
60
|
runtime,
|
59
61
|
children,
|
60
62
|
}) => {
|
@@ -14,10 +14,12 @@ import {
|
|
14
14
|
ContentPartState,
|
15
15
|
} from "../../api/ContentPartRuntime";
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
export namespace TextContentPartProvider {
|
18
|
+
export type Props = PropsWithChildren<{
|
19
|
+
text: string;
|
20
|
+
isRunning?: boolean | undefined;
|
21
|
+
}>;
|
22
|
+
}
|
21
23
|
|
22
24
|
const COMPLETE_STATUS: ContentPartStatus = {
|
23
25
|
type: "complete",
|
@@ -27,9 +29,11 @@ const RUNNING_STATUS: ContentPartStatus = {
|
|
27
29
|
type: "running",
|
28
30
|
};
|
29
31
|
|
30
|
-
export const TextContentPartProvider: FC<
|
31
|
-
|
32
|
-
|
32
|
+
export const TextContentPartProvider: FC<TextContentPartProvider.Props> = ({
|
33
|
+
children,
|
34
|
+
text,
|
35
|
+
isRunning,
|
36
|
+
}) => {
|
33
37
|
const [context] = useState<ContentPartContextValue>(() => {
|
34
38
|
const useContentPartRuntime = create(
|
35
39
|
// TODO
|
@@ -0,0 +1,54 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import { type FC, type PropsWithChildren, useEffect, useState } from "react";
|
4
|
+
import { create } from "zustand";
|
5
|
+
import {
|
6
|
+
ThreadListItemContext,
|
7
|
+
type ThreadListItemContextValue,
|
8
|
+
} from "../react/ThreadListItemContext";
|
9
|
+
import { writableStore } from "../ReadonlyStore";
|
10
|
+
import { ThreadListItemRuntime } from "../../api/ThreadListItemRuntime";
|
11
|
+
|
12
|
+
export namespace ThreadListItemRuntimeProvider {
|
13
|
+
export type Props = PropsWithChildren<{
|
14
|
+
runtime: ThreadListItemRuntime;
|
15
|
+
}>;
|
16
|
+
}
|
17
|
+
|
18
|
+
const useThreadListItemRuntimeStore = (runtime: ThreadListItemRuntime) => {
|
19
|
+
const [store] = useState(() => create(() => runtime));
|
20
|
+
|
21
|
+
useEffect(() => {
|
22
|
+
writableStore(store).setState(runtime, true);
|
23
|
+
}, [runtime, store]);
|
24
|
+
|
25
|
+
return store;
|
26
|
+
};
|
27
|
+
|
28
|
+
export const useThreadListItemStore = (runtime: ThreadListItemRuntime) => {
|
29
|
+
const [store] = useState(() => create(() => runtime.getState()));
|
30
|
+
useEffect(() => {
|
31
|
+
const updateState = () =>
|
32
|
+
writableStore(store).setState(runtime.getState(), true);
|
33
|
+
updateState();
|
34
|
+
return runtime.subscribe(updateState);
|
35
|
+
}, [runtime, store]);
|
36
|
+
|
37
|
+
return store;
|
38
|
+
};
|
39
|
+
|
40
|
+
export const ThreadListItemRuntimeProvider: FC<
|
41
|
+
ThreadListItemRuntimeProvider.Props
|
42
|
+
> = ({ runtime, children }) => {
|
43
|
+
const useThreadListItemRuntime = useThreadListItemRuntimeStore(runtime);
|
44
|
+
const useThreadListItem = useThreadListItemStore(runtime);
|
45
|
+
const [context] = useState<ThreadListItemContextValue>(() => {
|
46
|
+
return { useThreadListItemRuntime, useThreadListItem };
|
47
|
+
});
|
48
|
+
|
49
|
+
return (
|
50
|
+
<ThreadListItemContext.Provider value={context}>
|
51
|
+
{children}
|
52
|
+
</ThreadListItemContext.Provider>
|
53
|
+
);
|
54
|
+
};
|
@@ -7,12 +7,12 @@ import { createContextHook } from "./utils/createContextHook";
|
|
7
7
|
import { createContextStoreHook } from "./utils/createContextStoreHook";
|
8
8
|
import { UseBoundStore } from "zustand";
|
9
9
|
import { AssistantRuntime } from "../../api/AssistantRuntime";
|
10
|
-
import {
|
10
|
+
import { ThreadListState } from "../../api/ThreadListRuntime";
|
11
11
|
|
12
12
|
export type AssistantContextValue = {
|
13
13
|
useToolUIs: UseBoundStore<ReadonlyStore<AssistantToolUIsState>>;
|
14
14
|
useAssistantRuntime: UseBoundStore<ReadonlyStore<AssistantRuntime>>;
|
15
|
-
|
15
|
+
useThreadList: UseBoundStore<ReadonlyStore<ThreadListState>>;
|
16
16
|
|
17
17
|
/**
|
18
18
|
* @deprecated Use `useAssistantRuntime` instead. This will be removed in 0.6.0.
|
@@ -68,7 +68,7 @@ export const { useToolUIs, useToolUIsStore } = createContextStoreHook(
|
|
68
68
|
"useToolUIs",
|
69
69
|
);
|
70
70
|
|
71
|
-
export const {
|
71
|
+
export const { useThreadList } = createContextStoreHook(
|
72
72
|
useAssistantContext,
|
73
|
-
"
|
73
|
+
"useThreadList",
|
74
74
|
);
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import { createContext } from "react";
|
4
|
+
import { ReadonlyStore } from "../ReadonlyStore";
|
5
|
+
import { createContextStoreHook } from "./utils/createContextStoreHook";
|
6
|
+
import { createContextHook } from "./utils/createContextHook";
|
7
|
+
import { UseBoundStore } from "zustand";
|
8
|
+
import { ThreadListItemRuntime } from "../../api/ThreadListItemRuntime";
|
9
|
+
import { ThreadListItemState } from "../../api/ThreadListItemRuntime";
|
10
|
+
|
11
|
+
export type ThreadListItemContextValue = {
|
12
|
+
useThreadListItemRuntime: UseBoundStore<ReadonlyStore<ThreadListItemRuntime>>;
|
13
|
+
useThreadListItem: UseBoundStore<ReadonlyStore<ThreadListItemState>>;
|
14
|
+
};
|
15
|
+
|
16
|
+
export const ThreadListItemContext =
|
17
|
+
createContext<ThreadListItemContextValue | null>(null);
|
18
|
+
|
19
|
+
export const useThreadListItemContext = createContextHook(
|
20
|
+
ThreadListItemContext,
|
21
|
+
"a component passed to <ThreadListPrimitive.Items components={...}>",
|
22
|
+
);
|
23
|
+
|
24
|
+
export function useThreadListItemRuntime(options?: {
|
25
|
+
optional?: false | undefined;
|
26
|
+
}): ThreadListItemRuntime;
|
27
|
+
export function useThreadListItemRuntime(options?: {
|
28
|
+
optional?: boolean | undefined;
|
29
|
+
}): ThreadListItemRuntime | null;
|
30
|
+
export function useThreadListItemRuntime(options?: {
|
31
|
+
optional?: boolean | undefined;
|
32
|
+
}) {
|
33
|
+
const context = useThreadListItemContext(options);
|
34
|
+
if (!context) return null;
|
35
|
+
return context.useThreadListItemRuntime();
|
36
|
+
}
|
37
|
+
|
38
|
+
export const { useThreadListItem, useThreadListItemStore } =
|
39
|
+
createContextStoreHook(useThreadListItemContext, "useThreadListItem");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
export {
|
2
2
|
useAssistantRuntime,
|
3
|
-
|
3
|
+
useThreadList,
|
4
4
|
useToolUIs,
|
5
5
|
useToolUIsStore,
|
6
6
|
|
@@ -150,7 +150,7 @@ export {
|
|
150
150
|
useAttachment,
|
151
151
|
useAttachmentRuntime,
|
152
152
|
|
153
|
-
// TODO decide if we want to export/drop these?
|
153
|
+
// TODO decide if we want to export/drop these?
|
154
154
|
// useEditComposerAttachment,
|
155
155
|
// useEditComposerAttachmentRuntime,
|
156
156
|
// useMessageAttachment,
|
package/src/internal.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
export type { ThreadRuntimeCore } from "./runtimes/core/ThreadRuntimeCore";
|
2
|
-
export type {
|
2
|
+
export type { ThreadListRuntimeCore } from "./runtimes/core/ThreadListRuntimeCore";
|
3
3
|
export { DefaultThreadComposerRuntimeCore } from "./runtimes/composer/DefaultThreadComposerRuntimeCore";
|
4
4
|
export { ProxyConfigProvider } from "./utils/ProxyConfigProvider";
|
5
5
|
export { MessageRepository } from "./runtimes/utils/MessageRepository";
|
package/src/primitives/index.ts
CHANGED
@@ -6,6 +6,8 @@ export * as ComposerPrimitive from "./composer";
|
|
6
6
|
export * as ContentPartPrimitive from "./contentPart";
|
7
7
|
export * as MessagePrimitive from "./message";
|
8
8
|
export * as ThreadPrimitive from "./thread";
|
9
|
+
export * as ThreadListPrimitive from "./threadList";
|
10
|
+
export * as ThreadListItemPrimitive from "./threadListItem";
|
9
11
|
|
10
12
|
export type * from "./actionBar/types";
|
11
13
|
export type * from "./assistantModal/types";
|
@@ -0,0 +1,73 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import { ComponentType, FC, memo, useMemo } from "react";
|
4
|
+
import { ThreadListItemRuntimeProvider } from "../../context/providers/ThreadListItemRuntimeProvider";
|
5
|
+
import { useAssistantRuntime, useThreadList } from "../../context";
|
6
|
+
|
7
|
+
export namespace MessagePrimitiveContent {
|
8
|
+
export type Props = {
|
9
|
+
archived?: boolean | undefined;
|
10
|
+
components: {
|
11
|
+
ThreadListItem: ComponentType;
|
12
|
+
};
|
13
|
+
};
|
14
|
+
}
|
15
|
+
|
16
|
+
type ThreadListItemProps = {
|
17
|
+
partIndex: number;
|
18
|
+
archived: boolean;
|
19
|
+
components: MessagePrimitiveContent.Props["components"];
|
20
|
+
};
|
21
|
+
|
22
|
+
const ThreadListItemImpl: FC<ThreadListItemProps> = ({
|
23
|
+
partIndex,
|
24
|
+
archived,
|
25
|
+
components,
|
26
|
+
}) => {
|
27
|
+
const assistantRuntime = useAssistantRuntime();
|
28
|
+
const runtime = useMemo(
|
29
|
+
() =>
|
30
|
+
archived
|
31
|
+
? assistantRuntime.threadList.getThreadListArchivedItemByIndex(
|
32
|
+
partIndex,
|
33
|
+
)
|
34
|
+
: assistantRuntime.threadList.getThreadListItemByIndex(partIndex),
|
35
|
+
[assistantRuntime, partIndex],
|
36
|
+
);
|
37
|
+
|
38
|
+
const ThreadListItemComponent = components.ThreadListItem;
|
39
|
+
|
40
|
+
return (
|
41
|
+
<ThreadListItemRuntimeProvider runtime={runtime}>
|
42
|
+
<ThreadListItemComponent />
|
43
|
+
</ThreadListItemRuntimeProvider>
|
44
|
+
);
|
45
|
+
};
|
46
|
+
|
47
|
+
const ThreadListItem = memo(
|
48
|
+
ThreadListItemImpl,
|
49
|
+
(prev, next) =>
|
50
|
+
prev.partIndex === next.partIndex &&
|
51
|
+
prev.archived === next.archived &&
|
52
|
+
prev.components.ThreadListItem === next.components.ThreadListItem,
|
53
|
+
);
|
54
|
+
|
55
|
+
export const ThreadListPrimitiveItems: FC<MessagePrimitiveContent.Props> = ({
|
56
|
+
archived = false,
|
57
|
+
components,
|
58
|
+
}) => {
|
59
|
+
const contentLength = useThreadList((s) =>
|
60
|
+
archived ? s.archivedThreads.length : s.threads.length,
|
61
|
+
);
|
62
|
+
|
63
|
+
return Array.from({ length: contentLength }, (_, index) => (
|
64
|
+
<ThreadListItem
|
65
|
+
key={index}
|
66
|
+
partIndex={index}
|
67
|
+
archived={archived}
|
68
|
+
components={components}
|
69
|
+
/>
|
70
|
+
));
|
71
|
+
};
|
72
|
+
|
73
|
+
ThreadListPrimitiveItems.displayName = "ThreadListPrimitive.Items";
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import {
|
4
|
+
ActionButtonElement,
|
5
|
+
ActionButtonProps,
|
6
|
+
createActionButton,
|
7
|
+
} from "../../utils/createActionButton";
|
8
|
+
import { useAssistantRuntime } from "../../context";
|
9
|
+
|
10
|
+
const useThreadListNew = () => {
|
11
|
+
const runtime = useAssistantRuntime();
|
12
|
+
return () => {
|
13
|
+
runtime.switchToNewThread();
|
14
|
+
};
|
15
|
+
};
|
16
|
+
|
17
|
+
export namespace ThreadListPrimitiveNew {
|
18
|
+
export type Element = ActionButtonElement;
|
19
|
+
export type Props = ActionButtonProps<typeof useThreadListNew>;
|
20
|
+
}
|
21
|
+
|
22
|
+
export const ThreadListPrimitiveNew = createActionButton(
|
23
|
+
"ThreadListPrimitive.New",
|
24
|
+
useThreadListNew,
|
25
|
+
);
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import {
|
4
|
+
ActionButtonElement,
|
5
|
+
ActionButtonProps,
|
6
|
+
createActionButton,
|
7
|
+
} from "../../utils/createActionButton";
|
8
|
+
import { useThreadListItemRuntime } from "../../context/react/ThreadListItemContext";
|
9
|
+
|
10
|
+
const useThreadListItemArchive = () => {
|
11
|
+
const runtime = useThreadListItemRuntime();
|
12
|
+
return () => {
|
13
|
+
runtime.archive();
|
14
|
+
};
|
15
|
+
};
|
16
|
+
|
17
|
+
export namespace ThreadListItemPrimitiveArchive {
|
18
|
+
export type Element = ActionButtonElement;
|
19
|
+
export type Props = ActionButtonProps<typeof useThreadListItemArchive>;
|
20
|
+
}
|
21
|
+
|
22
|
+
export const ThreadListItemPrimitiveArchive = createActionButton(
|
23
|
+
"ThreadListItemPrimitive.Archive",
|
24
|
+
useThreadListItemArchive,
|
25
|
+
);
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import {
|
4
|
+
ActionButtonElement,
|
5
|
+
ActionButtonProps,
|
6
|
+
createActionButton,
|
7
|
+
} from "../../utils/createActionButton";
|
8
|
+
import { useThreadListItemRuntime } from "../../context/react/ThreadListItemContext";
|
9
|
+
|
10
|
+
const useThreadListItemDelete = () => {
|
11
|
+
const runtime = useThreadListItemRuntime();
|
12
|
+
return () => {
|
13
|
+
runtime.delete();
|
14
|
+
};
|
15
|
+
};
|
16
|
+
|
17
|
+
export namespace ThreadListItemPrimitiveDelete {
|
18
|
+
export type Element = ActionButtonElement;
|
19
|
+
export type Props = ActionButtonProps<typeof useThreadListItemDelete>;
|
20
|
+
}
|
21
|
+
|
22
|
+
export const ThreadListItemPrimitiveDelete = createActionButton(
|
23
|
+
"ThreadListItemPrimitive.Delete",
|
24
|
+
useThreadListItemDelete,
|
25
|
+
);
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import {
|
4
|
+
ActionButtonElement,
|
5
|
+
ActionButtonProps,
|
6
|
+
createActionButton,
|
7
|
+
} from "../../utils/createActionButton";
|
8
|
+
import { useThreadListItemRuntime } from "../../context/react/ThreadListItemContext";
|
9
|
+
|
10
|
+
const useThreadListItemUnarchive = () => {
|
11
|
+
const runtime = useThreadListItemRuntime();
|
12
|
+
return () => {
|
13
|
+
runtime.unarchive();
|
14
|
+
};
|
15
|
+
};
|
16
|
+
|
17
|
+
export namespace ThreadListItemPrimitiveUnarchive {
|
18
|
+
export type Element = ActionButtonElement;
|
19
|
+
export type Props = ActionButtonProps<typeof useThreadListItemUnarchive>;
|
20
|
+
}
|
21
|
+
|
22
|
+
export const ThreadListItemPrimitiveUnarchive = createActionButton(
|
23
|
+
"ThreadListItemPrimitive.Unarchive",
|
24
|
+
useThreadListItemUnarchive,
|
25
|
+
);
|