Issue
When a stream error occurs (e.g., AI_APICallError, socket closed unexpectedly), the desktop UI gets stuck showing "thinking..." indefinitely. No error message is displayed, no state recovery happens, and the session becomes unusable. The user must restart the app to recover.
Root Cause Analysis
After analyzing multiple server logs from debug dumps:
-
Stream errors are frequent but silently swallowed
AI_APICallError: <none> — empty error object, no details from the upstream API
AI_APICallError: The socket connection was closed unexpectedly — upstream proxy terminates the SSE stream mid-response
- These errors are logged on the server side but never propagated to the UI
-
UI state machine never transitions out of 'thinking'
- After a stream error, the server logs show the session is dead (no further
stream events)
- But the desktop UI continues displaying "thinking..." with no cancel button or error indicator
- The frontend apparently waits for a stream event that will never come
-
No automatic retry or timeout
- No retry mechanism after stream failure
- No client-side timeout to abort stuck states
- User must manually cancel or restart the app
-
Server log stops processing
- In one dump, the last log entry at
2026-06-15T01:46:02Z was a cancel event
- After that, zero log entries despite the UI showing "thinking"
- This confirms the server stopped processing but the UI never received this state change
Server Log Evidence
# Frequent silent stream errors (no error detail)
level=ERROR message="stream error" providerID=YerPlan modelID=qwen3.6-plus error.error="AI_APICallError: <none>"
# Socket-level failures
level=ERROR message="stream error" error.error="AI_APICallError: Cannot connect to API: The socket connection was closed unexpectedly"
# After stream errors, server stops responding but UI stays 'thinking'
level=INFO message=cancel session.id=ses_13898e204ffemfGewCcp9BrPCN
# ← zero further log entries after this point (01:46 UTC)
Steps to Reproduce
- Connect opencode desktop to an API provider via an openai-compatible proxy (e.g.,
https://api.xxx.com/v1)
- Use a worktree session on a local project directory
- Send a message that triggers a long-running response
- Wait for the upstream proxy to drop the connection (intermittent, but happens frequently with unstable proxies)
- Observe: UI stuck on "thinking...", no error shown, session unresponsive
Expected Behavior
- Display an error message when the stream fails (e.g., "Connection lost. Retry?")
- Provide a "Retry" or "Cancel" button
- Implement a client-side timeout to prevent indefinite stuck states
- Auto-recover when the server stops responding
Environment
- opencode: 1.17.7 (Desktop app)
- OS: macOS darwin arm64 (M-series)
- Electron: 42.3.3 / Chrome 148
- Provider: openai-compatible proxy (not direct Anthropic/OpenAI)
- Model: qwen3.6-plus (via proxy)
- Node: 24.15.0
Related Issues
Issue
When a stream error occurs (e.g.,
AI_APICallError, socket closed unexpectedly), the desktop UI gets stuck showing "thinking..." indefinitely. No error message is displayed, no state recovery happens, and the session becomes unusable. The user must restart the app to recover.Root Cause Analysis
After analyzing multiple server logs from debug dumps:
Stream errors are frequent but silently swallowed
AI_APICallError: <none>— empty error object, no details from the upstream APIAI_APICallError: The socket connection was closed unexpectedly— upstream proxy terminates the SSE stream mid-responseUI state machine never transitions out of 'thinking'
streamevents)No automatic retry or timeout
Server log stops processing
2026-06-15T01:46:02Zwas acanceleventServer Log Evidence
Steps to Reproduce
https://api.xxx.com/v1)Expected Behavior
Environment
Related Issues