diff --git a/openspec/changes/persistent-terminal-sessions/tasks.md b/openspec/changes/persistent-terminal-sessions/tasks.md index 4449a30..215140b 100644 --- a/openspec/changes/persistent-terminal-sessions/tasks.md +++ b/openspec/changes/persistent-terminal-sessions/tasks.md @@ -1,51 +1,51 @@ ## 1. Backend - TerminalSession Refactoring -- [ ] 1.1 Add circular output buffer to TerminalSession (10KB, stores raw bytes) -- [ ] 1.2 Add WebSocket connection tracking (support multiple connections, detach without closing) -- [ ] 1.3 Add last_activity timestamp and idle timeout support -- [ ] 1.4 Add reset() method to kill process and prepare for restart -- [ ] 1.5 Add health check for docker exec process -- [ ] 1.6 Modify read_output to also write to circular buffer +- [x] 1.1 Add circular output buffer to TerminalSession (10KB, stores raw bytes) +- [x] 1.2 Add WebSocket connection tracking (support multiple connections, detach without closing) +- [x] 1.3 Add last_activity timestamp and idle timeout support +- [x] 1.4 Add reset() method to kill process and prepare for restart +- [x] 1.5 Add health check for docker exec process +- [x] 1.6 Modify read_output to also write to circular buffer ## 2. Backend - TerminalManager Refactoring -- [ ] 2.1 Change session tracking from session_id to instance_id -- [ ] 2.2 Add get_or_create_session() method (reattach if exists, create if not) -- [ ] 2.3 Modify create_session to support reconnection (don't always create new) -- [ ] 2.4 Add reset_session() method (kill existing, create new) -- [ ] 2.5 Add attach_websocket() method (add WebSocket to existing session, replay buffer) -- [ ] 2.6 Add detach_websocket() method (remove WebSocket, keep session alive) -- [ ] 2.7 Add idle timeout background task (check every minute, cleanup after 30min) -- [ ] 2.8 Handle concurrent connections (close old WebSocket when new one connects) +- [x] 2.1 Change session tracking from session_id to instance_id +- [x] 2.2 Add get_or_create_session() method (reattach if exists, create if not) +- [x] 2.3 Modify create_session to support reconnection (don't always create new) +- [x] 2.4 Add reset_session() method (kill existing, create new) +- [x] 2.5 Add attach_websocket() method (add WebSocket to existing session, replay buffer) +- [x] 2.6 Add detach_websocket() method (remove WebSocket, keep session alive) +- [x] 2.7 Add idle timeout background task (check every minute, cleanup after 30min) +- [x] 2.8 Handle concurrent connections (close old WebSocket when new one connects) ## 3. Backend - Terminal WebSocket Endpoint -- [ ] 3.1 Modify endpoint to check for existing session first -- [ ] 3.2 Add reconnection logic (attach to existing vs create new) -- [ ] 3.3 Handle reset command from WebSocket (JSON message type: "reset") -- [ ] 3.4 Add buffer replay on WebSocket attach -- [ ] 3.5 Add proper cleanup on WebSocket disconnect (detach, don't kill) +- [x] 3.1 Modify endpoint to check for existing session first +- [x] 3.2 Add reconnection logic (attach to existing vs create new) +- [x] 3.3 Handle reset command from WebSocket (JSON message type: "reset") +- [x] 3.4 Add buffer replay on WebSocket attach +- [x] 3.5 Add proper cleanup on WebSocket disconnect (detach, don't kill) ## 4. Backend - API Reset Endpoint -- [ ] 4.1 Add POST /api/projects/{project_id}/repositories/{repo_id}/instances/{instance_id}/terminal/reset endpoint -- [ ] 4.2 Add authorization checks -- [ ] 4.3 Call TerminalManager.reset_session() -- [ ] 4.4 Return success/error response +- [x] 4.1 Add POST /api/projects/{project_id}/repositories/{repo_id}/instances/{instance_id}/terminal/reset endpoint +- [x] 4.2 Add authorization checks +- [x] 4.3 Call TerminalManager.reset_session() +- [x] 4.4 Return success/error response ## 5. Frontend - Terminal Component -- [ ] 5.1 Add "Reset Terminal" button to terminal UI -- [ ] 5.2 Handle WebSocket reconnection gracefully -- [ ] 5.3 Display "Reconnecting..." indicator -- [ ] 5.4 Handle reset confirmation dialog -- [ ] 5.5 Display session status (connected, reconnecting, reset) +- [x] 5.1 Add "Reset Terminal" button to terminal UI +- [x] 5.2 Handle WebSocket reconnection gracefully +- [x] 5.3 Display "Reconnecting..." indicator +- [x] 5.4 Handle reset confirmation dialog +- [x] 5.5 Display session status (connected, reconnecting, reset) ## 6. Frontend - Terminal Hook -- [ ] 6.1 Add reconnection logic with exponential backoff -- [ ] 6.2 Handle buffer replay on reconnect (process incoming bytes) -- [ ] 6.3 Add reset function (send WebSocket message or call API) +- [x] 6.1 Add reconnection logic with exponential backoff +- [x] 6.2 Handle buffer replay on reconnect (process incoming bytes) +- [x] 6.3 Add reset function (send WebSocket message or call API) - [ ] 6.4 Add heartbeat/ping to detect disconnections faster ## 7. Testing