Commit Graph

7 Commits

  • fix: await switchToTerminal to prevent race condition
    The issue was that switchToTerminal() was not being awaited, so
    launchCommand() was called while switchToTerminal() was still
    executing. This caused a race condition where the WebSocket
    closed before the command could be sent.
    
    By awaiting switchToTerminal(), we ensure the terminal is fully
    switched before attempting to send any commands.
  • debug: add switchToTerminal logging and fitAddon error handling
    - Log when switchToTerminal is called and if terminal is in map
    - Log fitAddon.fit() execution with error handling
    - Log when switchToTerminal completes
    
    This will help identify if switchToTerminal is causing the WebSocket closure
  • debug: add detailed spawn attempt and error logging
    - Log spawn attempt before calling spawn()
    - Add detailed error logging with stack trace
    - This will help identify if spawn is failing silently
  • debug: add PTY lifecycle logging
    - Log PTY PID and shell when spawned
    - Log all PTY output data
    - Log PTY exit events with exit code and signal
    - Log when WebSocket cannot send PTY data
    
    This will help identify if the PTY is exiting immediately
    or if there's an issue with the PTY process.
  • debug: add WebSocket stability delay and enhanced checks
    - Added 100ms delay before sending command to ensure WebSocket stability
    - Added detailed WebSocket state logging (CONNECTING, OPEN, CLOSING, CLOSED)
    - Added bufferedAmount check to wait for pending sends
    - Wrapped ws.send() in try-catch for better error reporting
    - Split terminal and ws existence checks for clearer debugging
  • debug: add visual debug panel and comprehensive logging
    - Added debug panel in terminal view that shows all terminal activity
    - Added debugLog() method to TerminalManager for consistent logging
    - Updated connectTerminal, handleTerminalMessage, launchCommand, createTerminal, initializeXTerm with detailed logging
    - Enhanced backend logging for WebSocket messages and close codes
    - Logs now show both to console and visual debug panel
    
    This should help diagnose the terminal command execution issue without
    requiring browser console access.
  • feat: add session move endpoint and project-session cascading delete
    - Add sessions table to database with projectId and deletedAt columns
    - Create POST /api/sessions/:id/move endpoint to reassign sessions
    - Update DELETE /api/projects/:id to cascade soft-delete to sessions
    - Support moving sessions between projects or to unassigned state
    - Handle both active (in-memory) and historical sessions
    
    Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>