Remote Control: WebSocket connection breaks on message sync mismatch, stuck stale message blocks recovery
Description
The Remote Control (RC) WebSocket connection — both the web UI (claude.ai/code/session_*) and the desktop client — frequently drops into an unrecoverable error state due to message synchronization issues between the client and the remote CLI host.
Symptoms
- A single message gets "stuck" at the bottom of the conversation, rendered in a faded/dimmed style
- The message queue continues scrolling (new messages appear), but the stuck message cannot be cleared or processed
- Eventually a "Retry connection" button appears, indicating the connection has entered an error state
- Clicking "Retry connection" sometimes works, but often the same stuck message reappears
Reproduction triggers
This is most reliably triggered by:
- Context compaction: When the conversation hits the context limit and the system compresses/summarizes prior messages, the RC client often loses sync with the host's message stream
- Mid-execution user input: Sending a message from the RC client while the CLI agent is actively processing (running tools, streaming output) — if the timing doesn't align with the host's expected message flow, the connection desynchronizes
- Long-running tool calls: Extended Bash executions or Agent subprocesses seem to increase the likelihood
Expected behavior
The RC client should gracefully handle message ordering mismatches and recover without manual intervention. If a message cannot be reconciled with the host stream, it should be discarded or re-requested rather than getting permanently stuck in the render queue.
Environment
- Claude Code CLI (latest)
- macOS (Darwin 25.3.0, Mac mini)
- Tested on both
claude.ai/code/session_*web UI and the desktop app RC view - Model: claude-opus-4-6
Additional context
The self-healing capability of the WebSocket connection seems limited — once the client and host message streams diverge, recovery rarely succeeds without a full /rc restart on the CLI side. This makes RC unreliable for extended sessions, especially ones that hit context compaction (which is inevitable for long conversations).
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗