Skip to content

Commit a936194

Browse files
authored
feat(tui): dynamic status indicator for Execute vs Streaming states (#122)
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
1 parent 636985c commit a936194

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/cortex-tui/src/app/streaming.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ use std::time::Instant;
44
#[derive(Debug, Clone, Default)]
55
pub struct StreamingState {
66
pub is_streaming: bool,
7+
/// Whether we are actively receiving tokens from the LLM.
8+
/// False when waiting for first token (processing), true when streaming.
9+
pub is_actively_streaming: bool,
710
pub current_tool: Option<String>,
811
pub tool_status: Option<String>,
912
pub thinking: bool,
@@ -29,6 +32,7 @@ impl StreamingState {
2932
/// If false, preserves existing timer (use for tool continuations).
3033
pub fn start(&mut self, tool: Option<String>, reset_timer: bool) {
3134
self.is_streaming = true;
35+
self.is_actively_streaming = false; // Not yet receiving tokens
3236
self.thinking = true;
3337
self.current_tool = tool;
3438
self.task_started_at = Some(Instant::now());
@@ -39,6 +43,12 @@ impl StreamingState {
3943
}
4044
}
4145

46+
/// Mark that we started actively receiving tokens from the LLM.
47+
/// This transitions from "Execute" (waiting) to "Streaming.." state.
48+
pub fn start_active_streaming(&mut self) {
49+
self.is_actively_streaming = true;
50+
}
51+
4252
/// Get the elapsed seconds since the task started
4353
pub fn elapsed_seconds(&self) -> u64 {
4454
self.task_started_at
@@ -57,6 +67,7 @@ impl StreamingState {
5767
/// Reset streaming state when task completes
5868
pub fn stop(&mut self) {
5969
self.is_streaming = false;
70+
self.is_actively_streaming = false;
6071
self.thinking = false;
6172
self.current_tool = None;
6273
self.tool_status = None;

src/cortex-tui/src/runner/event_loop/streaming.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ impl EventLoop {
305305
match event {
306306
StreamEvent::Delta(delta) => {
307307
self.stream_controller.append_text(&delta);
308+
// Mark that we are now actively receiving tokens (transition from Execute to Streaming..)
309+
self.app_state.streaming.start_active_streaming();
308310
// Track text for interleaved display
309311
self.app_state.append_streaming_text(&delta);
310312
// Keep scroll at bottom if pinned (user hasn't scrolled up)

src/cortex-tui/src/views/minimal_session/view.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,12 @@ impl<'a> MinimalSessionView<'a> {
402402
} else if self.app_state.streaming.thinking && self.app_state.thinking_budget.is_some() {
403403
"Thinking".to_string()
404404
} else if self.app_state.streaming.is_streaming {
405-
"Working".to_string()
405+
// Differentiate between waiting for first token and actively streaming
406+
if self.app_state.streaming.is_actively_streaming {
407+
"Streaming..".to_string()
408+
} else {
409+
"Execute".to_string()
410+
}
406411
} else {
407412
"Idle".to_string()
408413
}

0 commit comments

Comments
 (0)