feat(tui): display Execute tool command and streaming output#117
Open
feat(tui): display Execute tool command and streaming output#117
Conversation
- Wire AppEvent::ToolProgress to live_output buffer for real-time display - Display command being executed (e.g., '$ cargo build') in tool call header - Show up to 3 lines of real-time streaming output during command execution - Clear live output when command completes, replaced by result summary - Handle both string and array formats for command arguments - Add tests for live_output buffer management and command format handling The Execute tool now shows: 1. The command being run as a header (e.g., '$ cargo build --release') 2. Up to 3 lines of real-time output during execution 3. Result summary when command completes
Greptile OverviewGreptile SummaryThis PR successfully wires up streaming command output from the Execute tool to the TUI display, utilizing existing infrastructure ( Key Changes:
The implementation is clean and straightforward - it connects existing components without introducing new architectural patterns. All three modified files have focused, well-tested changes. Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| src/cortex-tui/src/runner/event_loop/input.rs | Forwards streaming output chunks to tool call display buffer by splitting into lines and filtering empty ones |
| src/cortex-tui/src/app/methods.rs | Clears live output buffer when tool completes to prevent stale streaming output from persisting |
| src/cortex-tui/src/views/tool_call.rs | Enhanced command formatting to support both string and array formats with comprehensive test coverage |
Sequence Diagram
sequenceDiagram
participant Backend as Execute Tool
participant EventAdapter as Event Adapter
participant EventLoop as Event Loop
participant AppState as App State
participant ToolDisplay as Tool Call Display
participant UI as TUI Renderer
Note over Backend,UI: Tool Execution Flow with Streaming Output
Backend->>EventAdapter: ExecCommandOutputDeltaEvent<br/>(call_id, base64 chunk)
EventAdapter->>EventAdapter: decode_output_chunk()
EventAdapter->>EventLoop: AppEvent::ToolProgress<br/>(name=call_id, status=chunk)
EventLoop->>EventLoop: Split status by lines
loop For each non-empty line
EventLoop->>AppState: append_tool_output(call_id, line)
AppState->>ToolDisplay: append_output(line)
ToolDisplay->>ToolDisplay: Push to live_output buffer<br/>(keep last 3 lines only)
end
UI->>ToolDisplay: Read live_output
UI->>UI: Render streaming output<br/>(if status == Running)
Note over Backend,UI: Tool Completion Flow
Backend->>EventLoop: Tool completion event
EventLoop->>AppState: update_tool_result(call_id, ...)
AppState->>ToolDisplay: clear_live_output()
ToolDisplay->>ToolDisplay: Clear live_output buffer
AppState->>ToolDisplay: set_result(ToolResultDisplay)
UI->>ToolDisplay: Read result summary
UI->>UI: Render completion summary
…parate lines - Show command on dedicated line with 8-space indentation (2x tabs) for Execute tool - Display streaming output lines below command with consistent 8-space indentation - Keep command visible while output streams in real-time - Better visual structure for Execute tool execution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances the Execute tool display in the TUI to show:
Changes
src/cortex-tui/src/runner/event_loop/input.rsAppEvent::ToolProgresshandler to forward output chunks to the tool call'slive_outputbuffersrc/cortex-tui/src/app/methods.rsclear_live_output()inupdate_tool_result()to clear streaming output when tool completessrc/cortex-tui/src/views/tool_call.rsformat_tool_summary()to handle both string and array formats for command argumentslive_outputbuffer management (append_output,clear_live_output)Testing
test_append_output_keeps_last_3_lines: Verifies buffer keeps only last 3 linestest_clear_live_output: Verifies buffer is properly clearedtest_format_tool_summary_execute_array: Verifies array command format handlingVisual Example
Before:
After:
The infrastructure for this feature (ToolCallDisplay.live_output, append_output(), rendering logic) already existed - this PR wires up the streaming output from command execution to the UI buffer.