The best way to control Claude Code, Codex and more from any computer or phone
fix(client): a message the host never answers fails after 60 seconds instead of spinning forever (#35076)
Julius Marminge committed
Nov 12, 2026 at 02:48 UTC
ced85c64ff357c69e7d0bd7b672959254ebba9da
3 files changed
+77
-5
apps/web/src/components/chat/useComposerSend.ts
+14
-2
@@ -433,17 +433,29 @@ export function useComposerSend(input: ComposerSendInput) {
433
if (
434
!readEnvironmentScope(environmentId, AuthOrchestrationOperateScope) ||
435
!activeThread ||
436
- (isSendBusy && !sendQueuesBehindSetup) ||
436
isRevertingCheckpoint ||
437
!clientSettingsHydrated ||
438
threadDetailLoading ||
439
readPendingEnvironmentChange() !== null ||
441
- sendInFlightRef.current ||
440
feedbackUploadsInFlightRef.current.has(routeThreadKey)
441
) {
442
notifyDirectAnnotationAttached();
443
return;
444
}
445
+ if ((isSendBusy && !sendQueuesBehindSetup) || sendInFlightRef.current) {
446
+ if (directAnnotation) {
447
+ notifyDirectAnnotationAttached();
448
+ } else {
449
+ toastManager.add(
450
+ stackedThreadToast({
451
+ type: "info",
452
+ title: "Still sending your previous message.",
453
+ description: "Send again once it goes through or fails.",
454
+ }),
455
+ );
456
+ }
457
+ return;
458
+ }
459
if (needsLoadBalancing) {
460
const draft = useComposerDraftStore.getState().getComposerDraft(composerDraftTarget);
461
toastManager.add({
packages/client-runtime/src/operations/commands.test.ts
+39
@@ -419,6 +419,45 @@ describe("V2 environment commands", () => {
419
}).pipe(Effect.provide(layerTestRandom)),
420
);
421
422
+ it.effect("fails a message dispatch the host never answers on a live socket", () =>
423
+ Effect.gen(function* () {
424
+ const commands: OrchestrationV2Command[] = [];
425
+ const supervisor = yield* makeSupervisor({ commands, projects: [] });
426
+ const healthySession = Option.getOrThrow(yield* SubscriptionRef.get(supervisor.session));
427
+ const silentClient = {
428
+ ...healthySession.client,
429
+ [ORCHESTRATION_V2_WS_METHODS.dispatchCommand]: (command: OrchestrationV2Command) =>
430
+ Effect.sync(() => commands.push(command)).pipe(Effect.andThen(Effect.never)),
431
+ } as unknown as WsRpcProtocolClient;
432
+ yield* SubscriptionRef.set(
433
+ supervisor.session,
434
+ Option.some({ ...healthySession, client: silentClient }),
435
+ );
436
+
437
+ const sendFiber = yield* startThreadTurn({
438
+ commandId: CommandId.make("command-unanswered"),
439
+ threadId: v2ThreadId,
440
+ message: {
441
+ messageId: MessageId.make("message-unanswered"),
442
+ role: "user",
443
+ text: "hello",
444
+ attachments: [],
445
+ },
446
+ runtimeMode: "full-access",
447
+ interactionMode: "default",
448
+ }).pipe(
449
+ Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
450
+ Effect.flip,
451
+ Effect.forkChild,
452
+ );
453
+ yield* TestClock.adjust("1 minute");
454
+
455
+ expect(sendFiber.pollUnsafe()).toBeDefined();
456
+ expect((yield* Fiber.join(sendFiber))._tag).toBe("EnvironmentRpcUnavailableError");
457
+ expect(commands.map((command) => command.commandId)).toEqual(["command-unanswered"]);
458
+ }).pipe(Effect.provide(layerTestRandom)),
459
+ );
460
+
461
it.effect("holds a lost message through reconnect backoff until disconnect", () =>
462
Effect.gen(function* () {
463
const commands: OrchestrationV2Command[] = [];
packages/client-runtime/src/operations/commands.ts
+24
-3
@@ -39,7 +39,12 @@ import * as Stream from "effect/Stream";
39
import * as SubscriptionRef from "effect/SubscriptionRef";
40
41
import * as EnvironmentSupervisor from "../connection/supervisor.ts";
42
-import { getInitialServerConfig, isRpcClientError, request } from "../rpc/client.ts";
42
+import {
43
+ EnvironmentRpcUnavailableError,
44
+ getInitialServerConfig,
45
+ isRpcClientError,
46
+ request,
47
+} from "../rpc/client.ts";
48
49
interface CommandMetadata {
50
readonly commandId?: CommandId;
@@ -293,15 +298,31 @@ const dispatch = (command: OrchestrationV2Command) =>
298
// stops a frame that kills the socket from looping.
299
const MAX_LOST_TRANSPORT_RESENDS = 2;
300
301
+// A live socket can still carry a command the host never answers; the heartbeat
302
+// alone would leave the send pending forever.
303
+const MESSAGE_DISPATCH_TIMEOUT = "60 seconds";
304
+
305
const dispatchMessage = Effect.fn("EnvironmentCommands.dispatchMessage")(function* (
306
command: Extract<OrchestrationV2Command, { type: "message.dispatch" }>,
307
resendAfterSocketLoss: boolean,
308
) {
300
- if (!resendAfterSocketLoss) return yield* dispatch(command);
309
const supervisor = yield* EnvironmentSupervisor.EnvironmentSupervisor;
310
+ const attempt = dispatch(command).pipe(
311
+ Effect.timeoutOrElse({
312
+ duration: MESSAGE_DISPATCH_TIMEOUT,
313
+ orElse: () =>
314
+ Effect.fail(
315
+ new EnvironmentRpcUnavailableError({
316
+ environmentId: supervisor.target.environmentId,
317
+ message: `${supervisor.target.label} did not confirm the message within 60 seconds.`,
318
+ }),
319
+ ),
320
+ }),
321
+ );
322
+ if (!resendAfterSocketLoss) return yield* attempt;
323
for (let resends = 0; ; resends += 1) {
324
const attemptSession = yield* SubscriptionRef.get(supervisor.session);
304
- const exit = yield* Effect.exit(dispatch(command));
325
+ const exit = yield* Effect.exit(attempt);
326
if (Exit.isSuccess(exit)) return exit.value;
327
// Closing the session interrupts the request, which can beat the protocol error.
328
const lostTransport =