@assistant-ui/core 0.3.18 → 0.3.19
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.
- package/dist/adapters/speech.d.ts.map +1 -1
- package/dist/adapters/speech.js +13 -3
- package/dist/adapters/speech.js.map +1 -1
- package/dist/adapters/thread-history.d.ts +4 -0
- package/dist/adapters/thread-history.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/model-context/frame/host.d.ts.map +1 -1
- package/dist/model-context/frame/host.js +26 -11
- package/dist/model-context/frame/host.js.map +1 -1
- package/dist/model-context/interactable-composer-metadata.js +11 -9
- package/dist/model-context/interactable-composer-metadata.js.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js +45 -7
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/client/DataRenderers.d.ts.map +1 -1
- package/dist/react/client/DataRenderers.js +20 -15
- package/dist/react/client/DataRenderers.js.map +1 -1
- package/dist/react/client/Interactables.d.ts.map +1 -1
- package/dist/react/client/Interactables.js +11 -5
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/RemoteThreadList.d.ts.map +1 -1
- package/dist/react/client/RemoteThreadList.js +3 -2
- package/dist/react/client/RemoteThreadList.js.map +1 -1
- package/dist/react/client/interactable-model-context.d.ts.map +1 -1
- package/dist/react/client/interactable-model-context.js +3 -2
- package/dist/react/client/interactable-model-context.js.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/dist/react/interactables-legacy/useAssistantInteractable.d.ts.map +1 -1
- package/dist/react/interactables-legacy/useAssistantInteractable.js +3 -0
- package/dist/react/interactables-legacy/useAssistantInteractable.js.map +1 -1
- package/dist/react/model-context/useInteractable.d.ts.map +1 -1
- package/dist/react/model-context/useInteractable.js +4 -1
- package/dist/react/model-context/useInteractable.js.map +1 -1
- package/dist/react/model-context/useInteractableVersions.js +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.d.ts +11 -2
- package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.js +3 -2
- package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
- package/dist/react/primitives/part/PartMessages.d.ts +1 -0
- package/dist/react/primitives/part/PartMessages.d.ts.map +1 -1
- package/dist/react/primitives/part/PartMessages.js +1 -0
- package/dist/react/primitives/part/PartMessages.js.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.js +6 -5
- package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +2 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +2 -24
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +135 -374
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +1 -0
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js +22 -2
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.d.ts +40 -15
- package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.js +62 -15
- package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts +2 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.js +4 -0
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/sdkIdentity.d.ts +6 -0
- package/dist/react/runtimes/cloud/sdkIdentity.d.ts.map +1 -0
- package/dist/react/runtimes/cloud/sdkIdentity.js +9 -0
- package/dist/react/runtimes/cloud/sdkIdentity.js.map +1 -0
- package/dist/react/runtimes/external-message-converter.d.ts +12 -2
- package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.js +26 -61
- package/dist/react/runtimes/external-message-converter.js.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.js +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/react/utils/groupParts.d.ts +6 -1
- package/dist/react/utils/groupParts.d.ts.map +1 -1
- package/dist/react/utils/groupParts.js +6 -0
- package/dist/react/utils/groupParts.js.map +1 -1
- package/dist/react/utils/useJSONEqual.d.ts +3 -1
- package/dist/react/utils/useJSONEqual.d.ts.map +1 -1
- package/dist/react/utils/useJSONEqual.js +6 -1
- package/dist/react/utils/useJSONEqual.js.map +1 -1
- package/dist/react/utils/useJSONSchemaDependency.d.ts +7 -0
- package/dist/react/utils/useJSONSchemaDependency.d.ts.map +1 -0
- package/dist/react/utils/useJSONSchemaDependency.js +20 -0
- package/dist/react/utils/useJSONSchemaDependency.js.map +1 -0
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.js +2 -5
- package/dist/runtime/api/thread-runtime.js.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +1 -0
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +46 -10
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +2 -0
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js +155 -64
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +6 -0
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.d.ts +5 -0
- package/dist/runtime/queue/message-queue.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js +61 -6
- package/dist/runtime/queue/message-queue.js.map +1 -1
- package/dist/runtime/utils/auto-status.d.ts +6 -2
- package/dist/runtime/utils/auto-status.d.ts.map +1 -1
- package/dist/runtime/utils/auto-status.js +12 -4
- package/dist/runtime/utils/auto-status.js.map +1 -1
- package/dist/runtime/utils/external-message-conversion.d.ts +16 -4
- package/dist/runtime/utils/external-message-conversion.d.ts.map +1 -1
- package/dist/runtime/utils/external-message-conversion.js +48 -12
- package/dist/runtime/utils/external-message-conversion.js.map +1 -1
- package/dist/runtime/utils/message-repository.js +3 -3
- package/dist/runtime/utils/message-repository.js.map +1 -1
- package/dist/runtime/utils/thread-message-like.d.ts +2 -1
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js +4 -2
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js +8 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/internal.d.ts +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +4 -1
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +2 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
- package/dist/store/clients/external-thread.d.ts.map +1 -1
- package/dist/store/clients/external-thread.js +241 -200
- package/dist/store/clients/external-thread.js.map +1 -1
- package/dist/store/clients/thread-tasks.d.ts +13 -0
- package/dist/store/clients/thread-tasks.d.ts.map +1 -0
- package/dist/store/clients/thread-tasks.js +69 -0
- package/dist/store/clients/thread-tasks.js.map +1 -0
- package/dist/store/index.d.ts +3 -2
- package/dist/store/index.js +3 -3
- package/dist/store/primitive-predicates.d.ts.map +1 -1
- package/dist/store/primitive-predicates.js +4 -4
- package/dist/store/primitive-predicates.js.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +176 -128
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/store/scope-registration.d.ts +2 -0
- package/dist/store/scope-registration.d.ts.map +1 -1
- package/dist/store/scopes/task.d.ts +36 -0
- package/dist/store/scopes/task.d.ts.map +1 -0
- package/dist/store/scopes/task.js +0 -0
- package/dist/store/scopes/thread.d.ts +20 -0
- package/dist/store/scopes/thread.d.ts.map +1 -1
- package/dist/subscribable/subscribable.d.ts +2 -1
- package/dist/subscribable/subscribable.d.ts.map +1 -1
- package/dist/subscribable/subscribable.js +23 -15
- package/dist/subscribable/subscribable.js.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/message.d.ts +8 -1
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/dist/utils/abortable-iterable.d.ts.map +1 -1
- package/dist/utils/abortable-iterable.js +30 -14
- package/dist/utils/abortable-iterable.js.map +1 -1
- package/dist/utils/getGroupStatus.d.ts +18 -2
- package/dist/utils/getGroupStatus.d.ts.map +1 -1
- package/dist/utils/getGroupStatus.js +32 -7
- package/dist/utils/getGroupStatus.js.map +1 -1
- package/dist/utils/wire-media.d.ts.map +1 -1
- package/dist/utils/wire-media.js +2 -2
- package/dist/utils/wire-media.js.map +1 -1
- package/package.json +6 -6
- package/src/adapters/speech.test.ts +236 -0
- package/src/adapters/speech.ts +17 -10
- package/src/adapters/thread-history.ts +3 -0
- package/src/index.ts +1 -0
- package/src/model-context/frame/host.test.ts +113 -1
- package/src/model-context/frame/host.ts +39 -12
- package/src/model-context/interactable-composer-metadata.test.ts +30 -0
- package/src/model-context/interactable-composer-metadata.ts +10 -10
- package/src/react/adapters/LocalStorageThreadListAdapter.test.ts +244 -0
- package/src/react/adapters/LocalStorageThreadListAdapter.tsx +104 -7
- package/src/react/client/DataRenderers.test.tsx +45 -0
- package/src/react/client/DataRenderers.ts +13 -9
- package/src/react/client/Interactables.test.ts +44 -1
- package/src/react/client/Interactables.ts +7 -1
- package/src/react/client/RemoteThreadList.test.ts +41 -1
- package/src/react/client/RemoteThreadList.ts +15 -2
- package/src/react/client/interactable-model-context.test.ts +44 -0
- package/src/react/client/interactable-model-context.ts +3 -2
- package/src/react/index.ts +5 -1
- package/src/react/interactables-legacy/useAssistantInteractable.test.tsx +132 -0
- package/src/react/interactables-legacy/useAssistantInteractable.ts +10 -1
- package/src/react/model-context/useInteractable.test.tsx +177 -0
- package/src/react/model-context/useInteractable.ts +3 -0
- package/src/react/primitive-hooks/useActionBarCopy.test.ts +0 -1
- package/src/react/primitive-hooks/useSuggestionTrigger.test.ts +0 -1
- package/src/react/primitives/message/MessageGroupedParts.test.tsx +96 -0
- package/src/react/primitives/message/MessageGroupedParts.tsx +15 -4
- package/src/react/primitives/part/PartMessages.test.tsx +104 -1
- package/src/react/primitives/part/PartMessages.tsx +1 -0
- package/src/react/primitives/thread/ThreadMessages.test.tsx +142 -0
- package/src/react/primitives/thread/ThreadMessages.tsx +8 -5
- package/src/react/providers/ReadonlyThreadProvider.test.tsx +56 -0
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +7 -1
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.ts +20 -14
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +221 -1
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +166 -512
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.test.ts +77 -0
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +27 -1
- package/src/react/runtimes/cloud/auiV0.ts +160 -25
- package/src/react/runtimes/cloud/createCloudThreadListAdapter.test.ts +21 -0
- package/src/react/runtimes/cloud/createCloudThreadListAdapter.ts +7 -1
- package/src/react/runtimes/cloud/sdkIdentity.ts +9 -0
- package/src/react/runtimes/cloud/useCloudThreadListAdapter.test.tsx +18 -4
- package/src/react/runtimes/external-message-converter.test.ts +136 -1
- package/src/react/runtimes/external-message-converter.ts +39 -93
- package/src/react/runtimes/useRemoteThreadListRuntime.ts +1 -1
- package/src/react/utils/groupParts.ts +12 -1
- package/src/react/utils/useJSONEqual.ts +9 -0
- package/src/react/utils/useJSONSchemaDependency.ts +22 -0
- package/src/runtime/api/thread-runtime.test.ts +58 -0
- package/src/runtime/api/thread-runtime.ts +2 -4
- package/src/runtime/base/base-composer-runtime-core.ts +69 -16
- package/src/runtime/base/base-thread-runtime-core.test.ts +1008 -1
- package/src/runtime/base/base-thread-runtime-core.ts +222 -83
- package/src/runtime/interfaces/thread-runtime-core.ts +6 -0
- package/src/runtime/queue/message-queue.ts +68 -6
- package/src/runtime/utils/auto-status.test.ts +112 -1
- package/src/runtime/utils/auto-status.ts +31 -5
- package/src/runtime/utils/external-message-conversion.test.ts +134 -0
- package/src/runtime/utils/external-message-conversion.ts +122 -31
- package/src/runtime/utils/message-repository.test.ts +49 -0
- package/src/runtime/utils/message-repository.ts +3 -3
- package/src/runtime/utils/thread-message-like.test.ts +52 -0
- package/src/runtime/utils/thread-message-like.ts +4 -0
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +31 -1
- package/src/runtimes/local/local-thread-runtime-core.test.ts +21 -0
- package/src/runtimes/local/local-thread-runtime-core.ts +11 -1
- package/src/runtimes/tool-invocations/EDGE_CASES.md +2 -6
- package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +133 -0
- package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +10 -6
- package/src/store/clients/external-thread.ts +19 -1
- package/src/store/clients/thread-tasks.test.ts +274 -0
- package/src/store/clients/thread-tasks.ts +138 -0
- package/src/store/index.ts +8 -0
- package/src/store/primitive-predicates.test.ts +48 -5
- package/src/store/primitive-predicates.ts +7 -2
- package/src/store/runtime-clients/thread-runtime-client.ts +31 -1
- package/src/store/scope-registration.ts +2 -0
- package/src/store/scopes/task.ts +34 -0
- package/src/store/scopes/thread.ts +16 -0
- package/src/store/thread-tasks.test.tsx +209 -0
- package/src/subscribable/subscribable.test.ts +156 -1
- package/src/subscribable/subscribable.ts +25 -15
- package/src/tests/MessageRepository.test.ts +1 -5
- package/src/tests/auiV0Encode.test.ts +300 -0
- package/src/tests/base-composer-runtime-core-send.test.ts +51 -0
- package/src/tests/base-composer-runtime-core.test.ts +314 -2
- package/src/tests/external-store-thread-runtime-core-adapter.test.ts +151 -0
- package/src/tests/external-thread-attachments.test.tsx +69 -0
- package/src/tests/external-thread-parity.test.tsx +34 -0
- package/src/tests/groupParts.test.ts +71 -0
- package/src/tests/message-queue.test.ts +253 -0
- package/src/tests/remote-thread-list-reactive-threadId.test.ts +51 -0
- package/src/tests/useRemoteThreadListRuntime-controlled.test.tsx +43 -0
- package/src/types/index.ts +1 -0
- package/src/types/message.ts +8 -0
- package/src/utils/abortable-iterable.test.ts +115 -0
- package/src/utils/abortable-iterable.ts +34 -23
- package/src/utils/getGroupStatus.test.ts +70 -4
- package/src/utils/getGroupStatus.ts +35 -12
- package/src/utils/wire-media.test.ts +10 -0
- package/src/utils/wire-media.ts +6 -2
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from "vitest";
|
|
2
2
|
import type { SubscribableWithState } from "./subscribable";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
EventSubscriptionSubject,
|
|
5
|
+
LazyMemoizeSubject,
|
|
6
|
+
NestedSubscriptionSubject,
|
|
7
|
+
runCleanups,
|
|
8
|
+
ShallowMemoizeSubject,
|
|
9
|
+
} from "./subscribable";
|
|
4
10
|
|
|
5
11
|
type TestState = {
|
|
6
12
|
status: string;
|
|
@@ -56,6 +62,57 @@ const createRebuildingBinding = (initialState: TestState) => {
|
|
|
56
62
|
};
|
|
57
63
|
};
|
|
58
64
|
|
|
65
|
+
describe("runCleanups", () => {
|
|
66
|
+
it("runs every cleanup before rethrowing an error", () => {
|
|
67
|
+
const cleanupError = new Error("cleanup failed");
|
|
68
|
+
const laterCleanup = vi.fn();
|
|
69
|
+
|
|
70
|
+
expect(() =>
|
|
71
|
+
runCleanups([
|
|
72
|
+
() => {
|
|
73
|
+
throw cleanupError;
|
|
74
|
+
},
|
|
75
|
+
laterCleanup,
|
|
76
|
+
]),
|
|
77
|
+
).toThrow(cleanupError);
|
|
78
|
+
expect(laterCleanup).toHaveBeenCalledOnce();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("preserves every error when multiple cleanups throw", () => {
|
|
82
|
+
const firstError = new Error("first cleanup failed");
|
|
83
|
+
const secondError = new Error("second cleanup failed");
|
|
84
|
+
const consoleError = vi
|
|
85
|
+
.spyOn(console, "error")
|
|
86
|
+
.mockImplementation(() => {});
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
let thrown: unknown;
|
|
90
|
+
try {
|
|
91
|
+
runCleanups([
|
|
92
|
+
() => {
|
|
93
|
+
throw firstError;
|
|
94
|
+
},
|
|
95
|
+
() => {
|
|
96
|
+
throw secondError;
|
|
97
|
+
},
|
|
98
|
+
]);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
thrown = error;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
expect(thrown).toBeInstanceOf(AggregateError);
|
|
104
|
+
expect((thrown as AggregateError).errors).toEqual([
|
|
105
|
+
firstError,
|
|
106
|
+
secondError,
|
|
107
|
+
]);
|
|
108
|
+
expect(consoleError).toHaveBeenNthCalledWith(1, firstError);
|
|
109
|
+
expect(consoleError).toHaveBeenNthCalledWith(2, secondError);
|
|
110
|
+
} finally {
|
|
111
|
+
consoleError.mockRestore();
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
59
116
|
describe("ShallowMemoizeSubject", () => {
|
|
60
117
|
it("notifies subscribers when a state key is removed", () => {
|
|
61
118
|
const source = createBinding({
|
|
@@ -110,6 +167,28 @@ describe("ShallowMemoizeSubject", () => {
|
|
|
110
167
|
expect(subject.getState()).toEqual({ status: "ready" });
|
|
111
168
|
expect(subscriber).not.toHaveBeenCalled();
|
|
112
169
|
});
|
|
170
|
+
|
|
171
|
+
it("reconnects after the previous connection cleanup throws", () => {
|
|
172
|
+
let subscribeCount = 0;
|
|
173
|
+
const cleanupError = new Error("cleanup failed");
|
|
174
|
+
const binding: SubscribableWithState<TestState, null> = {
|
|
175
|
+
path: null,
|
|
176
|
+
getState: () => ({ status: "ready" }),
|
|
177
|
+
subscribe: () => {
|
|
178
|
+
subscribeCount += 1;
|
|
179
|
+
return () => {
|
|
180
|
+
throw cleanupError;
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
const subject = new ShallowMemoizeSubject(binding);
|
|
185
|
+
|
|
186
|
+
const unsubscribe = subject.subscribe(() => {});
|
|
187
|
+
expect(() => unsubscribe()).toThrow(cleanupError);
|
|
188
|
+
|
|
189
|
+
subject.subscribe(() => {});
|
|
190
|
+
expect(subscribeCount).toBe(2);
|
|
191
|
+
});
|
|
113
192
|
});
|
|
114
193
|
|
|
115
194
|
describe("LazyMemoizeSubject", () => {
|
|
@@ -182,3 +261,79 @@ describe("LazyMemoizeSubject", () => {
|
|
|
182
261
|
expect(second).toEqual({ status: "done" });
|
|
183
262
|
});
|
|
184
263
|
});
|
|
264
|
+
|
|
265
|
+
describe("nested subscription swaps", () => {
|
|
266
|
+
it("connects the next nested source when the previous cleanup throws", () => {
|
|
267
|
+
const cleanupError = new Error("cleanup failed");
|
|
268
|
+
let outerUpdate!: () => void;
|
|
269
|
+
let nextUpdate!: () => void;
|
|
270
|
+
const previous = {
|
|
271
|
+
subscribe: () => () => {
|
|
272
|
+
throw cleanupError;
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
const nextSubscribe = vi.fn((callback: () => void) => {
|
|
276
|
+
nextUpdate = callback;
|
|
277
|
+
return () => {};
|
|
278
|
+
});
|
|
279
|
+
const next = { subscribe: nextSubscribe };
|
|
280
|
+
let current = previous;
|
|
281
|
+
const subject = new NestedSubscriptionSubject({
|
|
282
|
+
path: null,
|
|
283
|
+
getState: () => current,
|
|
284
|
+
subscribe: (callback) => {
|
|
285
|
+
outerUpdate = callback;
|
|
286
|
+
return () => {};
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
const listener = vi.fn();
|
|
290
|
+
subject.subscribe(listener);
|
|
291
|
+
|
|
292
|
+
current = next;
|
|
293
|
+
expect(() => outerUpdate()).toThrow(cleanupError);
|
|
294
|
+
expect(nextSubscribe).toHaveBeenCalledOnce();
|
|
295
|
+
expect(listener).toHaveBeenCalledOnce();
|
|
296
|
+
|
|
297
|
+
nextUpdate();
|
|
298
|
+
expect(listener).toHaveBeenCalledTimes(2);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
it("connects the next event source when the previous cleanup throws", () => {
|
|
302
|
+
const cleanupError = new Error("cleanup failed");
|
|
303
|
+
let outerUpdate!: () => void;
|
|
304
|
+
let nextEvent!: (payload?: unknown) => void;
|
|
305
|
+
const previous = {
|
|
306
|
+
unstable_on: () => () => {
|
|
307
|
+
throw cleanupError;
|
|
308
|
+
},
|
|
309
|
+
};
|
|
310
|
+
const nextSubscribe = vi.fn(
|
|
311
|
+
(_event: string, callback: (payload?: unknown) => void) => {
|
|
312
|
+
nextEvent = callback;
|
|
313
|
+
return () => {};
|
|
314
|
+
},
|
|
315
|
+
);
|
|
316
|
+
const next = { unstable_on: nextSubscribe };
|
|
317
|
+
let current = previous;
|
|
318
|
+
const subject = new EventSubscriptionSubject({
|
|
319
|
+
event: "test",
|
|
320
|
+
binding: {
|
|
321
|
+
path: null,
|
|
322
|
+
getState: () => current,
|
|
323
|
+
subscribe: (callback) => {
|
|
324
|
+
outerUpdate = callback;
|
|
325
|
+
return () => {};
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
const listener = vi.fn();
|
|
330
|
+
subject.subscribe(listener);
|
|
331
|
+
|
|
332
|
+
current = next;
|
|
333
|
+
expect(() => outerUpdate()).toThrow(cleanupError);
|
|
334
|
+
expect(nextSubscribe).toHaveBeenCalledOnce();
|
|
335
|
+
|
|
336
|
+
nextEvent("payload");
|
|
337
|
+
expect(listener).toHaveBeenCalledWith("payload");
|
|
338
|
+
});
|
|
339
|
+
});
|
|
@@ -58,6 +58,10 @@ export const notifySubscribers = <TArgs extends unknown[]>(
|
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
+
export const runCleanups = (cleanups: Iterable<Unsubscribe>): void => {
|
|
62
|
+
notifySubscribers(cleanups);
|
|
63
|
+
};
|
|
64
|
+
|
|
61
65
|
const shallowEqualOrUndefined = <T extends object>(
|
|
62
66
|
a: T | undefined,
|
|
63
67
|
b: T | undefined,
|
|
@@ -136,8 +140,9 @@ export abstract class BaseSubject {
|
|
|
136
140
|
if (this._connection) return;
|
|
137
141
|
this._connection = this._connect();
|
|
138
142
|
} else {
|
|
139
|
-
this._connection
|
|
143
|
+
const connection = this._connection;
|
|
140
144
|
this._connection = undefined;
|
|
145
|
+
connection?.();
|
|
141
146
|
}
|
|
142
147
|
}
|
|
143
148
|
|
|
@@ -284,17 +289,19 @@ export class NestedSubscriptionSubject<
|
|
|
284
289
|
if (newState === lastState) return;
|
|
285
290
|
lastState = newState;
|
|
286
291
|
|
|
287
|
-
innerUnsubscribe
|
|
288
|
-
innerUnsubscribe =
|
|
289
|
-
|
|
290
|
-
|
|
292
|
+
const previousInner = innerUnsubscribe;
|
|
293
|
+
innerUnsubscribe = undefined;
|
|
294
|
+
try {
|
|
295
|
+
previousInner?.();
|
|
296
|
+
} finally {
|
|
297
|
+
innerUnsubscribe = newState?.subscribe(callback);
|
|
298
|
+
callback();
|
|
299
|
+
}
|
|
291
300
|
};
|
|
292
301
|
|
|
293
302
|
const outerUnsubscribe = this.outerSubscribe(onRuntimeUpdate);
|
|
294
|
-
return () =>
|
|
295
|
-
outerUnsubscribe?.();
|
|
296
|
-
innerUnsubscribe?.();
|
|
297
|
-
};
|
|
303
|
+
return () =>
|
|
304
|
+
runCleanups([() => outerUnsubscribe?.(), () => innerUnsubscribe?.()]);
|
|
298
305
|
}
|
|
299
306
|
}
|
|
300
307
|
|
|
@@ -329,14 +336,17 @@ export class EventSubscriptionSubject<
|
|
|
329
336
|
if (newState === lastState) return;
|
|
330
337
|
lastState = newState;
|
|
331
338
|
|
|
332
|
-
innerUnsubscribe
|
|
333
|
-
innerUnsubscribe =
|
|
339
|
+
const previousInner = innerUnsubscribe;
|
|
340
|
+
innerUnsubscribe = undefined;
|
|
341
|
+
try {
|
|
342
|
+
previousInner?.();
|
|
343
|
+
} finally {
|
|
344
|
+
innerUnsubscribe = newState?.unstable_on(this.config.event, callback);
|
|
345
|
+
}
|
|
334
346
|
};
|
|
335
347
|
|
|
336
348
|
const outerUnsubscribe = this.outerSubscribe(onRuntimeUpdate);
|
|
337
|
-
return () =>
|
|
338
|
-
outerUnsubscribe?.();
|
|
339
|
-
innerUnsubscribe?.();
|
|
340
|
-
};
|
|
349
|
+
return () =>
|
|
350
|
+
runCleanups([() => outerUnsubscribe?.(), () => innerUnsubscribe?.()]);
|
|
341
351
|
}
|
|
342
352
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, vi
|
|
1
|
+
import { describe, it, expect, beforeEach, vi } from "vitest";
|
|
2
2
|
import {
|
|
3
3
|
MessageRepository,
|
|
4
4
|
ExportedMessageRepository,
|
|
@@ -59,10 +59,6 @@ describe("MessageRepository", () => {
|
|
|
59
59
|
mockGenerateId.mockImplementation(() => `mock-id-${nextMockId++}`);
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
afterEach(() => {
|
|
63
|
-
vi.clearAllMocks();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
62
|
// Core functionality tests - these test the public contract
|
|
67
63
|
describe("Basic CRUD operations", () => {
|
|
68
64
|
it("should add a new message to the repository", () => {
|
|
@@ -236,6 +236,36 @@ describe("auiV0Encode", () => {
|
|
|
236
236
|
]);
|
|
237
237
|
});
|
|
238
238
|
|
|
239
|
+
it("preserves reasoning provider metadata", () => {
|
|
240
|
+
const encoded = auiV0Encode({
|
|
241
|
+
id: "m1",
|
|
242
|
+
createdAt: new Date(),
|
|
243
|
+
role: "assistant",
|
|
244
|
+
status: { type: "complete", reason: "stop" },
|
|
245
|
+
content: [
|
|
246
|
+
{
|
|
247
|
+
type: "reasoning",
|
|
248
|
+
text: "thinking",
|
|
249
|
+
providerMetadata: { "assistant-ui": { duration: 3200 } },
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
metadata: {
|
|
253
|
+
unstable_state: null,
|
|
254
|
+
unstable_annotations: [],
|
|
255
|
+
unstable_data: [],
|
|
256
|
+
steps: [],
|
|
257
|
+
custom: {},
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
expect(encoded.content).toEqual([
|
|
261
|
+
{
|
|
262
|
+
type: "reasoning",
|
|
263
|
+
text: "thinking",
|
|
264
|
+
providerMetadata: { "assistant-ui": { duration: 3200 } },
|
|
265
|
+
},
|
|
266
|
+
]);
|
|
267
|
+
});
|
|
268
|
+
|
|
239
269
|
it("preserves reasoning summaries and omits absent summaries", () => {
|
|
240
270
|
const encoded = auiV0Encode({
|
|
241
271
|
id: "m1",
|
|
@@ -639,4 +669,274 @@ describe("auiV0Decode", () => {
|
|
|
639
669
|
{ type: "data", name: "PredictState", data: '{"steps":["a","b"]}' },
|
|
640
670
|
]);
|
|
641
671
|
});
|
|
672
|
+
|
|
673
|
+
it("round-trips parent IDs and tool-call state", () => {
|
|
674
|
+
const content = auiV0Encode({
|
|
675
|
+
id: "local",
|
|
676
|
+
createdAt: new Date("2026-03-15T00:00:00.000Z"),
|
|
677
|
+
role: "assistant",
|
|
678
|
+
status: { type: "complete", reason: "stop" },
|
|
679
|
+
metadata: {
|
|
680
|
+
unstable_state: null,
|
|
681
|
+
unstable_annotations: [],
|
|
682
|
+
unstable_data: [],
|
|
683
|
+
steps: [],
|
|
684
|
+
custom: {},
|
|
685
|
+
},
|
|
686
|
+
content: [
|
|
687
|
+
{ type: "text", text: "answer", parentId: "text-parent" },
|
|
688
|
+
{
|
|
689
|
+
type: "reasoning",
|
|
690
|
+
text: "thinking",
|
|
691
|
+
parentId: "reasoning-parent",
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
type: "source",
|
|
695
|
+
sourceType: "url",
|
|
696
|
+
id: "source-url",
|
|
697
|
+
url: "https://example.com",
|
|
698
|
+
parentId: "url-parent",
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
type: "source",
|
|
702
|
+
sourceType: "document",
|
|
703
|
+
id: "source-document",
|
|
704
|
+
title: "notes",
|
|
705
|
+
mediaType: "text/plain",
|
|
706
|
+
parentId: "document-parent",
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
type: "file",
|
|
710
|
+
data: "file-1",
|
|
711
|
+
mimeType: "application/pdf",
|
|
712
|
+
parentId: "file-parent",
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
type: "tool-call",
|
|
716
|
+
toolCallId: "tool-1",
|
|
717
|
+
toolName: "review",
|
|
718
|
+
args: { document: "proposal" },
|
|
719
|
+
argsText: '{"document":"proposal"}',
|
|
720
|
+
parentId: "tool-parent",
|
|
721
|
+
interrupt: { type: "human", payload: { question: "continue?" } },
|
|
722
|
+
timing: { startedAt: 10, completedAt: 20 },
|
|
723
|
+
mcp: {
|
|
724
|
+
app: { resourceUri: "ui://review", serverId: "server-1" },
|
|
725
|
+
},
|
|
726
|
+
messages: [
|
|
727
|
+
{
|
|
728
|
+
id: "nested",
|
|
729
|
+
createdAt: new Date("2026-03-15T00:00:00.000Z"),
|
|
730
|
+
role: "assistant",
|
|
731
|
+
status: { type: "complete", reason: "stop" },
|
|
732
|
+
metadata: {
|
|
733
|
+
unstable_state: null,
|
|
734
|
+
unstable_annotations: [],
|
|
735
|
+
unstable_data: [],
|
|
736
|
+
steps: [],
|
|
737
|
+
custom: {},
|
|
738
|
+
},
|
|
739
|
+
content: [
|
|
740
|
+
{ type: "text", text: "nested", parentId: "nested-parent" },
|
|
741
|
+
],
|
|
742
|
+
},
|
|
743
|
+
],
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
type: "generative-ui",
|
|
747
|
+
id: "ui-1",
|
|
748
|
+
parentId: "ui-parent",
|
|
749
|
+
spec: { root: { component: "Card", props: { title: "Review" } } },
|
|
750
|
+
},
|
|
751
|
+
],
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
expect(content.content).toEqual([
|
|
755
|
+
{ type: "text", text: "answer", parentId: "text-parent" },
|
|
756
|
+
{
|
|
757
|
+
type: "reasoning",
|
|
758
|
+
text: "thinking",
|
|
759
|
+
parentId: "reasoning-parent",
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
type: "source",
|
|
763
|
+
sourceType: "url",
|
|
764
|
+
id: "source-url",
|
|
765
|
+
url: "https://example.com",
|
|
766
|
+
parentId: "url-parent",
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
type: "source",
|
|
770
|
+
sourceType: "document",
|
|
771
|
+
id: "source-document",
|
|
772
|
+
title: "notes",
|
|
773
|
+
mediaType: "text/plain",
|
|
774
|
+
parentId: "document-parent",
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
type: "file",
|
|
778
|
+
data: "file-1",
|
|
779
|
+
mimeType: "application/pdf",
|
|
780
|
+
parentId: "file-parent",
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
type: "tool-call",
|
|
784
|
+
toolCallId: "tool-1",
|
|
785
|
+
toolName: "review",
|
|
786
|
+
args: { document: "proposal" },
|
|
787
|
+
parentId: "tool-parent",
|
|
788
|
+
interrupt: { type: "human", payload: { question: "continue?" } },
|
|
789
|
+
timing: { startedAt: 10, completedAt: 20 },
|
|
790
|
+
mcp: {
|
|
791
|
+
app: { resourceUri: "ui://review", serverId: "server-1" },
|
|
792
|
+
},
|
|
793
|
+
messages: [
|
|
794
|
+
{
|
|
795
|
+
id: "nested",
|
|
796
|
+
createdAt: "2026-03-15T00:00:00.000Z",
|
|
797
|
+
role: "assistant",
|
|
798
|
+
status: { type: "complete", reason: "stop" },
|
|
799
|
+
metadata: {
|
|
800
|
+
unstable_state: null,
|
|
801
|
+
unstable_annotations: [],
|
|
802
|
+
unstable_data: [],
|
|
803
|
+
steps: [],
|
|
804
|
+
custom: {},
|
|
805
|
+
},
|
|
806
|
+
content: [
|
|
807
|
+
{ type: "text", text: "nested", parentId: "nested-parent" },
|
|
808
|
+
],
|
|
809
|
+
},
|
|
810
|
+
],
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
type: "generative-ui",
|
|
814
|
+
id: "ui-1",
|
|
815
|
+
parentId: "ui-parent",
|
|
816
|
+
spec: { root: { component: "Card", props: { title: "Review" } } },
|
|
817
|
+
},
|
|
818
|
+
]);
|
|
819
|
+
|
|
820
|
+
const decoded = auiV0Decode({
|
|
821
|
+
id: "cloud",
|
|
822
|
+
parent_id: null,
|
|
823
|
+
format: "aui/v0",
|
|
824
|
+
content: content as never,
|
|
825
|
+
created_at: new Date("2026-03-15T00:00:00.000Z"),
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
if (decoded.message.role !== "assistant")
|
|
829
|
+
throw new Error("expected assistant");
|
|
830
|
+
expect(decoded.message.content).toEqual([
|
|
831
|
+
{ type: "text", text: "answer", parentId: "text-parent" },
|
|
832
|
+
{
|
|
833
|
+
type: "reasoning",
|
|
834
|
+
text: "thinking",
|
|
835
|
+
parentId: "reasoning-parent",
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
type: "source",
|
|
839
|
+
sourceType: "url",
|
|
840
|
+
id: "source-url",
|
|
841
|
+
url: "https://example.com",
|
|
842
|
+
parentId: "url-parent",
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
type: "source",
|
|
846
|
+
sourceType: "document",
|
|
847
|
+
id: "source-document",
|
|
848
|
+
title: "notes",
|
|
849
|
+
mediaType: "text/plain",
|
|
850
|
+
parentId: "document-parent",
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
type: "file",
|
|
854
|
+
data: "file-1",
|
|
855
|
+
mimeType: "application/pdf",
|
|
856
|
+
parentId: "file-parent",
|
|
857
|
+
},
|
|
858
|
+
expect.objectContaining({
|
|
859
|
+
type: "tool-call",
|
|
860
|
+
toolCallId: "tool-1",
|
|
861
|
+
toolName: "review",
|
|
862
|
+
args: { document: "proposal" },
|
|
863
|
+
argsText: '{"document":"proposal"}',
|
|
864
|
+
parentId: "tool-parent",
|
|
865
|
+
interrupt: { type: "human", payload: { question: "continue?" } },
|
|
866
|
+
timing: { startedAt: 10, completedAt: 20 },
|
|
867
|
+
mcp: {
|
|
868
|
+
app: { resourceUri: "ui://review", serverId: "server-1" },
|
|
869
|
+
},
|
|
870
|
+
messages: [
|
|
871
|
+
expect.objectContaining({
|
|
872
|
+
id: "nested",
|
|
873
|
+
createdAt: new Date("2026-03-15T00:00:00.000Z"),
|
|
874
|
+
role: "assistant",
|
|
875
|
+
content: [
|
|
876
|
+
{ type: "text", text: "nested", parentId: "nested-parent" },
|
|
877
|
+
],
|
|
878
|
+
}),
|
|
879
|
+
],
|
|
880
|
+
}),
|
|
881
|
+
{
|
|
882
|
+
type: "generative-ui",
|
|
883
|
+
id: "ui-1",
|
|
884
|
+
parentId: "ui-parent",
|
|
885
|
+
spec: { root: { component: "Card", props: { title: "Review" } } },
|
|
886
|
+
},
|
|
887
|
+
]);
|
|
888
|
+
});
|
|
889
|
+
|
|
890
|
+
it("keeps audio message and attachment parts as audio", () => {
|
|
891
|
+
const content = auiV0Encode({
|
|
892
|
+
id: "local",
|
|
893
|
+
createdAt: new Date("2026-03-15T00:00:00.000Z"),
|
|
894
|
+
role: "user",
|
|
895
|
+
metadata: { custom: {} },
|
|
896
|
+
content: [
|
|
897
|
+
{
|
|
898
|
+
type: "audio",
|
|
899
|
+
audio: { data: "SUQzAw==", format: "mp3" },
|
|
900
|
+
},
|
|
901
|
+
],
|
|
902
|
+
attachments: [
|
|
903
|
+
{
|
|
904
|
+
id: "attachment",
|
|
905
|
+
type: "file",
|
|
906
|
+
name: "recording",
|
|
907
|
+
status: { type: "complete" },
|
|
908
|
+
content: [
|
|
909
|
+
{
|
|
910
|
+
type: "audio",
|
|
911
|
+
audio: { data: "data:audio/wav;base64,UklGRg==", format: "wav" },
|
|
912
|
+
},
|
|
913
|
+
],
|
|
914
|
+
},
|
|
915
|
+
],
|
|
916
|
+
});
|
|
917
|
+
|
|
918
|
+
expect(content.content).toEqual([
|
|
919
|
+
{ type: "audio", audio: { data: "SUQzAw==", format: "mp3" } },
|
|
920
|
+
]);
|
|
921
|
+
expect(content.attachments?.[0]?.content).toEqual([
|
|
922
|
+
{
|
|
923
|
+
type: "audio",
|
|
924
|
+
audio: { data: "data:audio/wav;base64,UklGRg==", format: "wav" },
|
|
925
|
+
},
|
|
926
|
+
]);
|
|
927
|
+
|
|
928
|
+
const decoded = auiV0Decode({
|
|
929
|
+
id: "cloud",
|
|
930
|
+
parent_id: null,
|
|
931
|
+
format: "aui/v0",
|
|
932
|
+
content: content as never,
|
|
933
|
+
created_at: new Date("2026-03-15T00:00:00.000Z"),
|
|
934
|
+
});
|
|
935
|
+
|
|
936
|
+
if (decoded.message.role !== "user") throw new Error("expected user");
|
|
937
|
+
expect(decoded.message.content).toEqual(content.content);
|
|
938
|
+
expect(decoded.message.attachments[0]?.content).toEqual(
|
|
939
|
+
content.attachments?.[0]?.content,
|
|
940
|
+
);
|
|
941
|
+
});
|
|
642
942
|
});
|
|
@@ -5,6 +5,7 @@ import type { ThreadRuntimeCore } from "../runtime/interfaces/thread-runtime-cor
|
|
|
5
5
|
import type { PendingAttachment } from "../types/attachment";
|
|
6
6
|
import { MessageNotSentError } from "../types/error";
|
|
7
7
|
import { BaseComposerRuntimeCore } from "../runtime/base/base-composer-runtime-core";
|
|
8
|
+
import { LocalRuntimeCore } from "../runtimes/local/local-runtime-core";
|
|
8
9
|
|
|
9
10
|
const makeAdapter = (
|
|
10
11
|
overrides: Partial<AttachmentAdapter> = {},
|
|
@@ -379,6 +380,56 @@ describe("BaseComposerRuntimeCore.send restore-on-failure", () => {
|
|
|
379
380
|
await removePromise;
|
|
380
381
|
});
|
|
381
382
|
|
|
383
|
+
it("excludes cleared attachments when the upload finishes before adapter removal", async () => {
|
|
384
|
+
const upload = Promise.withResolvers<void>();
|
|
385
|
+
const removal = Promise.withResolvers<void>();
|
|
386
|
+
const adapter = makeAdapter({
|
|
387
|
+
send: async (attachment) => {
|
|
388
|
+
await upload.promise;
|
|
389
|
+
return { ...attachment, status: { type: "complete" }, content: [] };
|
|
390
|
+
},
|
|
391
|
+
remove: () => removal.promise,
|
|
392
|
+
});
|
|
393
|
+
const core = new LocalRuntimeCore(
|
|
394
|
+
{
|
|
395
|
+
adapters: {
|
|
396
|
+
chatModel: { run: async () => ({ content: [] }) },
|
|
397
|
+
attachments: adapter,
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
undefined,
|
|
401
|
+
);
|
|
402
|
+
const thread = core.threads.getMainThreadRuntimeCore();
|
|
403
|
+
const composer = thread.composer;
|
|
404
|
+
composer.setText("hello");
|
|
405
|
+
await composer.addAttachment(textFile());
|
|
406
|
+
await composer.addAttachment({
|
|
407
|
+
id: "ready",
|
|
408
|
+
name: "ready.txt",
|
|
409
|
+
content: [],
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
const sendPromise = composer.send({ startRun: false });
|
|
413
|
+
const clearPromise = composer.clearAttachments();
|
|
414
|
+
expect(composer.attachments).toEqual([]);
|
|
415
|
+
await composer.addAttachment({
|
|
416
|
+
id: "later",
|
|
417
|
+
name: "later.txt",
|
|
418
|
+
content: [],
|
|
419
|
+
});
|
|
420
|
+
upload.resolve();
|
|
421
|
+
await sendPromise;
|
|
422
|
+
|
|
423
|
+
expect(thread.messages).toMatchObject([
|
|
424
|
+
{ content: [{ type: "text", text: "hello" }], attachments: [] },
|
|
425
|
+
]);
|
|
426
|
+
expect(composer.attachments.map((attachment) => attachment.id)).toEqual([
|
|
427
|
+
"later",
|
|
428
|
+
]);
|
|
429
|
+
removal.resolve();
|
|
430
|
+
await clearPromise;
|
|
431
|
+
});
|
|
432
|
+
|
|
382
433
|
it("releases the in-flight lock on reset so a stalled send cannot brick the composer", async () => {
|
|
383
434
|
const adapter = makeAdapter({
|
|
384
435
|
send: () => new Promise(() => {}),
|