diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-03-28 00:32:35 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-03-28 00:32:35 +0300 |
| commit | f8c4d6a5f1bd4bcaee43ba3e1373465cd960cdc3 (patch) | |
| tree | 10e9d52f05b476f83a3ee88a87a7c8f7aca9eca6 /src/app | |
| parent | 787786c62009f6c27a0091b61017ae5ad5c95c0e (diff) | |
feat: add per-agent sound overrides
Diffstat (limited to 'src/app')
| -rw-r--r-- | src/app/actions.rs | 11 | ||||
| -rw-r--r-- | src/app/input.rs | 12 | ||||
| -rw-r--r-- | src/app/mod.rs | 2 | ||||
| -rw-r--r-- | src/app/state.rs | 9 |
4 files changed, 17 insertions, 17 deletions
diff --git a/src/app/actions.rs b/src/app/actions.rs index c73ba646..98159fcc 100644 --- a/src/app/actions.rs +++ b/src/app/actions.rs @@ -62,7 +62,8 @@ impl AppState { pub fn resize_pane(&mut self, direction: NavDirection) { if let Some(first) = self.view.pane_infos.first() { let area = self - .view.pane_infos + .view + .pane_infos .iter() .fold(first.rect, |acc, p| acc.union(p.rect)); if let Some(ws) = self.active.and_then(|i| self.workspaces.get_mut(i)) { @@ -168,7 +169,7 @@ impl AppState { } // Sound notifications for background state changes - if self.sound && !is_active_ws && state != prev_state { + if self.sound.allows(agent) && !is_active_ws && state != prev_state { match state { AgentState::Idle if prev_state != AgentState::Idle => { crate::sound::play(crate::sound::Sound::Done); @@ -390,7 +391,11 @@ mod tests { let bg_pane_id = *state.workspaces[1].panes.keys().next().unwrap(); // First set it to Busy - state.workspaces[1].panes.get_mut(&bg_pane_id).unwrap().state = AgentState::Busy; + state.workspaces[1] + .panes + .get_mut(&bg_pane_id) + .unwrap() + .state = AgentState::Busy; // Now transition to Idle while in background state.handle_app_event(AppEvent::StateChanged { diff --git a/src/app/input.rs b/src/app/input.rs index b9a52bda..c91722f7 100644 --- a/src/app/input.rs +++ b/src/app/input.rs @@ -373,12 +373,7 @@ impl AppState { mouse.row - info.inner_rect.y, mouse.column - info.inner_rect.x, ); - self.selection = Some(Selection::anchor( - info.id, - row, - col, - info.inner_rect, - )); + self.selection = Some(Selection::anchor(info.id, row, col, info.inner_rect)); if let Some(ws) = self.active.and_then(|i| self.workspaces.get_mut(i)) { if ws.layout.focused() != info.id { @@ -434,10 +429,7 @@ impl AppState { if self.drag.take().is_some() { // Drag ended } else { - let was_click = self - .selection - .as_ref() - .is_some_and(|s| s.was_just_click()); + let was_click = self.selection.as_ref().is_some_and(|s| s.was_just_click()); if was_click { self.selection = None; } else { diff --git a/src/app/mod.rs b/src/app/mod.rs index 47aaa3da..b3fab4a9 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -85,7 +85,7 @@ impl App { sidebar_collapsed: false, confirm_close: config.ui.confirm_close, accent: crate::config::parse_color(&config.ui.accent), - sound: config.ui.sound, + sound: config.ui.sound.clone(), keybinds: config.keybinds(), }; diff --git a/src/app/state.rs b/src/app/state.rs index 440bfc17..92d729e8 100644 --- a/src/app/state.rs +++ b/src/app/state.rs @@ -1,5 +1,5 @@ +use crate::config::{Keybinds, SoundConfig}; use crossterm::event::{KeyCode, KeyModifiers}; -use crate::config::Keybinds; use ratatui::layout::{Direction, Rect}; use ratatui::style::Color; @@ -69,7 +69,7 @@ pub struct AppState { pub sidebar_collapsed: bool, pub confirm_close: bool, pub accent: Color, - pub sound: bool, + pub sound: SoundConfig, pub keybinds: Keybinds, } @@ -120,7 +120,10 @@ impl AppState { sidebar_collapsed: false, confirm_close: true, accent: Color::Cyan, - sound: true, + sound: SoundConfig { + enabled: false, + ..SoundConfig::default() + }, keybinds: Keybinds { split_vertical: (KeyCode::Char('v'), KeyModifiers::empty()), split_horizontal: (KeyCode::Char('-'), KeyModifiers::empty()), |
