The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 08:15 UTC
test(server): stopped-queue steering test no longer races queue promotion (#22529)
Tristan Knight committed
Nov 1, 2026 at 20:53 UTC
ba49642a3bf1d51e9a2a78bd4e300a98e8d00be8
1 file changed
+19
-5
apps/server/src/orchestration-v2/SteeringCompletion.integration.test.ts
+19
-5
@@ -448,6 +448,7 @@ const nextTurnSelectionHarness = Effect.fn("nextTurnSelectionHarness")(function*
448
name: string,
449
canRestart = false,
450
canSteer = true,
451
+ interruptTurn: Effect.Effect<void> = Effect.void,
452
) {
453
const cwd = yield* checkpointWorkspace(name);
454
const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
@@ -538,7 +539,7 @@ const nextTurnSelectionHarness = Effect.fn("nextTurnSelectionHarness")(function*
539
interruptTurn: ({ providerTurnId }) =>
540
Effect.sync(() => {
541
interrupted.push(providerTurnId);
541
- }),
542
+ }).pipe(Effect.andThen(interruptTurn)),
543
respondToRuntimeRequest: () => Effect.void,
544
readThreadSnapshot: () => Effect.die("unused"),
545
rollbackThread: () => Effect.die("unused"),
@@ -1233,8 +1234,16 @@ it.effect("keeps a queued message queued when promoted into a run that Stop reac
1234
it.effect("queues a plain send behind the stopped queue and releases its hold", () =>
1235
Effect.scoped(
1236
Effect.gen(function* () {
1236
- const { started, steered, layer, startFirstTurn } =
1237
- yield* nextTurnSelectionHarness("plain-send-after-stop");
1237
+ const interruptReached = yield* Deferred.make<void>();
1238
+ const releaseInterrupt = yield* Deferred.make<void>();
1239
+ const { started, steered, layer, startFirstTurn } = yield* nextTurnSelectionHarness(
1240
+ "plain-send-after-stop",
1241
+ false,
1242
+ true,
1243
+ Deferred.succeed(interruptReached, undefined).pipe(
1244
+ Effect.andThen(Deferred.await(releaseInterrupt)),
1245
+ ),
1246
+ );
1247
yield* Effect.gen(function* () {
1248
const orchestrator = yield* Orchestrator.OrchestratorV2;
1249
const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
@@ -1264,10 +1273,12 @@ it.effect("queues a plain send behind the stopped queue and releases its hold",
1273
});
1274
// The provider has not stopped yet, so a plain send still resolves to a steer.
1275
yield* send("sent", "auto");
1267
- yield* worker.drain();
1276
+ // Once the stop settles, the run-update reactor promotes the queue on
1277
+ // its own fiber, so read the queue while the provider is still stopping.
1278
+ const draining = yield* worker.drain().pipe(Effect.forkScoped);
1279
+ yield* Deferred.await(interruptReached);
1280
1281
const projection = yield* orchestrator.getThreadProjection(threadId);
1270
- assert.deepEqual(steered, []);
1282
assert.equal(started.length, 1);
1283
const queued = projection.runs
1284
.filter((run) => run.status === "queued")
@@ -1280,6 +1291,9 @@ it.effect("queues a plain send behind the stopped queue and releases its hold",
1291
);
1292
// The user sent it, so the queue they stopped runs again once the provider stops.
1293
assert.isFalse(queued.some((run) => run.queueHeld === true));
1294
+ yield* Deferred.succeed(releaseInterrupt, undefined);
1295
+ yield* Fiber.join(draining);
1296
+ assert.deepEqual(steered, []);
1297
}).pipe(Effect.provide(layer));
1298
}),
1299
),