Skip to content

Live pane and web UI out of sync: task shown finished in live pane, web UI stays waiting #130

Closed

Description

@malys

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.

  1. The prompt grace period delays completion by up to 5 min. Line 883: const graceP = awaitAnnounced ? Math.ceil(AWAIT_GRACE_MS / POLL_MS) : 0;, with AWAIT_GRACE_MS = 300000 by default (CLAUDE_PROMPT_GRACE_MS). If awaitAnnounced stays true after 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.

  2. The primary completion signal can be missed. The main exit is if (endTurnSeen && !busy && !gotNewBytes) break; (line 867). endTurnSeen comes from the transcript stop_reason. Line 853 resets endTurnSeen = false when 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).

  3. Stream frames go only to the original socket. wsSend (line 426) sends only to the ws that started the turn. Only input_needed/input_resolved use wsSendAll (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 awaitAnnounced when 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) through wsSendAll/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

  1. Lexus2016 commented on Nov 8, 2026

    @Lexus2016
    Owner

    Your reading of the code holds. I verified the three points in v8.0.2:

    • AWAIT_GRACE_MS is 300000 by default (claude-interactive.js:68) and graceP is only added to the safety net when awaitAnnounced is true (:883).
    • endTurnSeen is reset when a new turn is seen in the pane (:853), and the primary exit is endTurnSeen && !busy && !gotNewBytes (:868), which the safety net or the 10-minute idle timeout has to rescue.
    • wsSendAll is used only for input_needed and input_resolved (:550, :558, :747, :750, :902). The end-of-turn frames and the timeout error go through wsSend, which sends only to the socket that started the turn (:654 for 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 awaitAnnounced to 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 awaitAnnounced when 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.

  2. Lexus2016 commented on Nov 15, 2026

    @Lexus2016
    Owner

    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:

    • The elapsed-timer regex /\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 matches 8s). So endTurnSeen latched correctly, but the break never fired. The turn sat there until CLAUDE_IDLE_TIMEOUT_MS (10 min) and then ended as a timeout, while the live pane showed the answer.
    • "Animation" meant any change of the whole pane, so a statusline clock below the input box, or typing into the live pane, also counted.

    The back-and-forth case you described was the worst version. With a permission/question dialog on screen and a Done (…) line above it, busy stayed true, awaiting is !busy && …, so input_needed was 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.js pin both directions.

    Your other two points, checked against the code:

    • awaitAnnounced stuck after an answer: awaiting already requires !gotNewBytes, so the first poll with new transcript bytes clears it and sends input_resolved. It could only stay set in the stuck-busy state above.
    • Frames to the original socket only: on the chat path the engine's ws is the turn's WsProxy. It buffers while the browser is away and is re-attached on subscribe_session. done is also broadcast to every watcher on both the success and the error paths. One real gap remains: after a full page reload, a pending input_needed banner 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.

  3. Lexus2016 commented on Nov 16, 2026

    @Lexus2016
    Owner

    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 on subscribe_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 fake claude drawing the trust screen (test/engine-prompt-replay.test.js).

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions