Skip to content

feat: stream output of executed commands#37

Closed
iamjpotts wants to merge 1 commit intolablup:mainfrom
iamjpotts:jp/execute-streaming
Closed

feat: stream output of executed commands#37
iamjpotts wants to merge 1 commit intolablup:mainfrom
iamjpotts:jp/execute-streaming

Conversation

@iamjpotts
Copy link

Wanted to gauge interest in accepting a PR that would stream the output of a command as it executes, rather than waiting for it to finish before returning its stdout / stderr output.

Useful for watching long running commands, such as for installing packages on a remote server.

Also useful for assessing if a remote command is hung, for example, if it is waiting for user input (which can happen when a dpkg install detects a changed config file and asks you if you want to keep or overwrite it, and you have not used the env vars or arguments to make that choice automatic).

So far this pr only adds two methods on public apis, and adds one test, but does not change the behavior of the cli tool.

Signed-off-by: Joshua Potts <8704475+iamjpotts@users.noreply.github.com>
@cla-assistant
Copy link

cla-assistant bot commented Sep 21, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@cla-assistant
Copy link

cla-assistant bot commented Sep 21, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@inureyes inureyes self-assigned this Oct 14, 2025
@inureyes inureyes added type:enhancement New feature or request feature status:review Under review priority:medium Medium priority issue and removed feature labels Oct 27, 2025
inureyes added a commit that referenced this pull request Oct 29, 2025
This commit implements the core streaming infrastructure for real-time SSH
command output, enabling future interactive UI features while maintaining
full backward compatibility.

## Key Changes

### Core Streaming Infrastructure
- Add `CommandOutput` enum for stdout/stderr streaming events
- Add `CommandOutputBuffer` for internal output collection
- Implement `execute_streaming()` method with tokio channel-based architecture
- Refactor existing `execute()` to use streaming internally (zero breaking changes)

### Public API Addition
- New `connect_and_execute_with_output_streaming()` method in SshClient
- Streaming API respects timeout configuration
- Channel capacity: 100 events with efficient memory usage (~16KB per command)

### Architecture Documentation
- Document streaming design patterns in ARCHITECTURE.md
- Include performance characteristics and memory overhead analysis
- Document backward compatibility guarantees
- Add implementation details for future phases

### Error Handling
- Add `JoinError` variant to tokio_client::Error
- Graceful handling of task join failures
- Silent handling of send errors when receiver is dropped

### Testing
- Add comprehensive streaming integration tests (tests/streaming_test.rs)
- Test stdout/stderr separation and ordering
- Test backward compatibility of refactored execute()
- All existing tests pass without modification (100% compatibility)

## Implementation Details

The streaming implementation uses a producer-consumer pattern:
- Background tokio task collects output chunks via bounded channel
- Zero-copy data transfer using russh's CryptoVec
- Graceful degradation if receiver drops early
- No performance impact on non-streaming usage

## Related Issues
- Implements Phase 1 of #68 (Core Streaming Infrastructure)
- Foundation for Phase 2 (Multi-node executor integration)
- Foundation for Phase 3 (Interactive TUI)
- Based on design concepts from PR #37
inureyes added a commit that referenced this pull request Oct 29, 2025
)

This commit implements the core streaming infrastructure for real-time SSH
command output, enabling future interactive UI features while maintaining
full backward compatibility.

## Key Changes

### Core Streaming Infrastructure
- Add `CommandOutput` enum for stdout/stderr streaming events
- Add `CommandOutputBuffer` for internal output collection
- Implement `execute_streaming()` method with tokio channel-based architecture
- Refactor existing `execute()` to use streaming internally (zero breaking changes)

### Public API Addition
- New `connect_and_execute_with_output_streaming()` method in SshClient
- Streaming API respects timeout configuration
- Channel capacity: 100 events with efficient memory usage (~16KB per command)

### Architecture Documentation
- Document streaming design patterns in ARCHITECTURE.md
- Include performance characteristics and memory overhead analysis
- Document backward compatibility guarantees
- Add implementation details for future phases

### Error Handling
- Add `JoinError` variant to tokio_client::Error
- Graceful handling of task join failures
- Silent handling of send errors when receiver is dropped

### Testing
- Add comprehensive streaming integration tests (tests/streaming_test.rs)
- Test stdout/stderr separation and ordering
- Test backward compatibility of refactored execute()
- All existing tests pass without modification (100% compatibility)

## Implementation Details

The streaming implementation uses a producer-consumer pattern:
- Background tokio task collects output chunks via bounded channel
- Zero-copy data transfer using russh's CryptoVec
- Graceful degradation if receiver drops early
- No performance impact on non-streaming usage

## Related Issues
- Implements Phase 1 of #68 (Core Streaming Infrastructure)
- Foundation for Phase 2 (Multi-node executor integration)
- Foundation for Phase 3 (Interactive TUI)
- Based on design concepts from PR #37
@inureyes
Copy link
Member

@iamjpotts CLA is not signed yet, therefore I advanced the topic to the full multi-terminal implementation issue and covered this topic on #69

@inureyes inureyes closed this Oct 29, 2025
@inureyes inureyes removed the status:review Under review label Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:medium Medium priority issue type:enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants