Repository navigation
Description
Version: v8.0.2 (Subscription / interactive engine, live pane)
Very often the live pane shows that the Claude task is finished, while the web UI keeps waiting. The results are not shown in the web UI. The live pane and the web UI get out of sync, and the web UI often becomes unusable.
It happens mostly during sessions with back-and-forth interactions between Claude and the user (Claude shows an interactive prompt, the user answers).
Analysis of the code (v8.0.2): possible causes
I have not confirmed these hypotheses at runtime. They come from reading claude-interactive.js.
-
The prompt grace period delays completion by up to 5 min. Line 883:
const graceP = awaitAnnounced ? Math.ceil(AWAIT_GRACE_MS / POLL_MS) : 0;, withAWAIT_GRACE_MS= 300000 by default (CLAUDE_PROMPT_GRACE_MS). IfawaitAnnouncedstaystrueafter the user answers in the live pane (for example, the pane-scraping heuristic still detects a select widget or a similar text), the safety-net completion (quietPolls >= 12 + graceP) waits about 5 min more. The TUI is already finished, but the web UI still waits. -
The primary completion signal can be missed. The main exit is
if (endTurnSeen && !busy && !gotNewBytes) break;(line 867).endTurnSeencomes from the transcriptstop_reason. Line 853 resetsendTurnSeen = falsewhen a new turn is detected in the pane. After an answer in the pane, the TUI can start a new turn that the web side does not track. The loop then relies only on the safety net (problem 1) or on the idle watchdog (IDLE_TIMEOUT_MS, 10 min by default). -
Stream frames go only to the original socket.
wsSend(line 426) sends only to thewsthat started the turn. Onlyinput_needed/input_resolvedusewsSendAll(fanout). If the browser reconnects during a long wait for the user's answer (sleep, network change, tab in background), the new socket does not get the text, the results or the end-of-turn frame. The UI stays in the waiting state until the history reloads.
Suggested fixes
- Clear
awaitAnnouncedwhen transcript activity resumes after an answer (new bytes), not only when the pane stops looking like a prompt. - Send the end-of-turn frame (
done/error) throughwsSendAll/fanout, or replay it on reconnect, so every window watching the chat leaves the waiting state. - Add a client-side reconciliation: if the session is no longer running on the server, reload the history and clear the spinner.
Expected: when the turn ends in the live pane, the web UI leaves the waiting state and shows the results.
Actual: the web UI stays in the waiting state, and no results are shown.
Activity
Lexus2016 commentedon Nov 8, 2026
Your reading of the code holds. I verified the three points in v8.0.2:
AWAIT_GRACE_MSis300000by default (claude-interactive.js:68) andgracePis only added to the safety net whenawaitAnnouncedis true (:883).endTurnSeenis reset when a new turn is seen in the pane (:853), and the primary exit isendTurnSeen && !busy && !gotNewBytes(:868), which the safety net or the 10-minute idle timeout has to rescue.wsSendAllis used only forinput_neededandinput_resolved(:550,:558,:747,:750,:902). The end-of-turn frames and the timeout error go throughwsSend, which sends only to the socket that started the turn (:654for the idle error).Of the three, the third is the one I would call a defect on its own rather than a hypothesis: a phone whose screen turns off, or any network change, replaces the socket, and the new one then never receives the frame that ends the turn. Even with a correct completion signal the page stays in the waiting state, because nothing is sent to the socket it now has. The first two need
awaitAnnouncedto be stuck true after an answer, which is possible but secondary: once the end-of-turn frame reaches every socket, a missed signal is repaired on reconnect instead of needing a page reload.The order I will take it in is therefore: send the end-of-turn and error frames for a session to every socket watching it (and replay the last one on reconnect), then clear
awaitAnnouncedwhen the transcript shows new bytes after an answer, then the client-side reconciliation against the server's session state.Your sleep/wake case is the one that will decide whether the fanout is enough, so a
[interactive]log line with the session id and the moment the pane went idle next to the moment the frame was sent would help if you can still reproduce it.engine: a finished turn no longer reads busy for ten minutes (#130) (#…
Lexus2016 commentedon Nov 15, 2026
Fixed in #143 (squash
3972899). The cause turned out to be different from all three hypotheses, though it sits right next to your first one.What held the turn open.
paneBusy()gates every exit of the poll loop except the idle watchdog. The turn-end break needs!busy, and so does the quiet safety net. Two of its signals could read a finished pane as busy for as long as it stayed on screen:/\d+s\s*[·)]/ran over the whole pane. A finished subagent is rendered as⎿ Done (3 tool uses · 12.4k tokens · 8s), which is the format string in the CLI 2.1.311 bundle, and that line matches8s). SoendTurnSeenlatched correctly, but the break never fired. The turn sat there untilCLAUDE_IDLE_TIMEOUT_MS(10 min) and then ended as a timeout, while the live pane showed the answer.The back-and-forth case you described was the worst version. With a permission/question dialog on screen and a
Done (…)line above it,busystayed true,awaitingis!busy && …, soinput_neededwas never sent, and the turn waited on a question the web UI never showed.Both signals now look only at the conversation above the input box, and the timer only at the spinner line. With no box on screen, the old whole-pane diff remains but the timer still has to look like a spinner. 22 cases in
test/pane-busy.test.jspin both directions.Your other two points, checked against the code:
awaitAnnouncedstuck after an answer:awaitingalready requires!gotNewBytes, so the first poll with new transcript bytes clears it and sendsinput_resolved. It could only stay set in the stuck-busy state above.wsis the turn'sWsProxy. It buffers while the browser is away and is re-attached onsubscribe_session.doneis also broadcast to every watcher on both the success and the error paths. One real gap remains: after a full page reload, a pendinginput_neededbanner is not re-sent to the new page. That is tracked as a follow-up, not part of this fix.I could not reproduce your exact session. If it still happens on the next release, please reopen with the error text: the idle-timeout message now ends with
The pane still looked busy (spinner|animation|legacy-marker)., which names the signal that held it.engine: a reloaded page is told about a prompt the turn is still wait…
Lexus2016 commentedon Nov 16, 2026
The follow-up mentioned above is merged in #144 (squash
f46ddf5): a page reloaded while a subscription turn waits on a TUI prompt is now sent the prompt again onsubscribe_session. It goes only to a foreground subscribe (not to background tabs, which still hold it) and only while the turn is live, so a page opened after the turn ended never sees a stale question. Covered by an end-to-end test that boots a real server against a fakeclaudedrawing the trust screen (test/engine-prompt-replay.test.js).