[Bug]: Stopped sessions remain active after restart and block settling
Before submitting
- [x] I searched existing issues and did not find a duplicate.
- [x] I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Start a turn, then steer it by sending another message while the turn is still running.
- Stop the active turn before the queued message is adopted.
- Quit the app while the provider session is shutting down.
- Restart the app.
Expected behavior
Stopping the turn should persist a final stopped session state across restart. The thread should stop showing as Working and should be settleable without creating more activity.
Actual behavior
Immediately after restart, sidebar v2 continues to show the thread as Working. Sending another message can move the visible sidebar state back to idle, but the thread can still be rejected when attempting to settle it.
The persisted state captured after restart shows the underlying lifecycle mismatch:
- the provider shutdown finalizer persisted
provider_session_runtime.status = stopped projection_thread_sessionsremainedstatus = startingwithactive_turn_id = NULL- an abandoned queued turn remained pending
No runtime event replays the durable stopped state on the next launch, and the session reaper skips the binding because it is already marked stopped. The missing final stopped-session transition therefore affects both the visible Working state and the server-side invariants used when settling.
Impact
The thread can remain visibly stuck and cannot be settled after restart without creating unwanted activity.
Version or commit
main at 5719e8ac4
Environment
macOS desktop app, Codex provider
Relevant persisted state
projection_thread_sessions:
status=starting
active_turn_id=NULL
provider_session_runtime:
status=stopped
runtime_payload.lastRuntimeEvent=provider.stopAll
projection_turns:
active turn=interrupted
queued turn=pending
Workaround
Sending another message can move the lifecycle forward and clear the visible Working state, but it creates unwanted thread activity and did not immediately make the thread settleable in the observed case.
Additional reproduction case
Environment: macOS, T3 Code latest, OpenCode Go backend
Steps to reproduce:
- Start a thread using OpenCode with a model that hits its usage quota mid-turn
- The backend dies silently but the UI still shows "Working..."
- Click "Settle" → error: "This thread still needs attention. Resolve or interrupt it first, then try again."
- Cannot interact with the thread at all — no settle, no interrupt, no continue
Root cause in DB:
projection_threads has pending_approval_count > 0 and settled_at IS NULL even though no actual approval is pending. The lifecycle state is desynchronized from reality.
Current workaround:
Force-settle via direct SQLite update on ~/.t3/userdata/state.sqlite:
python3 -c "import sqlite3, time; conn=sqlite3.connect('$HOME/.t3/userdata/state.sqlite'); conn.execute('UPDATE projection_threads SET pending_approval_count=0, pending_user_input_count=0, settled_at=? WHERE settled_at IS NULL', (time.strftime('%Y-%m-%dT%H:%M:%S.000Z', time.gmtime()),)); conn.commit(); conn.close()"
closing as completed. #7719 reconciles stopped or missing provider sessions during startup instead of leaving them active.
I reproduced a closely related stale-session mismatch on OpenCode, but without needing to quit during shutdown.
Setup
- T3 Code:
0.0.38-nightly.20260831.1236 - Server: Linux x64, Node
v22.23.2 - Connection:
t3 connecton the Linux VM - Clients: macOS desktop app and mobile app
- Provider: OpenCode
1.18.25 - Runtime mode: full access
Symptoms
- Pressing the red Stop button appears to do nothing.
- The problem occurs from both desktop and mobile, ruling out a client-specific click issue.
- The affected chat cannot be settled.
- Restarting
t3 connectbefore triage did not resolve it.
Evidence
The Stop commands reach the server. During one roughly two-minute interval, 58 distinct thread.turn-interrupt-requested events were persisted.
OpenCode then successfully acknowledged the interruption:
opencode.session.abort: successMessageAbortedError: emitted by OpenCodesession.status: idle: emitted repeatedly- Latest projected turn:
interrupted, withcompleted_atset
However, the durable session state remained stale:
projection_thread_sessions:
status=running
active_turn_id=opencode-turn-…
provider_session_runtime:
status=running
projection_turns latest:
state=interrupted
The affected thread had:
pending_approval_count=0
pending_user_input_count=0
Therefore settlement is blocked solely because canSettle sees the stale running session.
This is slightly different from the original report: the provider abort does not fail, and OpenCode clearly transitions to idle. The missing transition is between the adapter’s successful interruption/idle handling and the persisted session projection. It also reproduces across t3 connect restart and across two client surfaces.
Produced by GPT-5 Codex during a T3 Code triage session.