diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-02 01:23:10 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-02 01:23:10 +0300 |
| commit | 45005f1f733a96e3d9e6748577c01ca2c594304b (patch) | |
| tree | 58710dd980f8fa42d8df6f0c04290dc5e23c948d /src/app/actions.rs | |
| parent | 9ae93b125249dead6169bdc505c11e0f43309e40 (diff) | |
fix: mark visible done panes seen on terminal focus
Diffstat (limited to 'src/app/actions.rs')
| -rw-r--r-- | src/app/actions.rs | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/src/app/actions.rs b/src/app/actions.rs index 83e9bec6..0b187fed 100644 --- a/src/app/actions.rs +++ b/src/app/actions.rs @@ -179,6 +179,28 @@ impl AppState { } } + pub(crate) fn mark_active_tab_seen(&mut self) -> bool { + let Some(ws_idx) = self.active else { + return false; + }; + let Some(tab) = self + .workspaces + .get_mut(ws_idx) + .and_then(crate::workspace::Workspace::active_tab_mut) + else { + return false; + }; + + let mut changed = false; + for pane in tab.panes.values_mut() { + if !pane.seen { + pane.seen = true; + changed = true; + } + } + changed + } + pub fn next_workspace(&mut self) { if !self.workspaces.is_empty() { let current = self.active.unwrap_or(self.selected); @@ -591,10 +613,10 @@ impl AppState { return; }; - if is_background_completion_transition(change.previous_state, change.state) - && !suppress_active_tab_notifications - { - pane.seen = false; + if change.state != AgentState::Idle { + pane.seen = true; + } else if is_background_completion_transition(change.previous_state, change.state) { + pane.seen = suppress_active_tab_notifications; } if self.local_sound_playback && self.sound.allows(change.known_agent) { @@ -914,6 +936,27 @@ mod tests { } #[test] + fn active_tab_completion_marks_pane_seen() { + let mut state = app_with_workspaces(&["active"]); + state.active = Some(0); + state.outer_terminal_focus = Some(true); + let pane_id = *state.workspaces[0].panes.keys().next().unwrap(); + let pane = state.workspaces[0].panes.get_mut(&pane_id).unwrap(); + pane.state = AgentState::Working; + pane.seen = false; + + state.handle_app_event(AppEvent::StateChanged { + pane_id, + agent: Some(Agent::Pi), + state: AgentState::Idle, + }); + + let pane = state.workspaces[0].panes.get(&pane_id).unwrap(); + assert_eq!(pane.state, AgentState::Idle); + assert!(pane.seen); + } + + #[test] fn initial_idle_in_background_stays_seen() { let mut state = app_with_workspaces(&["active", "background"]); state.active = Some(0); |
