Open History to see the last commit
1import {
2 EnvironmentId,
3 EventId,
4 MessageId,
5 ORCHESTRATION_V2_WS_METHODS,
6 TurnItemId,
7 type OrchestrationV2ThreadHistoryPage,
8 type OrchestrationV2ThreadProjection,
9 type OrchestrationV2ThreadDetailSnapshot,
10 type OrchestrationV2ThreadStreamItem,
11} from "@t3tools/contracts";
12import { afterEach, describe, expect, it, vi } from "@effect/vitest";
13import * as Deferred from "effect/Deferred";
14import * as Effect from "effect/Effect";
15import * as Fiber from "effect/Fiber";
16import { HttpClient, HttpClientResponse } from "effect/unstable/http";
17import * as Layer from "effect/Layer";
18import * as Option from "effect/Option";
19import * as Queue from "effect/Queue";
20import * as Stream from "effect/Stream";
21import * as SubscriptionRef from "effect/SubscriptionRef";
22import { Atom, AtomRegistry } from "effect/unstable/reactivity";
23
24import type { ConnectionCatalogEntry } from "../connection/catalog.ts";
25import * as EnvironmentRegistry from "../connection/registry.ts";
26import {
27 AVAILABLE_CONNECTION_STATE,
28 PrimaryConnectionTarget,
29 type NetworkStatus,
30 type PreparedConnection,
31} from "../connection/model.ts";
32import * as EnvironmentSupervisor from "../connection/supervisor.ts";
33import * as Persistence from "../platform/persistence.ts";
34import type { WsRpcProtocolClient } from "../rpc/protocol.ts";
35import type { RpcSession } from "../rpc/session.ts";
36import { createEnvironmentThreadDetailAtoms } from "./threadDetail.ts";
37import { THREAD_SNAPSHOT_IDLE_TTL_MS } from "./threadRetention.ts";
38import { v2Projection, v2ThreadId } from "./orchestrationV2TestFixtures.ts";
39import * as ThreadHistoryController from "./threadHistoryController.ts";
40import { createEnvironmentThreadStateAtoms, type EnvironmentThreadState } from "./threads.ts";
41import * as ThreadSnapshotLoader from "./threadSnapshotHttp.ts";
42
43const TARGET = new PrimaryConnectionTarget({
44 environmentId: EnvironmentId.make("environment-1"),
45 label: "Test environment",
46 httpBaseUrl: "https://environment.example.test",
47 wsBaseUrl: "wss://environment.example.test",
48});
49const THREAD_ID = v2ThreadId;
50const THREAD: OrchestrationV2ThreadProjection = {
51 ...v2Projection,
52 thread: { ...v2Projection.thread, title: "Cached thread" },
53};
54const SNAPSHOT: OrchestrationV2ThreadDetailSnapshot = { snapshotSequence: 7, projection: THREAD };
55
56const makeHarness = Effect.fn("TestThreadAtoms.makeHarness")(function* (options?: {
57 readonly snapshot?: OrchestrationV2ThreadDetailSnapshot;
58 readonly snapshotUnavailable?: boolean;
59}) {
60 const subscriptions = yield* Queue.unbounded<{
61 readonly afterSequence: number | undefined;
62 readonly events: Queue.Queue<OrchestrationV2ThreadStreamItem>;
63 readonly closed: Deferred.Deferred<void>;
64 }>();
65 const olderLoads = yield* Queue.unbounded<{
66 readonly cursor: string | null;
67 readonly response: Deferred.Deferred<OrchestrationV2ThreadHistoryPage>;
68 readonly closed: Deferred.Deferred<void>;
69 }>();
70 const snapshot = options?.snapshot ?? SNAPSHOT;
71 let httpLoads = 0;
72 let diskLoads = 0;
73 let opened = 0;
74 let active = 0;
75 const client = {
76 [ORCHESTRATION_V2_WS_METHODS.subscribeThread]: (input: { readonly afterSequence?: number }) =>
77 Stream.unwrap(
78 Effect.gen(function* () {
79 const events = yield* Queue.unbounded<OrchestrationV2ThreadStreamItem>();
80 const closed = yield* Deferred.make<void>();
81 yield* Effect.acquireRelease(
82 Effect.sync(() => {
83 opened += 1;
84 active += 1;
85 }),
86 () =>
87 Effect.sync(() => {
88 active -= 1;
89 }).pipe(Effect.andThen(Deferred.succeed(closed, undefined))),
90 );
91 yield* Queue.offer(subscriptions, { afterSequence: input.afterSequence, events, closed });
92 return Stream.fromQueue(events);
93 }),
94 ),
95 } as unknown as WsRpcProtocolClient;
96 const session: RpcSession = {
97 client,
98 initialConfig: Effect.succeed({
99 threadResumeCompletionMarker: true,
100 threadSnapshotPagination: true,
101 } as never),
102 subscribeServerConfig: (input) => client.subscribeServerConfig(input),
103 ready: Effect.void,
104 probe: Effect.void,
105 closed: Effect.never,
106 };
107 const supervisor = EnvironmentSupervisor.EnvironmentSupervisor.of({
108 target: TARGET,
109 state: yield* SubscriptionRef.make(AVAILABLE_CONNECTION_STATE),
110 session: yield* SubscriptionRef.make(Option.some(session)),
111 prepared: yield* SubscriptionRef.make<Option.Option<PreparedConnection>>(
112 Option.some({
113 environmentId: TARGET.environmentId,
114 label: TARGET.label,
115 httpBaseUrl: TARGET.httpBaseUrl,
116 socketUrl: TARGET.wsBaseUrl,
117 httpAuthorization: null,
118 target: TARGET,
119 }),
120 ),
121 connect: Effect.void,
122 disconnect: Effect.void,
123 retryNow: Effect.void,
124 });
125 const environmentRegistry = EnvironmentRegistry.EnvironmentRegistry.of({
126 entries: yield* SubscriptionRef.make<ReadonlyMap<EnvironmentId, ConnectionCatalogEntry>>(
127 new Map(),
128 ),
129 networkStatus: yield* SubscriptionRef.make<NetworkStatus>("online"),
130 start: Effect.void,
131 register: () => Effect.die("Unexpected environment registration"),
132 registerPlatform: () => Effect.die("Unexpected environment registration"),
133 reconcilePlatform: () => Effect.die("Unexpected environment reconciliation"),
134 remove: () => Effect.die("Unexpected environment removal"),
135 removeRelayEnvironments: () => Effect.die("Unexpected environment removal"),
136 retryNow: () => Effect.void,
137 setEnabled: () => Effect.die("Unexpected environment toggle"),
138 setCompatibility: () => Effect.die("Unexpected compatibility update"),
139 state: () => SubscriptionRef.get(supervisor.state),
140 stateChanges: () => SubscriptionRef.changes(supervisor.state),
141 run: (_environmentId, effect) =>
142 Effect.provideService(effect, EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
143 runStream: (_environmentId, stream) =>
144 Stream.provideService(stream, EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
145 followStream: (_environmentId, stream) =>
146 Stream.provideService(stream, EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
147 });
148 const historyController = yield* Effect.service(
149 ThreadHistoryController.ThreadHistoryController,
150 ).pipe(Effect.provide(ThreadHistoryController.layer));
151 const historyHttpClient = HttpClient.make((request, url) =>
152 Effect.gen(function* () {
153 const response = yield* Deferred.make<OrchestrationV2ThreadHistoryPage>();
154 const closed = yield* Deferred.make<void>();
155 yield* Effect.addFinalizer(() => Deferred.succeed(closed, undefined));
156 yield* Queue.offer(olderLoads, { cursor: url.searchParams.get("cursor"), response, closed });
157 const page = yield* Deferred.await(response);
158 return HttpClientResponse.fromWeb(request, Response.json(page));
159 }).pipe(Effect.scoped),
160 );
161 const runtime = Atom.runtime(
162 Layer.mergeAll(
163 Layer.succeed(ThreadHistoryController.ThreadHistoryController, historyController),
164 Layer.succeed(HttpClient.HttpClient, historyHttpClient),
165 Layer.succeed(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
166 Layer.succeed(
167 Persistence.EnvironmentCacheStore,
168 Persistence.EnvironmentCacheStore.of({
169 loadShell: () => Effect.succeedNone,
170 saveShell: () => Effect.void,
171 loadThread: () =>
172 Effect.sync(() => {
173 diskLoads += 1;
174 return Option.none();
175 }),
176 saveThread: () => Effect.void,
177 removeThread: () => Effect.void,
178 loadServerConfig: () => Effect.succeedNone,
179 saveServerConfig: () => Effect.void,
180 loadVcsRefs: () => Effect.succeedNone,
181 saveVcsRefs: () => Effect.void,
182 removeVcsRefs: () => Effect.void,
183 clearVcsRefs: () => Effect.void,
184 clear: () => Effect.void,
185 }),
186 ),
187 Layer.succeed(
188 ThreadSnapshotLoader.ThreadSnapshotLoader,
189 ThreadSnapshotLoader.ThreadSnapshotLoader.of({
190 load: () =>
191 Effect.sync(() => {
192 httpLoads += 1;
193 if (options?.snapshotUnavailable === true) {
194 return { _tag: "unavailable" as const };
195 }
196 return {
197 _tag: "present" as const,
198 snapshot,
199 ...(snapshot.historyCursor === undefined
200 ? {}
201 : {
202 history: {
203 historyCursor: snapshot.historyCursor,
204 hasMoreHistory: snapshot.hasMoreHistory ?? false,
205 latestLocalTurnOrdinal: snapshot.latestLocalTurnOrdinal ?? null,
206 },
207 }),
208 };
209 }),
210 }),
211 ),
212 ),
213 );
214 const raw = createEnvironmentThreadStateAtoms(runtime);
215 const details = createEnvironmentThreadDetailAtoms(raw.stateAtom);
216 const ref = { environmentId: TARGET.environmentId, threadId: THREAD_ID };
217 const stateAtom = details.stateAtom(ref);
218 const makeRegistry = Effect.acquireRelease(
219 Effect.sync(() => AtomRegistry.make({ defaultIdleTTL: 60_000, timeoutResolution: 1 })),
220 (registry) => Effect.sync(() => registry.dispose()),
221 );
222 const registry = yield* makeRegistry;
223
224 return {
225 registry,
226 makeRegistry,
227 rawAtoms: raw,
228 stateAtom,
229 details,
230 ref,
231 subscriptions,
232 olderLoads,
233 loadEarlier: () => historyController.loadEarlier(TARGET.environmentId, THREAD_ID),
234 counts: () => ({ httpLoads, diskLoads, opened, active }),
235 };
236});
237
238function observeState(
239 registry: AtomRegistry.AtomRegistry,
240 atom: Atom.Atom<EnvironmentThreadState>,
241 predicate: (state: EnvironmentThreadState) => boolean,
242) {
243 return AtomRegistry.toStream(registry, atom).pipe(
244 Stream.filter(predicate),
245 Stream.runHead,
246 Effect.map(Option.getOrThrow),
247 );
248}
249
250function currentThread(
251 registry: AtomRegistry.AtomRegistry,
252 atom: Atom.Atom<EnvironmentThreadState>,
253) {
254 return Option.getOrThrow(registry.get(atom).data);
255}
256
257describe("createEnvironmentThreadStateAtoms", () => {
258 afterEach(() => {
259 vi.useRealTimers();
260 vi.restoreAllMocks();
261 });
262
263 it.effect("shares one live stream and closes it after the last detail consumer leaves", () =>
264 Effect.gen(function* () {
265 const h = yield* makeHarness();
266 const unmountMessages = h.registry.mount(h.details.visibleTurnItemsAtom(h.ref));
267 const first = yield* Queue.take(h.subscriptions);
268 const unmountStatus = h.registry.mount(h.details.statusAtom(h.ref));
269 expect(h.counts()).toEqual({ httpLoads: 1, diskLoads: 1, opened: 1, active: 1 });
270 unmountMessages();
271 yield* Queue.offer(first.events, { kind: "synchronized" });
272 yield* observeState(h.registry, h.stateAtom, (state) => state.status === "live");
273 expect(h.counts().active).toBe(1);
274 unmountStatus();
275 yield* Deferred.await(first.closed);
276 expect(h.counts().active).toBe(0);
277 }),
278 );
279
280 it.effect("keeps warm data and resumes a completed cursor without loading another snapshot", () =>
281 Effect.gen(function* () {
282 const h = yield* makeHarness();
283 const unmount = h.registry.mount(h.stateAtom);
284 const first = yield* Queue.take(h.subscriptions);
285 yield* Queue.offer(first.events, {
286 kind: "event",
287 sequence: 8,
288 event: {
289 id: EventId.make("metadata-1"),
290 type: "thread.metadata-updated",
291 threadId: THREAD_ID,
292 occurredAt: THREAD.thread.updatedAt,
293 payload: { ...THREAD.thread, title: "Retained title" },
294 },
295 });
296 yield* Queue.offer(first.events, { kind: "synchronized" });
297 yield* observeState(h.registry, h.stateAtom, (state) => state.status === "live");
298 const before = currentThread(h.registry, h.stateAtom);
299 unmount();
300 yield* Deferred.await(first.closed);
301 const remount = h.registry.mount(h.stateAtom);
302 expect(currentThread(h.registry, h.stateAtom)).toBe(before);
303 const next = yield* Queue.take(h.subscriptions);
304 expect(next.afterSequence).toBe(8);
305 expect(h.counts()).toEqual({ httpLoads: 1, diskLoads: 1, opened: 2, active: 1 });
306 remount();
307 yield* Deferred.await(next.closed);
308 }),
309 );
310
311 it.effect("keeps warm data when the raw atom family's weak entry is collected", () =>
312 Effect.gen(function* () {
313 const h = yield* makeHarness();
314 const oldRaw = h.rawAtoms.stateAtom(TARGET.environmentId, THREAD_ID);
315 const unmount = h.registry.mount(h.stateAtom);
316 const first = yield* Queue.take(h.subscriptions);
317 const latest = { ...THREAD, thread: { ...THREAD.thread, title: "Newer cached thread" } };
318 yield* Queue.offer(first.events, {
319 kind: "snapshot",
320 snapshotSequence: 8,
321 projection: latest,
322 });
323 yield* Queue.offer(first.events, { kind: "synchronized" });
324 yield* observeState(h.registry, h.stateAtom, (value) => value.status === "live");
325 unmount();
326 yield* Deferred.await(first.closed);
327
328 // Force the weak-family miss without depending on host GC timing.
329 const deref = WeakRef.prototype.deref;
330 vi.spyOn(WeakRef.prototype, "deref").mockImplementation(function (this: WeakRef<object>) {
331 const value = deref.call(this);
332 return value === oldRaw ? undefined : value;
333 });
334 const remount = h.registry.mount(h.stateAtom);
335 expect(currentThread(h.registry, h.stateAtom)).toBe(latest);
336 const next = yield* Queue.take(h.subscriptions);
337 expect(next.afterSequence).toBe(8);
338 expect(h.counts()).toEqual({ httpLoads: 1, diskLoads: 1, opened: 2, active: 1 });
339 remount();
340 yield* Deferred.await(next.closed);
341 }),
342 );
343
344 it.effect("keeps cached snapshots local to each registry", () =>
345 Effect.gen(function* () {
346 const h = yield* makeHarness();
347 const unmount = h.registry.mount(h.stateAtom);
348 const first = yield* Queue.take(h.subscriptions);
349 unmount();
350 yield* Deferred.await(first.closed);
351 const otherRegistry = yield* h.makeRegistry;
352 const unmountOther = otherRegistry.mount(h.stateAtom);
353 const other = yield* Queue.take(h.subscriptions);
354 expect(h.counts()).toEqual({ httpLoads: 2, diskLoads: 2, opened: 2, active: 1 });
355 unmountOther();
356 yield* Deferred.await(other.closed);
357 }),
358 );
359
360 it.effect("expires the plain snapshot after five idle minutes", () =>
361 Effect.gen(function* () {
362 vi.useFakeTimers({ toFake: ["Date", "setTimeout", "clearTimeout"] });
363 const h = yield* makeHarness();
364 const unmount = h.registry.mount(h.stateAtom);
365 const first = yield* Queue.take(h.subscriptions);
366 unmount();
367 yield* Deferred.await(first.closed);
368 yield* Effect.yieldNow;
369 yield* Effect.promise(() => vi.advanceTimersByTimeAsync(THREAD_SNAPSHOT_IDLE_TTL_MS + 1));
370 const remount = h.registry.mount(h.stateAtom);
371 const next = yield* Queue.take(h.subscriptions);
372 expect(h.counts()).toEqual({ httpLoads: 2, diskLoads: 2, opened: 2, active: 1 });
373 remount();
374 yield* Deferred.await(next.closed);
375 }),
376 );
377
378 it.effect("cancels older-page work on unmount and permits it again on a warm return", () =>
379 Effect.gen(function* () {
380 const h = yield* makeHarness({
381 snapshot: {
382 ...SNAPSHOT,
383 historyCursor: "older-1",
384 hasMoreHistory: true,
385 },
386 });
387 const unmount = h.registry.mount(h.stateAtom);
388 const first = yield* Queue.take(h.subscriptions);
389 const loading = yield* h.loadEarlier().pipe(Effect.forkScoped);
390 const older = yield* Queue.take(h.olderLoads);
391 expect(h.registry.get(h.stateAtom).history.loading).toBe(true);
392 unmount();
393 yield* Deferred.await(first.closed);
394 yield* Deferred.await(older.closed);
395 yield* Fiber.await(loading);
396 const remount = h.registry.mount(h.stateAtom);
397 const next = yield* Queue.take(h.subscriptions);
398 expect(h.registry.get(h.stateAtom).history.loading).toBe(false);
399 const retrying = yield* h.loadEarlier().pipe(Effect.forkScoped);
400 const retried = yield* Queue.take(h.olderLoads);
401 expect(retried.cursor).toBe("older-1");
402 expect(h.counts().httpLoads).toBe(1);
403 remount();
404 yield* Deferred.await(next.closed);
405 yield* Deferred.await(retried.closed);
406 yield* Fiber.await(retrying);
407 }),
408 );
409
410 it.effect(
411 "merges older history after an HTTP failure falls back to a bounded socket snapshot",
412 () =>
413 Effect.gen(function* () {
414 const h = yield* makeHarness({ snapshotUnavailable: true });
415 const unmount = h.registry.mount(h.stateAtom);
416 const subscription = yield* Queue.take(h.subscriptions);
417 expect(subscription.afterSequence).toBeUndefined();
418
419 yield* Queue.offer(subscription.events, {
420 kind: "snapshot",
421 snapshotSequence: 12,
422 projection: THREAD,
423 historyCursor: "socket-older-1",
424 hasMoreHistory: true,
425 latestLocalTurnOrdinal: 4,
426 payloadBudgetExceeded: false,
427 });
428 yield* Queue.offer(subscription.events, { kind: "synchronized" });
429 yield* observeState(
430 h.registry,
431 h.stateAtom,
432 (state) => state.status === "live" && state.history.historyCursor === "socket-older-1",
433 );
434
435 const loading = yield* h.loadEarlier().pipe(Effect.forkScoped);
436 const request = yield* Queue.take(h.olderLoads);
437 expect(request.cursor).toBe("socket-older-1");
438 const olderItem = {
439 id: TurnItemId.make("socket-fallback-older-item"),
440 type: "command_execution" as const,
441 threadId: THREAD_ID,
442 runId: null,
443 nodeId: null,
444 providerThreadId: null,
445 providerTurnId: null,
446 nativeItemRef: null,
447 parentItemId: null,
448 ordinal: 1,
449 status: "completed" as const,
450 title: "Earlier command",
451 input: "pwd",
452 output: "/workspace",
453 exitCode: 0,
454 startedAt: THREAD.thread.createdAt,
455 completedAt: THREAD.thread.createdAt,
456 updatedAt: THREAD.thread.createdAt,
457 };
458 yield* Deferred.succeed(request.response, {
459 snapshotSequence: 12,
460 items: [
461 {
462 position: 0,
463 visibility: "local",
464 sourceThreadId: THREAD_ID,
465 sourceItemId: olderItem.id,
466 item: olderItem,
467 },
468 ],
469 nextCursor: null,
470 hasMoreHistory: false,
471 });
472 expect(yield* Fiber.join(loading)).toEqual({ _tag: "loaded" });
473
474 const state = h.registry.get(h.stateAtom);
475 expect(
476 Option.getOrThrow(state.data).visibleTurnItems.map((row) => row.sourceItemId),
477 ).toEqual([olderItem.id]);
478 expect(state.history).toMatchObject({
479 historyCursor: null,
480 hasMoreHistory: false,
481 loading: false,
482 error: null,
483 expanded: true,
484 latestLocalTurnOrdinal: 4,
485 });
486 expect(h.counts().httpLoads).toBe(1);
487
488 unmount();
489 yield* Deferred.await(subscription.closed);
490 }),
491 );
492});
493
494it.effect.each([1, 16, 500])("publishes V2 message replay once per batch of %i", (batchSize) =>
495 Effect.gen(function* () {
496 const h = yield* makeHarness();
497 const unmount = h.registry.mount(h.stateAtom);
498 const first = yield* Queue.take(h.subscriptions);
499 let updates = 0;
500 const stop = h.registry.subscribe(
501 Atom.map(h.stateAtom, (state) => Option.getOrNull(state.data)?.messages),
502 () => updates++,
503 {
504 immediate: true,
505 },
506 );
507 updates = 0;
508 const events: OrchestrationV2ThreadStreamItem[] = Array.from({ length: 500 }, (_, index) => ({
509 kind: "event",
510 sequence: 8 + index,
511 event: {
512 id: EventId.make(`replay-${index}`),
513 type: "message.updated",
514 threadId: THREAD_ID,
515 occurredAt: THREAD.thread.createdAt,
516 payload: {
517 id: MessageId.make("replayed-message"),
518 threadId: THREAD_ID,
519 runId: null,
520 nodeId: null,
521 role: "assistant",
522 text: `${index},`,
523 streaming: true,
524 attachments: [],
525 createdBy: "agent",
526 creationSource: "provider",
527 createdAt: THREAD.thread.createdAt,
528 updatedAt: THREAD.thread.createdAt,
529 },
530 },
531 }));
532 for (let offset = 0; offset < events.length; offset += batchSize) {
533 yield* Queue.offerAll(first.events, events.slice(offset, offset + batchSize));
534 const last = Math.min(offset + batchSize, events.length) - 1;
535 yield* observeState(
536 h.registry,
537 h.stateAtom,
538 (state) => Option.getOrNull(state.data)?.messages[0]?.text === `${last},`,
539 );
540 }
541 yield* Queue.offerAll(first.events, [events[499]!, events[0]!, { kind: "synchronized" }]);
542 yield* observeState(h.registry, h.stateAtom, (state) => state.status === "live");
543 expect(currentThread(h.registry, h.stateAtom).messages[0]?.text).toBe("499,");
544 expect(updates).toBe(Math.ceil(500 / batchSize));
545 stop();
546 unmount();
547 yield* Deferred.await(first.closed);
548 const remount = h.registry.mount(h.stateAtom);
549 const next = yield* Queue.take(h.subscriptions);
550 expect(next.afterSequence).toBe(507);
551 remount();
552 yield* Deferred.await(next.closed);
553 }),
554);
555
556it.effect("keeps snapshot boundaries and completion markers ordered inside a replay batch", () =>
557 Effect.gen(function* () {
558 const h = yield* makeHarness();
559 const unmount = h.registry.mount(h.stateAtom);
560 const first = yield* Queue.take(h.subscriptions);
561 const title = (sequence: number, value: string): OrchestrationV2ThreadStreamItem => ({
562 kind: "event",
563 sequence,
564 event: {
565 id: EventId.make(`batch-title-${sequence}`),
566 type: "thread.metadata-updated",
567 threadId: THREAD_ID,
568 occurredAt: THREAD.thread.updatedAt,
569 payload: { ...THREAD.thread, title: value },
570 },
571 });
572 yield* Queue.offerAll(first.events, [
573 title(8, "Before snapshot"),
574 {
575 kind: "snapshot",
576 snapshotSequence: 20,
577 projection: THREAD,
578 historyCursor: "older-batch",
579 hasMoreHistory: true,
580 latestLocalTurnOrdinal: 10,
581 },
582 title(21, "After snapshot"),
583 title(19, "Stale replay"),
584 { kind: "synchronized" },
585 ]);
586 const state = yield* observeState(h.registry, h.stateAtom, (value) => value.status === "live");
587 expect(Option.getOrThrow(state.data).thread.title).toBe("After snapshot");
588 expect(state.history.historyCursor).toBe("older-batch");
589 expect(state.history.latestLocalTurnOrdinal).toBe(10);
590 unmount();
591 yield* Deferred.await(first.closed);
592 const remount = h.registry.mount(h.stateAtom);
593 const next = yield* Queue.take(h.subscriptions);
594 expect(next.afterSequence).toBe(21);
595 remount();
596 yield* Deferred.await(next.closed);
597 }),
598);