@assistant-ui/core 0.1.16 → 0.2.0

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 (173) hide show
  1. package/dist/index.d.ts +7 -7
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +2 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/react/index.d.ts +3 -1
  6. package/dist/react/index.d.ts.map +1 -1
  7. package/dist/react/index.js +2 -0
  8. package/dist/react/index.js.map +1 -1
  9. package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts +5 -0
  10. package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts.map +1 -0
  11. package/dist/react/primitive-hooks/useThreadListLoadMore.js +11 -0
  12. package/dist/react/primitive-hooks/useThreadListLoadMore.js.map +1 -0
  13. package/dist/react/primitives/message/MessageGroupedParts.d.ts +104 -0
  14. package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -0
  15. package/dist/react/primitives/message/MessageGroupedParts.js +74 -0
  16. package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -0
  17. package/dist/react/primitives/message/MessageParts.d.ts +8 -1
  18. package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
  19. package/dist/react/primitives/message/MessageParts.js +45 -42
  20. package/dist/react/primitives/message/MessageParts.js.map +1 -1
  21. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +2 -4
  22. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  23. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +4 -3
  24. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
  25. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +8 -6
  26. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  27. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +86 -38
  28. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  29. package/dist/react/runtimes/useLocalRuntime.d.ts +1 -1
  30. package/dist/react/utils/groupParts.d.ts +49 -0
  31. package/dist/react/utils/groupParts.d.ts.map +1 -0
  32. package/dist/react/utils/groupParts.js +97 -0
  33. package/dist/react/utils/groupParts.js.map +1 -0
  34. package/dist/runtime/api/assistant-runtime.d.ts +0 -33
  35. package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
  36. package/dist/runtime/api/assistant-runtime.js +0 -23
  37. package/dist/runtime/api/assistant-runtime.js.map +1 -1
  38. package/dist/runtime/api/bindings.d.ts +1 -3
  39. package/dist/runtime/api/bindings.d.ts.map +1 -1
  40. package/dist/runtime/api/composer-runtime.d.ts +3 -3
  41. package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
  42. package/dist/runtime/api/composer-runtime.js +1 -1
  43. package/dist/runtime/api/composer-runtime.js.map +1 -1
  44. package/dist/runtime/api/message-runtime.d.ts +1 -6
  45. package/dist/runtime/api/message-runtime.d.ts.map +1 -1
  46. package/dist/runtime/api/message-runtime.js.map +1 -1
  47. package/dist/runtime/api/thread-list-item-runtime.d.ts +18 -3
  48. package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
  49. package/dist/runtime/api/thread-list-item-runtime.js +1 -1
  50. package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
  51. package/dist/runtime/api/thread-list-runtime.d.ts +4 -0
  52. package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
  53. package/dist/runtime/api/thread-list-runtime.js +6 -0
  54. package/dist/runtime/api/thread-list-runtime.js.map +1 -1
  55. package/dist/runtime/api/thread-runtime.d.ts +6 -29
  56. package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
  57. package/dist/runtime/api/thread-runtime.js +2 -21
  58. package/dist/runtime/api/thread-runtime.js.map +1 -1
  59. package/dist/runtime/base/base-composer-runtime-core.d.ts +4 -3
  60. package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
  61. package/dist/runtime/base/base-composer-runtime-core.js +47 -33
  62. package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
  63. package/dist/runtime/base/base-thread-runtime-core.d.ts +3 -4
  64. package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
  65. package/dist/runtime/base/base-thread-runtime-core.js +11 -11
  66. package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
  67. package/dist/runtime/interfaces/composer-runtime-core.d.ts +28 -2
  68. package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
  69. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +3 -0
  70. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
  71. package/dist/runtime/interfaces/thread-runtime-core.d.ts +35 -4
  72. package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
  73. package/dist/runtime/utils/chat-model-adapter.d.ts +0 -4
  74. package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -1
  75. package/dist/runtime/utils/external-store-message.d.ts +0 -4
  76. package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
  77. package/dist/runtime/utils/external-store-message.js +0 -7
  78. package/dist/runtime/utils/external-store-message.js.map +1 -1
  79. package/dist/runtimes/assistant-transport/utils.d.ts +0 -9
  80. package/dist/runtimes/assistant-transport/utils.d.ts.map +1 -1
  81. package/dist/runtimes/assistant-transport/utils.js +0 -13
  82. package/dist/runtimes/assistant-transport/utils.js.map +1 -1
  83. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +0 -1
  84. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  85. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +2 -5
  86. package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
  87. package/dist/runtimes/local/local-thread-runtime-core.d.ts +0 -1
  88. package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
  89. package/dist/runtimes/local/local-thread-runtime-core.js +2 -6
  90. package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
  91. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +0 -1
  92. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
  93. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +0 -3
  94. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
  95. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
  96. package/dist/runtimes/remote-thread-list/empty-thread-core.js +0 -3
  97. package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
  98. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +12 -1
  99. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
  100. package/dist/runtimes/remote-thread-list/remote-thread-state.js +34 -0
  101. package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -1
  102. package/dist/runtimes/remote-thread-list/types.d.ts +5 -1
  103. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  104. package/dist/store/clients/thread-message-client.d.ts.map +1 -1
  105. package/dist/store/clients/thread-message-client.js +0 -1
  106. package/dist/store/clients/thread-message-client.js.map +1 -1
  107. package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
  108. package/dist/store/runtime-clients/composer-runtime-client.js +5 -6
  109. package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
  110. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
  111. package/dist/store/runtime-clients/thread-list-runtime-client.js +3 -0
  112. package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
  113. package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
  114. package/dist/store/runtime-clients/thread-runtime-client.js +0 -1
  115. package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
  116. package/dist/store/scopes/composer.d.ts +11 -1
  117. package/dist/store/scopes/composer.d.ts.map +1 -1
  118. package/dist/store/scopes/message.d.ts +1 -3
  119. package/dist/store/scopes/message.d.ts.map +1 -1
  120. package/dist/store/scopes/thread-list-item.d.ts +10 -0
  121. package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
  122. package/dist/store/scopes/thread.d.ts +17 -4
  123. package/dist/store/scopes/thread.d.ts.map +1 -1
  124. package/dist/store/scopes/threads.d.ts +3 -0
  125. package/dist/store/scopes/threads.d.ts.map +1 -1
  126. package/dist/subscribable/subscribable.d.ts +4 -4
  127. package/dist/subscribable/subscribable.d.ts.map +1 -1
  128. package/dist/subscribable/subscribable.js +4 -4
  129. package/dist/subscribable/subscribable.js.map +1 -1
  130. package/package.json +25 -13
  131. package/src/index.ts +12 -6
  132. package/src/react/index.ts +3 -0
  133. package/src/react/primitive-hooks/useThreadListLoadMore.ts +15 -0
  134. package/src/react/primitives/message/MessageGroupedParts.tsx +186 -0
  135. package/src/react/primitives/message/MessageParts.tsx +80 -55
  136. package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +7 -6
  137. package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +96 -43
  138. package/src/react/utils/groupParts.ts +152 -0
  139. package/src/runtime/api/assistant-runtime.ts +0 -62
  140. package/src/runtime/api/bindings.ts +1 -6
  141. package/src/runtime/api/composer-runtime.ts +10 -9
  142. package/src/runtime/api/message-runtime.ts +1 -8
  143. package/src/runtime/api/thread-list-item-runtime.ts +28 -6
  144. package/src/runtime/api/thread-list-runtime.ts +10 -0
  145. package/src/runtime/api/thread-runtime.ts +12 -53
  146. package/src/runtime/base/base-composer-runtime-core.ts +85 -42
  147. package/src/runtime/base/base-thread-runtime-core.ts +21 -13
  148. package/src/runtime/interfaces/composer-runtime-core.ts +39 -7
  149. package/src/runtime/interfaces/thread-list-runtime-core.ts +3 -0
  150. package/src/runtime/interfaces/thread-runtime-core.ts +42 -9
  151. package/src/runtime/utils/chat-model-adapter.ts +0 -5
  152. package/src/runtime/utils/external-store-message.ts +0 -8
  153. package/src/runtimes/assistant-transport/utils.ts +0 -28
  154. package/src/runtimes/external-store/external-store-thread-runtime-core.ts +2 -6
  155. package/src/runtimes/local/local-thread-runtime-core.ts +2 -7
  156. package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +0 -4
  157. package/src/runtimes/remote-thread-list/empty-thread-core.ts +0 -4
  158. package/src/runtimes/remote-thread-list/remote-thread-state.ts +54 -1
  159. package/src/runtimes/remote-thread-list/types.ts +6 -1
  160. package/src/store/clients/thread-message-client.ts +0 -1
  161. package/src/store/runtime-clients/composer-runtime-client.ts +5 -9
  162. package/src/store/runtime-clients/thread-list-runtime-client.ts +3 -0
  163. package/src/store/runtime-clients/thread-runtime-client.ts +0 -1
  164. package/src/store/scopes/composer.ts +11 -0
  165. package/src/store/scopes/message.ts +1 -6
  166. package/src/store/scopes/thread-list-item.ts +10 -0
  167. package/src/store/scopes/thread.ts +17 -5
  168. package/src/store/scopes/threads.ts +3 -0
  169. package/src/subscribable/subscribable.ts +10 -7
  170. package/src/tests/RemoteThreadListThreadListRuntimeCore-loadMore.test.ts +448 -0
  171. package/src/tests/RemoteThreadListThreadListRuntimeCore-reload.test.ts +6 -1
  172. package/src/tests/base-composer-runtime-core-addAttachment.test.ts +63 -0
  173. package/src/tests/groupParts.test.ts +114 -0
@@ -226,10 +226,6 @@ export class LocalThreadRuntimeCore
226
226
  throw new Error("Runtime does not support importing external states.");
227
227
  }
228
228
 
229
- public unstable_loadExternalState(): void {
230
- throw new Error("Runtime does not support importing external states.");
231
- }
232
-
233
229
  public async startRun(
234
230
  { parentId, runConfig }: StartRunConfig,
235
231
  runCallback?: ChatModelAdapter["run"],
@@ -253,7 +249,7 @@ export class LocalThreadRuntimeCore
253
249
  createdAt: new Date(),
254
250
  };
255
251
 
256
- this._notifyEventSubscribers("runStart");
252
+ this._notifyEventSubscribers("runStart", {});
257
253
 
258
254
  try {
259
255
  this._suggestions = [];
@@ -271,7 +267,7 @@ export class LocalThreadRuntimeCore
271
267
  runCallback = undefined;
272
268
  } while (shouldContinue(message, this._options.unstable_humanToolNames));
273
269
  } finally {
274
- this._notifyEventSubscribers("runEnd");
270
+ this._notifyEventSubscribers("runEnd", {});
275
271
  }
276
272
 
277
273
  this._suggestionsController = new AbortController();
@@ -405,7 +401,6 @@ export class LocalThreadRuntimeCore
405
401
  runConfig: this._lastRunConfig,
406
402
  abortSignal,
407
403
  context,
408
- config: context,
409
404
  unstable_assistantMessageId: message.id,
410
405
  unstable_threadId: threadId,
411
406
  unstable_parentId: parentId,
@@ -104,10 +104,6 @@ export class ReadonlyThreadRuntimeCore
104
104
  throw READONLY_THREAD_ERROR;
105
105
  }
106
106
 
107
- unstable_loadExternalState(): void {
108
- throw READONLY_THREAD_ERROR;
109
- }
110
-
111
107
  composer = {
112
108
  attachments: [] as never[],
113
109
  attachmentAccept: "*",
@@ -83,10 +83,6 @@ export const EMPTY_THREAD_CORE: ThreadRuntimeCore = {
83
83
  throw EMPTY_THREAD_ERROR;
84
84
  },
85
85
 
86
- unstable_loadExternalState() {
87
- throw EMPTY_THREAD_ERROR;
88
- },
89
-
90
86
  composer: {
91
87
  attachments: [],
92
88
  attachmentAccept: "*",
@@ -1,4 +1,7 @@
1
- import type { RemoteThreadInitializeResponse } from "./types";
1
+ import type {
2
+ RemoteThreadInitializeResponse,
3
+ RemoteThreadMetadata,
4
+ } from "./types";
2
5
 
3
6
  export type RemoteThreadData =
4
7
  | {
@@ -34,8 +37,58 @@ export function createThreadMappingId(id: string): THREAD_MAPPING_ID {
34
37
  return id as THREAD_MAPPING_ID;
35
38
  }
36
39
 
40
+ export const normalizeCursor = (c: string | undefined): string | undefined =>
41
+ c || undefined;
42
+
43
+ type ClassifyAccumulator = {
44
+ threadIds: string[];
45
+ archivedThreadIds: string[];
46
+ threadIdMap: Record<string, THREAD_MAPPING_ID>;
47
+ threadData: Record<THREAD_MAPPING_ID, RemoteThreadData>;
48
+ };
49
+
50
+ export const classifyThreads = (
51
+ threads: readonly RemoteThreadMetadata[],
52
+ acc: ClassifyAccumulator,
53
+ ): ClassifyAccumulator => {
54
+ for (const thread of threads) {
55
+ if (acc.threadIdMap[thread.remoteId] !== undefined) continue;
56
+
57
+ switch (thread.status) {
58
+ case "regular":
59
+ acc.threadIds.push(thread.remoteId);
60
+ break;
61
+ case "archived":
62
+ acc.archivedThreadIds.push(thread.remoteId);
63
+ break;
64
+ default: {
65
+ const _exhaustiveCheck: never = thread.status;
66
+ throw new Error(`Unsupported state: ${_exhaustiveCheck}`);
67
+ }
68
+ }
69
+
70
+ const mappingId = createThreadMappingId(thread.remoteId);
71
+ acc.threadIdMap[thread.remoteId] = mappingId;
72
+ acc.threadData[mappingId] = {
73
+ id: thread.remoteId,
74
+ remoteId: thread.remoteId,
75
+ externalId: thread.externalId,
76
+ status: thread.status,
77
+ title: thread.title,
78
+ custom: thread.custom,
79
+ initializeTask: Promise.resolve({
80
+ remoteId: thread.remoteId,
81
+ externalId: thread.externalId,
82
+ }),
83
+ };
84
+ }
85
+ return acc;
86
+ };
87
+
37
88
  export type RemoteThreadState = {
38
89
  readonly isLoading: boolean;
90
+ readonly isLoadingMore: boolean;
91
+ readonly cursor: string | undefined;
39
92
  readonly newThreadId: string | undefined;
40
93
  readonly threadIds: readonly string[];
41
94
  readonly archivedThreadIds: readonly string[];
@@ -18,10 +18,15 @@ export type RemoteThreadMetadata = {
18
18
 
19
19
  export type RemoteThreadListResponse = {
20
20
  threads: RemoteThreadMetadata[];
21
+ nextCursor?: string | undefined;
22
+ };
23
+
24
+ export type RemoteThreadListPageOptions = {
25
+ after?: string | undefined;
21
26
  };
22
27
 
23
28
  export type RemoteThreadListAdapter = {
24
- list(): Promise<RemoteThreadListResponse>;
29
+ list(params?: RemoteThreadListPageOptions): Promise<RemoteThreadListResponse>;
25
30
 
26
31
  rename(remoteId: string, newTitle: string): Promise<void>;
27
32
  archive(remoteId: string): Promise<void>;
@@ -106,7 +106,6 @@ export const ThreadMessageClient = resource(
106
106
  branchNumber,
107
107
  branchCount,
108
108
  speech: undefined,
109
- submittedFeedback: message.metadata.submittedFeedback,
110
109
  isCopied: isCopiedState,
111
110
  isHovering: isHoveringState,
112
111
  };
@@ -63,19 +63,15 @@ export const ComposerClient = resource(
63
63
  unsubscribers.push(unsubscribe);
64
64
  }
65
65
 
66
- // attachmentAddError carries the failed attachment ID
67
66
  unsubscribers.push(
68
- runtime.unstable_on("attachmentAddError", () => {
69
- const errorAttachment = runtime
70
- .getState()
71
- .attachments.findLast(
72
- (a) =>
73
- a.status.type === "incomplete" && a.status.reason === "error",
74
- );
67
+ runtime.unstable_on("attachmentAddError", (payload) => {
68
+ // payload.error omitted: raw Error is not store-serializable; use runtime.unstable_on for it.
75
69
  emit("composer.attachmentAddError", {
76
70
  threadId: threadIdRef.current,
77
71
  ...(messageIdRef && { messageId: messageIdRef.current }),
78
- ...(errorAttachment && { attachmentId: errorAttachment.id }),
72
+ ...(payload.attachmentId && { attachmentId: payload.attachmentId }),
73
+ reason: payload.reason,
74
+ message: payload.message,
79
75
  });
80
76
  }),
81
77
  );
@@ -53,6 +53,8 @@ export const ThreadListClient = resource(
53
53
  mainThreadId: runtimeState.mainThreadId,
54
54
  newThreadId: runtimeState.newThreadId ?? null,
55
55
  isLoading: runtimeState.isLoading,
56
+ isLoadingMore: runtimeState.isLoadingMore,
57
+ hasMore: runtimeState.hasMore,
56
58
  threadIds: runtimeState.threadIds,
57
59
  archivedThreadIds: runtimeState.archivedThreadIds,
58
60
  threadItems: threadItems.state,
@@ -87,6 +89,7 @@ export const ThreadListClient = resource(
87
89
  },
88
90
  getLoadThreadsPromise: () => runtime.getLoadThreadsPromise(),
89
91
  reload: () => runtime.reload(),
92
+ loadMore: () => runtime.loadMore(),
90
93
  __internal_getAssistantRuntime: () => __internal_assistantRuntime,
91
94
  };
92
95
  },
@@ -116,7 +116,6 @@ export const ThreadClient = resource(
116
116
  append: runtime.append,
117
117
  startRun: runtime.startRun,
118
118
  resumeRun: runtime.resumeRun,
119
- unstable_resumeRun: runtime.resumeRun,
120
119
  cancelRun: runtime.cancelRun,
121
120
  getModelContext: runtime.getModelContext,
122
121
  export: runtime.export,
@@ -4,6 +4,7 @@ import type { QuoteInfo } from "../../types/quote";
4
4
  import type { RunConfig } from "../../types/message";
5
5
  import type { ComposerRuntime } from "../../runtime/api/composer-runtime";
6
6
  import type {
7
+ AttachmentAddErrorReason,
7
8
  DictationState,
8
9
  SendOptions,
9
10
  } from "../../runtime/interfaces/composer-runtime-core";
@@ -91,12 +92,22 @@ export type ComposerMeta = {
91
92
  };
92
93
 
93
94
  export type ComposerEvents = {
95
+ /**
96
+ * @deprecated State-derivable. Observe composer `text` clearing via
97
+ * `useAuiState` instead. Kept for backward compatibility.
98
+ */
94
99
  "composer.send": { threadId: string; messageId?: string };
100
+ /**
101
+ * @deprecated State-derivable. Observe composer `attachments` via
102
+ * `useAuiState` instead. Kept for backward compatibility.
103
+ */
95
104
  "composer.attachmentAdd": { threadId: string; messageId?: string };
96
105
  "composer.attachmentAddError": {
97
106
  threadId: string;
98
107
  messageId?: string;
99
108
  attachmentId?: string;
109
+ reason: AttachmentAddErrorReason;
110
+ message: string;
100
111
  };
101
112
  };
102
113
 
@@ -1,9 +1,6 @@
1
1
  import type { ThreadMessage } from "../../types/message";
2
2
  import type { RunConfig } from "../../types/message";
3
- import type {
4
- SpeechState,
5
- SubmittedFeedback,
6
- } from "../../runtime/interfaces/thread-runtime-core";
3
+ import type { SpeechState } from "../../runtime/interfaces/thread-runtime-core";
7
4
  import type { MessageRuntime } from "../../runtime/api/message-runtime";
8
5
  import type { ComposerMethods, ComposerState } from "./composer";
9
6
  import type { PartMethods, PartState } from "./part";
@@ -31,8 +28,6 @@ export type MessageState = ThreadMessage & {
31
28
  * });
32
29
  */
33
30
  readonly speech: SpeechState | undefined;
34
- /** @deprecated Use `message.metadata.submittedFeedback` instead. This will be removed in 0.12.0. */
35
- readonly submittedFeedback: SubmittedFeedback | undefined;
36
31
  readonly composer: ComposerState;
37
32
  readonly parts: readonly PartState[];
38
33
  readonly isCopied: boolean;
@@ -32,7 +32,17 @@ export type ThreadListItemMeta = {
32
32
  };
33
33
 
34
34
  export type ThreadListItemEvents = {
35
+ /**
36
+ * @deprecated State-derivable. Compare `s.threads.mainThreadId` against the
37
+ * item's `s.threadListItem.id` via `useAuiState` instead. Kept for backward
38
+ * compatibility.
39
+ */
35
40
  "threadListItem.switchedTo": { threadId: string };
41
+ /**
42
+ * @deprecated State-derivable. Compare `s.threads.mainThreadId` against the
43
+ * item's `s.threadListItem.id` via `useAuiState` instead. Kept for backward
44
+ * compatibility.
45
+ */
36
46
  "threadListItem.switchedAway": { threadId: string };
37
47
  };
38
48
 
@@ -98,11 +98,6 @@ export type ThreadMethods = {
98
98
  * @param config The configuration for resuming the run
99
99
  */
100
100
  resumeRun(config: CreateResumeRunConfig): void;
101
-
102
- /**
103
- * @deprecated Use `resumeRun` instead.
104
- */
105
- unstable_resumeRun(config: CreateResumeRunConfig): void;
106
101
  cancelRun(): void;
107
102
  getModelContext(): ModelContext;
108
103
  export(): ExportedMessageRepository;
@@ -130,9 +125,26 @@ export type ThreadMeta = {
130
125
  };
131
126
 
132
127
  export type ThreadEvents = {
128
+ /**
129
+ * @deprecated State-derivable. Observe `isRunning` flipping to `true` via
130
+ * `useAuiState` instead. Kept for backward compatibility.
131
+ */
133
132
  "thread.runStart": { threadId: string };
133
+ /**
134
+ * @deprecated State-derivable. Observe `isRunning` flipping to `false` via
135
+ * `useAuiState` instead. Kept for backward compatibility.
136
+ */
134
137
  "thread.runEnd": { threadId: string };
138
+ /**
139
+ * @deprecated State-derivable. This event fires before the first message is
140
+ * added; observe `messages` becoming non-empty via `useAuiState` instead of
141
+ * reading state inside this event handler. Kept for backward compatibility.
142
+ */
135
143
  "thread.initialize": { threadId: string };
144
+ /**
145
+ * Truly transient. Model context lives in a provider, not in thread state,
146
+ * so this event has no state-derivable equivalent.
147
+ */
136
148
  "thread.modelContextUpdate": { threadId: string };
137
149
  };
138
150
 
@@ -9,6 +9,8 @@ export type ThreadsState = {
9
9
  readonly mainThreadId: string;
10
10
  readonly newThreadId: string | null;
11
11
  readonly isLoading: boolean;
12
+ readonly isLoadingMore: boolean;
13
+ readonly hasMore: boolean;
12
14
  readonly threadIds: readonly string[];
13
15
  readonly archivedThreadIds: readonly string[];
14
16
  readonly threadItems: readonly ThreadListItemState[];
@@ -28,6 +30,7 @@ export type ThreadsMethods = {
28
30
  thread(selector: "main"): ThreadMethods;
29
31
  getLoadThreadsPromise(): Promise<void>;
30
32
  reload(): Promise<void>;
33
+ loadMore(): Promise<void>;
31
34
  __internal_getAssistantRuntime?(): AssistantRuntime;
32
35
  };
33
36
 
@@ -21,7 +21,10 @@ export type EventSubscribable<TEvent extends string> = {
21
21
  event: TEvent;
22
22
  binding: SubscribableWithState<
23
23
  | {
24
- unstable_on: (event: TEvent, callback: () => void) => Unsubscribe;
24
+ unstable_on: (
25
+ event: TEvent,
26
+ callback: (payload?: unknown) => void,
27
+ ) => Unsubscribe;
25
28
  }
26
29
  | undefined,
27
30
  unknown
@@ -87,7 +90,7 @@ export class BaseSubscribable {
87
90
 
88
91
  // lazy connect/disconnect: only opens upstream subscription while it has subscribers
89
92
  export abstract class BaseSubject {
90
- private _subscriptions = new Set<() => void>();
93
+ private _subscriptions = new Set<(payload?: unknown) => void>();
91
94
  private _connection: Unsubscribe | undefined;
92
95
 
93
96
  protected get isConnected() {
@@ -96,8 +99,8 @@ export abstract class BaseSubject {
96
99
 
97
100
  protected abstract _connect(): Unsubscribe;
98
101
 
99
- protected notifySubscribers() {
100
- for (const callback of this._subscriptions) callback();
102
+ protected notifySubscribers(payload?: unknown) {
103
+ for (const callback of this._subscriptions) callback(payload);
101
104
  }
102
105
 
103
106
  private _updateConnection() {
@@ -110,7 +113,7 @@ export abstract class BaseSubject {
110
113
  }
111
114
  }
112
115
 
113
- public subscribe(callback: () => void) {
116
+ public subscribe(callback: (payload?: unknown) => void) {
114
117
  this._subscriptions.add(callback);
115
118
  this._updateConnection();
116
119
 
@@ -270,8 +273,8 @@ export class EventSubscriptionSubject<
270
273
  }
271
274
 
272
275
  protected _connect(): Unsubscribe {
273
- const callback = () => {
274
- this.notifySubscribers();
276
+ const callback = (payload?: unknown) => {
277
+ this.notifySubscribers(payload);
275
278
  };
276
279
 
277
280
  let lastState = this.config.binding.getState();