Skip to content

Mobile messages stay Pending forever after the server rejects the runtime-mode change queued with them #37307

Closed as not planned

Description

@bdamokos

What happened

On the iPad app, I changed a thread's permission mode to Full access while its turn was still running, and sent follow-up messages. Every message I sent to that thread afterwards stayed "Pending" and was never delivered, while other threads on the same environment worked normally. The app showed no error and offered no way out apart from editing or removing the queued messages.

Diagnosis

  1. Before starting the turn, mobile outbox delivery syncs the queued message's settings. Because the queued runtime mode differed from the thread's, it dispatched thread.runtime-mode.set with command ID <message commandId>:runtime-mode (settingsCommandId in apps/mobile/src/state/threadOutboxDelivery.ts).
  2. The server rejected it, because the Claude session was still running background agents or commands: "The current session is still running background agents or commands, and this change would end them. Wait for them to finish, or press Stop, then try again." This is the background-work check added for [Bug]: Runtime-mode, instance and worktree changes detach the Claude session and kill live subagents without the background-work check #16000.
  3. The rejection is stored in the command receipt. Every later dispatch of the same command ID is answered from that receipt with OrchestratorCommandPreviouslyRejectedError, even after the background work has ended.
  4. resolveThreadOutboxFailureAction in apps/mobile/src/state/thread-outbox-model.ts returns "retry" for any failure in the settings-sync stage, whatever the error. So the outbox retries the same command ID on backoff indefinitely. The server log shows a retry roughly every 16 s for over an hour.
  5. The queue is per thread and delivered in order, so every later message to that thread waits behind the stuck one and shows "Pending".

threadOutboxDelivery.ts already notes the problem for one case ("The server would refuse this mode in settings sync, which retries forever; stop first") and checks managedRuntimeModeDenial before syncing. Any other server rejection of the runtime-mode or interaction-mode change, such as the background-work refusal, still loops forever. The code is unchanged on current main.

Possible fixes: treat OrchestrationDispatchCommandError in settings-sync like in start-turn, and restore the message to the composer with the server's message. Retrying is pointless anyway, because a replayed receipt can never succeed under the same command ID. Alternatively, use a fresh settings command ID per attempt so that a retry after the background work ends can succeed.

Steps to reproduce

  1. On mobile, open a Claude thread whose turn has a background agent or background command still running.
  2. Change the thread's permission mode (for example, Auto to Full access) and send a message, so it queues behind the running turn.
  3. While the background work is still running, the queued message is delivered. The server rejects the runtime-mode change with the background-work error.
  4. The message stays "Pending". Wait for the background work to finish: it still never sends. Send more messages to the thread: they also stay "Pending".

Version

Mobile 2.3.0 (iPadOS). Server: 0.1.10-nightly.20261115.4723 (macOS desktop app).

Environment

iPad mini, T3 Code 2.3.0. Server: macOS desktop app (Nightly). Provider: Claude (claude-opus-5-5).

Evidence

17:34:27 ws.rpc.orchestration.dispatchCommand thread.runtime-mode.set (<id>:runtime-mode)
  OrchestrationV2DispatchCommandError: The current session is still running background agents or commands,
  and this change would end them. Wait for them to finish, or press Stop, then try again.

17:34:28, 17:34:31, ... 17:42:53, ... (65+ times, about every 16 s)
  OrchestratorCommandPreviouslyRejectedError: Command <id>:runtime-mode was previously rejected:
  Failed to dispatch orchestration command thread.runtime-mode.set (<id>:runtime-mode).

orchestration_command_receipts: command_id <id>:runtime-mode, command_type thread.runtime-mode.set, status rejected
// apps/mobile/src/state/thread-outbox-model.ts
export function resolveThreadOutboxFailureAction(input) {
  if (input.stage === "settings-sync" || input.interrupted || shouldRetryThreadOutboxDelivery(input.error)) {
    return "retry";
  }
  return "restore";
}

Related issues

#16000 (closed) added the background-work check that produces the rejection. Open PR #24446 ("preserve background work when thread settings change") would avoid the rejection in the first place, but the outbox would still loop on any other settings rejection. #26546 covers how queued follow-ups look, not delivery. No existing issue found for this.

Fix applied or workaround

None so far. Restarting the mobile app does not help: the queued message keeps its command ID, so the retries resume against the same rejected receipt.

Selecting the same permission mode on desktop did not help either. The desktop picker only changes the composer draft (useComposerSelection.handleRuntimeModeChange), and the thread's mode changes only when a message is sent from there, so the thread stayed on auto and mobile kept retrying.

Confirmed: sending a message from desktop with the new mode selected applies it to the thread. Mobile then skips the stuck runtime-mode command and delivers the queued messages.

From the code, untested: removing the stuck message on mobile and sending it again (it gets a new command ID) should also unblock the queue.

Filed by

Claude Code (claude-opus-5-5) via T3 Code triage

Automated comment from a coding agent. Model: claude-opus-5-5

Activity

  1. juliusmarminge commented on Nov 15, 2026

    @juliusmarminge
    Member

    I tried to reproduce this on the current build and could not.

    Commit dd7255d (origin/main). Not reproduced in a running app: the background-work rejection of thread.runtime-mode.set comes only from a live Claude session (ClaudeAdapterV2 is the only adapter with supportsRuntimeModeSwitchInSession: false and a background-work probe), and first-party Claude is not available on the VM. The code path was confirmed: (1) Orchestrator.replayCommandReceipt answers any command whose receipt has status 'rejected' with OrchestratorCommandPreviouslyRejectedError, so the same command ID can never succeed again; (2) threadOutboxDelivery.ts dispatches the settings commands with the deterministic ID ${message.commandId}:runtime-mode / :interaction-mode; (3) resolveThreadOutboxFailureAction in thread-outbox-model.ts returns 'retry' for any stage === 'settings-sync' failure, including OrchestrationDispatchCommandError, which shouldRetryThreadOutboxDelivery already treats as deterministic. Added one assertion to the existing 'retains queued messages when settings synchronization fails before startTurn' test: an OrchestrationDispatchCommandError (the server's background-work message) at settings-sync should be 'restore'. vp test run src/state/thread-outbox.test.ts -t "settings synchronization" in apps/mobile fails on main: expected 'retry' to be 'restore'.

    Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.

  2. bdamokos commented on Nov 15, 2026

    @bdamokos
    Author

    Thanks for looking into this. I reproduced it again today on current builds and can add the details.

    Versions: iPad mini, mobile 2.3.0. Server: desktop 0.1.10-nightly.20261115.4736, with Claude (claude-opus-5-5).

    Steps:

    1. On the iPad, start a Claude thread and have it start a background shell command (I used a 5-minute loop) and end its turn.
    2. While the command is still running, change the thread's permission mode from Auto to Full access on the iPad and send a message from the iPad.
    3. The server refuses thread.runtime-mode.set with "The current session is still running background agents or commands…". The message shows "Pending".
    4. Stop the background command. The message stays "Pending", and later messages to the thread queue behind it.

    Server log for the settings command (<id>:runtime-mode), times in UTC:

    18:59:01  OrchestrationV2DispatchCommandError: The current session is still running background agents or commands, ...
    18:59:02, :04, :08, :16, :32, :48, 19:00:04, :20, ...
              OrchestratorCommandPreviouslyRejectedError: Command <id>:runtime-mode was previously rejected
    19:01:09  background command stopped
    19:01:24, :40, :57, 19:02:13, ..., 19:03:40, 19:04:45
              OrchestratorCommandPreviouslyRejectedError (unchanged)
    

    The receipt row is thread.runtime-mode.set, status rejected. After the background work ends, every retry is answered from that receipt, so the message can never be delivered.

    On the reproduction attempt: the trigger needs a live Claude session, which explains why the VM couldn't produce it. The rest of the analysis above matches what happens here, and the test it added (expected 'retry' to be 'restore') fails on main for the same reason. resolveThreadOutboxFailureAction is unchanged at 26b63a44f9.

    Open PR #24446 looks like it would fix this: it gives mobile settings-sync attempts fresh command IDs, so a retry can succeed once the background work has ended. Could this be reopened and linked to that PR?

    Automated comment from a coding agent. Model: claude-opus-5-5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions