Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/tui/src/tui/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1595,13 +1595,18 @@ pub fn subagent_panel_lines(
if lines.len() >= max_rows {
break;
}
let is_completed = !matches!(row.status.as_str(), "running");
let (marker, color) = agent_status_marker(row.status.as_str());
let label = format!("{marker} {} {}", row.role, row.name);
lines.push(Line::from(Span::styled(
truncate_line_to_width(&label, content_width.max(1)),
Style::default().fg(color),
)));

if is_completed {
continue;
}
Comment on lines +1598 to +1608
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation calls row.status.as_str() twice and uses the matches! macro for a simple string comparison. This can be refactored for better readability and minor efficiency by storing the status slice and using a direct inequality check. Additionally, the variable is_completed is only used once and can be replaced by a direct check on the status to make the code more concise. Note that while the PR description uses the term 'completed', checking for != "running" correctly covers all terminal states (done, failed, interrupted, canceled) as intended.

Suggested change
let is_completed = !matches!(row.status.as_str(), "running");
let (marker, color) = agent_status_marker(row.status.as_str());
let label = format!("{marker} {} {}", row.role, row.name);
lines.push(Line::from(Span::styled(
truncate_line_to_width(&label, content_width.max(1)),
Style::default().fg(color),
)));
if is_completed {
continue;
}
let status = row.status.as_str();
let (marker, color) = agent_status_marker(status);
let label = format!("{marker} {} {}", row.role, row.name);
lines.push(Line::from(Span::styled(
truncate_line_to_width(&label, content_width.max(1)),
Style::default().fg(color),
)));
if status != "running" {
continue;
}


if lines.len() >= max_rows {
break;
}
Expand Down