mirror of
https://github.com/openai/codex.git
synced 2026-04-28 00:25:56 +00:00
utils/pty: add streaming spawn and terminal sizing primitives (#13695)
Enhance pty utils: * Support closing stdin * Separate stderr and stdout streams to allow consumers differentiate them * Provide compatibility helper to merge both streams back into combined one * Support specifying terminal size for pty, including on-demand resizes while process is already running * Support terminating the process while still consuming its outputs
This commit is contained in:
committed by
GitHub
parent
4e68fb96e2
commit
5b04cc657f
@@ -124,13 +124,20 @@ trust_level = "trusted"
|
||||
&repo_root,
|
||||
&env,
|
||||
&None,
|
||||
codex_utils_pty::TerminalSize::default(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let mut output = Vec::new();
|
||||
let mut output_rx = spawned.output_rx;
|
||||
let mut exit_rx = spawned.exit_rx;
|
||||
let writer_tx = spawned.session.writer_sender();
|
||||
let codex_utils_pty::SpawnedProcess {
|
||||
session,
|
||||
stdout_rx,
|
||||
stderr_rx,
|
||||
exit_rx,
|
||||
} = spawned;
|
||||
let mut output_rx = codex_utils_pty::combine_output_receivers(stdout_rx, stderr_rx);
|
||||
let mut exit_rx = exit_rx;
|
||||
let writer_tx = session.writer_sender();
|
||||
let interrupt_writer = writer_tx.clone();
|
||||
let interrupt_task = tokio::spawn(async move {
|
||||
sleep(Duration::from_secs(2)).await;
|
||||
@@ -165,7 +172,7 @@ trust_level = "trusted"
|
||||
Ok(Ok(code)) => code,
|
||||
Ok(Err(err)) => return Err(err.into()),
|
||||
Err(_) => {
|
||||
spawned.session.terminate();
|
||||
session.terminate();
|
||||
anyhow::bail!("timed out waiting for codex resume to exit");
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user