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, 12:00 UTC
fix(server): fail Claude turns waiting for unsupported mod input (#24320)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 29, 2026 at 22:14 UTC
0a455d725878f653b3df607eaaff18fbfa90db99
2 files changed
+204
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+166
@@ -9159,6 +9159,172 @@ describe("ClaudeAdapterV2 background wake turns", () => {
9159
),
9160
);
9161
9162
+ // regression: #17531 a mod that holds a tool behind a focused pane must fail the turn, not hang it
9163
+ it.effect.each([
9164
+ { case: "fails a turn whose mod requests focus for a pane T3 cannot show", focus: true },
9165
+ { case: "keeps a turn running beside a passive mod pane", focus: false },
9166
+ ] as const)("$case", ({ focus }) =>
9167
+ Effect.scoped(
9168
+ Effect.gen(function* () {
9169
+ const closed = yield* Deferred.make<void>();
9170
+ const harness = yield* makeWakeHarnessWithOptions({
9171
+ close: () => Deferred.succeed(closed, undefined),
9172
+ });
9173
+ const now = yield* DateTime.now;
9174
+ yield* harness.runtime.startTurn(
9175
+ makeClaudeTestTurnInput({
9176
+ threadId: harness.threadId,
9177
+ providerThread: harness.providerThread,
9178
+ now,
9179
+ attemptId: RunAttemptId.make("attempt-claude-mod-pane-focus"),
9180
+ text: "Run rm -r build",
9181
+ attachments: [],
9182
+ }),
9183
+ );
9184
+ // Captured from Claude 2.1.303 with the blast-radius mod holding a Bash
9185
+ // call: the mod waits for keyboard input in its pane and nothing else
9186
+ // arrives until it gives up.
9187
+ yield* Queue.offer(
9188
+ harness.sdkMessages,
9189
+ claudeSdkFrame({
9190
+ type: "system",
9191
+ subtype: "ui_panes",
9192
+ panes: [
9193
+ { id: "blast-radius", title: "Blast Radius", plugin: "blast-radius", rows: 10 },
9194
+ ],
9195
+ shown_id: "blast-radius",
9196
+ focused_id: null,
9197
+ focus_requested_id: focus ? "blast-radius" : null,
9198
+ uuid: "00000000-0000-4000-8000-000000000795",
9199
+ session_id: WAKE_NATIVE_SESSION,
9200
+ }),
9201
+ );
9202
+ yield* Queue.offer(
9203
+ harness.sdkMessages,
9204
+ claudeSdkFrame({
9205
+ type: "system",
9206
+ subtype: "ui_invalidate",
9207
+ event: "ui.render",
9208
+ uuid: "00000000-0000-4000-8000-000000000796",
9209
+ session_id: WAKE_NATIVE_SESSION,
9210
+ }),
9211
+ );
9212
+ // Frames are handled in order, so a later notice proves the pane frame
9213
+ // was handled without the turn ending.
9214
+ yield* Queue.offer(
9215
+ harness.sdkMessages,
9216
+ claudeSdkFrame({
9217
+ type: "system",
9218
+ subtype: "informational",
9219
+ content: "Processing barrier.",
9220
+ level: "warning",
9221
+ uuid: "00000000-0000-4000-8000-000000000797",
9222
+ session_id: WAKE_NATIVE_SESSION,
9223
+ }),
9224
+ );
9225
+ yield* harness.until(
9226
+ () =>
9227
+ harness.terminalEvents().length > 0 ||
9228
+ harness.events.some(
9229
+ (event) =>
9230
+ event.type === "turn_item.updated" && event.turnItem.type === "system_notice",
9231
+ ),
9232
+ );
9233
+ const [terminal] = harness.terminalEvents();
9234
+ if (!focus) {
9235
+ assert.equal(terminal, undefined);
9236
+ return;
9237
+ }
9238
+ assert.equal(terminal?.status, "failed");
9239
+ if (terminal?.status !== "failed") return;
9240
+ assert.include(terminal.failure.message, "blast-radius");
9241
+ // The held tool call is abandoned by closing the query, never answered.
9242
+ yield* Deferred.await(closed);
9243
+ }).pipe(
9244
+ Effect.provide(
9245
+ Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
9246
+ ),
9247
+ ),
9248
+ ),
9249
+ );
9250
+
9251
+ // regression: #17531 a follow-up sent while the failed mod turn's process closes gets a new process
9252
+ it.effect("runs a follow-up in a fresh query while the mod-blocked query is closing", () =>
9253
+ Effect.scoped(
9254
+ Effect.gen(function* () {
9255
+ const releaseClose = yield* Deferred.make<void>();
9256
+ const replacementClosedOld = yield* Deferred.make<void>();
9257
+ let oldCloses = 0;
9258
+ const harness = yield* makeWakeHarnessWithOptions({
9259
+ // The held CLI never answers an interrupt; closure must not need one.
9260
+ interrupt: Effect.never,
9261
+ close: (sdkMessages) =>
9262
+ Effect.suspend(() =>
9263
+ ++oldCloses === 2 ? Deferred.succeed(replacementClosedOld, undefined) : Effect.void,
9264
+ ).pipe(
9265
+ Effect.andThen(Deferred.await(releaseClose)),
9266
+ Effect.andThen(Queue.shutdown(sdkMessages)),
9267
+ ),
9268
+ freshQueueOnReopen: true,
9269
+ });
9270
+ // Added after the harness so it runs first: a failed assertion must not
9271
+ // leave teardown waiting on the held close.
9272
+ yield* Effect.addFinalizer(() => Deferred.succeed(releaseClose, undefined));
9273
+ const now = yield* DateTime.now;
9274
+ const turnInput = makeClaudeTestTurnInput({
9275
+ threadId: harness.threadId,
9276
+ providerThread: harness.providerThread,
9277
+ now,
9278
+ attemptId: RunAttemptId.make("attempt-claude-mod-pane-blocked"),
9279
+ text: "Run rm -r build",
9280
+ attachments: [],
9281
+ });
9282
+ yield* harness.runtime.startTurn(turnInput);
9283
+ yield* Queue.offer(
9284
+ harness.sdkMessages,
9285
+ claudeSdkFrame({
9286
+ type: "system",
9287
+ subtype: "ui_panes",
9288
+ panes: [
9289
+ { id: "blast-radius", title: "Blast Radius", plugin: "blast-radius", rows: 10 },
9290
+ ],
9291
+ shown_id: "blast-radius",
9292
+ focused_id: null,
9293
+ focus_requested_id: "blast-radius",
9294
+ uuid: "00000000-0000-4000-8000-000000000798",
9295
+ session_id: WAKE_NATIVE_SESSION,
9296
+ }),
9297
+ );
9298
+ assert.equal((yield* Queue.take(harness.terminalReceipts)).status, "failed");
9299
+
9300
+ const followUp = yield* harness.runtime
9301
+ .startTurn({
9302
+ ...turnInput,
9303
+ attemptId: RunAttemptId.make("attempt-claude-after-mod-pane"),
9304
+ providerTurnOrdinal: 2,
9305
+ })
9306
+ .pipe(Effect.forkScoped);
9307
+ // Reusing the closing process would offer the prompt to it instead.
9308
+ yield* Effect.raceFirst(
9309
+ Deferred.await(replacementClosedOld),
9310
+ harness.until(() => harness.offeredMessages.length >= 2),
9311
+ );
9312
+ assert.isTrue(yield* Deferred.isDone(replacementClosedOld));
9313
+ yield* Deferred.succeed(releaseClose, undefined);
9314
+ yield* Fiber.join(followUp);
9315
+ assert.equal(harness.processQueues.length, 2);
9316
+ yield* harness.offerAndWait(
9317
+ makeResultFrame({ uuid: "after-mod-pane-result", result: "Done." }),
9318
+ );
9319
+ assert.equal((yield* Queue.take(harness.terminalReceipts)).status, "completed");
9320
+ }).pipe(
9321
+ Effect.provide(
9322
+ Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
9323
+ ),
9324
+ ),
9325
+ ),
9326
+ );
9327
+
9328
// regression: #16897 a prompt whose uuid the session already holds must not hang or end early
9329
it.effect("keeps a started prompt running until its result", () =>
9330
Effect.scoped(
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+38
@@ -4213,6 +4213,20 @@ function claudeTaskString(value: unknown, key: string): string | undefined {
4213
return typeof field === "string" && field.trim().length > 0 ? field.trim() : undefined;
4214
}
4215
4216
+// A Claude Code mod can hold a tool call until the user acts in its terminal
4217
+// pane. T3 cannot provide the requested pane interaction (#17531).
4218
+// Passive panes never request focus and keep working.
4219
+function claudeFocusRequestedPanePlugin(message: SDKMessage): string | null {
4220
+ if (message.type !== "system" || claudeTaskField(message, "subtype") !== "ui_panes") return null;
4221
+ const paneId = claudeTaskString(message, "focus_requested_id");
4222
+ if (paneId === undefined) return null;
4223
+ const panes = claudeTaskField(message, "panes");
4224
+ const pane = Array.isArray(panes)
4225
+ ? panes.find((entry) => claudeTaskField(entry, "id") === paneId)
4226
+ : undefined;
4227
+ return claudeTaskString(pane, "plugin") ?? paneId;
4228
+}
4229
+
4230
function claudeTaskStatus(value: unknown): OrchestrationV2PlanStep["status"] | undefined {
4231
switch (value) {
4232
case "pending":
@@ -8182,6 +8196,28 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
8196
}
8197
return;
8198
}
8199
+ const focusedPlugin = claudeFocusRequestedPanePlugin(message);
8200
+ if (focusedPlugin !== null && context === (yield* Ref.get(activeTurn))) {
8201
+ yield* Effect.logWarning("orchestration-v2.claude-mod-pane-focus-unsupported", {
8202
+ providerTurnId: context.providerTurnId,
8203
+ plugin: focusedPlugin,
8204
+ });
8205
+ liveQuery.stopping = true;
8206
+ yield* finalizeActiveTurn({
8207
+ context,
8208
+ status: "failed",
8209
+ completedAt: yield* DateTime.now,
8210
+ failure: makeProviderFailure({
8211
+ class: "provider_error",
8212
+ code: "claude_mod_ui_unsupported",
8213
+ message: `The Claude Code mod "${focusedPlugin}" is waiting for input in its terminal pane, which T3 Code cannot show. Disable the mod for sessions run from T3 Code, or run the task in the Claude Code terminal.`,
8214
+ }),
8215
+ });
8216
+ // Closing ends the CLI process and abandons the held tool call
8217
+ // without answering it. Not interrupt: the held CLI may never ack it.
8218
+ yield* liveQuery.query.close.pipe(Effect.ignore);
8219
+ return;
8220
+ }
8221
yield* trackClaudeGoal({ nativeThreadId: liveQuery.nativeThreadId, context, message });
8222
8223
if (message.type === "stream_event" && !message.parent_tool_use_id) {
@@ -9817,6 +9853,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
9853
if (
9854
existing !== null &&
9855
existing.nativeThreadId === nativeThreadId &&
9856
+ !existing.stopping &&
9857
isClaudeProviderContinuationTurn(turnInput)
9858
) {
9859
return existing;
@@ -9848,6 +9885,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
9885
existing !== null &&
9886
existing.nativeThreadId === nativeThreadId &&
9887
existing.queryPolicyKey === queryPolicyKey &&
9888
+ !existing.stopping &&
9889
existing.selection.queryIdentity === compiledSelection.queryIdentity
9890
) {
9891
// A denied ExitPlanMode leaves Claude in plan mode. Restore only from plan: