Skip to main content

handle_pty_shell_input

Function handle_pty_shell_input 

Source
pub(super) async fn handle_pty_shell_input(
    __arg0: State<AppState>,
    __arg1: Json<PtyShellInputRequest>,
) -> impl IntoResponse
Expand description

POST /api/v1/ptyshell/input — write raw text to the PTY, as if typed. Unlike /api/v1/shell/input, no newline is appended: a real terminal doesn’t add one either, and PTY programs (readline, Sharprompt) expect the caller to send exactly what a keyboard would (e.g. "y\n" to answer a prompt and press Enter, or "\x03" for Ctrl+C — the OS PTY layer translates that raw byte into a real interrupt delivered to the foreground process, same as a human pressing Ctrl+C in a real terminal, without ending the shell).

There is deliberately no separate “send a signal” endpoint: an earlier version of this API had one (PtyShellSignal, BlockInputUnion::signal), removed after Codex correctly flagged (PR #3177) that ShellController’s input loop treats ANY signal as “close the PTY” — if input.sig_name.is_some() { break; } in blockcontroller/shell/lifecycle.rs — so it terminated the whole shell instead of interrupting just the foreground command, the opposite of what it advertised. Real signal delivery through a PTY is the raw control byte, handled here, not a separate primitive.