Skip to content

Commit 7ba6cf0

Browse files
armanossilokoclaude
andcommitted
fix(queue): sending another queued message keeps an open edit's hold
Send now and Resume shared one handler, so sending one queued message also cleared the edit hold on every other queued message. Only Resume clears edit holds now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b97a371 commit 7ba6cf0

2 files changed

Lines changed: 31 additions & 3 deletions

File tree

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13184,8 +13184,12 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
1318413184
runId: run.id,
1318513185
providerInstanceId: run.providerInstanceId,
1318613186
occurredAt: now,
13187-
// Also the way out of an edit hold left by a client that went away.
13188-
payload: { ...run, queueHeld: false, editing: false },
13187+
// Resume is also the way out of an edit hold left by a client that went away.
13188+
payload: {
13189+
...run,
13190+
queueHeld: false,
13191+
...(command.type === "queue.resume" ? { editing: false } : {}),
13192+
},
1318913193
});
1319013194
}
1319113195
if (queued.length === 0) {

‎apps/server/src/orchestration-v2/runtimeLayer.test.ts‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5829,10 +5829,34 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
58295829
["completed", "queued", "queued"],
58305830
);
58315831

5832+
// Sending another message now keeps the edit hold.
5833+
yield* orchestrator.dispatch({
5834+
type: "queued-run.start",
5835+
commandId: CommandId.make(`${threadId}:send-behind`),
5836+
threadId,
5837+
runId: behind!.id,
5838+
});
5839+
const sent = yield* orchestrator.getThreadProjection(threadId);
5840+
assert.equal(sent.runs.find((run) => run.id === behind!.id)?.status, "starting");
5841+
assert.isTrue(sent.runs.find((run) => run.id === edited!.id)?.editing);
5842+
58325843
yield* setEditing(false);
5844+
const sentRun = sent.runs.find((run) => run.id === behind!.id)!;
5845+
yield* eventSink.write({
5846+
events: [
5847+
{
5848+
id: EventId.make(`${threadId}:behind-completed`),
5849+
type: "run.updated",
5850+
threadId,
5851+
runId: sentRun.id,
5852+
occurredAt: now,
5853+
payload: { ...sentRun, status: "completed", completedAt: now },
5854+
},
5855+
],
5856+
});
5857+
yield* orchestrator.resumeQueuedRuns;
58335858
const after = yield* orchestrator.getThreadProjection(threadId);
58345859
assert.equal(after.runs.find((run) => run.id === edited!.id)?.status, "starting");
5835-
assert.equal(after.runs.find((run) => run.id === behind!.id)?.status, "queued");
58365860
}),
58375861
);
58385862

0 commit comments

Comments
 (0)