@assistant-ui/react-google-adk 0.0.32 → 0.0.34
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/LICENSE +1 -1
- package/dist/AdkEventAccumulator.d.ts.map +1 -1
- package/dist/AdkEventAccumulator.js +4 -1
- package/dist/AdkEventAccumulator.js.map +1 -1
- package/dist/adkToolApproval.js +1 -1
- package/dist/adkToolApproval.js.map +1 -1
- package/dist/contentToParts.d.ts.map +1 -1
- package/dist/contentToParts.js +1 -0
- package/dist/contentToParts.js.map +1 -1
- package/dist/convertAdkMessages.d.ts.map +1 -1
- package/dist/convertAdkMessages.js +34 -19
- package/dist/convertAdkMessages.js.map +1 -1
- package/dist/convertToAdkMessages.d.ts.map +1 -1
- package/dist/convertToAdkMessages.js +2 -2
- package/dist/convertToAdkMessages.js.map +1 -1
- package/dist/sdkIdentity.js +1 -1
- package/dist/useAdkMessages.d.ts.map +1 -1
- package/dist/useAdkMessages.js +29 -11
- package/dist/useAdkMessages.js.map +1 -1
- package/dist/useAdkRuntime.d.ts.map +1 -1
- package/dist/useAdkRuntime.js +5 -4
- package/dist/useAdkRuntime.js.map +1 -1
- package/package.json +9 -6
- package/src/AdkEventAccumulator.test.ts +32 -0
- package/src/AdkEventAccumulator.ts +1 -0
- package/src/adkToolApproval.test.ts +19 -0
- package/src/adkToolApproval.ts +1 -1
- package/src/contentToParts.ts +2 -0
- package/src/convertAdkMessages.test.ts +142 -0
- package/src/convertAdkMessages.ts +24 -1
- package/src/convertToAdkMessages.test.ts +20 -0
- package/src/convertToAdkMessages.ts +4 -1
- package/src/tests/settleOutsideAct.ts +15 -0
- package/src/useAdkMessages.fast-refresh.test.tsx +114 -0
- package/src/useAdkMessages.test.ts +48 -0
- package/src/useAdkMessages.ts +40 -9
- package/src/useAdkRuntime.cancellation.test.tsx +544 -0
- package/src/useAdkRuntime.fast-refresh.test.tsx +166 -0
- package/src/useAdkRuntime.refetch.test.tsx +8 -6
- package/src/useAdkRuntime.replacement.test.tsx +4 -3
- package/src/useAdkRuntime.toolOwnership.test.tsx +4 -3
- package/src/useAdkRuntime.ts +4 -4
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
import { useAui } from "@assistant-ui/store";
|
|
12
12
|
import { useAdkRuntime } from "./useAdkRuntime";
|
|
13
13
|
import type { AdkMessage, AdkThreadSnapshot } from "./types";
|
|
14
|
+
import { settleOutsideAct } from "./tests/settleOutsideAct";
|
|
14
15
|
|
|
15
16
|
const deferred = <T,>() => {
|
|
16
17
|
let resolve!: (value: T) => void;
|
|
@@ -97,9 +98,9 @@ const renderAdk = async (
|
|
|
97
98
|
});
|
|
98
99
|
await waitFor(() => expect(capture.runtime).not.toBeNull());
|
|
99
100
|
|
|
100
|
-
await
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
await settleOutsideAct(() =>
|
|
102
|
+
capture.runtime!.threads.switchToThread("adk-1"),
|
|
103
|
+
);
|
|
103
104
|
|
|
104
105
|
return { capture, streamMock, unmount };
|
|
105
106
|
};
|
|
@@ -250,9 +251,9 @@ describe("useAdkRuntime refetch", () => {
|
|
|
250
251
|
await act(async () => {
|
|
251
252
|
render(<Inner />);
|
|
252
253
|
});
|
|
253
|
-
await
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
await settleOutsideAct(() =>
|
|
255
|
+
capture.runtime!.threads.switchToThread("adk-1"),
|
|
256
|
+
);
|
|
256
257
|
await waitFor(() => expect(load).toHaveBeenCalledTimes(1));
|
|
257
258
|
|
|
258
259
|
let settled = false;
|
|
@@ -329,6 +330,7 @@ describe("useAdkRuntime refetch", () => {
|
|
|
329
330
|
expect(signals[1]?.aborted).toBe(false);
|
|
330
331
|
|
|
331
332
|
unmount();
|
|
333
|
+
await act(async () => {});
|
|
332
334
|
|
|
333
335
|
expect(signals[1]?.aborted).toBe(true);
|
|
334
336
|
pending.resolve({ messages: [] });
|
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
} from "@assistant-ui/core";
|
|
11
11
|
import { useAdkRuntime } from "./useAdkRuntime";
|
|
12
12
|
import type { AdkEvent } from "./types";
|
|
13
|
+
import { settleOutsideAct } from "./tests/settleOutsideAct";
|
|
13
14
|
|
|
14
15
|
const makeThreadListAdapter = (): RemoteThreadListAdapter => ({
|
|
15
16
|
list: vi.fn(async () => ({
|
|
@@ -97,9 +98,9 @@ describe("useAdkRuntime replacement runs", () => {
|
|
|
97
98
|
render(<Inner />);
|
|
98
99
|
});
|
|
99
100
|
await waitFor(() => expect(capture.runtime).not.toBeNull());
|
|
100
|
-
await
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
await settleOutsideAct(() =>
|
|
102
|
+
capture.runtime!.threads.switchToThread("adk-1"),
|
|
103
|
+
);
|
|
103
104
|
|
|
104
105
|
act(() => {
|
|
105
106
|
capture.runtime!.thread.append({
|
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
} from "@assistant-ui/core";
|
|
15
15
|
import { useAdkRuntime } from "./useAdkRuntime";
|
|
16
16
|
import type { AdkEvent } from "./types";
|
|
17
|
+
import { settleOutsideAct } from "./tests/settleOutsideAct";
|
|
17
18
|
|
|
18
19
|
const makeThreadListAdapter = (): RemoteThreadListAdapter => ({
|
|
19
20
|
list: vi.fn(async () => ({
|
|
@@ -153,9 +154,9 @@ const renderStreamingAdk = async (first: AdkEvent, second: AdkEvent) => {
|
|
|
153
154
|
render(<Inner />);
|
|
154
155
|
});
|
|
155
156
|
await waitFor(() => expect(capture.runtime).not.toBeNull());
|
|
156
|
-
await
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
await settleOutsideAct(() =>
|
|
158
|
+
capture.runtime!.threads.switchToThread("adk-1"),
|
|
159
|
+
);
|
|
159
160
|
await act(async () => {
|
|
160
161
|
await new Promise((r) => setTimeout(r, 0));
|
|
161
162
|
});
|
package/src/useAdkRuntime.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCallback,
|
|
3
|
-
useEffect,
|
|
4
3
|
useInsertionEffect,
|
|
5
4
|
useMemo,
|
|
6
5
|
useRef,
|
|
@@ -30,6 +29,7 @@ import {
|
|
|
30
29
|
useExternalStoreRuntime,
|
|
31
30
|
} from "@assistant-ui/core/react";
|
|
32
31
|
import { useAui } from "@assistant-ui/store";
|
|
32
|
+
import { useReplaySafeEffect } from "@assistant-ui/store/internal";
|
|
33
33
|
import type { AssistantCloud } from "assistant-cloud";
|
|
34
34
|
import type { RemoteThreadListAdapter } from "@assistant-ui/core";
|
|
35
35
|
import type {
|
|
@@ -147,7 +147,7 @@ const useAdkRuntimeImpl = (options: UseAdkRuntimeOptions) => {
|
|
|
147
147
|
useInsertionEffect(() => {
|
|
148
148
|
loadRef.current = load;
|
|
149
149
|
}, [load]);
|
|
150
|
-
const loadController =
|
|
150
|
+
const [loadController] = useState(createAbortableThreadLoad);
|
|
151
151
|
const messagesRef = useRef(messages);
|
|
152
152
|
useInsertionEffect(() => {
|
|
153
153
|
messagesRef.current = messages;
|
|
@@ -325,7 +325,7 @@ const useAdkRuntimeImpl = (options: UseAdkRuntimeOptions) => {
|
|
|
325
325
|
[threadListItem, loadController, applySnapshot],
|
|
326
326
|
);
|
|
327
327
|
|
|
328
|
-
|
|
328
|
+
useReplaySafeEffect(() => {
|
|
329
329
|
runLoad();
|
|
330
330
|
return () => {
|
|
331
331
|
// Whatever is current, not this effect's own controller: a refetch swaps
|
|
@@ -333,7 +333,7 @@ const useAdkRuntimeImpl = (options: UseAdkRuntimeOptions) => {
|
|
|
333
333
|
loadController.abort();
|
|
334
334
|
setIsLoadingThread(false);
|
|
335
335
|
};
|
|
336
|
-
}, [
|
|
336
|
+
}, [threadListItem]);
|
|
337
337
|
|
|
338
338
|
const runtime = useExternalStoreRuntime({
|
|
339
339
|
...pickExternalStoreSharedOptions(options),
|