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 21, 13:30 UTC
fix(server): a self-settle survives a queued message steered into the turn (#36896)
Julius Marminge committed
Nov 14, 2026 at 11:48 UTC
74178f471260b79ae968504909b01ee20e9ba870
2 files changed
+25
-3
apps/server/src/orchestration-v2/ThreadManagementService.test.ts
+6
-2
@@ -695,6 +695,8 @@ it.effect.each([
695
{ status: "completed" as const, followUp: "held-notification", settles: true },
696
{ status: "completed" as const, followUp: "user", settles: false },
697
{ status: "completed" as const, followUp: "steered-notification", settles: false },
698
+ // Send now cancels the queued run; its message joins the run that asked to settle.
699
+ { status: "completed" as const, followUp: "promoted-to-steer", settles: true },
700
])("settleAfterRun handles $status with $followUp follow-up", ({ status, followUp, settles }) =>
701
Effect.gen(function* () {
702
const projectId = ProjectId.make("project:thread-management:settle-after-run");
@@ -742,7 +744,7 @@ it.effect.each([
744
{ id: MessageId.make("original"), runId, role: "user" as const },
745
{
746
id: nextRun.userMessageId,
745
- runId: followUpId,
747
+ runId: followUp === "promoted-to-steer" ? runId : followUpId,
748
role: "user" as const,
749
...(followUp.endsWith("notification") ? { notification: {} } : {}),
750
...(followUp === "delegated" ? { delegatedCompletion: {} } : {}),
@@ -809,7 +811,9 @@ it.effect.each([
811
? "failed"
812
: followUp === "held-notification"
813
? "queued"
812
- : "completed";
814
+ : followUp === "promoted-to-steer"
815
+ ? "cancelled"
816
+ : "completed";
817
yield* Queue.offer(events, {
818
sequence: 1,
819
event: { type: "run.updated", threadId, payload: nextRun },
apps/server/src/orchestration-v2/ThreadManagementService.ts
+19
-1
@@ -1142,7 +1142,25 @@ const make = Effect.gen(function* () {
1142
)
1143
)
1144
return true;
1145
- const following = records.runs.filter((candidate) => candidate.ordinal > run.ordinal);
1145
+ const later = records.runs.filter((candidate) => candidate.ordinal > run.ordinal);
1146
+ const cancelledMessageIds = later
1147
+ .filter((candidate) => candidate.status === "cancelled")
1148
+ .map((candidate) => candidate.userMessageId);
1149
+ // Send now cancels a queued run and moves its message into the running turn.
1150
+ const steeredMessageIds =
1151
+ cancelledMessageIds.length === 0
1152
+ ? new Set()
1153
+ : new Set(
1154
+ (yield* getProjectThreadRecords(input, ["messages"], {
1155
+ messageIds: cancelledMessageIds,
1156
+ })).messages
1157
+ .filter((message) => message.runId === run.id)
1158
+ .map((message) => message.id),
1159
+ );
1160
+ const following = later.filter(
1161
+ (candidate) =>
1162
+ candidate.status !== "cancelled" || !steeredMessageIds.has(candidate.userMessageId),
1163
+ );
1164
if (following.length > 0) {
1165
const { messages } = yield* getProjectThreadRecords(input, ["messages"], {
1166
messageRunIds: following.map((candidate) => candidate.id),