Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ const composerSelection = {
const nextTurnSelectionHarness = Effect.fn("nextTurnSelectionHarness")(function* (
name: string,
canRestart = false,
interruptTurn: Effect.Effect<void> = Effect.void,
) {
const cwd = yield* checkpointWorkspace(name);
const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
Expand Down Expand Up @@ -503,7 +504,7 @@ const nextTurnSelectionHarness = Effect.fn("nextTurnSelectionHarness")(function*
Effect.sync(() => {
steered.push(turn.message.text);
}),
interruptTurn: () => Effect.void,
interruptTurn: () => interruptTurn,
respondToRuntimeRequest: () => Effect.void,
readThreadSnapshot: () => Effect.die("unused"),
rollbackThread: () => Effect.die("unused"),
Expand Down Expand Up @@ -878,8 +879,15 @@ it.effect("keeps a queued message queued when promoted into a run that Stop reac
it.effect("queues a plain send behind the stopped queue and releases its hold", () =>
Effect.scoped(
Effect.gen(function* () {
const { started, steered, layer, startFirstTurn } =
yield* nextTurnSelectionHarness("plain-send-after-stop");
const interruptReached = yield* Deferred.make<void>();
const releaseInterrupt = yield* Deferred.make<void>();
const { started, steered, layer, startFirstTurn } = yield* nextTurnSelectionHarness(
"plain-send-after-stop",
false,
Deferred.succeed(interruptReached, undefined).pipe(
Effect.andThen(Deferred.await(releaseInterrupt)),
),
);
yield* Effect.gen(function* () {
const orchestrator = yield* Orchestrator.OrchestratorV2;
const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
Expand Down Expand Up @@ -909,10 +917,12 @@ it.effect("queues a plain send behind the stopped queue and releases its hold",
});
// The provider has not stopped yet, so a plain send still resolves to a steer.
yield* send("sent", "auto");
yield* worker.drain();
// Once the stop settles, the run-update reactor promotes the queue on
// its own fiber, so read the queue while the provider is still stopping.
const draining = yield* worker.drain().pipe(Effect.forkScoped);
yield* Deferred.await(interruptReached);

const projection = yield* orchestrator.getThreadProjection(threadId);
assert.deepEqual(steered, []);
assert.equal(started.length, 1);
const queued = projection.runs
.filter((run) => run.status === "queued")
Expand All @@ -925,6 +935,9 @@ it.effect("queues a plain send behind the stopped queue and releases its hold",
);
// The user sent it, so the queue they stopped runs again once the provider stops.
assert.isFalse(queued.some((run) => run.queueHeld === true));
yield* Deferred.succeed(releaseInterrupt, undefined);
yield* Fiber.join(draining);
assert.deepEqual(steered, []);
}).pipe(Effect.provide(layer));
}),
),
Expand Down
Loading