@assistant-ui/react 0.7.38 → 0.7.39

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. package/dist/primitives/actionBar/ActionBarRoot.d.ts +2 -2
  2. package/dist/primitives/actionBar/ActionBarRoot.d.ts.map +1 -1
  3. package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
  4. package/dist/primitives/actionBar/ActionBarRoot.mjs.map +1 -1
  5. package/dist/primitives/assistantModal/AssistantModalAnchor.d.ts +2 -2
  6. package/dist/primitives/assistantModal/AssistantModalAnchor.d.ts.map +1 -1
  7. package/dist/primitives/assistantModal/AssistantModalAnchor.js.map +1 -1
  8. package/dist/primitives/assistantModal/AssistantModalAnchor.mjs.map +1 -1
  9. package/dist/primitives/assistantModal/AssistantModalContent.d.ts +2 -2
  10. package/dist/primitives/assistantModal/AssistantModalContent.d.ts.map +1 -1
  11. package/dist/primitives/assistantModal/AssistantModalContent.js.map +1 -1
  12. package/dist/primitives/assistantModal/AssistantModalContent.mjs.map +1 -1
  13. package/dist/primitives/assistantModal/AssistantModalTrigger.d.ts +2 -2
  14. package/dist/primitives/assistantModal/AssistantModalTrigger.d.ts.map +1 -1
  15. package/dist/primitives/assistantModal/AssistantModalTrigger.js.map +1 -1
  16. package/dist/primitives/assistantModal/AssistantModalTrigger.mjs.map +1 -1
  17. package/dist/primitives/assistantModal/scope.d.ts +3 -3
  18. package/dist/primitives/assistantModal/scope.d.ts.map +1 -1
  19. package/dist/primitives/assistantModal/scope.js.map +1 -1
  20. package/dist/primitives/assistantModal/scope.mjs.map +1 -1
  21. package/dist/primitives/attachment/AttachmentRoot.d.ts +2 -2
  22. package/dist/primitives/attachment/AttachmentRoot.d.ts.map +1 -1
  23. package/dist/primitives/attachment/AttachmentRoot.js.map +1 -1
  24. package/dist/primitives/attachment/AttachmentRoot.mjs.map +1 -1
  25. package/dist/primitives/attachment/AttachmentThumb.d.ts +2 -2
  26. package/dist/primitives/attachment/AttachmentThumb.d.ts.map +1 -1
  27. package/dist/primitives/attachment/AttachmentThumb.js.map +1 -1
  28. package/dist/primitives/attachment/AttachmentThumb.mjs.map +1 -1
  29. package/dist/primitives/branchPicker/BranchPickerRoot.d.ts +2 -2
  30. package/dist/primitives/branchPicker/BranchPickerRoot.d.ts.map +1 -1
  31. package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
  32. package/dist/primitives/branchPicker/BranchPickerRoot.mjs.map +1 -1
  33. package/dist/primitives/composer/ComposerRoot.d.ts +2 -2
  34. package/dist/primitives/composer/ComposerRoot.d.ts.map +1 -1
  35. package/dist/primitives/composer/ComposerRoot.js.map +1 -1
  36. package/dist/primitives/composer/ComposerRoot.mjs.map +1 -1
  37. package/dist/primitives/contentPart/ContentPartImage.d.ts +2 -2
  38. package/dist/primitives/contentPart/ContentPartImage.d.ts.map +1 -1
  39. package/dist/primitives/contentPart/ContentPartImage.js.map +1 -1
  40. package/dist/primitives/contentPart/ContentPartImage.mjs.map +1 -1
  41. package/dist/primitives/contentPart/ContentPartText.d.ts +2 -2
  42. package/dist/primitives/contentPart/ContentPartText.d.ts.map +1 -1
  43. package/dist/primitives/contentPart/ContentPartText.js.map +1 -1
  44. package/dist/primitives/contentPart/ContentPartText.mjs.map +1 -1
  45. package/dist/primitives/message/MessageRoot.d.ts +2 -2
  46. package/dist/primitives/message/MessageRoot.d.ts.map +1 -1
  47. package/dist/primitives/message/MessageRoot.js.map +1 -1
  48. package/dist/primitives/message/MessageRoot.mjs.map +1 -1
  49. package/dist/primitives/thread/ThreadRoot.d.ts +2 -2
  50. package/dist/primitives/thread/ThreadRoot.d.ts.map +1 -1
  51. package/dist/primitives/thread/ThreadRoot.js.map +1 -1
  52. package/dist/primitives/thread/ThreadRoot.mjs.map +1 -1
  53. package/dist/primitives/thread/ThreadViewport.d.ts +2 -2
  54. package/dist/primitives/thread/ThreadViewport.d.ts.map +1 -1
  55. package/dist/primitives/thread/ThreadViewport.js.map +1 -1
  56. package/dist/primitives/thread/ThreadViewport.mjs.map +1 -1
  57. package/dist/primitives/threadListItem/ThreadListItemRoot.d.ts +2 -2
  58. package/dist/primitives/threadListItem/ThreadListItemRoot.d.ts.map +1 -1
  59. package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
  60. package/dist/primitives/threadListItem/ThreadListItemRoot.mjs.map +1 -1
  61. package/dist/runtimes/local/LocalThreadListRuntimeCore.js +2 -2
  62. package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -1
  63. package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs +2 -2
  64. package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs.map +1 -1
  65. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts +4 -2
  66. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  67. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js +17 -14
  68. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
  69. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs +24 -15
  70. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs.map +1 -1
  71. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +3 -2
  72. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  73. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +94 -64
  74. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  75. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs +95 -65
  76. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs.map +1 -1
  77. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.d.ts +2 -0
  78. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.d.ts.map +1 -1
  79. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.js +3 -0
  80. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.js.map +1 -1
  81. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.mjs +3 -0
  82. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.mjs.map +1 -1
  83. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.d.ts +10 -6
  84. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.d.ts.map +1 -1
  85. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.js +25 -8
  86. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.js.map +1 -1
  87. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.mjs +25 -8
  88. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.mjs.map +1 -1
  89. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.d.ts +2 -2
  90. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.d.ts.map +1 -1
  91. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.js +7 -8
  92. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.js.map +1 -1
  93. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.mjs +7 -8
  94. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.mjs.map +1 -1
  95. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudRuns.d.ts +15 -0
  96. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudRuns.d.ts.map +1 -0
  97. package/dist/runtimes/remote-thread-list/cloud/{CloudContext.js → AssistantCloudRuns.js} +23 -9
  98. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudRuns.js.map +1 -0
  99. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudRuns.mjs +21 -0
  100. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudRuns.mjs.map +1 -0
  101. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.d.ts +22 -0
  102. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.d.ts.map +1 -0
  103. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.js +85 -0
  104. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.js.map +1 -0
  105. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.mjs +60 -0
  106. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.mjs.map +1 -0
  107. package/dist/runtimes/remote-thread-list/cloud/index.d.ts +1 -1
  108. package/dist/runtimes/remote-thread-list/cloud/index.d.ts.map +1 -1
  109. package/dist/runtimes/remote-thread-list/cloud/index.js +3 -3
  110. package/dist/runtimes/remote-thread-list/cloud/index.js.map +1 -1
  111. package/dist/runtimes/remote-thread-list/cloud/index.mjs +2 -2
  112. package/dist/runtimes/remote-thread-list/cloud/index.mjs.map +1 -1
  113. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
  114. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.js +47 -19
  115. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.js.map +1 -1
  116. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.mjs +54 -20
  117. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.mjs.map +1 -1
  118. package/dist/runtimes/remote-thread-list/types.d.ts +10 -2
  119. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  120. package/dist/runtimes/remote-thread-list/types.js.map +1 -1
  121. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.d.ts.map +1 -1
  122. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js +1 -0
  123. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
  124. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs +1 -0
  125. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs.map +1 -1
  126. package/dist/styles/index.css.map +1 -1
  127. package/dist/ui/base/button.d.ts.map +1 -1
  128. package/dist/ui/base/button.js.map +1 -1
  129. package/dist/ui/base/button.mjs.map +1 -1
  130. package/dist/ui/base/dialog.js.map +1 -1
  131. package/dist/ui/base/dialog.mjs.map +1 -1
  132. package/dist/utils/createActionButton.d.ts +2 -2
  133. package/dist/utils/createActionButton.d.ts.map +1 -1
  134. package/dist/utils/createActionButton.js.map +1 -1
  135. package/dist/utils/createActionButton.mjs.map +1 -1
  136. package/package.json +7 -10
  137. package/src/primitives/actionBar/ActionBarRoot.tsx +2 -2
  138. package/src/primitives/assistantModal/AssistantModalAnchor.tsx +2 -2
  139. package/src/primitives/assistantModal/AssistantModalContent.tsx +2 -2
  140. package/src/primitives/assistantModal/AssistantModalTrigger.tsx +2 -2
  141. package/src/primitives/assistantModal/scope.tsx +1 -1
  142. package/src/primitives/attachment/AttachmentRoot.tsx +2 -2
  143. package/src/primitives/attachment/AttachmentThumb.tsx +2 -2
  144. package/src/primitives/branchPicker/BranchPickerRoot.tsx +2 -2
  145. package/src/primitives/composer/ComposerRoot.tsx +2 -2
  146. package/src/primitives/contentPart/ContentPartImage.tsx +2 -2
  147. package/src/primitives/contentPart/ContentPartText.tsx +2 -2
  148. package/src/primitives/message/MessageRoot.tsx +2 -2
  149. package/src/primitives/thread/ThreadRoot.tsx +2 -2
  150. package/src/primitives/thread/ThreadViewport.tsx +2 -2
  151. package/src/primitives/threadListItem/ThreadListItemRoot.tsx +2 -2
  152. package/src/runtimes/local/LocalThreadListRuntimeCore.tsx +2 -2
  153. package/src/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +40 -24
  154. package/src/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +119 -80
  155. package/src/runtimes/remote-thread-list/cloud/AssistantCloud.tsx +3 -0
  156. package/src/runtimes/remote-thread-list/cloud/AssistantCloudAPI.tsx +36 -16
  157. package/src/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.tsx +5 -6
  158. package/src/runtimes/remote-thread-list/cloud/AssistantCloudRuns.tsx +26 -0
  159. package/src/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.tsx +89 -0
  160. package/src/runtimes/remote-thread-list/cloud/index.ts +1 -1
  161. package/src/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.tsx +63 -28
  162. package/src/runtimes/remote-thread-list/types.tsx +18 -4
  163. package/src/runtimes/remote-thread-list/useRemoteThreadListRuntime.tsx +1 -0
  164. package/src/ui/base/button.tsx +2 -2
  165. package/src/ui/base/dialog.tsx +5 -5
  166. package/src/utils/createActionButton.tsx +2 -2
  167. package/dist/runtimes/remote-thread-list/cloud/CloudContext.d.ts +0 -10
  168. package/dist/runtimes/remote-thread-list/cloud/CloudContext.d.ts.map +0 -1
  169. package/dist/runtimes/remote-thread-list/cloud/CloudContext.js.map +0 -1
  170. package/dist/runtimes/remote-thread-list/cloud/CloudContext.mjs +0 -7
  171. package/dist/runtimes/remote-thread-list/cloud/CloudContext.mjs.map +0 -1
  172. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.d.ts +0 -4
  173. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.d.ts.map +0 -1
  174. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.js +0 -46
  175. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.js.map +0 -1
  176. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.mjs +0 -22
  177. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.mjs.map +0 -1
  178. package/src/runtimes/remote-thread-list/cloud/CloudContext.tsx +0 -12
  179. package/src/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.tsx +0 -19
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
 
3
- import { ComponentPropsWithoutRef, ElementRef, forwardRef } from "react";
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 = ElementRef<typeof PopoverPrimitive.Anchor>;
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, ElementRef, forwardRef } from "react";
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 = ElementRef<typeof PopoverPrimitive.Content>;
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, ElementRef, forwardRef } from "react";
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 = ElementRef<typeof PopoverPrimitive.Trigger>;
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, ElementRef, forwardRef } from "react";
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 = ElementRef<typeof Primitive.div>;
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 ElementRef } from "react";
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 = ElementRef<typeof Primitive.div>;
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 ElementRef, forwardRef, ComponentPropsWithoutRef } from "react";
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 = ElementRef<typeof Primitive.div>;
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 ElementRef,
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 = ElementRef<typeof Primitive.form>;
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 ElementRef, forwardRef, ComponentPropsWithoutRef } from "react";
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 = ElementRef<typeof Primitive.img>;
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 ElementRef,
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 = ElementRef<typeof Primitive.span>;
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 ElementRef,
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 = ElementRef<typeof Primitive.div>;
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 ElementRef, forwardRef, ComponentPropsWithoutRef } from "react";
2
+ import { type ComponentRef, forwardRef, ComponentPropsWithoutRef } from "react";
3
3
 
4
4
  export namespace ThreadPrimitiveRoot {
5
- export type Element = ElementRef<typeof Primitive.div>;
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 ElementRef, forwardRef, ComponentPropsWithoutRef } from "react";
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 = ElementRef<typeof Primitive.div>;
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 ElementRef, forwardRef, ComponentPropsWithoutRef } from "react";
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 = ElementRef<typeof Primitive.div>;
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, data.threadId];
135
+ this._threadIds = [data.threadId, ...this._threadIds];
136
136
  break;
137
137
 
138
138
  case "archived":
139
- this._archivedThreadIds = [...this._archivedThreadIds, data.threadId];
139
+ this._archivedThreadIds = [data.threadId, ...this._archivedThreadIds];
140
140
  break;
141
141
 
142
142
  case "deleted":
@@ -1,6 +1,15 @@
1
1
  "use client";
2
2
 
3
- import { FC, useCallback, useRef, useEffect, memo, useMemo } from "react";
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";
@@ -104,31 +113,38 @@ export class RemoteThreadListHookInstanceManager extends BaseSubscribable {
104
113
  return null;
105
114
  };
106
115
 
107
- private _OuterActiveThreadProvider: FC<{ threadId: string }> = memo(
108
- ({ threadId }) => {
109
- const assistantRuntime = useAssistantRuntime();
110
- const threadListItemRuntime = useMemo(
111
- () => assistantRuntime.threadList.getItemById(threadId),
112
- [assistantRuntime, threadId],
113
- );
114
-
115
- return (
116
- <ThreadListItemRuntimeProvider runtime={threadListItemRuntime}>
116
+ private _OuterActiveThreadProvider: FC<{
117
+ threadId: string;
118
+ provider: ComponentType<PropsWithChildren>;
119
+ }> = memo(({ threadId, provider: Provider }) => {
120
+ const assistantRuntime = useAssistantRuntime();
121
+ const threadListItemRuntime = useMemo(
122
+ () => assistantRuntime.threadList.getItemById(threadId),
123
+ [assistantRuntime, threadId],
124
+ );
125
+
126
+ return (
127
+ <ThreadListItemRuntimeProvider runtime={threadListItemRuntime}>
128
+ <Provider>
117
129
  <this._InnerActiveThreadProvider />
118
- </ThreadListItemRuntimeProvider>
119
- );
120
- },
121
- );
122
-
123
- public __internal_RenderThreadRuntimes: FC = () => {
130
+ </Provider>
131
+ </ThreadListItemRuntimeProvider>
132
+ );
133
+ });
134
+
135
+ public __internal_RenderThreadRuntimes: FC<{
136
+ provider: ComponentType<PropsWithChildren>;
137
+ }> = ({ provider }) => {
124
138
  this.useAliveThreadsKeysChanged(); // trigger re-render on alive threads change
125
139
 
126
- return [
127
- ...this.instances
128
- .keys()
129
- .map((threadId) => (
130
- <this._OuterActiveThreadProvider key={threadId} threadId={threadId} />
131
- )),
132
- ];
140
+ return this.instances
141
+ .keys()
142
+ .map((threadId) => (
143
+ <this._OuterActiveThreadProvider
144
+ key={threadId}
145
+ threadId={threadId}
146
+ provider={provider}
147
+ />
148
+ ));
133
149
  };
134
150
  }
@@ -2,14 +2,17 @@
2
2
 
3
3
  import { ThreadListRuntimeCore } from "../core/ThreadListRuntimeCore";
4
4
  import { generateId } from "../../internal";
5
- import { RemoteThreadListAdapter } from "./types";
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 { CloudInitializeResponse } from "./cloud/CloudContext";
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 readonly _loadThreadsPromise: Promise<void>;
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 (task: Promise<CloudInitializeResponse>) => {
325
- const threadId = this._state.value.newThreadId;
326
- if (!threadId)
327
- throw new Error(
328
- "ThreadListAdapter called onInitialize before switching to new thread",
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 task;
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(remoteId);
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
- <Provider>
471
- {(boundIds.length === 0 || boundIds[0] === id) && (
472
- // only render if the component is the first one mounted
473
- <this._hookManager.__internal_RenderThreadRuntimes />
474
- )}
475
- </Provider>
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
  }
@@ -1,10 +1,12 @@
1
1
  import { AssistantCloudAPI, AssistantCloudConfig } from "./AssistantCloudAPI";
2
2
  import { AssistantCloudAuthTokens } from "./AssistantCloudAuthTokens";
3
+ import { AssistantCloudRuns } from "./AssistantCloudRuns";
3
4
  import { AssistantCloudThreads } from "./AssistantCloudThreads";
4
5
 
5
6
  export class AssistantCloud {
6
7
  public readonly threads;
7
8
  public readonly auth;
9
+ public readonly runs;
8
10
 
9
11
  constructor(config: AssistantCloudConfig) {
10
12
  const api = new AssistantCloudAPI(config);
@@ -12,5 +14,6 @@ export class AssistantCloud {
12
14
  this.auth = {
13
15
  tokens: new AssistantCloudAuthTokens(api),
14
16
  };
17
+ this.runs = new AssistantCloudRuns(api);
15
18
  }
16
19
  }