@assistant-ui/react 0.10.41 → 0.10.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/primitives/composer/ComposerAttachments.d.ts +24 -0
  2. package/dist/primitives/composer/ComposerAttachments.d.ts.map +1 -1
  3. package/dist/primitives/composer/ComposerAttachments.js +14 -13
  4. package/dist/primitives/composer/ComposerAttachments.js.map +1 -1
  5. package/dist/primitives/composer/index.d.ts +1 -0
  6. package/dist/primitives/composer/index.d.ts.map +1 -1
  7. package/dist/primitives/composer/index.js +2 -0
  8. package/dist/primitives/composer/index.js.map +1 -1
  9. package/dist/primitives/message/MessageAttachments.d.ts +24 -0
  10. package/dist/primitives/message/MessageAttachments.d.ts.map +1 -1
  11. package/dist/primitives/message/MessageAttachments.js +14 -13
  12. package/dist/primitives/message/MessageAttachments.js.map +1 -1
  13. package/dist/primitives/message/MessageParts.d.ts +24 -0
  14. package/dist/primitives/message/MessageParts.d.ts.map +1 -1
  15. package/dist/primitives/message/MessageParts.js +16 -15
  16. package/dist/primitives/message/MessageParts.js.map +1 -1
  17. package/dist/primitives/message/index.d.ts +2 -0
  18. package/dist/primitives/message/index.d.ts.map +1 -1
  19. package/dist/primitives/message/index.js +4 -0
  20. package/dist/primitives/message/index.js.map +1 -1
  21. package/dist/primitives/thread/ThreadMessages.d.ts +24 -0
  22. package/dist/primitives/thread/ThreadMessages.d.ts.map +1 -1
  23. package/dist/primitives/thread/ThreadMessages.js +20 -15
  24. package/dist/primitives/thread/ThreadMessages.js.map +1 -1
  25. package/dist/primitives/thread/index.d.ts +1 -0
  26. package/dist/primitives/thread/index.d.ts.map +1 -1
  27. package/dist/primitives/thread/index.js +2 -0
  28. package/dist/primitives/thread/index.js.map +1 -1
  29. package/dist/primitives/threadList/ThreadListItems.d.ts +24 -0
  30. package/dist/primitives/threadList/ThreadListItems.d.ts.map +1 -1
  31. package/dist/primitives/threadList/ThreadListItems.js +15 -18
  32. package/dist/primitives/threadList/ThreadListItems.js.map +1 -1
  33. package/dist/primitives/threadList/index.d.ts +1 -0
  34. package/dist/primitives/threadList/index.d.ts.map +1 -1
  35. package/dist/primitives/threadList/index.js +2 -0
  36. package/dist/primitives/threadList/index.js.map +1 -1
  37. package/dist/tests/setup.js +10 -10
  38. package/dist/tests/setup.js.map +1 -1
  39. package/package.json +9 -9
  40. package/src/primitives/composer/ComposerAttachments.tsx +48 -24
  41. package/src/primitives/composer/index.ts +1 -0
  42. package/src/primitives/message/MessageAttachments.tsx +48 -24
  43. package/src/primitives/message/MessageParts.tsx +53 -33
  44. package/src/primitives/message/index.ts +2 -0
  45. package/src/primitives/thread/ThreadMessages.tsx +47 -27
  46. package/src/primitives/thread/index.ts +1 -0
  47. package/src/primitives/threadList/ThreadListItems.tsx +48 -33
  48. package/src/primitives/threadList/index.ts +1 -0
package/package.json CHANGED
@@ -28,7 +28,7 @@
28
28
  "conversational-ui",
29
29
  "conversational-ai"
30
30
  ],
31
- "version": "0.10.41",
31
+ "version": "0.10.43",
32
32
  "license": "MIT",
33
33
  "type": "module",
34
34
  "exports": {
@@ -48,22 +48,22 @@
48
48
  ],
49
49
  "sideEffects": false,
50
50
  "dependencies": {
51
- "@radix-ui/primitive": "^1.1.2",
51
+ "@radix-ui/primitive": "^1.1.3",
52
52
  "@radix-ui/react-compose-refs": "^1.1.2",
53
53
  "@radix-ui/react-context": "^1.1.2",
54
- "@radix-ui/react-popover": "^1.1.14",
54
+ "@radix-ui/react-popover": "^1.1.15",
55
55
  "@radix-ui/react-primitive": "^2.1.3",
56
56
  "@radix-ui/react-slot": "^1.2.3",
57
57
  "@radix-ui/react-use-callback-ref": "^1.1.1",
58
58
  "@radix-ui/react-use-escape-keydown": "^1.1.1",
59
59
  "@standard-schema/spec": "^1.0.0",
60
- "assistant-stream": "^0.2.22",
60
+ "assistant-stream": "^0.2.23",
61
61
  "json-schema": "^0.4.0",
62
62
  "nanoid": "5.1.5",
63
63
  "react-textarea-autosize": "^8.5.9",
64
- "zod": "^4.0.14",
64
+ "zod": "^4.0.17",
65
65
  "zustand": "^5.0.7",
66
- "assistant-cloud": "0.1.0"
66
+ "assistant-cloud": "0.1.1"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@types/react": "*",
@@ -83,10 +83,10 @@
83
83
  "@stryker-mutator/core": "^9.0.1",
84
84
  "@stryker-mutator/vitest-runner": "^9.0.1",
85
85
  "@types/json-schema": "^7.0.15",
86
- "@types/node": "^24.1.0",
86
+ "@types/node": "^24.3.0",
87
87
  "eslint": "^9",
88
- "eslint-config-next": "15.4.5",
89
- "tsx": "^4.20.3",
88
+ "eslint-config-next": "15.4.6",
89
+ "tsx": "^4.20.4",
90
90
  "vitest": "^3.2.4",
91
91
  "@assistant-ui/x-buildutils": "0.0.1"
92
92
  },
@@ -48,31 +48,55 @@ const AttachmentComponent: FC<{
48
48
  return <Component />;
49
49
  };
50
50
 
51
- const ComposerAttachmentImpl: FC<
52
- ComposerPrimitiveAttachments.Props & { attachmentIndex: number }
53
- > = ({ components, attachmentIndex }) => {
54
- const composerRuntime = useComposerRuntime();
55
- const runtime = useMemo(
56
- () => composerRuntime.getAttachmentByIndex(attachmentIndex),
57
- [composerRuntime, attachmentIndex],
58
- );
51
+ export namespace ComposerPrimitiveAttachmentByIndex {
52
+ export type Props = {
53
+ index: number;
54
+ components?: ComposerPrimitiveAttachments.Props["components"];
55
+ };
56
+ }
57
+
58
+ /**
59
+ * Renders a single attachment at the specified index within the composer.
60
+ *
61
+ * This component provides direct access to render a specific attachment
62
+ * from the composer's attachment list using the provided component configuration.
63
+ *
64
+ * @example
65
+ * ```tsx
66
+ * <ComposerPrimitive.AttachmentByIndex
67
+ * index={0}
68
+ * components={{
69
+ * Image: MyImageAttachment,
70
+ * Document: MyDocumentAttachment
71
+ * }}
72
+ * />
73
+ * ```
74
+ */
75
+ export const ComposerPrimitiveAttachmentByIndex: FC<ComposerPrimitiveAttachmentByIndex.Props> =
76
+ memo(
77
+ ({ index, components }) => {
78
+ const composerRuntime = useComposerRuntime();
79
+ const runtime = useMemo(
80
+ () => composerRuntime.getAttachmentByIndex(index),
81
+ [composerRuntime, index],
82
+ );
59
83
 
60
- return (
61
- <AttachmentRuntimeProvider runtime={runtime}>
62
- <AttachmentComponent components={components} />
63
- </AttachmentRuntimeProvider>
84
+ return (
85
+ <AttachmentRuntimeProvider runtime={runtime}>
86
+ <AttachmentComponent components={components} />
87
+ </AttachmentRuntimeProvider>
88
+ );
89
+ },
90
+ (prev, next) =>
91
+ prev.index === next.index &&
92
+ prev.components?.Image === next.components?.Image &&
93
+ prev.components?.Document === next.components?.Document &&
94
+ prev.components?.File === next.components?.File &&
95
+ prev.components?.Attachment === next.components?.Attachment,
64
96
  );
65
- };
66
97
 
67
- const ComposerAttachment = memo(
68
- ComposerAttachmentImpl,
69
- (prev, next) =>
70
- prev.attachmentIndex === next.attachmentIndex &&
71
- prev.components?.Image === next.components?.Image &&
72
- prev.components?.Document === next.components?.Document &&
73
- prev.components?.File === next.components?.File &&
74
- prev.components?.Attachment === next.components?.Attachment,
75
- );
98
+ ComposerPrimitiveAttachmentByIndex.displayName =
99
+ "ComposerPrimitive.AttachmentByIndex";
76
100
 
77
101
  export const ComposerPrimitiveAttachments: FC<
78
102
  ComposerPrimitiveAttachments.Props
@@ -81,9 +105,9 @@ export const ComposerPrimitiveAttachments: FC<
81
105
 
82
106
  const attachmentElements = useMemo(() => {
83
107
  return Array.from({ length: attachmentsCount }, (_, index) => (
84
- <ComposerAttachment
108
+ <ComposerPrimitiveAttachmentByIndex
85
109
  key={index}
86
- attachmentIndex={index}
110
+ index={index}
87
111
  components={components}
88
112
  />
89
113
  ));
@@ -4,4 +4,5 @@ export { ComposerPrimitiveSend as Send } from "./ComposerSend";
4
4
  export { ComposerPrimitiveCancel as Cancel } from "./ComposerCancel";
5
5
  export { ComposerPrimitiveAddAttachment as AddAttachment } from "./ComposerAddAttachment";
6
6
  export { ComposerPrimitiveAttachments as Attachments } from "./ComposerAttachments";
7
+ export { ComposerPrimitiveAttachmentByIndex as AttachmentByIndex } from "./ComposerAttachments";
7
8
  export { ComposerPrimitiveIf as If } from "./ComposerIf";
@@ -46,31 +46,55 @@ const AttachmentComponent: FC<{
46
46
  return <Component />;
47
47
  };
48
48
 
49
- const MessageAttachmentImpl: FC<
50
- MessagePrimitiveAttachments.Props & { attachmentIndex: number }
51
- > = ({ components, attachmentIndex }) => {
52
- const messageRuntime = useMessageRuntime();
53
- const runtime = useMemo(
54
- () => messageRuntime.getAttachmentByIndex(attachmentIndex),
55
- [messageRuntime, attachmentIndex],
56
- );
49
+ export namespace MessagePrimitiveAttachmentByIndex {
50
+ export type Props = {
51
+ index: number;
52
+ components?: MessagePrimitiveAttachments.Props["components"];
53
+ };
54
+ }
55
+
56
+ /**
57
+ * Renders a single attachment at the specified index within the current message.
58
+ *
59
+ * This component provides direct access to render a specific attachment
60
+ * from the message's attachment list using the provided component configuration.
61
+ *
62
+ * @example
63
+ * ```tsx
64
+ * <MessagePrimitive.AttachmentByIndex
65
+ * index={0}
66
+ * components={{
67
+ * Image: MyImageAttachment,
68
+ * Document: MyDocumentAttachment
69
+ * }}
70
+ * />
71
+ * ```
72
+ */
73
+ export const MessagePrimitiveAttachmentByIndex: FC<MessagePrimitiveAttachmentByIndex.Props> =
74
+ memo(
75
+ ({ index, components }) => {
76
+ const messageRuntime = useMessageRuntime();
77
+ const runtime = useMemo(
78
+ () => messageRuntime.getAttachmentByIndex(index),
79
+ [messageRuntime, index],
80
+ );
57
81
 
58
- return (
59
- <AttachmentRuntimeProvider runtime={runtime}>
60
- <AttachmentComponent components={components} />
61
- </AttachmentRuntimeProvider>
82
+ return (
83
+ <AttachmentRuntimeProvider runtime={runtime}>
84
+ <AttachmentComponent components={components} />
85
+ </AttachmentRuntimeProvider>
86
+ );
87
+ },
88
+ (prev, next) =>
89
+ prev.index === next.index &&
90
+ prev.components?.Image === next.components?.Image &&
91
+ prev.components?.Document === next.components?.Document &&
92
+ prev.components?.File === next.components?.File &&
93
+ prev.components?.Attachment === next.components?.Attachment,
62
94
  );
63
- };
64
95
 
65
- const MessageAttachment = memo(
66
- MessageAttachmentImpl,
67
- (prev, next) =>
68
- prev.attachmentIndex === next.attachmentIndex &&
69
- prev.components?.Image === next.components?.Image &&
70
- prev.components?.Document === next.components?.Document &&
71
- prev.components?.File === next.components?.File &&
72
- prev.components?.Attachment === next.components?.Attachment,
73
- );
96
+ MessagePrimitiveAttachmentByIndex.displayName =
97
+ "MessagePrimitive.AttachmentByIndex";
74
98
 
75
99
  export const MessagePrimitiveAttachments: FC<
76
100
  MessagePrimitiveAttachments.Props
@@ -82,9 +106,9 @@ export const MessagePrimitiveAttachments: FC<
82
106
 
83
107
  const attachmentElements = useMemo(() => {
84
108
  return Array.from({ length: attachmentsCount }, (_, index) => (
85
- <MessageAttachment
109
+ <MessagePrimitiveAttachmentByIndex
86
110
  key={index}
87
- attachmentIndex={index}
111
+ index={index}
88
112
  components={components}
89
113
  />
90
114
  ));
@@ -279,38 +279,58 @@ const MessagePartComponent: FC<MessagePartComponentProps> = ({
279
279
  }
280
280
  };
281
281
 
282
- type MessagePartProps = {
283
- partIndex: number;
284
- components: MessagePrimitiveParts.Props["components"];
285
- };
286
-
287
- const MessagePartImpl: FC<MessagePartProps> = ({ partIndex, components }) => {
288
- const messageRuntime = useMessageRuntime();
289
- const runtime = useMemo(
290
- () => messageRuntime.getMessagePartByIndex(partIndex),
291
- [messageRuntime, partIndex],
292
- );
282
+ export namespace MessagePrimitivePartByIndex {
283
+ export type Props = {
284
+ index: number;
285
+ components: MessagePrimitiveParts.Props["components"];
286
+ };
287
+ }
293
288
 
294
- return (
295
- <MessagePartRuntimeProvider runtime={runtime}>
296
- <MessagePartComponent components={components} />
297
- </MessagePartRuntimeProvider>
289
+ /**
290
+ * Renders a single message part at the specified index.
291
+ *
292
+ * This component provides direct access to render a specific message part
293
+ * within the current message context, using the provided component configuration.
294
+ *
295
+ * @example
296
+ * ```tsx
297
+ * <MessagePrimitive.PartByIndex
298
+ * index={0}
299
+ * components={{
300
+ * Text: MyTextComponent,
301
+ * Image: MyImageComponent
302
+ * }}
303
+ * />
304
+ * ```
305
+ */
306
+ export const MessagePrimitivePartByIndex: FC<MessagePrimitivePartByIndex.Props> =
307
+ memo(
308
+ ({ index, components }) => {
309
+ const messageRuntime = useMessageRuntime();
310
+ const runtime = useMemo(
311
+ () => messageRuntime.getMessagePartByIndex(index),
312
+ [messageRuntime, index],
313
+ );
314
+
315
+ return (
316
+ <MessagePartRuntimeProvider runtime={runtime}>
317
+ <MessagePartComponent components={components} />
318
+ </MessagePartRuntimeProvider>
319
+ );
320
+ },
321
+ (prev, next) =>
322
+ prev.index === next.index &&
323
+ prev.components?.Text === next.components?.Text &&
324
+ prev.components?.Reasoning === next.components?.Reasoning &&
325
+ prev.components?.Source === next.components?.Source &&
326
+ prev.components?.Image === next.components?.Image &&
327
+ prev.components?.File === next.components?.File &&
328
+ prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&
329
+ prev.components?.tools === next.components?.tools &&
330
+ prev.components?.ToolGroup === next.components?.ToolGroup,
298
331
  );
299
- };
300
332
 
301
- const MessagePart = memo(
302
- MessagePartImpl,
303
- (prev, next) =>
304
- prev.partIndex === next.partIndex &&
305
- prev.components?.Text === next.components?.Text &&
306
- prev.components?.Reasoning === next.components?.Reasoning &&
307
- prev.components?.Source === next.components?.Source &&
308
- prev.components?.Image === next.components?.Image &&
309
- prev.components?.File === next.components?.File &&
310
- prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&
311
- prev.components?.tools === next.components?.tools &&
312
- prev.components?.ToolGroup === next.components?.ToolGroup,
313
- );
333
+ MessagePrimitivePartByIndex.displayName = "MessagePrimitive.PartByIndex";
314
334
 
315
335
  const COMPLETE_STATUS: MessagePartStatus = Object.freeze({
316
336
  type: "complete",
@@ -386,9 +406,9 @@ export const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props> = ({
386
406
  return messageRanges.map((range) => {
387
407
  if (range.type === "single") {
388
408
  return (
389
- <MessagePart
409
+ <MessagePrimitivePartByIndex
390
410
  key={range.index}
391
- partIndex={range.index}
411
+ index={range.index}
392
412
  components={components}
393
413
  />
394
414
  );
@@ -404,9 +424,9 @@ export const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props> = ({
404
424
  {Array.from(
405
425
  { length: range.endIndex - range.startIndex + 1 },
406
426
  (_, i) => (
407
- <MessagePart
427
+ <MessagePrimitivePartByIndex
408
428
  key={i}
409
- partIndex={range.startIndex + i}
429
+ index={range.startIndex + i}
410
430
  components={components}
411
431
  />
412
432
  ),
@@ -1,8 +1,10 @@
1
1
  export { MessagePrimitiveRoot as Root } from "./MessageRoot";
2
2
  export { MessagePrimitiveParts as Parts } from "./MessageParts";
3
+ export { MessagePrimitivePartByIndex as PartByIndex } from "./MessageParts";
3
4
  export { MessagePrimitiveParts as Content } from "./MessageParts";
4
5
  export { MessagePrimitiveIf as If } from "./MessageIf";
5
6
  export { MessagePrimitiveAttachments as Attachments } from "./MessageAttachments";
7
+ export { MessagePrimitiveAttachmentByIndex as AttachmentByIndex } from "./MessageAttachments";
6
8
  export { MessagePrimitiveError as Error } from "./MessageError";
7
9
  export {
8
10
  MessagePrimitiveUnstable_PartsGrouped as Unstable_PartsGrouped,
@@ -136,35 +136,51 @@ const ThreadMessageComponent: FC<ThreadMessageComponentProps> = ({
136
136
 
137
137
  return <Component />;
138
138
  };
139
+ export namespace ThreadPrimitiveMessageByIndex {
140
+ export type Props = {
141
+ index: number;
142
+ components: ThreadPrimitiveMessages.Props["components"];
143
+ };
144
+ }
139
145
 
140
- type ThreadMessageProps = {
141
- messageIndex: number;
142
- components: ThreadPrimitiveMessages.Props["components"];
143
- };
144
-
145
- const ThreadMessageImpl: FC<ThreadMessageProps> = ({
146
- messageIndex,
147
- components,
148
- }) => {
149
- const threadRuntime = useThreadRuntime();
150
- const runtime = useMemo(
151
- () => threadRuntime.getMesssageByIndex(messageIndex),
152
- [threadRuntime, messageIndex],
153
- );
154
-
155
- return (
156
- <MessageRuntimeProvider runtime={runtime}>
157
- <ThreadMessageComponent components={components} />
158
- </MessageRuntimeProvider>
146
+ /**
147
+ * Renders a single message at the specified index in the current thread.
148
+ *
149
+ * This component provides message context for a specific message in the thread
150
+ * and renders it using the provided component configuration.
151
+ *
152
+ * @example
153
+ * ```tsx
154
+ * <ThreadPrimitive.MessageByIndex
155
+ * index={0}
156
+ * components={{
157
+ * UserMessage: MyUserMessage,
158
+ * AssistantMessage: MyAssistantMessage
159
+ * }}
160
+ * />
161
+ * ```
162
+ */
163
+ export const ThreadPrimitiveMessageByIndex: FC<ThreadPrimitiveMessageByIndex.Props> =
164
+ memo(
165
+ ({ index, components }) => {
166
+ const threadRuntime = useThreadRuntime();
167
+ const runtime = useMemo(
168
+ () => threadRuntime.getMesssageByIndex(index),
169
+ [threadRuntime, index],
170
+ );
171
+
172
+ return (
173
+ <MessageRuntimeProvider runtime={runtime}>
174
+ <ThreadMessageComponent components={components} />
175
+ </MessageRuntimeProvider>
176
+ );
177
+ },
178
+ (prev, next) =>
179
+ prev.index === next.index &&
180
+ isComponentsSame(prev.components, next.components),
159
181
  );
160
- };
161
182
 
162
- const ThreadMessage = memo(
163
- ThreadMessageImpl,
164
- (prev, next) =>
165
- prev.messageIndex === next.messageIndex &&
166
- isComponentsSame(prev.components, next.components),
167
- );
183
+ ThreadPrimitiveMessageByIndex.displayName = "ThreadPrimitive.MessageByIndex";
168
184
 
169
185
  /**
170
186
  * Renders all messages in the current thread using the provided component configuration.
@@ -192,7 +208,11 @@ export const ThreadPrimitiveMessagesImpl: FC<ThreadPrimitiveMessages.Props> = ({
192
208
  const messageElements = useMemo(() => {
193
209
  if (messagesLength === 0) return null;
194
210
  return Array.from({ length: messagesLength }, (_, index) => (
195
- <ThreadMessage key={index} messageIndex={index} components={components} />
211
+ <ThreadPrimitiveMessageByIndex
212
+ key={index}
213
+ index={index}
214
+ components={components}
215
+ />
196
216
  ));
197
217
  }, [messagesLength, components]);
198
218
 
@@ -3,5 +3,6 @@ export { ThreadPrimitiveEmpty as Empty } from "./ThreadEmpty";
3
3
  export { ThreadPrimitiveIf as If } from "./ThreadIf";
4
4
  export { ThreadPrimitiveViewport as Viewport } from "./ThreadViewport";
5
5
  export { ThreadPrimitiveMessages as Messages } from "./ThreadMessages";
6
+ export { ThreadPrimitiveMessageByIndex as MessageByIndex } from "./ThreadMessages";
6
7
  export { ThreadPrimitiveScrollToBottom as ScrollToBottom } from "./ThreadScrollToBottom";
7
8
  export { ThreadPrimitiveSuggestion as Suggestion } from "./ThreadSuggestion";
@@ -13,42 +13,57 @@ export namespace ThreadListPrimitiveItems {
13
13
  };
14
14
  }
15
15
 
16
- type ThreadListItemProps = {
17
- partIndex: number;
18
- archived: boolean;
19
- components: ThreadListPrimitiveItems.Props["components"];
20
- };
16
+ export namespace ThreadListPrimitiveItemByIndex {
17
+ export type Props = {
18
+ index: number;
19
+ archived?: boolean | undefined;
20
+ components: ThreadListPrimitiveItems.Props["components"];
21
+ };
22
+ }
21
23
 
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.threads.getArchivedItemByIndex(partIndex)
32
- : assistantRuntime.threads.getItemByIndex(partIndex),
33
- [assistantRuntime, partIndex, archived],
34
- );
24
+ /**
25
+ * Renders a single thread list item at the specified index.
26
+ *
27
+ * This component provides direct access to render a specific thread
28
+ * from the thread list using the provided component configuration.
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * <ThreadListPrimitive.ItemByIndex
33
+ * index={0}
34
+ * components={{
35
+ * ThreadListItem: MyThreadListItem
36
+ * }}
37
+ * />
38
+ * ```
39
+ */
40
+ export const ThreadListPrimitiveItemByIndex: FC<ThreadListPrimitiveItemByIndex.Props> =
41
+ memo(
42
+ ({ index, archived = false, components }) => {
43
+ const assistantRuntime = useAssistantRuntime();
44
+ const runtime = useMemo(
45
+ () =>
46
+ archived
47
+ ? assistantRuntime.threads.getArchivedItemByIndex(index)
48
+ : assistantRuntime.threads.getItemByIndex(index),
49
+ [assistantRuntime, index, archived],
50
+ );
35
51
 
36
- const ThreadListItemComponent = components.ThreadListItem;
52
+ const ThreadListItemComponent = components.ThreadListItem;
37
53
 
38
- return (
39
- <ThreadListItemRuntimeProvider runtime={runtime}>
40
- <ThreadListItemComponent />
41
- </ThreadListItemRuntimeProvider>
54
+ return (
55
+ <ThreadListItemRuntimeProvider runtime={runtime}>
56
+ <ThreadListItemComponent />
57
+ </ThreadListItemRuntimeProvider>
58
+ );
59
+ },
60
+ (prev, next) =>
61
+ prev.index === next.index &&
62
+ prev.archived === next.archived &&
63
+ prev.components.ThreadListItem === next.components.ThreadListItem,
42
64
  );
43
- };
44
65
 
45
- const ThreadListItem = memo(
46
- ThreadListItemImpl,
47
- (prev, next) =>
48
- prev.partIndex === next.partIndex &&
49
- prev.archived === next.archived &&
50
- prev.components.ThreadListItem === next.components.ThreadListItem,
51
- );
66
+ ThreadListPrimitiveItemByIndex.displayName = "ThreadListPrimitive.ItemByIndex";
52
67
 
53
68
  export const ThreadListPrimitiveItems: FC<ThreadListPrimitiveItems.Props> = ({
54
69
  archived = false,
@@ -60,9 +75,9 @@ export const ThreadListPrimitiveItems: FC<ThreadListPrimitiveItems.Props> = ({
60
75
 
61
76
  const listElements = useMemo(() => {
62
77
  return Array.from({ length: contentLength }, (_, index) => (
63
- <ThreadListItem
78
+ <ThreadListPrimitiveItemByIndex
64
79
  key={index}
65
- partIndex={index}
80
+ index={index}
66
81
  archived={archived}
67
82
  components={components}
68
83
  />
@@ -1,3 +1,4 @@
1
1
  export { ThreadListPrimitiveNew as New } from "./ThreadListNew";
2
2
  export { ThreadListPrimitiveItems as Items } from "./ThreadListItems";
3
+ export { ThreadListPrimitiveItemByIndex as ItemByIndex } from "./ThreadListItems";
3
4
  export { ThreadListPrimitiveRoot as Root } from "./ThreadListRoot";