feat: cli passthrough state transitions (#95)

This commit is contained in:
Carlos Florêncio
2026-01-25 18:37:37 +00:00
committed by GitHub
parent 66cda240e0
commit ab404261dd
14 changed files with 144 additions and 874 deletions
@@ -314,6 +314,8 @@ func (h *TerminalHandler) runTerminalBridge(
zap.Error(err))
return
}
// Detect Enter key (user submitted input) - notify lifecycle manager
h.detectInputSubmission(sessionID, data)
} else {
// PTY not ready yet - try to set it up
if h.setupPtyAccess(sessionID, processID, interactiveRunner, wsw, &ptyWriter) {
@@ -331,6 +333,8 @@ func (h *TerminalHandler) runTerminalBridge(
zap.Error(err))
return
}
// Detect Enter key (user submitted input) - notify lifecycle manager
h.detectInputSubmission(sessionID, data)
} else {
h.logger.Debug("PTY not ready, dropping input",
zap.String("session_id", sessionID),
@@ -340,6 +344,29 @@ func (h *TerminalHandler) runTerminalBridge(
}
}
// detectInputSubmission checks if the input contains Enter key and notifies
// the lifecycle manager to update the execution state to Running.
func (h *TerminalHandler) detectInputSubmission(sessionID string, data []byte) {
// Check for Enter key (CR or LF)
hasEnter := false
for _, b := range data {
if b == '\n' || b == '\r' {
hasEnter = true
break
}
}
if hasEnter {
// Notify lifecycle manager that user submitted input
if err := h.lifecycleMgr.MarkPassthroughRunning(sessionID); err != nil {
// Log at debug level - may fail if session ended or not in passthrough mode
h.logger.Debug("failed to mark passthrough as running",
zap.String("session_id", sessionID),
zap.Error(err))
}
}
}
// setupPtyAccess attempts to get PTY writer and set up direct output.
// Returns true if successful.
func (h *TerminalHandler) setupPtyAccess(