diff --git a/tui/src/app.rs b/tui/src/app.rs index 440ff381e..7a472f88c 100644 --- a/tui/src/app.rs +++ b/tui/src/app.rs @@ -64,6 +64,8 @@ pub struct AppState { pub collapsed_messages_scroll: usize, pub collapsed_messages_selected: usize, pub has_user_messages: bool, + /// Count of assistant message rounds/steps in the current session + pub assistant_message_count: usize, /// Per-message rendered line cache for efficient incremental rendering pub per_message_cache: PerMessageCache, /// Assembled lines cache (the final combined output of all message lines) @@ -384,6 +386,7 @@ impl AppState { mouse_capture_enabled: false, // Will be set based on terminal detection in event_loop loading_manager: LoadingStateManager::new(), has_user_messages: false, + assistant_message_count: 0, message_tool_calls: None, approval_bar: ApprovalBar::new(), message_approved_tools: Vec::new(), diff --git a/tui/src/services/handlers/message.rs b/tui/src/services/handlers/message.rs index 36d61d524..6b00438c1 100644 --- a/tui/src/services/handlers/message.rs +++ b/tui/src/services/handlers/message.rs @@ -63,6 +63,7 @@ pub fn handle_stream_message( state .messages .push(Message::assistant(Some(id), s.clone(), None)); + state.assistant_message_count += 1; state.text_area.set_text(""); if !was_at_bottom { diff --git a/tui/src/services/handlers/misc.rs b/tui/src/services/handlers/misc.rs index 615894319..ef52a92f8 100644 --- a/tui/src/services/handlers/misc.rs +++ b/tui/src/services/handlers/misc.rs @@ -304,6 +304,7 @@ pub fn handle_end_loading_operation(state: &mut AppState, operation: crate::app: /// Handle assistant message event pub fn handle_assistant_message(state: &mut AppState, msg: String) { state.messages.push(Message::assistant(None, msg, None)); + state.assistant_message_count += 1; // Invalidate cache since messages changed crate::services::message::invalidate_message_lines_cache(state); diff --git a/tui/src/services/side_panel.rs b/tui/src/services/side_panel.rs index 0d523613f..0fb7a0a7d 100644 --- a/tui/src/services/side_panel.rs +++ b/tui/src/services/side_panel.rs @@ -70,7 +70,7 @@ pub fn render_side_panel(f: &mut Frame, state: &mut AppState, area: Rect) { let context_height = if context_collapsed { collapsed_height } else { - 5 // Header + Tokens + Model + Provider + 6 // Header + Tokens + Model + Provider + Steps }; // Billing section is hidden when billing_info is None (local mode) @@ -193,6 +193,14 @@ fn render_context_section(f: &mut Frame, state: &AppState, area: Rect, collapsed .unwrap_or_default(); let max_tokens = context_info.max_tokens as u32; + // Steps - show assistant message count (rounds/steps) + let steps_value = if state.assistant_message_count == 0 { + "N/A".to_string() + } else { + state.assistant_message_count.to_string() + }; + lines.push(make_row("Steps", steps_value, Color::White)); + // Show N/A when no content yet (tokens == 0) if tokens == 0 { lines.push(make_row("Tokens", "N/A".to_string(), Color::DarkGray));