fix(tui/agents): only show auto review success after completion

This commit is contained in:
James Peter
2025-12-09 14:46:21 +10:00
parent 746f941cc0
commit 496564ccdf
3 changed files with 145 additions and 53 deletions
+45 -29
View File
@@ -15116,35 +15116,46 @@ impl ChatWidget<'_> {
let mut bullets: Vec<(String, ratatui::style::Style)> = Vec::new();
if matches!(entry.source_kind, Some(AgentSourceKind::AutoReview)) {
let (has_findings, findings_count, summary) =
Self::parse_agent_review_result(entry.result.as_deref());
let mut label = if has_findings {
let plural = if findings_count == 1 { "issue" } else { "issues" };
format!("Auto Review: {findings_count} {plural} found")
} else {
"Auto Review: no issues found".to_string()
};
if label.is_empty() {
label = "Auto Review".to_string();
}
let is_terminal = matches!(
entry.status,
AgentStatus::Completed | AgentStatus::Failed | AgentStatus::Cancelled
);
let color = if has_findings {
ratatui::style::Style::default().fg(crate::colors::warning())
} else {
ratatui::style::Style::default().fg(crate::colors::success())
};
bullets.push((label, color));
if is_terminal {
let (has_findings, findings_count, summary) =
Self::parse_agent_review_result(entry.result.as_deref());
let mut label = if has_findings {
let plural = if findings_count == 1 { "issue" } else { "issues" };
format!("Auto Review: {findings_count} {plural} found")
} else if matches!(entry.status, AgentStatus::Completed) {
"Auto Review: no issues found".to_string()
} else {
String::new()
};
if label.is_empty() {
label = "Auto Review".to_string();
}
if let Some(summary_text) = summary {
for line in summary_text.lines() {
let trimmed = line.trim();
if trimmed.is_empty() {
continue;
if has_findings || matches!(entry.status, AgentStatus::Completed) {
let color = if has_findings {
ratatui::style::Style::default().fg(crate::colors::warning())
} else {
ratatui::style::Style::default().fg(crate::colors::success())
};
bullets.push((label, color));
}
if let Some(summary_text) = summary {
for line in summary_text.lines() {
let trimmed = line.trim();
if trimmed.is_empty() {
continue;
}
bullets.push((
self.truncate_overlay_text(trimmed, 280),
ratatui::style::Style::default().fg(crate::colors::text_dim()),
));
}
bullets.push((
self.truncate_overlay_text(trimmed, 280),
ratatui::style::Style::default().fg(crate::colors::text_dim()),
));
}
}
}
@@ -34151,10 +34162,10 @@ impl ChatWidget<'_> {
// Sidebar list of agents grouped by batch id
let mut items: Vec<ListItem> = Vec::new();
let mut row_entries: Vec<Option<AgentsSidebarEntry>> = Vec::new();
items.push(ListItem::new(Line::from(vec![Span::raw(" ")])));
row_entries.push(None);
let groups = self.agents_terminal.sidebar_groups();
let last_group_idx = groups.len().saturating_sub(1);
for group in self.agents_terminal.sidebar_groups() {
for (group_idx, group) in groups.into_iter().enumerate() {
items.push(ListItem::new(Line::from(vec![
Span::styled(
group.label.clone(),
@@ -34214,6 +34225,11 @@ impl ChatWidget<'_> {
row_entries.push(Some(AgentsSidebarEntry::Agent(agent_id.clone())));
}
}
if group_idx < last_group_idx {
items.push(ListItem::new(Line::from(vec![Span::raw(" ")])));
row_entries.push(None);
}
}
if items.is_empty() {
@@ -6,28 +6,28 @@ expression: "&output"
| Code |
+--------------------------------------------------------------------------------------------+
+ Agents - Ctrl+A to close-------------------------------------------------------------------+
| |
| Docs Sweep + Agent History ---------------------------------------------+ |
| › ★ Overview | Docs Sweep 2 agents | |
| • claude-3-opus | Models: claude-3-opus, gpt-4o | |
| • gpt-4o | | |
| | Context | |
| | Focus on October 2025 product changes | |
| | | |
| | Action History | |
| | | |
| | [MM:SS] claude-3-opus status: Status → Running | |
| | | |
| | [MM:SS] claude-3-opus detail: ... | |
| |
| | | |
| | [MM:SS] gpt-4o status: Status → Pending | |
| | | |
| | [MM:SS] claude-3-opus status: Status → Completed | |
| | | |
| | [MM:SS] claude-3-opus detail: ... | |
| |
| +------------------------------------------------------------+ |
| ↑/↓ Navigate/Scroll →/Enter Focus output ← Back to list Tab Next agent PgUp/PgDn Page |
| |
| Filter 1 All - 2 Running - 3 Failed - 4 Done - 5 Review Sort: ( Recent ▼ ) |
| +----------------------++----------------------------------------------------------------+ |
| |Docs Sweep || Docs Sweep / CLAUDE-3-Opus | |
| |› CLAUDE-3-Opus ✔ || Status: ✔ Completed Model: CLAUDE-3-Opus ID: #docs-sw | |
| | GPT-4o ✖ ||Batch: Batch batchdoc | |
| | || | |
| | ||+ Highlights (h) ▼ --------------------------------------------+| |
| | ||| • Final: ### Highlights - New Auto Drive controls - Faster | |
| | ||| release approvals | |
| | ||+---------------------------------------------------------------| |
| | || | |
| | || Context | |
| | || Focus on October 2025 product changes | |
| | || | |
| | ||+ Action Log (a) ▼ - 5 entries --------------------------------+| |
| | ||| STATUS | |
| | ||| MM:SS Status → Running | |
| | ||| PROGRESS | |
| | ||| MM:SS Collecting release notes | |
| | ||| Reviewing eng updates | |
| | ||| STATUS | |
| | ||| MM:SS Status → Completed | |
| +----------------------++----------------------------------------------------------------+ |
| [↑/↓/←/→] Navigate [1-5] Filter [S] Sort [H/A] Toggle Details [X] Stop [Ctrl+A] |
+--------------------------------------------------------------------------------------------+
@@ -9,6 +9,7 @@
use code_core::protocol::{
AgentInfo,
AgentSourceKind,
AgentMessageDeltaEvent,
AgentMessageEvent,
AgentStatusUpdateEvent,
@@ -1968,6 +1969,81 @@ fn agents_terminal_overlay_full_details() {
insta::assert_snapshot!("agents_terminal_overlay_full_details", &output);
}
#[test]
fn auto_review_highlights_wait_for_completion_before_no_errors() {
let mut harness = ChatWidgetHarness::new();
let mut event_seq = 0;
let mut order_seq = 0;
push_ordered_event(
&mut harness,
&mut event_seq,
&mut order_seq,
EventMsg::AgentStatusUpdate(AgentStatusUpdateEvent {
agents: vec![AgentInfo {
id: "auto-review-agent".into(),
name: "Auto Review".into(),
status: "running".into(),
batch_id: Some("auto-review-batch".into()),
model: Some("code-reviewer".into()),
last_progress: Some("Scanning staged changes".into()),
result: None,
error: None,
elapsed_ms: Some(1_200),
token_count: Some(1_800),
source_kind: Some(AgentSourceKind::AutoReview),
}],
context: Some("Review the current workspace".into()),
task: Some("Auto review".into()),
}),
);
harness.send_key(make_key(KeyCode::Char('a'), KeyModifiers::CONTROL));
let running_frame = normalize_output(render_chat_widget_to_vt100(&mut harness, 96, 26));
assert!(
!running_frame.contains("Auto Review: no issues found"),
"running auto review should not report success",
);
let no_findings = r#"{
"findings": [],
"overall_correctness": "correct",
"overall_explanation": "Clean run",
"overall_confidence_score": 0.72
}"#
.to_string();
push_ordered_event(
&mut harness,
&mut event_seq,
&mut order_seq,
EventMsg::AgentStatusUpdate(AgentStatusUpdateEvent {
agents: vec![AgentInfo {
id: "auto-review-agent".into(),
name: "Auto Review".into(),
status: "completed".into(),
batch_id: Some("auto-review-batch".into()),
model: Some("code-reviewer".into()),
last_progress: Some("Summarizing results".into()),
result: Some(no_findings),
error: None,
elapsed_ms: Some(4_800),
token_count: Some(3_400),
source_kind: Some(AgentSourceKind::AutoReview),
}],
context: Some("Review the current workspace".into()),
task: Some("Auto review".into()),
}),
);
let completed_frame = normalize_output(render_chat_widget_to_vt100(&mut harness, 96, 26));
assert!(
completed_frame.contains("Auto Review: no issues found"),
"completed auto review should surface no-issues label",
);
}
#[test]
fn plan_agent_keeps_single_aggregate_block() {
let mut harness = ChatWidgetHarness::new();