brain: Hide completed commit diff summary
72285fee5adb1cd951d62cb65b3509e6d8214a73
1 parent
0fbd41af
crates/brain/src/session/status.rs
+36 -7
| 219 | 219 | }; |
|
| 220 | 220 | let full_file_fg = match self.visibility.file { |
|
| 221 | 221 | FileVisibility::Context => FOOTER_FG, |
|
| 222 | 222 | FileVisibility::Full => FULL_FILE_MODE_FG, |
|
| 223 | 223 | }; |
|
| 224 | - | let files = file_count(self.stats.files_changed); |
|
| 224 | + | let mut status = Line::blank().extend(progress_bar(self.progress, self.palette, FOOTER_FG)); |
|
| 225 | + | if !matches!(self.context, StatusContext::Commit { .. }) || !self.progress.is_complete() { |
|
| 226 | + | status = status |
|
| 227 | + | .item(Label::space()) |
|
| 228 | + | .extend(diffstat(self.stats.into(), self.palette)) |
|
| 229 | + | .item(Label::new(FOOTER_SEPARATOR).fg(FOOTER_FG)) |
|
| 230 | + | .item(Label::new(&file_count(self.stats.files_changed)).fg(FOOTER_VALUE_FG)); |
|
| 231 | + | } |
|
| 225 | 232 | ||
| 226 | - | Line::blank() |
|
| 227 | - | .extend(progress_bar(self.progress, self.palette, FOOTER_FG)) |
|
| 228 | - | .item(Label::space()) |
|
| 229 | - | .extend(diffstat(self.stats.into(), self.palette)) |
|
| 230 | - | .item(Label::new(FOOTER_SEPARATOR).fg(FOOTER_FG)) |
|
| 231 | - | .item(Label::new(&files).fg(FOOTER_VALUE_FG)) |
|
| 233 | + | status |
|
| 232 | 234 | .item(Label::new(FOOTER_SEPARATOR).fg(FOOTER_FG)) |
|
| 233 | 235 | .item(Label::new(APPROVED_HUNKS_MODE_ICON).fg(accepted_fg)) |
|
| 234 | 236 | .item(Label::space()) |
|
| 235 | 237 | .item(Label::new(FULL_FILE_MODE_ICON).fg(full_file_fg)) |
|
| 236 | 238 | .style(Style::default().bg(FOOTER_BG)) |
| 668 | 670 | assert_eq!(buffer.get(78, 0).unwrap().glyph(), FULL_FILE_MODE_ICON); |
|
| 669 | 671 | assert_eq!(buffer.get(79, 0).unwrap().glyph(), " "); |
|
| 670 | 672 | assert_eq!(buffer.get(79, 0).unwrap().style().bg_color(), FOOTER_BG); |
|
| 671 | 673 | } |
|
| 672 | 674 | ||
| 675 | + | #[test] |
|
| 676 | + | fn completed_commit_status_hides_diff_summary() { |
|
| 677 | + | let mut status = Status { |
|
| 678 | + | mode: "commit", |
|
| 679 | + | context: StatusContext::Commit { |
|
| 680 | + | short: "1234567".to_owned(), |
|
| 681 | + | summary: "summary".to_owned(), |
|
| 682 | + | }, |
|
| 683 | + | progress: ReviewProgress { |
|
| 684 | + | accepted: 5, |
|
| 685 | + | total: 5, |
|
| 686 | + | }, |
|
| 687 | + | stats: DiffStat::default(), |
|
| 688 | + | palette: DiffPalette::default(), |
|
| 689 | + | visibility: Visibility::default(), |
|
| 690 | + | error: None, |
|
| 691 | + | }; |
|
| 692 | + | let mut buffer = Buffer::empty(Rect::new(0, 0, 80, 1)); |
|
| 693 | + | ||
| 694 | + | status.render(buffer.area(), &mut buffer); |
|
| 695 | + | let rendered = (0..buffer.area().cols) |
|
| 696 | + | .map(|x| buffer.get(x, 0).unwrap().glyph()) |
|
| 697 | + | .collect::<String>(); |
|
| 698 | + | ||
| 699 | + | assert!(rendered.ends_with("━━━━━━━━ · ✔ ↕ ")); |
|
| 700 | + | } |
|
| 701 | + | ||
| 673 | 702 | #[test] |
|
| 674 | 703 | fn commit_row_reserves_stats_suffix_before_truncating_metadata() { |
|
| 675 | 704 | let now = 2_000_000_000; |
|
| 676 | 705 | let recency = CommitTime { |
|
| 677 | 706 | seconds: now - 3_600, |