@assistant-ui/react 0.7.44 → 0.7.45
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/runtimes/remote-thread-list/OptimisticState.d.ts +1 -1
- package/dist/runtimes/remote-thread-list/OptimisticState.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/OptimisticState.js +7 -5
- package/dist/runtimes/remote-thread-list/OptimisticState.js.map +1 -1
- package/dist/runtimes/remote-thread-list/OptimisticState.mjs +7 -5
- package/dist/runtimes/remote-thread-list/OptimisticState.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js +9 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs +13 -2
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +10 -2
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +35 -9
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs +35 -9
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs.map +1 -1
- package/dist/ui/assistant-message.d.ts.map +1 -1
- package/dist/ui/assistant-message.js +14 -10
- package/dist/ui/assistant-message.js.map +1 -1
- package/dist/ui/assistant-message.mjs +14 -10
- package/dist/ui/assistant-message.mjs.map +1 -1
- package/dist/ui/thread-config.d.ts +1 -0
- package/dist/ui/thread-config.d.ts.map +1 -1
- package/dist/ui/thread-config.js.map +1 -1
- package/dist/ui/thread-config.mjs.map +1 -1
- package/package.json +1 -1
- package/src/runtimes/remote-thread-list/OptimisticState.ts +15 -8
- package/src/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +15 -2
- package/src/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +47 -9
- package/src/ui/assistant-message.tsx +2 -0
- package/src/ui/thread-config.tsx +1 -0
@@ -2,7 +2,10 @@
|
|
2
2
|
|
3
3
|
import { ThreadListRuntimeCore } from "../core/ThreadListRuntimeCore";
|
4
4
|
import { generateId } from "../../internal";
|
5
|
-
import {
|
5
|
+
import {
|
6
|
+
RemoteThreadInitializeResponse,
|
7
|
+
RemoteThreadListAdapter,
|
8
|
+
} from "./types";
|
6
9
|
import { RemoteThreadListHookInstanceManager } from "./RemoteThreadListHookInstanceManager";
|
7
10
|
import { BaseSubscribable } from "./BaseSubscribable";
|
8
11
|
import { EMPTY_THREAD_CORE } from "./EMPTY_THREAD_CORE";
|
@@ -21,6 +24,15 @@ type RemoteThreadData =
|
|
21
24
|
}
|
22
25
|
| {
|
23
26
|
readonly threadId: string;
|
27
|
+
readonly initializeTask: Promise<RemoteThreadInitializeResponse>;
|
28
|
+
readonly remoteId?: undefined;
|
29
|
+
readonly externalId?: undefined;
|
30
|
+
readonly status: "regular" | "archived";
|
31
|
+
readonly title?: string | undefined;
|
32
|
+
}
|
33
|
+
| {
|
34
|
+
readonly threadId: string;
|
35
|
+
readonly initializeTask: Promise<RemoteThreadInitializeResponse>;
|
24
36
|
readonly remoteId: string;
|
25
37
|
readonly externalId: string | undefined;
|
26
38
|
readonly status: "regular" | "archived";
|
@@ -185,6 +197,10 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
185
197
|
externalId: thread.externalId,
|
186
198
|
status: thread.status,
|
187
199
|
title: thread.title,
|
200
|
+
initializeTask: Promise.resolve({
|
201
|
+
remoteId: thread.remoteId,
|
202
|
+
externalId: thread.externalId,
|
203
|
+
}),
|
188
204
|
};
|
189
205
|
}
|
190
206
|
|
@@ -338,8 +354,12 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
338
354
|
}
|
339
355
|
|
340
356
|
public initialize = async (threadId: string) => {
|
341
|
-
if (this._state.value.newThreadId !== threadId)
|
342
|
-
|
357
|
+
if (this._state.value.newThreadId !== threadId) {
|
358
|
+
const data = this.getItemById(threadId);
|
359
|
+
if (!data) throw new Error("Thread not found");
|
360
|
+
if (data.status === "new") throw new Error("Unexpected new state");
|
361
|
+
return data.initializeTask;
|
362
|
+
}
|
343
363
|
|
344
364
|
return this._state.optimisticUpdate({
|
345
365
|
execute: () => {
|
@@ -348,6 +368,19 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
348
368
|
optimistic: (state) => {
|
349
369
|
return updateStatusReducer(state, threadId, "regular");
|
350
370
|
},
|
371
|
+
loading: (state, task) => {
|
372
|
+
const mappingId = createThreadMappingId(threadId);
|
373
|
+
return {
|
374
|
+
...state,
|
375
|
+
threadData: {
|
376
|
+
...state.threadData,
|
377
|
+
[mappingId]: {
|
378
|
+
...state.threadData[mappingId],
|
379
|
+
initializeTask: task,
|
380
|
+
},
|
381
|
+
},
|
382
|
+
};
|
383
|
+
},
|
351
384
|
then: (state, { remoteId, externalId }) => {
|
352
385
|
const data = getThreadData(state, threadId);
|
353
386
|
if (!data) return state;
|
@@ -361,8 +394,9 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
361
394
|
},
|
362
395
|
threadData: {
|
363
396
|
...state.threadData,
|
364
|
-
[
|
397
|
+
[mappingId]: {
|
365
398
|
...data,
|
399
|
+
initializeTask: Promise.resolve({ remoteId, externalId }),
|
366
400
|
remoteId,
|
367
401
|
externalId,
|
368
402
|
},
|
@@ -406,8 +440,9 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
406
440
|
if (data.status === "new") throw new Error("Thread is not yet initialized");
|
407
441
|
|
408
442
|
return this._state.optimisticUpdate({
|
409
|
-
execute: () => {
|
410
|
-
|
443
|
+
execute: async () => {
|
444
|
+
const { remoteId } = await data.initializeTask;
|
445
|
+
return this._adapter.rename(remoteId, newTitle);
|
411
446
|
},
|
412
447
|
optimistic: (state) => {
|
413
448
|
const data = getThreadData(state, threadIdOrRemoteId);
|
@@ -448,7 +483,8 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
448
483
|
return this._state.optimisticUpdate({
|
449
484
|
execute: async () => {
|
450
485
|
await this._ensureThreadIsNotMain(data.threadId);
|
451
|
-
|
486
|
+
const { remoteId } = await data.initializeTask;
|
487
|
+
return this._adapter.archive(remoteId);
|
452
488
|
},
|
453
489
|
optimistic: (state) => {
|
454
490
|
return updateStatusReducer(state, data.threadId, "archived");
|
@@ -464,7 +500,8 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
464
500
|
return this._state.optimisticUpdate({
|
465
501
|
execute: async () => {
|
466
502
|
try {
|
467
|
-
|
503
|
+
const { remoteId } = await data.initializeTask;
|
504
|
+
return await this._adapter.unarchive(remoteId);
|
468
505
|
} catch (error) {
|
469
506
|
await this._ensureThreadIsNotMain(data.threadId);
|
470
507
|
throw error;
|
@@ -485,7 +522,8 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
485
522
|
return this._state.optimisticUpdate({
|
486
523
|
execute: async () => {
|
487
524
|
await this._ensureThreadIsNotMain(data.threadId);
|
488
|
-
|
525
|
+
const { remoteId } = await data.initializeTask;
|
526
|
+
return await this._adapter.delete(remoteId);
|
489
527
|
},
|
490
528
|
optimistic: (state) => {
|
491
529
|
return updateStatusReducer(state, data.threadId, "deleted");
|
@@ -65,6 +65,7 @@ const AssistantMessageContent = forwardRef<
|
|
65
65
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
66
66
|
[...(tools ?? []), components.ToolFallback],
|
67
67
|
);
|
68
|
+
const Footer = components.Footer;
|
68
69
|
|
69
70
|
return (
|
70
71
|
<AssistantMessageContentWrapper {...rest} ref={ref}>
|
@@ -76,6 +77,7 @@ const AssistantMessageContent = forwardRef<
|
|
76
77
|
tools: toolsComponents,
|
77
78
|
}}
|
78
79
|
/>
|
80
|
+
{Footer && <Footer />}
|
79
81
|
</AssistantMessageContentWrapper>
|
80
82
|
);
|
81
83
|
});
|
package/src/ui/thread-config.tsx
CHANGED
@@ -45,6 +45,7 @@ export type AssistantMessageConfig = {
|
|
45
45
|
Text?: TextContentPartComponent | undefined;
|
46
46
|
Empty?: EmptyContentPartComponent | undefined;
|
47
47
|
ToolFallback?: ComponentType<ToolCallContentPartProps> | undefined;
|
48
|
+
Footer?: ComponentType | undefined;
|
48
49
|
}
|
49
50
|
| undefined;
|
50
51
|
};
|