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, 23:30 UTC
fix(server): auto thread sends queue while a turn is stopping (#34163)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Tanav Poswal committed
Nov 11, 2026 at 11:02 UTC
c192c6786779ebd439e5a47bc181b076ba0bbee5
2 files changed
+93
apps/server/src/orchestration-v2/ThreadManagementService.ts
+1
@@ -865,6 +865,7 @@ const make = Effect.gen(function* () {
865
...(input.modelSelection === undefined ? {} : { modelSelection: input.modelSelection }),
866
...(input.freshContext ? { freshContext: true } : {}),
867
dispatchMode,
868
+ ...(mode === "auto" ? { deliveryIntent: "auto" } : {}),
869
createdBy: input.createdBy,
870
creationSource: input.creationSource,
871
});
apps/server/src/orchestration-v2/ThreadStop.test.ts
+92
@@ -796,6 +796,98 @@ it.effect("a message the user sends after Stop releases the held queue; an agent
796
}).pipe(Effect.provide(layerTest)),
797
);
798
799
+it.effect(
800
+ "an agent's auto send queues behind a run that is still stopping instead of steering it",
801
+ () =>
802
+ Effect.gen(function* () {
803
+ const orchestrator = yield* Orchestrator.OrchestratorV2;
804
+ const projections = yield* ProjectionStore.ProjectionStoreV2;
805
+ const threads = yield* ThreadManagementService.ThreadManagementService;
806
+ const threadId = ThreadId.make("thread:stop-mcp-send");
807
+ yield* createWatchingThread(threadId, 6);
808
+ yield* send(threadId, "active", "start_immediately");
809
+ const initial = yield* orchestrator.getThreadProjection(threadId);
810
+ const run = initial.runs[0]!;
811
+ const providerSessionId = ProviderSessionId.make("session:stop-mcp-send");
812
+ const now = yield* DateTime.now;
813
+ yield* projections.apply({
814
+ id: EventId.make("event:stop-mcp-send:session"),
815
+ type: "provider-session.updated",
816
+ threadId,
817
+ occurredAt: now,
818
+ payload: {
819
+ id: providerSessionId,
820
+ driver: adapter.driver,
821
+ providerInstanceId: instanceId,
822
+ status: "ready",
823
+ cwd: "/repo",
824
+ model: modelSelection.model,
825
+ capabilities: CodexProviderCapabilitiesV2,
826
+ createdAt: now,
827
+ updatedAt: now,
828
+ lastError: null,
829
+ },
830
+ });
831
+ yield* projections.apply({
832
+ id: EventId.make("event:stop-mcp-send:provider-thread"),
833
+ type: "provider-thread.updated",
834
+ threadId,
835
+ occurredAt: now,
836
+ payload: { ...initial.providerThreads[0]!, providerSessionId },
837
+ });
838
+ yield* projections.apply({
839
+ id: EventId.make("event:stop-mcp-send:running"),
840
+ type: "run.updated",
841
+ threadId,
842
+ runId: run.id,
843
+ occurredAt: now,
844
+ payload: { ...run, status: "running", startedAt: now },
845
+ });
846
+ yield* projections.apply({
847
+ id: EventId.make("event:stop-mcp-send:turn"),
848
+ type: "provider-turn.updated",
849
+ threadId,
850
+ occurredAt: now,
851
+ payload: {
852
+ id: ProviderTurnId.make("provider-turn:stop-mcp-send"),
853
+ providerThreadId: run.providerThreadId!,
854
+ nodeId: run.rootNodeId!,
855
+ runAttemptId: run.activeAttemptId!,
856
+ nativeTurnRef: null,
857
+ ordinal: 1,
858
+ status: "running",
859
+ startedAt: now,
860
+ completedAt: null,
861
+ },
862
+ });
863
+ yield* send(threadId, "queued before the stop", "queue_after_active");
864
+ yield* orchestrator.dispatch({
865
+ type: "thread.stop",
866
+ commandId: CommandId.make("stop-mcp-send"),
867
+ threadId,
868
+ });
869
+ assert.deepEqual((yield* threadState(threadId)).runs, ["running", "queued:held"]);
870
+
871
+ const result = yield* threads.sendToThread({
872
+ projectId: ProjectId.make("project:thread-stop"),
873
+ commandId: CommandId.make("command:stop-mcp-send"),
874
+ threadId,
875
+ messageId: MessageId.make("message:stop-mcp-send"),
876
+ text: "Follow up after Stop",
877
+ attachments: [],
878
+ mode: "auto",
879
+ createdBy: "agent",
880
+ creationSource: "mcp",
881
+ });
882
+ assert.equal(result.delivery, "queued");
883
+ assert.deepEqual((yield* threadState(threadId)).runs, [
884
+ "running",
885
+ "queued:held",
886
+ "queued:held",
887
+ ]);
888
+ }).pipe(Effect.provide(layerTest)),
889
+);
890
+
891
it.effect(
892
"thread.stop ends an idle thread's watches and accepts a thread with nothing to stop",
893
() =>