brain: Hide hunk count at completion
ad9387a4b5e01ab1a3d03dc07ac8fad409277311
Completed commits showed a hunk-count suffix after 100%, which added irrelevant detail to the final state. Render only the percentage for accepted commits while keeping the count for other review states. Assisted-by: Codex:gpt-5.6-sol
1 parent
95942f2d
crates/brain/src/session/status.rs
+26 -18
| 485 | 485 | CommitReviewState::Pending => Label::from_char(PENDING_MARK).fg(colors::fixed::MUTED), |
|
| 486 | 486 | }; |
|
| 487 | 487 | let progress = Line::new(state) |
|
| 488 | 488 | .item(Label::space()) |
|
| 489 | 489 | .item(Label::new(&format!("{percent}%")).fg(hunk_color)) |
|
| 490 | - | .item(Label::new("/").fg(colors::fixed::MUTED)) |
|
| 491 | - | .item( |
|
| 492 | - | Label::new(&format!("{:<HISTORY_HUNK_COUNT_WIDTH$}", slot.total_hunks)) |
|
| 493 | - | .fg(colors::fixed::MUTED), |
|
| 494 | - | ) |
|
| 495 | 490 | .style(row_style); |
|
| 491 | + | let progress = if matches!(slot.state, CommitReviewState::Accepted) { |
|
| 492 | + | progress |
|
| 493 | + | } else { |
|
| 494 | + | progress |
|
| 495 | + | .item(Label::new("/").fg(colors::fixed::MUTED)) |
|
| 496 | + | .item( |
|
| 497 | + | Label::new(&format!("{:<HISTORY_HUNK_COUNT_WIDTH$}", slot.total_hunks)) |
|
| 498 | + | .fg(colors::fixed::MUTED), |
|
| 499 | + | ) |
|
| 500 | + | }; |
|
| 496 | 501 | let comments = slot |
|
| 497 | 502 | .loaded |
|
| 498 | 503 | .as_ref() |
|
| 499 | 504 | .map_or(slot.comment_count, |loaded| loaded.comments.len()); |
|
| 500 | 505 | [ |
| 951 | 956 | DiffPalette::default(), |
|
| 952 | 957 | now as u64, |
|
| 953 | 958 | stats.insertions + stats.deletions, |
|
| 954 | 959 | 8, |
|
| 955 | 960 | ); |
|
| 956 | - | assert!( |
|
| 957 | - | progress |
|
| 958 | - | .to_string() |
|
| 959 | - | .contains(&format!("{expected_percent}%/2")) |
|
| 960 | - | ); |
|
| 961 | + | let rendered = progress.to_string(); |
|
| 962 | + | if matches!(state, CommitReviewState::Accepted) { |
|
| 963 | + | assert_eq!(rendered, format!("{REVIEWED_MARK} {expected_percent}%")); |
|
| 964 | + | } else { |
|
| 965 | + | assert!(rendered.contains(&format!("{expected_percent}%/2"))); |
|
| 966 | + | } |
|
| 961 | 967 | let mut buffer = Buffer::empty(Rect::new(0, 0, 16, 1)); |
|
| 962 | 968 | progress.render(buffer.area(), &mut buffer); |
|
| 963 | 969 | let slash_col = 2 + expected_percent.to_string().len() + 1; |
|
| 964 | 970 | ||
| 965 | 971 | let icon_color = match (state, accepted_lines) { |
| 976 | 982 | ); |
|
| 977 | 983 | assert_eq!( |
|
| 978 | 984 | buffer.get(2, 0).unwrap().style(), |
|
| 979 | 985 | Style::default().fg(expected_color) |
|
| 980 | 986 | ); |
|
| 981 | - | assert_eq!( |
|
| 982 | - | buffer.get(slash_col, 0).unwrap().style(), |
|
| 983 | - | Style::default().fg(colors::fixed::MUTED) |
|
| 984 | - | ); |
|
| 985 | - | assert_eq!( |
|
| 986 | - | buffer.get(slash_col + 1, 0).unwrap().style(), |
|
| 987 | - | Style::default().fg(colors::fixed::MUTED) |
|
| 988 | - | ); |
|
| 987 | + | if !matches!(state, CommitReviewState::Accepted) { |
|
| 988 | + | assert_eq!( |
|
| 989 | + | buffer.get(slash_col, 0).unwrap().style(), |
|
| 990 | + | Style::default().fg(colors::fixed::MUTED) |
|
| 991 | + | ); |
|
| 992 | + | assert_eq!( |
|
| 993 | + | buffer.get(slash_col + 1, 0).unwrap().style(), |
|
| 994 | + | Style::default().fg(colors::fixed::MUTED) |
|
| 995 | + | ); |
|
| 996 | + | } |
|
| 989 | 997 | } |
|
| 990 | 998 | } |
|
| 991 | 999 | ||
| 992 | 1000 | #[test] |
|
| 993 | 1001 | fn history_diffstat_scales_against_largest_commit() { |