From 81f355fadac7d0d45b077dfc28f9f679add6bbb6 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Tue, 28 Jul 2026 14:56:51 +0300 Subject: perf: replace agent spinners with static status marks --- src/app/mod.rs | 9 --------- src/app/runtime.rs | 46 ++++++---------------------------------------- src/app/state.rs | 3 --- 3 files changed, 6 insertions(+), 52 deletions(-) (limited to 'src/app') diff --git a/src/app/mod.rs b/src/app/mod.rs index b2aa4ff2..c8c8113a 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -33,9 +33,6 @@ use std::sync::Arc; use std::time::{Duration, Instant}; const MIN_RENDER_INTERVAL: Duration = Duration::from_millis(16); -pub(crate) const ANIMATION_INTERVAL: Duration = Duration::from_millis(16); -pub(crate) const HEADLESS_ANIMATION_INTERVAL: Duration = Duration::from_millis(128); -pub(crate) const HEADLESS_ANIMATION_TICK_STEP: u32 = 8; pub(crate) const SELECTION_AUTOSCROLL_INTERVAL: Duration = Duration::from_millis(30); const RESIZE_POLL_INTERVAL: Duration = Duration::from_millis(100); const GIT_REMOTE_STATUS_REFRESH_INTERVAL: Duration = Duration::from_millis(1500); @@ -125,7 +122,6 @@ pub struct App { pub(crate) last_pane_click: Option, pub(crate) pending_url_click_sources: HashSet, pub(crate) next_resize_poll: Instant, - pub(crate) next_animation_tick: Option, pub(crate) next_auto_update_check: Option, pub(crate) next_agent_manifest_update_check: Option, pub(crate) update_version_check_enabled: bool, @@ -664,7 +660,6 @@ impl App { local_sound_playback: true, toast_config: config.ui.toast.clone(), keybinds: config.keybinds(), - spinner_tick: 0, palette: theme_palette, theme_name, theme_runtime, @@ -753,7 +748,6 @@ impl App { last_pane_click: None, pending_url_click_sources: HashSet::new(), next_resize_poll: Instant::now() + RESIZE_POLL_INTERVAL, - next_animation_tick: None, next_auto_update_check: version_check_enabled .then_some(Instant::now() + AUTO_UPDATE_CHECK_INTERVAL), next_agent_manifest_update_check: manifest_check_enabled @@ -1046,7 +1040,6 @@ impl App { } let now = Instant::now(); - self.sync_animation_timer(now); self.sync_host_mouse_capture(&mut host_mouse_capture_active)?; self.sync_host_keyboard_report_all(&mut host_keyboard_report_all_active)?; @@ -4672,7 +4665,6 @@ mod tests { app.next_resize_poll = now - Duration::from_millis(1); app.config_diagnostic_deadline = None; app.toast_deadline = None; - app.next_animation_tick = None; app.next_auto_update_check = None; app.session_save_deadline = None; app.state.workspaces.clear(); @@ -4764,7 +4756,6 @@ mod tests { let now = Instant::now(); app.next_resize_poll = now + Duration::from_millis(300); app.selection_autoscroll_deadline = Some(now + Duration::from_millis(5)); - app.next_animation_tick = Some(now + Duration::from_millis(100)); app.session_save_deadline = Some(now + Duration::from_millis(200)); assert_eq!( app.next_loop_deadline(now, false), diff --git a/src/app/runtime.rs b/src/app/runtime.rs index bd7830b9..ef0a452d 100644 --- a/src/app/runtime.rs +++ b/src/app/runtime.rs @@ -1,11 +1,13 @@ -use std::time::{Duration, Instant}; +use std::time::Instant; + +#[cfg(test)] +use std::time::Duration; use crossterm::terminal; use super::{ - background_update_check_enabled, pressed_key_identity, App, ANIMATION_INTERVAL, - AUTO_UPDATE_CHECK_INTERVAL, MIN_RENDER_INTERVAL, RESIZE_POLL_INTERVAL, - SELECTION_AUTOSCROLL_INTERVAL, + background_update_check_enabled, pressed_key_identity, App, AUTO_UPDATE_CHECK_INTERVAL, + MIN_RENDER_INTERVAL, RESIZE_POLL_INTERVAL, SELECTION_AUTOSCROLL_INTERVAL, }; fn retain_custom_command_after_wait( pid: u32, @@ -224,8 +226,6 @@ impl App { let mut changed = false; let mut resized = false; - self.sync_animation_timer(now); - if now >= self.next_resize_poll { resized = self.handle_resize_poll(); changed |= resized; @@ -286,15 +286,6 @@ impl App { changed = true; } - if self - .next_animation_tick - .is_some_and(|deadline| now >= deadline) - { - self.state.spinner_tick = self.state.spinner_tick.wrapping_add(1); - self.next_animation_tick = Some(now + ANIMATION_INTERVAL); - changed = true; - } - if self .selection_autoscroll_deadline .is_some_and(|deadline| now >= deadline) @@ -336,7 +327,6 @@ impl App { self.sync_pending_agent_resume_deadline(now); changed |= self.start_pending_agent_resumes(self.pending_agent_resume_due(now)); } - self.sync_animation_timer(now); changed } @@ -393,29 +383,6 @@ impl App { self.sync_agent_metadata_deadline(); } - pub(crate) fn sync_animation_timer(&mut self, now: Instant) { - self.sync_animation_timer_with_interval(now, ANIMATION_INTERVAL); - } - - pub(crate) fn sync_headless_animation_timer(&mut self, now: Instant) { - self.sync_animation_timer_with_interval(now, crate::app::HEADLESS_ANIMATION_INTERVAL); - } - - fn sync_animation_timer_with_interval(&mut self, now: Instant, interval: Duration) { - if self.agent_panel_has_animation() { - self.next_animation_tick.get_or_insert(now + interval); - } else { - self.next_animation_tick = None; - } - } - - fn agent_panel_has_animation(&self) -> bool { - self.state - .workspaces - .iter() - .any(|ws| ws.has_working_pane(&self.state.terminals)) - } - pub(crate) fn tick_selection_autoscroll(&mut self, now: Instant) { let Some(autoscroll) = self.state.selection_autoscroll.clone() else { // Self-heal: state cleared but deadline leaked @@ -568,7 +535,6 @@ impl App { self.state.next_pending_agent_notification_deadline(), self.state.next_managed_agent_deadline(), self.copy_feedback_deadline, - self.next_animation_tick, include_git_refresh .then(|| self.git_refresh_deadline()) .flatten(), diff --git a/src/app/state.rs b/src/app/state.rs index 17b3ae4c..67318f02 100644 --- a/src/app/state.rs +++ b/src/app/state.rs @@ -1551,8 +1551,6 @@ pub struct AppState { pub local_sound_playback: bool, pub toast_config: ToastConfig, pub keybinds: Keybinds, - /// Frame counter for spinner animations (wraps around). - pub spinner_tick: u32, /// UI color palette — all sidebar/UI colors centralized for theming. pub palette: Palette, /// Currently applied theme name (for settings UI). @@ -1920,7 +1918,6 @@ impl AppState { local_sound_playback: false, toast_config: ToastConfig::default(), keybinds: Keybinds::default(), - spinner_tick: 0, palette: Palette::catppuccin(), theme_name: "catppuccin".to_string(), theme_runtime: ThemeRuntimeConfig { -- cgit v1.2.3