@assistant-ui/react-statewire 0.13.0 → 0.15.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 (57) hide show
  1. package/dist/StatewireThread.d.ts +86 -105
  2. package/dist/StatewireThread.d.ts.map +1 -1
  3. package/dist/StatewireThread.js +36 -51
  4. package/dist/StatewireThread.js.map +1 -1
  5. package/dist/hooks.d.ts +6 -9
  6. package/dist/hooks.d.ts.map +1 -1
  7. package/dist/hooks.js +9 -20
  8. package/dist/hooks.js.map +1 -1
  9. package/dist/index.d.ts +2 -3
  10. package/dist/index.js +2 -3
  11. package/dist/inputRequests.d.ts +4 -4
  12. package/dist/inputRequests.d.ts.map +1 -1
  13. package/dist/inputRequests.js +1 -1
  14. package/dist/inputRequests.js.map +1 -1
  15. package/dist/runCommands.d.ts +8 -24
  16. package/dist/runCommands.d.ts.map +1 -1
  17. package/dist/runCommands.js +3 -3
  18. package/dist/runCommands.js.map +1 -1
  19. package/dist/runsOptimistic.d.ts.map +1 -1
  20. package/dist/runsOptimistic.js +30 -13
  21. package/dist/runsOptimistic.js.map +1 -1
  22. package/package.json +4 -5
  23. package/src/StatewireThread.runs.test.tsx +65 -33
  24. package/src/StatewireThread.test.tsx +228 -426
  25. package/src/StatewireThread.ts +133 -224
  26. package/src/__tests__/testHelpers.tsx +6 -226
  27. package/src/hooks.ts +11 -32
  28. package/src/index.ts +2 -4
  29. package/src/inputRequests.ts +7 -9
  30. package/src/runCommands.ts +17 -23
  31. package/src/runsMaterialize.test.ts +7 -8
  32. package/src/runsOptimistic.test.ts +86 -19
  33. package/src/runsOptimistic.ts +49 -19
  34. package/dist/AssistantTransportThread.d.ts +0 -227
  35. package/dist/AssistantTransportThread.d.ts.map +0 -1
  36. package/dist/AssistantTransportThread.js +0 -264
  37. package/dist/AssistantTransportThread.js.map +0 -1
  38. package/dist/host.d.ts +0 -38
  39. package/dist/host.d.ts.map +0 -1
  40. package/dist/host.js +0 -299
  41. package/dist/host.js.map +0 -1
  42. package/dist/replayBoundaryStream.d.ts +0 -6
  43. package/dist/replayBoundaryStream.d.ts.map +0 -1
  44. package/dist/replayBoundaryStream.js +0 -49
  45. package/dist/replayBoundaryStream.js.map +0 -1
  46. package/dist/stateOps.d.ts +0 -10
  47. package/dist/stateOps.d.ts.map +0 -1
  48. package/dist/stateOps.js +0 -114
  49. package/dist/stateOps.js.map +0 -1
  50. package/src/AssistantTransportThread.ts +0 -791
  51. package/src/athena.e2e.test.tsx +0 -654
  52. package/src/host.ts +0 -437
  53. package/src/legacy-diff.test.tsx +0 -628
  54. package/src/replayBoundaryStream.ts +0 -71
  55. package/src/stateOps.test.ts +0 -165
  56. package/src/stateOps.ts +0 -126
  57. package/src/transport.test.tsx +0 -3001
@@ -1,654 +0,0 @@
1
- // @vitest-environment jsdom
2
-
3
- // End-to-end simulation of the olympus deep-agent call site: LangGraph-shaped
4
- // state, optimistic dedup via a WeakMap trackingId cache, attachment stripping
5
- // in prepareSendCommandsRequest, async headers, body fn, frontend tool
6
- // execution, custom resume command, cancel mid-stream, resume via resumeApi.
7
-
8
- import { render, waitFor } from "@testing-library/react";
9
- import type { FC } from "react";
10
- import { afterEach, describe, expect, it, vi } from "vitest";
11
- import { AuiProvider, useAui } from "@assistant-ui/store";
12
- import type { ExternalThreadMessage } from "@assistant-ui/react";
13
- import { AssistantTransportThread } from "./AssistantTransportThread";
14
- import { useAssistantTransportSendCommand } from "./hooks";
15
-
16
- import {
17
- createStreamResponse,
18
- installFetch,
19
- threadTexts,
20
- } from "./__tests__/testHelpers";
21
-
22
- type LangGraphMessage =
23
- | { id: string; type: "human"; content: string; trackingId?: string }
24
- | {
25
- id: string;
26
- type: "ai";
27
- content: string;
28
- tool_calls?: { id: string; name: string; args: object }[];
29
- }
30
- | { id: string; type: "tool"; content: string; tool_call_id: string };
31
-
32
- type LangGraphState = {
33
- messages: LangGraphMessage[];
34
- todos: string[];
35
- inputRequests?: AssistantTransportThread.InputRequestState[];
36
- isRunning?: boolean;
37
- };
38
-
39
- const INITIAL_STATE: LangGraphState = { messages: [], todos: [] };
40
-
41
- // Athena's optimistic dedup: each user-message command gets a stable
42
- // trackingId; the server echoes it on the human message, which retires the
43
- // optimistic copy without a flicker frame or a phantom duplicate.
44
- type UserMessageCommand = (
45
- | AssistantTransportThread.RunSteerCommand
46
- | AssistantTransportThread.RunEditCommand
47
- ) & {
48
- message: AssistantTransportThread.RunUserMessage;
49
- };
50
-
51
- const isUserMessageCommand = (
52
- c: AssistantTransportThread.Command,
53
- ): c is UserMessageCommand =>
54
- (c.type === "run/steer" || c.type === "run/edit") && "message" in c;
55
-
56
- const createConverter = () => {
57
- const trackingIds = new WeakMap<object, string>();
58
- let nextTrackingId = 0;
59
- const trackingIdOf = (command: object) => {
60
- let id = trackingIds.get(command);
61
- if (id === undefined) {
62
- id = `track-${nextTrackingId++}`;
63
- trackingIds.set(command, id);
64
- }
65
- return id;
66
- };
67
-
68
- // The optimistic fold stamps isRunning and inserts the pending user
69
- // message unless the server already echoed its trackingId.
70
- const optimistic: AssistantTransportThread.Optimistic<LangGraphState> = (
71
- draft,
72
- command,
73
- ) => {
74
- draft.isRunning = true;
75
- if (!isUserMessageCommand(command)) return;
76
- const trackingId = trackingIdOf(command);
77
- const echoed = draft.messages.some(
78
- (m) => m.type === "human" && m.trackingId === trackingId,
79
- );
80
- if (echoed) return;
81
- draft.messages.push({
82
- id: `optimistic-${trackingId}`,
83
- type: "human",
84
- content: command.message.parts.find((p) => p.type === "text")?.text ?? "",
85
- trackingId,
86
- });
87
- };
88
-
89
- const converter: AssistantTransportThread.StateConverter<LangGraphState> = (
90
- state,
91
- ) => {
92
- const toolResults = new Map<string, string>();
93
- for (const m of state.messages) {
94
- if (m.type === "tool") toolResults.set(m.tool_call_id, m.content);
95
- }
96
-
97
- const messages: ExternalThreadMessage[] = [];
98
- for (const m of state.messages) {
99
- if (m.type === "human") {
100
- messages.push({
101
- id: m.id,
102
- role: "user",
103
- createdAt: new Date(0),
104
- content: [{ type: "text", text: m.content }],
105
- attachments: [],
106
- metadata: { custom: { trackingId: m.trackingId } },
107
- } as unknown as ExternalThreadMessage);
108
- } else if (m.type === "ai") {
109
- const content = [
110
- ...(m.content ? [{ type: "text", text: m.content }] : []),
111
- ...(m.tool_calls ?? []).map((tc) => ({
112
- type: "tool-call",
113
- toolCallId: tc.id,
114
- toolName: tc.name,
115
- args: tc.args,
116
- argsText: JSON.stringify(tc.args),
117
- ...(toolResults.has(tc.id) && {
118
- result: JSON.parse(toolResults.get(tc.id)!),
119
- }),
120
- })),
121
- ];
122
- const unresolved = (m.tool_calls ?? []).some(
123
- (tc) => !toolResults.has(tc.id),
124
- );
125
- messages.push({
126
- id: m.id,
127
- role: "assistant",
128
- createdAt: new Date(0),
129
- content,
130
- attachments: [],
131
- metadata: { custom: {} },
132
- status: unresolved
133
- ? { type: "requires-action", reason: "tool-call" }
134
- : { type: "complete", reason: "stop" },
135
- } as unknown as ExternalThreadMessage);
136
- }
137
- }
138
-
139
- return {
140
- messages,
141
- isRunning: state.isRunning ?? false,
142
- state: { todos: state.todos },
143
- inputRequests: state.inputRequests ?? [],
144
- };
145
- };
146
-
147
- return { converter, optimistic, trackingIdOf };
148
- };
149
-
150
- const mountDeepAgent = () => {
151
- const { converter, optimistic, trackingIdOf } = createConverter();
152
- const cancelled: AssistantTransportThread.Command[][] = [];
153
- const errored: AssistantTransportThread.Command[][] = [];
154
- const responses: (string | null)[] = [];
155
- let finishCount = 0;
156
-
157
- const captured: {
158
- aui?: ReturnType<typeof useAui>;
159
- sendCommand?: (command: AssistantTransportThread.Command) => void;
160
- } = {};
161
- const Capture: FC = () => {
162
- captured.aui = useAui();
163
- captured.sendCommand = useAssistantTransportSendCommand();
164
- return null;
165
- };
166
-
167
- const options: AssistantTransportThread.Options<LangGraphState> = {
168
- initialState: INITIAL_STATE,
169
- api: "https://sync.example.com/api/chat",
170
- resumeApi: "https://sync.example.com/api/resume",
171
- protocol: "assistant-transport",
172
- converter,
173
- optimistic,
174
- capabilities: { edit: true },
175
- headers: async () => ({
176
- Authorization: "Bearer test-token",
177
- "X-Thread-Id": "thread-42",
178
- }),
179
- body: () => Promise.resolve({ backendPath: "deep-agent" }),
180
- prepareSendCommandsRequest: (body) => ({
181
- ...body,
182
- commands: body.commands.map((c) =>
183
- isUserMessageCommand(c)
184
- ? {
185
- ...c,
186
- trackingId: trackingIdOf(c),
187
- message: {
188
- ...c.message,
189
- parts: c.message.parts.filter((p) => p.type !== "file"),
190
- },
191
- }
192
- : c,
193
- ),
194
- }),
195
- onResponse: (response) => {
196
- responses.push(response.headers.get("X-Stream-Status"));
197
- },
198
- onFinish: () => {
199
- finishCount += 1;
200
- },
201
- onError: (_error, { commands, updateState }) => {
202
- errored.push(commands);
203
- // Athena re-attaches failed user messages into the local state so the
204
- // UI does not lose them.
205
- updateState((state) => ({
206
- ...state,
207
- messages: [
208
- ...state.messages,
209
- ...commands.flatMap((c, i) =>
210
- isUserMessageCommand(c)
211
- ? [
212
- {
213
- id: `reattached-${i}`,
214
- type: "human" as const,
215
- content:
216
- c.message.parts.find((p) => p.type === "text")?.text ??
217
- "",
218
- trackingId: trackingIdOf(c),
219
- },
220
- ]
221
- : [],
222
- ),
223
- ],
224
- }));
225
- },
226
- onCancel: ({ commands }) => {
227
- cancelled.push(commands);
228
- },
229
- };
230
-
231
- const App: FC = () => {
232
- const aui = useAui({
233
- thread: AssistantTransportThread<LangGraphState>(options),
234
- });
235
- return (
236
- <AuiProvider value={aui}>
237
- <Capture />
238
- </AuiProvider>
239
- );
240
- };
241
- const utils = render(<App />);
242
- return {
243
- aui: () => captured.aui!,
244
- sendCommand: (c: AssistantTransportThread.Command) =>
245
- captured.sendCommand!(c),
246
- cancelled,
247
- errored,
248
- responses,
249
- finishCount: () => finishCount,
250
- ...utils,
251
- };
252
- };
253
-
254
- afterEach(() => {
255
- vi.unstubAllGlobals();
256
- });
257
-
258
- describe("deep-agent e2e", () => {
259
- it("runs a full conversation: send, echo, tool call, follow-up, interrupt, cancel, resume", async () => {
260
- const fetchMock = installFetch();
261
- const servers: ReturnType<typeof createStreamResponse>[] = [];
262
- fetchMock.setHandler(() => {
263
- const server = createStreamResponse(
264
- fetchMock.requests.length === 4
265
- ? { headers: { "X-Stream-Status": "active" } }
266
- : undefined,
267
- );
268
- servers.push(server);
269
- return server.response;
270
- });
271
-
272
- const harness = mountDeepAgent();
273
- const { aui, sendCommand, responses } = harness;
274
-
275
- aui()
276
- .modelContext()
277
- .register({
278
- getModelContext: () => ({
279
- tools: {
280
- get_weather: {
281
- parameters: {
282
- type: "object",
283
- properties: { city: { type: "string" } },
284
- },
285
- execute: async (args: any) => ({ temp: 20, city: args.city }),
286
- },
287
- },
288
- }),
289
- });
290
-
291
- // 1 — user sends a message with an image attachment part.
292
- aui()
293
- .thread()
294
- .append({
295
- role: "user",
296
- content: [
297
- { type: "text", text: "what's the weather in SF?" },
298
- { type: "image", image: "data:image/png;base64,abc" },
299
- ],
300
- });
301
-
302
- // Optimistic message renders before any network round trip completes.
303
- await waitFor(() =>
304
- expect(threadTexts(aui)).toEqual(["what's the weather in SF?"]),
305
- );
306
- expect(
307
- aui().thread().getState().messages.at(0)!.id.startsWith("optimistic-"),
308
- ).toBe(true);
309
- expect(aui().thread().getState().isRunning).toBe(true);
310
-
311
- await waitFor(() => expect(fetchMock.requests).toHaveLength(1));
312
- const r1 = fetchMock.requests[0]!;
313
- expect(r1.url).toBe("https://sync.example.com/api/chat");
314
- const headers = new Headers(r1.init.headers);
315
- expect(headers.get("Authorization")).toBe("Bearer test-token");
316
- expect(headers.get("X-Thread-Id")).toBe("thread-42");
317
- expect(r1.body.backendPath).toBe("deep-agent");
318
- expect(r1.body.state).toEqual(INITIAL_STATE);
319
- // prepareSendCommandsRequest stripped the file part (the converted image
320
- // attachment), kept trackingId.
321
- expect(r1.body.commands).toEqual([
322
- {
323
- type: "run/steer",
324
- runId: expect.any(String),
325
- trackingId: "track-0",
326
- message: {
327
- id: expect.any(String),
328
- role: "user",
329
- parts: [{ type: "text", text: "what's the weather in SF?" }],
330
- },
331
- runAnchorMessageId: null,
332
- },
333
- ]);
334
-
335
- // 2 — server echoes the human message (backend id + trackingId) and
336
- // streams the AI reply via append-text, then a tool call.
337
- servers[0]!.emit({
338
- type: "update-state",
339
- operations: [
340
- {
341
- type: "set",
342
- path: ["messages"],
343
- value: [
344
- {
345
- id: "h1",
346
- type: "human",
347
- content: "what's the weather in SF?",
348
- trackingId: "track-0",
349
- },
350
- { id: "a1", type: "ai", content: "" },
351
- ],
352
- },
353
- ],
354
- });
355
- await waitFor(() =>
356
- expect(threadTexts(aui)).toEqual(["what's the weather in SF?", ""]),
357
- );
358
- // Optimistic copy retired — the echoed message replaced it, no phantom.
359
- expect(
360
- aui()
361
- .thread()
362
- .getState()
363
- .messages.map((m) => m.id),
364
- ).toEqual(["h1", "a1"]);
365
-
366
- servers[0]!.emit({
367
- type: "update-state",
368
- operations: [
369
- {
370
- type: "append-text",
371
- path: ["messages", "1", "content"],
372
- value: "Let me",
373
- },
374
- {
375
- type: "append-text",
376
- path: ["messages", "1", "content"],
377
- value: " check.",
378
- },
379
- ],
380
- });
381
- await waitFor(() =>
382
- expect(threadTexts(aui)).toEqual([
383
- "what's the weather in SF?",
384
- "Let me check.",
385
- ]),
386
- );
387
-
388
- servers[0]!.emit({
389
- type: "update-state",
390
- operations: [
391
- {
392
- type: "set",
393
- path: ["messages", "1", "tool_calls"],
394
- value: [{ id: "tc1", name: "get_weather", args: { city: "SF" } }],
395
- },
396
- {
397
- type: "set",
398
- path: ["inputRequests"],
399
- value: [
400
- {
401
- type: "tool-call",
402
- id: "in-tc1",
403
- toolCallId: "tc1",
404
- response: null,
405
- },
406
- ],
407
- },
408
- ],
409
- });
410
- servers[0]!.done();
411
-
412
- // 3 — frontend tool executes and answers the parked input request via
413
- // run/input in a follow-up run.
414
- await waitFor(() => expect(fetchMock.requests).toHaveLength(2));
415
- const r2 = fetchMock.requests[1]!;
416
- expect(r2.url).toBe("https://sync.example.com/api/chat");
417
- expect(r2.body.commands).toEqual([
418
- {
419
- type: "run/input",
420
- requestId: "in-tc1",
421
- response: { output: { temp: 20, city: "SF" } },
422
- },
423
- ]);
424
- // The follow-up run posts the converged state from run 1.
425
- expect(r2.body.state.messages.map((m: LangGraphMessage) => m.id)).toEqual([
426
- "h1",
427
- "a1",
428
- ]);
429
-
430
- servers[1]!.emit({
431
- type: "update-state",
432
- operations: [
433
- {
434
- type: "set",
435
- path: ["messages", "2"],
436
- value: {
437
- id: "t1",
438
- type: "tool",
439
- content: '{"temp":20,"city":"SF"}',
440
- tool_call_id: "tc1",
441
- },
442
- },
443
- {
444
- type: "set",
445
- path: ["messages", "3"],
446
- value: { id: "a2", type: "ai", content: "It is 20°C in SF." },
447
- },
448
- { type: "set", path: ["todos"], value: ["report weather"] },
449
- ],
450
- });
451
- servers[1]!.done();
452
-
453
- await waitFor(() =>
454
- expect(threadTexts(aui)).toEqual([
455
- "what's the weather in SF?",
456
- "Let me check.",
457
- "It is 20°C in SF.",
458
- ]),
459
- );
460
- expect(aui().thread().getState().state).toEqual({
461
- todos: ["report weather"],
462
- });
463
- await waitFor(() =>
464
- expect(aui().thread().getState().isRunning).toBe(false),
465
- );
466
-
467
- // 4 — interrupt resolution via a custom resume command (approval banner).
468
- sendCommand({ type: "resume", payload: { approve: true } } as never);
469
- await waitFor(() => expect(fetchMock.requests).toHaveLength(3));
470
- expect(fetchMock.requests[2]!.body.commands).toEqual([
471
- { type: "resume", payload: { approve: true } },
472
- ]);
473
-
474
- // 5 — the run streams a partial reply, then the user cancels mid-stream.
475
- servers[2]!.emit({
476
- type: "update-state",
477
- operations: [
478
- {
479
- type: "set",
480
- path: ["messages", "4"],
481
- value: { id: "a3", type: "ai", content: "Working on" },
482
- },
483
- ],
484
- });
485
- await waitFor(() => expect(threadTexts(aui).at(-1)).toBe("Working on"));
486
-
487
- aui().thread().cancelRun();
488
- servers[2]!.error(
489
- new DOMException("The operation was aborted.", "AbortError"),
490
- );
491
- await waitFor(() =>
492
- expect(aui().thread().getState().isRunning).toBe(false),
493
- );
494
- // Partial state from before the cancel is preserved.
495
- expect(threadTexts(aui).at(-1)).toBe("Working on");
496
- expect(harness.cancelled).toHaveLength(1);
497
-
498
- // 6 — reconnect: probe says a run is still active, client resumes.
499
- aui().thread().resumeRun({ parentId: null });
500
- await waitFor(() => expect(fetchMock.requests).toHaveLength(4));
501
- const r4 = fetchMock.requests[3]!;
502
- expect(r4.url).toBe("https://sync.example.com/api/resume");
503
- expect(r4.body.commands).toEqual([]);
504
- await waitFor(() => expect(responses.at(-1)).toBe("active"));
505
-
506
- servers[3]!.emit({
507
- type: "update-state",
508
- operations: [
509
- {
510
- type: "set",
511
- path: ["messages", "4", "content"],
512
- value: "Working on it. Done.",
513
- },
514
- ],
515
- });
516
- servers[3]!.done();
517
-
518
- await waitFor(() =>
519
- expect(threadTexts(aui)).toEqual([
520
- "what's the weather in SF?",
521
- "Let me check.",
522
- "It is 20°C in SF.",
523
- "Working on it. Done.",
524
- ]),
525
- );
526
- await waitFor(() =>
527
- expect(aui().thread().getState().isRunning).toBe(false),
528
- );
529
- expect(harness.finishCount()).toBe(4);
530
- expect(harness.errored).toHaveLength(0);
531
- });
532
-
533
- it("edits a user message and dedups the optimistic copy against the echoed branch", async () => {
534
- const fetchMock = installFetch();
535
- const servers: ReturnType<typeof createStreamResponse>[] = [];
536
- fetchMock.setHandler(() => {
537
- const server = createStreamResponse();
538
- servers.push(server);
539
- return server.response;
540
- });
541
-
542
- const { aui } = mountDeepAgent();
543
-
544
- aui().thread().importExternalState!({
545
- messages: [
546
- { id: "h1", type: "human", content: "hello" },
547
- { id: "a1", type: "ai", content: "hi" },
548
- { id: "h2", type: "human", content: "bad question" },
549
- { id: "a2", type: "ai", content: "bad answer" },
550
- ],
551
- todos: [],
552
- } satisfies LangGraphState);
553
- await waitFor(() =>
554
- expect(threadTexts(aui)).toEqual([
555
- "hello",
556
- "hi",
557
- "bad question",
558
- "bad answer",
559
- ]),
560
- );
561
-
562
- const composer = aui().thread().message({ id: "h2" }).composer();
563
- composer.beginEdit();
564
- await waitFor(() => expect(composer.getState().isEditing).toBe(true));
565
- composer.setText("better question");
566
- await waitFor(() =>
567
- expect(composer.getState().text).toBe("better question"),
568
- );
569
- composer.send();
570
-
571
- await waitFor(() => expect(fetchMock.requests).toHaveLength(1));
572
- expect(fetchMock.requests[0]!.body.commands).toEqual([
573
- {
574
- type: "run/edit",
575
- runId: expect.any(String),
576
- trackingId: "track-0",
577
- message: {
578
- id: expect.any(String),
579
- role: "user",
580
- parts: [{ type: "text", text: "better question" }],
581
- },
582
- sourceId: "h2",
583
- runAnchorMessageId: "a1",
584
- },
585
- ]);
586
- expect("parentId" in fetchMock.requests[0]!.body).toBe(false);
587
-
588
- // Optimistic edit rides alongside the old branch until the server
589
- // replaces it wholesale with the new branch.
590
- await waitFor(() =>
591
- expect(threadTexts(aui).at(-1)).toBe("better question"),
592
- );
593
-
594
- servers[0]!.emit({
595
- type: "update-state",
596
- operations: [
597
- {
598
- type: "set",
599
- path: ["messages"],
600
- value: [
601
- { id: "h1", type: "human", content: "hello" },
602
- { id: "a1", type: "ai", content: "hi" },
603
- {
604
- id: "h3",
605
- type: "human",
606
- content: "better question",
607
- trackingId: "track-0",
608
- },
609
- { id: "a3", type: "ai", content: "great answer" },
610
- ],
611
- },
612
- ],
613
- });
614
- servers[0]!.done();
615
-
616
- await waitFor(() =>
617
- expect(threadTexts(aui)).toEqual([
618
- "hello",
619
- "hi",
620
- "better question",
621
- "great answer",
622
- ]),
623
- );
624
- expect(
625
- aui()
626
- .thread()
627
- .getState()
628
- .messages.map((m) => m.id),
629
- ).toEqual(["h1", "a1", "h3", "a3"]);
630
- });
631
-
632
- it("re-attaches failed user messages via onError updateState", async () => {
633
- const fetchMock = installFetch();
634
- fetchMock.setHandler(() => new Response("backend down", { status: 500 }));
635
-
636
- const harness = mountDeepAgent();
637
- const { aui } = harness;
638
-
639
- aui().thread().append("save this message");
640
-
641
- await waitFor(() => expect(harness.errored).toHaveLength(1));
642
- expect(harness.errored[0]!.map((c) => c.type)).toEqual(["run/steer"]);
643
-
644
- // The command left the queue (no longer optimistic/pending) but the
645
- // re-attached copy keeps it visible.
646
- await waitFor(() =>
647
- expect(threadTexts(aui)).toEqual(["save this message"]),
648
- );
649
- expect(aui().thread().getState().messages.at(0)!.id).toBe("reattached-0");
650
- await waitFor(() =>
651
- expect(aui().thread().getState().isRunning).toBe(false),
652
- );
653
- });
654
- });