aboutsummaryrefslogtreecommitdiff
path: root/src/app/mod.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-09 21:57:26 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-09 21:57:26 +0300
commit819a71ea7a939e45234648c6ee09aa3bcaa6ff77 (patch)
tree49013b4736d9569a4e7c4e3ae2fa3c95cdad0299 /src/app/mod.rs
parentd984ab2a3cb4b24788e24b3aaba24adea38b510f (diff)
fix: refresh git status off the main loop
fixes #85
Diffstat (limited to 'src/app/mod.rs')
-rw-r--r--src/app/mod.rs50
1 files changed, 48 insertions, 2 deletions
diff --git a/src/app/mod.rs b/src/app/mod.rs
index 1d09230a..1ea315cf 100644
--- a/src/app/mod.rs
+++ b/src/app/mod.rs
@@ -66,6 +66,7 @@ pub struct App {
pub(crate) config_diagnostic_deadline: Option<Instant>,
pub(crate) toast_deadline: Option<Instant>,
pub(crate) last_git_remote_status_refresh: Instant,
+ pub(crate) git_refresh_in_flight: bool,
pub(crate) last_sidebar_divider_click: Option<Instant>,
pub(crate) next_resize_poll: Instant,
pub(crate) next_animation_tick: Option<Instant>,
@@ -368,7 +369,7 @@ impl App {
};
for ws in &mut state.workspaces {
- ws.refresh_git_ahead_behind();
+ ws.refresh_git_branch();
}
// Background auto-update is disabled in monolithic no-session mode
@@ -395,7 +396,8 @@ impl App {
state,
event_tx,
event_rx,
- last_git_remote_status_refresh: Instant::now(),
+ last_git_remote_status_refresh: Instant::now() - GIT_REMOTE_STATUS_REFRESH_INTERVAL,
+ git_refresh_in_flight: false,
last_sidebar_divider_click: None,
next_resize_poll: Instant::now() + RESIZE_POLL_INTERVAL,
next_animation_tick: None,
@@ -909,6 +911,50 @@ mod tests {
}
#[test]
+ fn git_refresh_deadline_is_suppressed_while_in_flight() {
+ let mut app = test_app();
+ app.state.workspaces.push(Workspace::test_new("one"));
+ app.git_refresh_in_flight = true;
+
+ assert_eq!(app.git_refresh_deadline(), None);
+ }
+
+ #[test]
+ fn git_status_event_clears_in_flight_refresh() {
+ let mut app = test_app();
+ app.git_refresh_in_flight = true;
+ let previous_refresh = Instant::now() - Duration::from_secs(10);
+ app.last_git_remote_status_refresh = previous_refresh;
+
+ app.handle_internal_event(AppEvent::GitStatusRefreshed {
+ results: Vec::new(),
+ });
+
+ assert!(!app.git_refresh_in_flight);
+ assert!(app.last_git_remote_status_refresh > previous_refresh);
+ }
+
+ #[test]
+ fn git_status_event_marks_render_dirty_when_status_changes() {
+ let mut app = test_app();
+ app.state.workspaces.push(Workspace::test_new("one"));
+ app.render_dirty.store(false, Ordering::Release);
+ let workspace_id = app.state.workspaces[0].id.clone();
+ let resolved_identity_cwd = app.state.workspaces[0].resolved_identity_cwd().unwrap();
+
+ app.handle_internal_event(AppEvent::GitStatusRefreshed {
+ results: vec![crate::workspace::WorkspaceGitStatus {
+ workspace_id,
+ resolved_identity_cwd,
+ branch: Some("render-dirty-test".into()),
+ ahead_behind: Some((1, 0)),
+ }],
+ });
+
+ assert!(app.render_dirty.load(Ordering::Acquire));
+ }
+
+ #[test]
fn startup_uses_configured_agent_panel_scope() {
let mut config = Config::default();
config.ui.agent_panel_scope = crate::config::AgentPanelScopeConfig::Current;