brain: Focus commit metadata initially
72c27cfc88c553415319421f4588aac965020f78
Keep each newly opened diff at the top with no selected hunk. Explicit hunk navigation establishes the first hunk focus. Assisted-by: Codex:gpt-5.6
1 parent
4f69c52d
crates/brain/src/session.rs
+0 -13
| 132 | 132 | error: None, |
|
| 133 | 133 | }; |
|
| 134 | 134 | session.current()?; |
|
| 135 | 135 | session.reconcile_reviews()?; |
|
| 136 | 136 | session.activate()?; |
|
| 137 | - | session.focus_initial_hunk(viewer_area(session.terminal.area()))?; |
|
| 138 | 137 | session.redraw()?; |
|
| 139 | 138 | ||
| 140 | 139 | while let Ok(event) = events_rx.recv() { |
|
| 141 | 140 | let mut redraw = false; |
|
| 142 | 141 | let mut next = Some(event); |
| 358 | 357 | if newly_loaded { |
|
| 359 | 358 | // Project exact acceptance onto the freshly decoded hunks. |
|
| 360 | 359 | self.reconcile_reviews()?; |
|
| 361 | 360 | } |
|
| 362 | 361 | self.activate()?; |
|
| 363 | - | if newly_loaded { |
|
| 364 | - | self.focus_initial_hunk(viewer_area(self.terminal.area()))?; |
|
| 365 | - | } |
|
| 366 | 362 | ||
| 367 | 363 | Ok(()) |
|
| 368 | 364 | } |
|
| 369 | 365 | ||
| 370 | 366 | /// Routes one key while the commit-list tab is open. |
| 780 | 776 | self.restart_highlighter()?; |
|
| 781 | 777 | ||
| 782 | 778 | Ok(()) |
|
| 783 | 779 | } |
|
| 784 | 780 | ||
| 785 | - | /// Focuses the first visible hunk when a commit has no restored focus. |
|
| 786 | - | fn focus_initial_hunk(&mut self, area: Rect) -> Result<(), Error> { |
|
| 787 | - | let loaded = self.current()?; |
|
| 788 | - | if loaded.viewer.state().focus.is_none() { |
|
| 789 | - | loaded.viewer.apply(DiffAction::NextHunk, area); |
|
| 790 | - | } |
|
| 791 | - | Ok(()) |
|
| 792 | - | } |
|
| 793 | - | ||
| 794 | 781 | /// Rebuilds the current commit's files to match accepted-hunk visibility. |
|
| 795 | 782 | /// |
|
| 796 | 783 | /// The original decoded files are kept in `CommitReview::files`; the viewer |
|
| 797 | 784 | /// receives a filtered copy when accepted hunks are hidden. |
|
| 798 | 785 | fn refresh_visibility(&mut self) -> Result<(), Error> { |