Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Remote stop button gives no feedback and leaves thread stuck in Thinking #8618

ClosedImBIOS(GitHub profile, opens in a new tab) opened this issue 2 comments

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate.

Area

apps/web • apps/mobile • packages/client-runtime • apps/server

Description

Using a remote T3 Code server, clicking the Stop button gives no UI feedback and the thread stays stuck in Thinking / Working for Xm Ys indefinitely.

Screenshot attached: prompt list me all ~/dev/projects/* → Working for 6m 26s + Thinking, bottom composer shows red stop ■ still active, environment myrehat-dev.asia-southeast1-a.c.myrehat-... · Local checkout · main, model Muse Spark 1.2 Contrib..., Xhigh · Build, Full access.

Expected: Stop shows Stopping... immediately (disabled) and within seconds drops Thinking/Working, even on relay/tunnel. Actual: no visual change, subsequent Stop clicks also silent, thread never recovers until server restart or manual projection_thread_sessions stopped + projection_turns interrupted repair.

Steps to reproduce (remote)

  1. Start remote server (npx t3 --share / --tunnel / npx t3 behind Tailscale on myrehat-dev...).
  2. Connect from app.t3.codes or mobile via pairingUrl: token (remote mode, not local).
  3. Open thread with Local checkout, send a prompt that streams (list me all ~/dev/projects/* and it…, or any long agent run).
  4. While Thinking/session.status === "running", click the red Stop button in the composer.

Actual

  • Button does not morph to Stopping..., not disabled, no toast, no spinner change (100–400ms relay RTT makes it obvious; local 10–20ms masks it).
  • Timeline keeps Working for ... ticking forever.
  • DB: projection_thread_sessions.status = 'running' with active_turn_id pinned to a turn already interrupted/completed (completed_at set), or NULL with pending turn forever (#4713 detection query hits):
    SELECT s.thread_id, tu.state, tu.completed_at
      FROM projection_thread_sessions s
      JOIN projection_turns tu ON tu.turn_id = s.active_turn_id
     WHERE s.status = 'running'
       AND tu.state IN ('interrupted','completed','error')
       AND tu.completed_at IS NOT NULL;
    Widened query also catches active_turn_id IS NULL + pending turn (report at 2026-08-24T23:30:31Z in #4713).
  • Every further Stop appends thread.turn-interrupt-requested in orchestration_events (accepted in orchestration_command_receipts) but produces no follow-up thread.session-set; the stop handler has nothing to act on.

Expected

  • Optimistic Stopping... within one frame on every surface (web composer, mobile ThreadRouteScreen), disabled until terminal session-set stopped/interrupted or error.
  • Even when buildThreadTurnInterruptInput omits turnId (stale activeTurnId), the client and projection still flip latestTurn.state → interrupted optimistically.
  • If provider interrupt succeeds yet CLI stays alive, server escalates after ~5s to stopSession → session-set stopped, so derivePhase → disconnected/ready and MessagesTimeline clears Working.
  • Relay blips surface as toast instead of silent no-op (reportFailure:false currently swallows EnvironmentRpcUnavailableError while phase === "available"|"offline").

Evidence & analysis

Investigated in worktree t3code-a1ef8329 (6a9d9f9):

  • UI: apps/web/src/components/ChatView.tsx:1246 interruptThreadTurn = useAtomCommand(threadEnvironment.interruptTurn, {reportFailure:false}), 5487-5510 onInterrupt has no isStoppingTurn state. Contrast handleStopBackgroundWork 4677-4740 which correctly tracks isStoppingBackgroundWork, disables Button 4543 and shows "Stopping..." 4546.
  • Input guard: ChatView.logic.ts:141-150 buildThreadTurnInterruptInput includes turnId only if session.status==="running" && activeTurnId!==null. Remote snapshots lag (THREAD_RESUME_MAX_GAP 1000, SHELL_COALESCE_WINDOW 50ms ws.ts:841), so Stop often persists thread.turn-interrupt-requested without turnId. Both threadReducer.ts:271-292 and ProjectionPipeline.ts:1441-1476 return unchanged/no-op for turnId===undefined.
  • Projection: session-logic.ts:1894-1905 derivePhase = running iff session.status==="running"|"starting"; MessagesTimeline.tsx:210,1313 WorkingTimelineRow only clears when isWorking===false. threadReducer latestTurn.state==="interrupted" alone does not clear it.
  • Server reactor: ProviderCommandReactor.ts:1228-1321 only tears down on failure (recoverInterruptFailure → stopSession). On success it waits for provider session-set. When ClaudeAdapter.ts:query.interrupt() never settles / OpenCodeAdapter.ts:2932 10s abort times out / CodexAdapter ignores, session never leaves running. Serial interruptTurn (threadCommands.ts:177-182 concurrency:{mode:"serial"} per (env,thread)) then queues further clicks.
  • Family: pingdotgg/t3code#4713 (40+ accepted interrupts no effect, SIGTERM workaround), #4589 (threads stop updating), #7820, #2644, #7349 (bounded Claude query.interrupt 10s + getContextUsage 1s — but only for failure path), #7589, #7987.

Impact

Major: remote is primary use (Tailscale/tunnel/mobile). User cannot cancel, cannot archive (useThreadActions.ts:214 refuses archive while running), mobile outbox gates on running (use-thread-outbox-drain.ts:317) so queued messages never deliver. Only way out is SIGTERM --resume <cursor> or manual DB session-set stopped + restart.

Environment

  • T3 Code v0.0.37-nightly.20260829.1218 6a9d9f9 (local) / remote myrehat-dev Linux aarch64, provider opencode Muse Spark 1.2 Contrib...
  • Client app.t3.codes / desktop wrap, remote relay.
  • Also reproduced for claudeAgent, Codex, Cursor per #4713.

Suggested fix (non-negotiables)

  1. Web + mobile optimistic isStoppingTurn (mirror isStoppingBackgroundWork) → Stopping... disabled.
  2. Relax turnId===undefined guard to fallback to activeTurnId ?? latest unsettled turn.
  3. Server 5s fallback stopSession when interrupt succeeds but session still running (success-still-running), with bounded getContextUsage.
  4. interruptTurn timeout / singleFlight so promise doesn't hang; surface transport errors for Stop.
  5. Tests + projector coverage.

Logs

  • state.sqlite orchestration_events thread.turn-interrupt-requested accepted without follow-up thread.session-set.
  • projection_thread_sessions running + projection_turns interrupted/pending as above.

Managed via forkhub as fix-remote-stop-no-feedback-stuck-thinking-7h3k9p2m. See ImBIOS/.forkhub INTENT.md for full non-negotiables and implementation notes.

  1. Fresh repro on latest nightly (new variant of this bug)

    Reproduced today on 0.0.39-nightly.20260903.1262, remote server on a GCP VM, opencode provider. Three threads stuck on Working 1h23m+, surviving desktop reload and full app restart. Root cause is different from a hung provider: the provider is already gone.

    Trigger: provider workers died mid-run

    The opencode serve workers backing these runs are gone (ports connection-refused, PIDs exited). Their turns actually finished server-side — all three rows in projection_turns are already state='interrupted' with completed_at set. But the run-level rows never transitioned, so the sidebar keeps rendering Working (session.status==='running' && activeTurnId!=null).

    Orphaned rows (all three threads, identical pattern)

    projection_thread_sessions: status='running', active_turn_id pointing at the already-completed turn, provider_session_id=NULL, updated_at frozen ~1.5h ago.

    provider_session_runtime: status='running', last_seen_at frozen, lastRuntimeEvent='provider.sendTurn'. (Note: the real opencode sessionId (ses_…) only exists in this table's resume_cursor_json — the session projection has NULL, so Stop has no provider target to act on, which matches the silent no-op.)

    projection_threads: settled_override=NULL, settled_at=NULL despite the turn being done.

    Local opencode workers all idle, remote workers all idle (/session/status → {}), near-zero CPU — nothing executing anywhere. Pure stale state, but persisted server-side, so no amount of client reload/restart clears it.

    Manual repair that cleared the badges

    projection_thread_sessions → status='stopped', active_turn_id=NULL; projection_threads → settled_override='settled', settled_at=now; provider_session_runtime → status='stopped'. Badge clears on the session flip alone; the settle moves them to the Settled shelf.

    Suggested fix (beyond #8619)

    #8619 covers the interrupt path while a provider exists. This variant needs startup reconciliation: on boot, any session running whose provider session/worker no longer exists (and whose turn is already terminal) should transition to stopped (+ runtime row), instead of staying running forever. Today the only recovery is hand-editing state.sqlite.

  2. Reproduced on T3 Code v0.0.38 (Linux x64, remote server through the T3 tunnel) with the OpenCode provider.

    Trigger in this case:

    1. A model returned weekly usage limit reached.
    2. The model selector was changed to opencode/muse-spark-1.3-contributor-free.
    3. A new short prompt was submitted.
    4. The thread remained in Thinking for 27+ minutes and the red Stop button had no effect.

    Provider and projection disagreed:

    • OpenCode GET /session/status?directory=... returned {}, so no model request was active.
    • Direct OpenCode POST /session/{id}/abort returned true, but T3 remained stale.
    • projection_thread_sessions: status=running, active_turn_id still set.
    • provider_session_runtime: status=running, lastRuntimeEvent=provider.sendTurn, stale last_seen_at.
    • projection_turns: latest turn remained pending, completed_at=NULL.
    • A direct authenticated thread.turn.interrupt through /api/orchestration/dispatch returned HTTP 200 with an accepted sequence, but produced no session/turn transition after waiting.

    This is slightly different from the terminal-turn orphan already described above: here the provider was idle while the projected turn itself remained pending. It also confirms that the issue is not only missing UI feedback; the server accepts the interrupt command but does not reconcile the stale OpenCode/T3 state after a quota error plus model switch.

    All repository names, prompts, session IDs, turn IDs, and credentials have been omitted.

  3. juliusmarminge closed this

Sign in to join this conversation.