- Add docs/api/terminal.md with WebSocket protocol and reset endpoint - Add docs/features/terminal.md with user guide for persistent sessions - Add docs/features/terminal-troubleshooting.md with diagnostic steps - Mark tasks 8.1-8.3 complete Refs: persistent-terminal-sessions tasks 8.x
4.4 KiB
Terminal Troubleshooting Guide
Common Issues
Cannot Connect to Terminal
Symptom: Terminal shows "Connection closed" or "Error" status immediately.
Solutions:
-
Verify the tool instance is running:
- Check instance status in the UI
- Start the instance if it's stopped
-
Check browser console for errors:
- Open browser DevTools (F12)
- Look for WebSocket connection errors
- Check for CORS or authentication errors
-
Verify network connectivity:
- Ensure you can reach the API server
- Check if WebSocket connections are blocked by firewall/proxy
- Try accessing from a different network
If the issue persists:
- Reset the terminal session
- Refresh the page
- Check server logs for errors
Terminal Freezes or Becomes Unresponsive
Symptom: Terminal accepts no input or stops updating.
Solutions:
-
Reset the terminal:
- Click the Reset button in the terminal header
- Confirm the reset action
- Wait for the new session to start
-
Check for stuck processes:
- Try Ctrl+C to interrupt any running process
- If that doesn't work, reset the terminal
-
Browser issues:
- Close and reopen the browser tab
- Clear browser cache and cookies
- Try a different browser
Output Not Showing
Symptom: Commands execute but no output appears.
Solutions:
-
Check terminal focus:
- Click inside the terminal area
- Look for the cursor indicator
-
Resize the terminal:
- The terminal may need a resize event to render properly
- Try resizing the browser window slightly
-
Reset the terminal session
Reconnection Loop
Symptom: Terminal keeps disconnecting and reconnecting repeatedly.
Solutions:
-
Check instance health:
- The instance may be unhealthy or restarting
- Check instance logs for errors
-
Network stability:
- Unstable network causes repeated disconnections
- Try on a more stable connection
-
Multiple tabs:
- Only one tab can connect to a terminal session
- Close other tabs with the same terminal open
Diagnostic Steps
Check WebSocket Connection
- Open browser DevTools (F12)
- Go to Network tab
- Filter by "WS" (WebSocket)
- Look for the terminal WebSocket connection
- Check:
- Connection status (should be 101 Switching Protocols)
- Messages tab for ping/pong traffic
- Any error messages in the connection
Verify Terminal Session
To check if a terminal session exists on the server:
# Check server logs for session activity
docker logs hq-api | grep -i "terminal"
Look for:
- "Terminal session ready" - session created successfully
- "Reattaching to existing terminal session" - reconnecting to existing session
- "Cleaning up idle terminal session" - session expired
Test Basic Connectivity
# Test if the WebSocket endpoint is reachable
curl -i -N \
-H "Connection: Upgrade" \
-H "Upgrade: websocket" \
-H "Sec-WebSocket-Key: test" \
-H "Sec-WebSocket-Version: 13" \
https://your-api-domain/ws/tool-instances/test/terminal
Expected: HTTP 400 (invalid instance ID) or redirect to auth
Error Codes
WebSocket Close Codes
- 1000: Normal closure - connection closed cleanly
- 4000: Generic error - check server logs
- 4001: Invalid instance ID - verify the instance exists
- 4003: Unauthorized - session expired or invalid
- 4004: Instance not running - start the instance first
HTTP Status Codes
- 404: Instance not found - verify instance ID
- 400: Instance not running - start the instance
- 500: Server error - check server logs
Resetting Everything
If all else fails:
-
Reset terminal session:
POST /api/projects/{project_id}/repositories/{repo_id}/instances/{instance_id}/terminal/reset -
Restart the tool instance:
- Stop the instance
- Start the instance again
- Reconnect to the terminal
-
Clear browser data:
- Clear cookies for the domain
- Clear local storage
- Hard refresh the page (Ctrl+F5)
Getting Help
If issues persist:
-
Collect diagnostic information:
- Browser console logs
- Network tab WebSocket messages
- Server logs (
docker logs hq-api) - Instance status and health
-
Check the Terminal API documentation for protocol details
-
Report issues with:
- Steps to reproduce
- Expected vs actual behavior
- Browser and OS version
- Instance type and configuration