feat(tui): dynamic status indicator for Execute vs Streaming states#122
feat(tui): dynamic status indicator for Execute vs Streaming states#122
Conversation
Add distinct status indicators for different streaming phases: - 'Execute' when request is pending (waiting for first token) - 'Streaming..' when actively receiving tokens from the LLM This provides clearer feedback to users about the current state of their request. Previously, both states showed 'Working' which didn't distinguish between waiting for a response and actively streaming one. Changes: - Add is_actively_streaming field to StreamingState - Update status_header() to show different text based on streaming phase - Mark is_actively_streaming = true when first delta arrives
Greptile OverviewGreptile SummaryThis PR adds a new Main thing to validate is that Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| src/cortex-tui/src/app/streaming.rs | Adds is_actively_streaming flag to StreamingState, resets it on start/stop, and exposes start_active_streaming() helper. |
| src/cortex-tui/src/runner/event_loop/streaming.rs | Marks start_active_streaming() on every StreamEvent::Delta; needs guarding to avoid incorrectly switching to Streaming on empty/non-content deltas. |
| src/cortex-tui/src/views/minimal_session/view.rs | Updates status header to show Execute vs Streaming.. based on new is_actively_streaming flag. |
Sequence Diagram
sequenceDiagram
participant U as User
participant L as EventLoop
participant S as StreamingState
participant V as MinimalSessionView
participant P as LLM Provider
U->>L: "Submit prompt"
L->>S: "start_streaming()"
V-->>U: "Status shows Execute"
L->>P: "Begin provider stream"
P-->>L: "Delta arrives"
L->>S: "start_active_streaming()"
V-->>U: "Status shows Streaming.."
P-->>L: "Done"
L->>S: "stop_streaming()"
V-->>U: "Status shows Idle"
| match event { | ||
| StreamEvent::Delta(delta) => { | ||
| self.stream_controller.append_text(&delta); | ||
| // Mark that we are now actively receiving tokens (transition from Execute to Streaming..) |
There was a problem hiding this comment.
Active-streaming flips too early
start_active_streaming() is called on every StreamEvent::Delta, but Delta can be an empty/whitespace keepalive (or other non-user-visible chunk). In that case the UI will switch from Execute to Streaming.. even though the user still hasn’t received the first token. Consider guarding this with something like if !delta.is_empty() / if delta.chars().any(|c| !c.is_whitespace()) (or using a dedicated “first content token received” event/flag from the streaming layer).
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cortex-tui/src/runner/event_loop/streaming.rs
Line: 305:308
Comment:
**Active-streaming flips too early**
`start_active_streaming()` is called on every `StreamEvent::Delta`, but `Delta` can be an empty/whitespace keepalive (or other non-user-visible chunk). In that case the UI will switch from `Execute` to `Streaming..` even though the user still hasn’t received the first token. Consider guarding this with something like `if !delta.is_empty()` / `if delta.chars().any(|c| !c.is_whitespace())` (or using a dedicated “first content token received” event/flag from the streaming layer).
How can I resolve this? If you propose a fix, please make it concise.
Summary
Add distinct status indicators for different streaming phases:
Motivation
Previously, both states showed 'Working' which didn't distinguish between waiting for a response and actively streaming one. This provides clearer feedback to users about the current state of their request.
Changes
is_actively_streamingfield toStreamingStatestatus_header()to show different text based on streaming phaseis_actively_streaming = truewhen first delta arrivesTesting