diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-03-30 00:30:24 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-03-30 00:30:24 +0300 |
| commit | 263b8f32654588bc0ca229361f7b7be30d72aed2 (patch) | |
| tree | 9f777e31a43169dc6a3237dcd48ac0e8e106eda1 /src/app | |
| parent | 00e5da8704ecc1a59fbb270e01defdf7dcd9593e (diff) | |
feat: show upstream status in workspace sidebar
Diffstat (limited to 'src/app')
| -rw-r--r-- | src/app/mod.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/app/mod.rs b/src/app/mod.rs index c7408e47..f352f97c 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -11,6 +11,8 @@ pub mod state; use std::io; use std::time::{Duration, Instant}; +const GIT_REMOTE_STATUS_REFRESH_INTERVAL: Duration = Duration::from_millis(1500); + use crossterm::event::{self, Event, KeyEventKind}; use ratatui::layout::Rect; use ratatui::DefaultTerminal; @@ -34,6 +36,7 @@ pub struct App { no_session: bool, config_diagnostic_deadline: Option<Instant>, toast_deadline: Option<Instant>, + last_git_remote_status_refresh: Instant, } /// Resolve the palette from config: base theme + optional custom overrides. @@ -105,7 +108,7 @@ impl App { state::Mode::Navigate }; - let state = AppState { + let mut state = AppState { workspaces, active, selected, @@ -154,6 +157,10 @@ impl App { }, }; + for ws in &mut state.workspaces { + ws.refresh_git_ahead_behind(); + } + // Background auto-update (skipped in --no-session / test mode) if !no_session { let update_tx = event_tx.clone(); @@ -176,6 +183,7 @@ impl App { state, event_tx, event_rx, + last_git_remote_status_refresh: Instant::now(), api_rx, event_hub, last_focus, @@ -203,6 +211,13 @@ impl App { self.state.spinner_tick = self.state.spinner_tick.wrapping_add(1); + if self.last_git_remote_status_refresh.elapsed() >= GIT_REMOTE_STATUS_REFRESH_INTERVAL { + for ws in &mut self.state.workspaces { + ws.refresh_git_ahead_behind(); + } + self.last_git_remote_status_refresh = Instant::now(); + } + terminal.draw(|frame| { crate::ui::compute_view(&mut self.state, frame.area()); crate::ui::render(&self.state, frame); @@ -976,7 +991,8 @@ impl App { focus: bool, ) -> std::io::Result<usize> { let (rows, cols) = self.state.estimate_pane_size(); - let ws = Workspace::new(initial_cwd, rows, cols, self.event_tx.clone())?; + let mut ws = Workspace::new(initial_cwd, rows, cols, self.event_tx.clone())?; + ws.refresh_git_ahead_behind(); self.state.workspaces.push(ws); let idx = self.state.workspaces.len() - 1; if focus || self.state.active.is_none() { |
