@assistant-ui/react-statewire 0.11.2 → 0.13.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 (39) hide show
  1. package/dist/AssistantTransportThread.d.ts +19 -6
  2. package/dist/AssistantTransportThread.d.ts.map +1 -1
  3. package/dist/AssistantTransportThread.js +22 -15
  4. package/dist/AssistantTransportThread.js.map +1 -1
  5. package/dist/StatewireThread.d.ts +27 -15
  6. package/dist/StatewireThread.d.ts.map +1 -1
  7. package/dist/StatewireThread.js +37 -37
  8. package/dist/StatewireThread.js.map +1 -1
  9. package/dist/hooks.d.ts +3 -1
  10. package/dist/hooks.d.ts.map +1 -1
  11. package/dist/hooks.js +11 -2
  12. package/dist/hooks.js.map +1 -1
  13. package/dist/index.d.ts +2 -2
  14. package/dist/index.js +2 -2
  15. package/dist/inputRequests.d.ts +2 -2
  16. package/dist/inputRequests.d.ts.map +1 -1
  17. package/dist/inputRequests.js +4 -2
  18. package/dist/inputRequests.js.map +1 -1
  19. package/dist/runCommands.d.ts +15 -4
  20. package/dist/runCommands.d.ts.map +1 -1
  21. package/dist/runCommands.js +27 -11
  22. package/dist/runCommands.js.map +1 -1
  23. package/dist/runsOptimistic.d.ts.map +1 -1
  24. package/dist/runsOptimistic.js +6 -6
  25. package/dist/runsOptimistic.js.map +1 -1
  26. package/package.json +1 -1
  27. package/src/AssistantTransportThread.ts +53 -16
  28. package/src/StatewireThread.runs.test.tsx +69 -55
  29. package/src/StatewireThread.test.tsx +40 -53
  30. package/src/StatewireThread.ts +89 -78
  31. package/src/athena.e2e.test.tsx +4 -2
  32. package/src/hooks.ts +11 -0
  33. package/src/index.ts +1 -0
  34. package/src/inputRequests.ts +4 -0
  35. package/src/legacy-diff.test.tsx +2 -1
  36. package/src/runCommands.ts +48 -10
  37. package/src/runsOptimistic.test.ts +64 -26
  38. package/src/runsOptimistic.ts +10 -7
  39. package/src/transport.test.tsx +46 -9
@@ -45,8 +45,8 @@ describe("runsOptimistic", () => {
45
45
  const draft = mount({ status: "running", runId: "run-1" });
46
46
  apply(draft, "run/steer", {
47
47
  type: "run/steer",
48
+ runId: "run-1",
48
49
  message: message("s1"),
49
- anchorMessageId: null,
50
50
  });
51
51
  expect(run(draft).steerQueue.map((e: Draft) => e.id)).toEqual(["s1"]);
52
52
  expect(draft.status).toBe("running");
@@ -57,17 +57,18 @@ describe("runsOptimistic", () => {
57
57
  it("parks a steer in the lane after a stop and predicts the continue run", () => {
58
58
  const draft = mount({
59
59
  status: "stopped",
60
+ runId: "run-1",
60
61
  steerQueue: [message("s1")],
61
62
  error: { message: "boom" },
62
63
  });
63
64
  apply(draft, "run/steer", {
64
65
  type: "run/steer",
66
+ runId: "run-1",
65
67
  message: message("s2"),
66
- anchorMessageId: null,
67
68
  });
68
69
  expect(draft.status).toBe("running");
69
70
  expect(run(draft).status).toBe("running");
70
- expect(run(draft).runId).toBe("optimistic-7");
71
+ expect(run(draft).runId).toBe("run-1");
71
72
  expect(run(draft).steerQueue.map((e: Draft) => e.id)).toEqual(["s1", "s2"]);
72
73
  expect(run(draft).dispatching).toBeNull();
73
74
  expect(run(draft).error).toBeNull();
@@ -82,11 +83,11 @@ describe("runsOptimistic", () => {
82
83
  });
83
84
  apply(draft, "run/steer", {
84
85
  type: "run/steer",
86
+ runId: "run-1",
85
87
  message: message("s2"),
86
- anchorMessageId: null,
87
88
  });
88
89
  expect(draft.status).toBe("running");
89
- expect(run(draft).runId).toBe("optimistic-7");
90
+ expect(run(draft).runId).toBe("run-1");
90
91
  expect(run(draft).steerQueue).toEqual([]);
91
92
  expect(run(draft).dispatching.trigger).toBe("message-send");
92
93
  expect(run(draft).dispatching.messages.map((e: Draft) => e.id)).toEqual([
@@ -99,21 +100,26 @@ describe("runsOptimistic", () => {
99
100
  const ready = mount();
100
101
  apply(ready, "run/enqueue", {
101
102
  type: "run/enqueue",
103
+ runId: "mint-1",
102
104
  message: message("a"),
103
- anchorMessageId: null,
105
+ runAnchorMessageId: null,
104
106
  });
105
107
  expect(ready.status).toBe("running");
106
- expect(run(ready).runId).toBe("optimistic-7");
108
+ expect(run(ready).runId).toBe("mint-1");
107
109
  expect(run(ready).queue).toEqual([]);
108
110
  expect(run(ready).dispatching.messages.map((e: Draft) => e.id)).toEqual([
109
111
  "a",
110
112
  ]);
111
113
 
112
- const stopped = mount({ status: "stopped", queue: [message("q1")] });
114
+ const stopped = mount({
115
+ status: "stopped",
116
+ runId: "run-1",
117
+ queue: [message("q1")],
118
+ });
113
119
  apply(stopped, "run/enqueue", {
114
120
  type: "run/enqueue",
121
+ runId: "run-1",
115
122
  message: message("a"),
116
- anchorMessageId: null,
117
123
  });
118
124
  expect(stopped.status).toBe("stopped");
119
125
  expect(run(stopped).queue.map((e: Draft) => e.id)).toEqual(["q1", "a"]);
@@ -127,8 +133,8 @@ describe("runsOptimistic", () => {
127
133
  });
128
134
  apply(draft, "run/enqueue", {
129
135
  type: "run/enqueue",
136
+ runId: "r",
130
137
  message: message("x"),
131
- anchorMessageId: null,
132
138
  insertAfter: "a",
133
139
  });
134
140
  expect(run(draft).queue.map((e: Draft) => e.id)).toEqual(["a", "x", "b"]);
@@ -142,10 +148,14 @@ describe("runsOptimistic", () => {
142
148
  });
143
149
  apply(draft, "run/enqueue", {
144
150
  type: "run/enqueue",
151
+ runId: "r",
145
152
  message: message("d1"),
146
- anchorMessageId: null,
147
153
  });
148
- apply(draft, "run/steer", { type: "run/steer", messageId: "d1" });
154
+ apply(draft, "run/steer", {
155
+ type: "run/steer",
156
+ runId: "r",
157
+ messageId: "d1",
158
+ });
149
159
  expect(run(draft).queue).toEqual([]);
150
160
  expect(run(draft).steerQueue).toEqual([]);
151
161
  expect(run(draft).dispatching.messages.map((e: Draft) => e.id)).toEqual([
@@ -159,19 +169,28 @@ describe("runsOptimistic", () => {
159
169
  runId: "r",
160
170
  queue: [{ ...message("q1"), meta: { m: 1 } }, message("q2")],
161
171
  });
162
- apply(draft, "run/steer", { type: "run/steer", messageId: "q1" });
172
+ apply(draft, "run/steer", {
173
+ type: "run/steer",
174
+ runId: "r",
175
+ messageId: "q1",
176
+ });
163
177
  expect(run(draft).queue.map((e: Draft) => e.id)).toEqual(["q2"]);
164
178
  expect(run(draft).steerQueue.map((e: Draft) => e.id)).toEqual(["q1"]);
165
179
  expect(run(draft).steerQueue[0].meta).toEqual({ m: 1 });
166
180
 
167
181
  apply(draft, "run/enqueue", {
168
182
  type: "run/enqueue",
183
+ runId: "r",
169
184
  message: { ...message("q2"), parts: [{ type: "text", text: "new" }] },
170
185
  });
171
186
  expect(run(draft).queue.map((e: Draft) => e.id)).toEqual(["q2"]);
172
187
  expect(run(draft).queue[0].parts).toEqual([{ type: "text", text: "new" }]);
173
188
 
174
- apply(draft, "run/dequeue", { type: "run/dequeue", messageId: "q1" });
189
+ apply(draft, "run/dequeue", {
190
+ type: "run/dequeue",
191
+ runId: "r",
192
+ messageId: "q1",
193
+ });
175
194
  expect(run(draft).steerQueue).toEqual([]);
176
195
  });
177
196
 
@@ -183,12 +202,13 @@ describe("runsOptimistic", () => {
183
202
  });
184
203
  apply(draft, "run/edit", {
185
204
  type: "run/edit",
205
+ runId: "run-1",
186
206
  message: message("m2b"),
187
207
  sourceId: "m2",
188
- rollbackTo: "a1",
208
+ runAnchorMessageId: "a1",
189
209
  });
190
210
  expect(draft.status).toBe("running");
191
- expect(run(draft).runId).toBe("optimistic-7");
211
+ expect(run(draft).runId).toBe("run-1");
192
212
  expect(run(draft).inputRequests).toBeUndefined();
193
213
  expect(run(draft).dispatching).toEqual({
194
214
  trigger: "message-edit",
@@ -198,14 +218,19 @@ describe("runsOptimistic", () => {
198
218
  });
199
219
 
200
220
  it("run/reload predicts the rewind dispatch record", () => {
201
- const draft = mount({ status: "stopped", error: { message: "boom" } });
221
+ const draft = mount({
222
+ status: "stopped",
223
+ runId: "run-1",
224
+ error: { message: "boom" },
225
+ });
202
226
  apply(draft, "run/reload", {
203
227
  type: "run/reload",
228
+ runId: "run-1",
204
229
  sourceId: "a1",
205
- rollbackTo: null,
230
+ runAnchorMessageId: null,
206
231
  });
207
232
  expect(draft.status).toBe("running");
208
- expect(run(draft).runId).toBe("optimistic-7");
233
+ expect(run(draft).runId).toBe("run-1");
209
234
  expect(run(draft).error).toBeNull();
210
235
  expect(run(draft).dispatching).toEqual({
211
236
  trigger: "message-reload",
@@ -215,9 +240,14 @@ describe("runsOptimistic", () => {
215
240
  });
216
241
 
217
242
  it("run/continue starts the run and drains the steer lane optimistically", () => {
218
- const stopped = mount({ status: "stopped", steerQueue: [message("s1")] });
219
- apply(stopped, "run/continue", { type: "run/continue" });
243
+ const stopped = mount({
244
+ status: "stopped",
245
+ runId: "run-1",
246
+ steerQueue: [message("s1")],
247
+ });
248
+ apply(stopped, "run/continue", { type: "run/continue", runId: "run-1" });
220
249
  expect(stopped.status).toBe("running");
250
+ expect(run(stopped).runId).toBe("run-1");
221
251
  expect(run(stopped).steerQueue).toEqual([]);
222
252
  });
223
253
 
@@ -225,13 +255,14 @@ describe("runsOptimistic", () => {
225
255
  const draft = mount();
226
256
  apply(draft, "run/steer", {
227
257
  type: "run/steer",
258
+ runId: "mint-1",
228
259
  message: message("s1"),
229
- anchorMessageId: null,
260
+ runAnchorMessageId: null,
230
261
  });
231
262
  expect(draft.status).toBe("running");
232
263
  expect(draft.runs).toHaveLength(1);
233
264
  expect(run(draft)).toEqual({
234
- runId: "optimistic-7",
265
+ runId: "mint-1",
235
266
  status: "running",
236
267
  queue: [],
237
268
  steerQueue: [],
@@ -251,6 +282,7 @@ describe("runsOptimistic", () => {
251
282
  });
252
283
  apply(draft, "run/input", {
253
284
  type: "run/input",
285
+ runId: "run-1",
254
286
  requestId: "r1",
255
287
  response: { ok: true },
256
288
  });
@@ -259,10 +291,12 @@ describe("runsOptimistic", () => {
259
291
 
260
292
  apply(draft, "run/input", {
261
293
  type: "run/input",
294
+ runId: "run-1",
262
295
  requestId: "r2",
263
296
  response: { ok: true },
264
297
  });
265
298
  expect(draft.status).toBe("running");
299
+ expect(run(draft).runId).toBe("run-1");
266
300
  expect(run(draft).inputRequests).toBeUndefined();
267
301
  });
268
302
 
@@ -277,11 +311,11 @@ describe("runsOptimistic", () => {
277
311
  });
278
312
  apply(draft, "run/steer", {
279
313
  type: "run/steer",
314
+ runId: "run-1",
280
315
  message: message("s1"),
281
- anchorMessageId: null,
282
316
  });
283
317
  expect(draft.status).toBe("running");
284
- expect(run(draft).runId).toBe("optimistic-7");
318
+ expect(run(draft).runId).toBe("run-1");
285
319
  expect(run(draft).inputRequests).toBeUndefined();
286
320
  expect(run(draft).steerQueue).toEqual([]);
287
321
  expect(run(draft).dispatching.messages.map((e: Draft) => e.id)).toEqual([
@@ -292,7 +326,11 @@ describe("runsOptimistic", () => {
292
326
  it("leaves the draft untouched for run/stop and unknown moves", () => {
293
327
  const draft = mount({ status: "running", runId: "run-1" });
294
328
  apply(draft, "run/stop", { runId: "run-1" });
295
- apply(draft, "run/enqueue", { type: "run/enqueue", messageId: "ghost" });
329
+ apply(draft, "run/enqueue", {
330
+ type: "run/enqueue",
331
+ runId: "run-1",
332
+ messageId: "ghost",
333
+ });
296
334
  expect(draft).toEqual(mount({ status: "running", runId: "run-1" }));
297
335
  });
298
336
  });
@@ -24,7 +24,7 @@ type RunEntry = {
24
24
  };
25
25
 
26
26
  type RunsDraft = {
27
- status: StatewireThread.RunStatus;
27
+ status: Exclude<StatewireThread.ThreadStatus, "loading">;
28
28
  runs?: RunEntry[];
29
29
  };
30
30
 
@@ -38,7 +38,8 @@ const startRun = (draft: RunsDraft, runId: string): RunEntry => {
38
38
  error: null,
39
39
  });
40
40
  entry.status = "running";
41
- entry.runId = runId;
41
+ // A live run keeps its identity; a mint folds the client-generated id.
42
+ if (entry.runId === null) entry.runId = runId;
42
43
  entry.error = null;
43
44
  delete entry.inputRequests;
44
45
  draft.status = "running";
@@ -133,7 +134,9 @@ export const runsOptimistic = (
133
134
  ctx: StatewireClient.OptimisticContext,
134
135
  ): void => {
135
136
  const draft = mount as RunsDraft;
136
- const runId = `optimistic-${ctx.seq}`;
137
+ const commandRunId = (command.params[0] as { runId?: string } | undefined)
138
+ ?.runId;
139
+ const runId = commandRunId ?? `optimistic-${ctx.seq}`;
137
140
  switch (command.method) {
138
141
  case "run/enqueue":
139
142
  case "run/steer": {
@@ -147,22 +150,22 @@ export const runsOptimistic = (
147
150
  break;
148
151
  }
149
152
  case "run/edit": {
150
- const { message, rollbackTo } = command
153
+ const { message, runAnchorMessageId } = command
151
154
  .params[0] as StatewireThread.RunEditCommand;
152
155
  startRun(draft, runId).dispatching = {
153
156
  trigger: "message-edit",
154
157
  messages: [{ ...message }],
155
- rollbackTo,
158
+ rollbackTo: runAnchorMessageId,
156
159
  };
157
160
  break;
158
161
  }
159
162
  case "run/reload": {
160
- const { rollbackTo } = command
163
+ const { runAnchorMessageId } = command
161
164
  .params[0] as StatewireThread.RunReloadCommand;
162
165
  startRun(draft, runId).dispatching = {
163
166
  trigger: "message-reload",
164
167
  messages: [],
165
- rollbackTo,
168
+ rollbackTo: runAnchorMessageId,
166
169
  };
167
170
  break;
168
171
  }
@@ -60,12 +60,13 @@ describe("AssistantTransportThread", () => {
60
60
  expect(fetchMock.requests[0]!.body.commands).toEqual([
61
61
  {
62
62
  type: "run/steer",
63
+ runId: expect.any(String),
63
64
  message: {
64
65
  id: expect.any(String),
65
66
  role: "user",
66
67
  parts: [{ type: "text", text: "hello" }],
67
68
  },
68
- anchorMessageId: null,
69
+ runAnchorMessageId: null,
69
70
  },
70
71
  ]);
71
72
  expect(fetchMock.requests[0]!.body.state).toEqual(INITIAL_STATE);
@@ -143,10 +144,12 @@ describe("AssistantTransportThread", () => {
143
144
  const { aui } = mountThread();
144
145
  sendCommand(aui, {
145
146
  type: "run/steer",
147
+ runId: "run-u1",
146
148
  message: { id: "u1", role: "user", parts: [{ type: "text", text: "a" }] },
147
149
  });
148
150
  sendCommand(aui, {
149
151
  type: "run/steer",
152
+ runId: "run-u2",
150
153
  message: { id: "u2", role: "user", parts: [{ type: "text", text: "b" }] },
151
154
  });
152
155
 
@@ -193,10 +196,12 @@ describe("AssistantTransportThread", () => {
193
196
 
194
197
  sendCommand(aui, {
195
198
  type: "run/steer",
199
+ runId: "run-u1",
196
200
  message: { id: "u1", role: "user", parts: [{ type: "text", text: "a" }] },
197
201
  });
198
202
  sendCommand(aui, {
199
203
  type: "run/steer",
204
+ runId: "run-u2",
200
205
  message: { id: "u2", role: "user", parts: [{ type: "text", text: "b" }] },
201
206
  });
202
207
  await waitFor(() => expect(fetchMock.requests).toHaveLength(1));
@@ -245,6 +250,7 @@ describe("AssistantTransportThread", () => {
245
250
  sendCommand(aui, { type: "custom-a" } as never);
246
251
  sendCommand(aui, {
247
252
  type: "run/steer",
253
+ runId: "run-u1",
248
254
  message: {
249
255
  id: "u1",
250
256
  role: "user",
@@ -359,6 +365,7 @@ describe("AssistantTransportThread", () => {
359
365
 
360
366
  sendCommand(aui, {
361
367
  type: "run/steer",
368
+ runId: "run-u1",
362
369
  message: {
363
370
  id: "u1",
364
371
  role: "user",
@@ -1318,13 +1325,14 @@ describe("AssistantTransportThread", () => {
1318
1325
  expect(fetchMock.requests[0]!.body.commands).toEqual([
1319
1326
  {
1320
1327
  type: "run/edit",
1328
+ runId: expect.any(String),
1321
1329
  message: {
1322
1330
  id: expect.any(String),
1323
1331
  role: "user",
1324
1332
  parts: [{ type: "text", text: "edited" }],
1325
1333
  },
1326
1334
  sourceId: "u2",
1327
- rollbackTo: "a1",
1335
+ runAnchorMessageId: "a1",
1328
1336
  },
1329
1337
  ]);
1330
1338
  expect("parentId" in fetchMock.requests[0]!.body).toBe(false);
@@ -1354,12 +1362,13 @@ describe("AssistantTransportThread", () => {
1354
1362
  expect(body.commands).toEqual([
1355
1363
  {
1356
1364
  type: "run/steer",
1365
+ runId: expect.any(String),
1357
1366
  message: {
1358
1367
  id: expect.any(String),
1359
1368
  role: "user",
1360
1369
  parts: [{ type: "text", text: "again" }],
1361
1370
  },
1362
- anchorMessageId: "a1",
1371
+ runAnchorMessageId: "a1",
1363
1372
  },
1364
1373
  ]);
1365
1374
 
@@ -1618,12 +1627,13 @@ describe("AssistantTransportThread", () => {
1618
1627
  });
1619
1628
  expect(commands).toContainEqual({
1620
1629
  type: "run/steer",
1630
+ runId: expect.any(String),
1621
1631
  message: {
1622
1632
  id: expect.any(String),
1623
1633
  role: "user",
1624
1634
  parts: [{ type: "text", text: "next question" }],
1625
1635
  },
1626
- anchorMessageId: "a-tool",
1636
+ runAnchorMessageId: "a-tool",
1627
1637
  });
1628
1638
  });
1629
1639
  });
@@ -2061,8 +2071,9 @@ describe("reload", () => {
2061
2071
  expect(fetchMock.requests[1]!.body.commands).toEqual([
2062
2072
  {
2063
2073
  type: "run/reload",
2074
+ runId: expect.any(String),
2064
2075
  sourceId: "m2",
2065
- rollbackTo: "m1",
2076
+ runAnchorMessageId: "m1",
2066
2077
  },
2067
2078
  ]);
2068
2079
  expect("parentId" in fetchMock.requests[1]!.body).toBe(false);
@@ -2096,8 +2107,9 @@ describe("reload", () => {
2096
2107
  expect(fetchMock.requests[2]!.body.commands).toEqual([
2097
2108
  {
2098
2109
  type: "run/reload",
2110
+ runId: expect.any(String),
2099
2111
  sourceId: "m2",
2100
- rollbackTo: "m1",
2112
+ runAnchorMessageId: "m1",
2101
2113
  },
2102
2114
  ]);
2103
2115
  });
@@ -2262,6 +2274,14 @@ describe("server queue projection", () => {
2262
2274
  type QueueState = TestState & {
2263
2275
  queue?: { id: string; parts: { type: "text"; text: string }[] }[];
2264
2276
  steerQueue?: { id: string; parts: { type: "text"; text: string }[] }[];
2277
+ runs?: {
2278
+ runId: string | null;
2279
+ status: string;
2280
+ queue: never[];
2281
+ steerQueue: never[];
2282
+ dispatching: null;
2283
+ error: null;
2284
+ }[];
2265
2285
  };
2266
2286
 
2267
2287
  const queueConverter: typeof defaultConverter = (state) => ({
@@ -2298,12 +2318,13 @@ describe("server queue projection", () => {
2298
2318
  expect(fetchMock.requests[0]!.body.commands).toEqual([
2299
2319
  {
2300
2320
  type: "run/enqueue",
2321
+ runId: expect.any(String),
2301
2322
  message: {
2302
2323
  id: expect.any(String),
2303
2324
  role: "user",
2304
2325
  parts: [{ type: "text", text: "hello" }],
2305
2326
  },
2306
- anchorMessageId: null,
2327
+ runAnchorMessageId: null,
2307
2328
  },
2308
2329
  ]);
2309
2330
  });
@@ -2333,12 +2354,13 @@ describe("server queue projection", () => {
2333
2354
  await waitFor(() =>
2334
2355
  expect(allCommands(fetchMock.requests)).toContainEqual({
2335
2356
  type: "run/steer",
2357
+ runId: expect.any(String),
2336
2358
  message: {
2337
2359
  id: expect.any(String),
2338
2360
  role: "user",
2339
2361
  parts: [{ type: "text", text: "steer me" }],
2340
2362
  },
2341
- anchorMessageId: null,
2363
+ runAnchorMessageId: null,
2342
2364
  }),
2343
2365
  );
2344
2366
  });
@@ -2347,10 +2369,21 @@ describe("server queue projection", () => {
2347
2369
  const fetchMock = installFetch();
2348
2370
  const { aui } = mountThread({
2349
2371
  converter: queueConverter,
2372
+ runs: true,
2350
2373
  initialState: {
2351
2374
  messages: [],
2352
2375
  queue: [textEntry("q1", "first"), textEntry("q2", "second")],
2353
2376
  steerQueue: [textEntry("s1", "urgent")],
2377
+ runs: [
2378
+ {
2379
+ runId: "run-7",
2380
+ status: "running",
2381
+ queue: [],
2382
+ steerQueue: [],
2383
+ dispatching: null,
2384
+ error: null,
2385
+ },
2386
+ ],
2354
2387
  } as QueueState,
2355
2388
  });
2356
2389
 
@@ -2362,6 +2395,7 @@ describe("server queue projection", () => {
2362
2395
  await waitFor(() =>
2363
2396
  expect(allCommands(fetchMock.requests)).toContainEqual({
2364
2397
  type: "run/steer",
2398
+ runId: "run-7",
2365
2399
  messageId: "q1",
2366
2400
  insertAfter: null,
2367
2401
  }),
@@ -2375,6 +2409,7 @@ describe("server queue projection", () => {
2375
2409
  await waitFor(() =>
2376
2410
  expect(allCommands(fetchMock.requests)).toContainEqual({
2377
2411
  type: "run/enqueue",
2412
+ runId: "run-7",
2378
2413
  messageId: "q2",
2379
2414
  insertBefore: "q1",
2380
2415
  }),
@@ -2384,6 +2419,7 @@ describe("server queue projection", () => {
2384
2419
  await waitFor(() =>
2385
2420
  expect(allCommands(fetchMock.requests)).toContainEqual({
2386
2421
  type: "run/dequeue",
2422
+ runId: "run-7",
2387
2423
  messageId: "s1",
2388
2424
  }),
2389
2425
  );
@@ -2906,13 +2942,14 @@ describe("runs fold and materialize", () => {
2906
2942
  });
2907
2943
  sendCommand(aui, {
2908
2944
  type: "run/edit",
2945
+ runId: "run-e1",
2909
2946
  message: {
2910
2947
  id: "u1b",
2911
2948
  role: "user",
2912
2949
  parts: [{ type: "text", text: "one'" }],
2913
2950
  },
2914
2951
  sourceId: "u1",
2915
- rollbackTo: null,
2952
+ runAnchorMessageId: null,
2916
2953
  });
2917
2954
 
2918
2955
  await waitFor(() => expect(threadTexts(aui)).toEqual(["one'"]));