Skip to content

utils/pty: add streaming spawn and terminal sizing primitives#13695

Open
euroelessar wants to merge 1 commit intomainfrom
ruslan/pty-and-streaming
Open

utils/pty: add streaming spawn and terminal sizing primitives#13695
euroelessar wants to merge 1 commit intomainfrom
ruslan/pty-and-streaming

Conversation

@euroelessar
Copy link
Contributor

Split stdout and stderr routing into reusable output sinks, expose explicit streaming spawn helpers, and thread terminal sizing through the shared PTY layer.

This keeps the spawn helpers intact so existing callers only need mechanical call-site updates while app-server gains the lower-level primitives it needs for interactive command execution.

@euroelessar euroelessar force-pushed the ruslan/pty-and-streaming branch 2 times, most recently from 7c5bb76 to 6cfc6f8 Compare March 6, 2026 07:13
Split stdout and stderr routing into reusable output sinks, expose explicit streaming spawn helpers, and thread terminal sizing through the shared PTY layer.

This keeps the legacy spawn helpers intact so existing callers only need mechanical call-site updates while app-server gains the lower-level primitives it needs for interactive command execution.
@euroelessar euroelessar force-pushed the ruslan/pty-and-streaming branch from 6cfc6f8 to f59dcaf Compare March 6, 2026 07:58
arg0: &Option<String>,
stdin_mode: PipeStdinMode,
) -> Result<SpawnedProcess> {
output_sink: OutputSink,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does the sink need to be passed in? Why not keep the same design as before where we return the output (even if we split output in two separate streams)

}

#[derive(Clone, Debug)]
pub enum OutputSink {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type feels complicated. Can we have the output always in a separate mode and a helper that creates a merged consumer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, always return two mpsc receivers & have a helper which would spawn a task to merge them & return one broadcast receiver (to maintain behavior of existing call sites)?

writer_tx: StdMutex<Option<mpsc::Sender<Vec<u8>>>>,
output_tx: Option<broadcast::Sender<Vec<u8>>>,
killer: StdMutex<Option<Box<dyn ChildTerminator>>>,
#[allow(dead_code)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did this become dead code?

- `writer_sender()` → `mpsc::Sender<Vec<u8>>` (stdin)
- `output_receiver()` → `broadcast::Receiver<Vec<u8>>` (stdout/stderr merged)
- `resize(TerminalSize)`
- `close_stdin()`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need an explicit close_stdin?

Copy link
Collaborator

@pakrym-oai pakrym-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we've split how pty process work based on whether we want merged or separate output. I don't think we should push this distinction so deep into the process implementation. Instead the process should always operate in split mode and when needed we can combine streams into a merged one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants