Description#
When using opencode as a provider in t3code, the connection to the opencode server frequently drops/disconnects. Sessions suddenly die with no automatic reconnection.
Root Cause (from source code analysis)#
No reconnect logic - t3code spawns opencode serve as a child process. When that process crashes or exits, the session dies immediately with no auto-restart. (apps/server/src/provider/Layers/OpenCodeAdapter.ts)
SSE event stream is fragile - Real-time communication uses Server-Sent Events (long-lived HTTP streaming) with no heartbeat/keepalive mechanism.
Short startup timeout (5 seconds) - DEFAULT_OPENCODE_SERVER_TIMEOUT_MS = 5000. If the server is slow to start (e.g., due to many plugins/MCP/LSP servers), it times out.
Text generation server idle TTL of 30 seconds - OPENCODE_TEXT_GENERATION_IDLE_TTL = "30 seconds". The shared server is killed after 30 seconds of inactivity. (apps/server/src/textGeneration/OpenCodeTextGeneration.ts)
No clear error message in UI - Users only see "disconnected" without knowing the actual cause.
Environment#
- t3code version:
- opencode version:
- OS:
Steps to Reproduce#
- Open t3code, select opencode as provider
- Start a session and use it for a while
- Let it sit idle, or just let the server run
- Session suddenly disconnects / connection lost
Expected Behavior#
- Stable connection or auto-reconnect when disconnected
- Clear error messages when something goes wrong
- Server should not be killed after short idle periods
Additional Context#
Related issues: #2378 (t3code should resume same conversation after idle timeout)
Closing as a duplicate of #2644, which is the canonical OpenCode disconnect/SSE-lifecycle report. PR #2908 previously attempted the shared fix but closed unmerged; there is currently no active superseding PR, so future implementation should stay attached to #2644.