Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions src/app/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,12 @@ impl App {
.state
.active
.and_then(|idx| self.state.workspaces.get(idx))
.is_some_and(|ws| ws.has_working_pane(&self.state.terminals)),
.is_some_and(|ws| ws.has_animated_pane(&self.state.terminals)),
crate::app::state::AgentPanelScope::AllWorkspaces => self
.state
.workspaces
.iter()
.any(|ws| ws.has_working_pane(&self.state.terminals)),
.any(|ws| ws.has_animated_pane(&self.state.terminals)),
}
}

Expand Down Expand Up @@ -648,6 +648,34 @@ mod tests {
(app, pane_id)
}

#[test]
fn blocked_pane_keeps_agent_animation_timer_running() {
let (mut app, pane_id) = test_app_with_pane();
app.state.ensure_test_terminals();
let terminal_id = app.state.workspaces[0]
.pane_state(pane_id)
.expect("test pane should exist")
.attached_terminal_id
.clone();
app.state
.terminals
.get_mut(&terminal_id)
.expect("test terminal should exist")
.state = crate::detect::AgentState::Blocked;

assert!(app.agent_panel_has_animation());
app.sync_animation_timer(Instant::now());
assert!(app.next_animation_tick.is_some());

app.state
.terminals
.get_mut(&terminal_id)
.expect("test terminal should exist")
.state = crate::detect::AgentState::Idle;
app.sync_animation_timer(Instant::now());
assert!(app.next_animation_tick.is_none());
}

#[test]
fn git_refresh_deduplicates_workspaces_with_same_cache_key() {
let repo =
Expand Down
3 changes: 2 additions & 1 deletion src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ const COLLAPSED_WIDTH: u16 = 4; // num + space + dot + separator

// Braille spinner frames — smooth rotation
const SPINNERS: &[&str] = &["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
const SPINNER_TICKS_PER_FRAME: u32 = 8;

/// Map spinner_tick (incremented every frame at ~60fps) to a spinner frame.
/// We want ~8 updates/sec so divide by 8.
pub(super) fn spinner_frame(tick: u32) -> &'static str {
SPINNERS[(tick as usize / 8) % SPINNERS.len()]
SPINNERS[(tick as usize / SPINNER_TICKS_PER_FRAME as usize) % SPINNERS.len()]
}

/// Compute view geometry and reconcile pane sizes.
Expand Down
41 changes: 40 additions & 1 deletion src/ui/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,14 @@ pub(super) fn agent_icon(
p: &Palette,
) -> (&'static str, Style) {
match (state, seen) {
(AgentState::Blocked, _) => ("◉", Style::default().fg(p.red)),
(AgentState::Blocked, _) => {
let icon = if (tick / super::SPINNER_TICKS_PER_FRAME).is_multiple_of(2) {
"◉"
} else {
"○"
};
(icon, Style::default().fg(p.red))
}
(AgentState::Working, _) => (super::spinner_frame(tick), Style::default().fg(p.yellow)),
(AgentState::Idle, false) => ("●", Style::default().fg(p.teal)),
(AgentState::Idle, true) => ("✓", Style::default().fg(p.green)),
Expand All @@ -198,3 +205,35 @@ pub(super) fn state_label_color(state: AgentState, seen: bool, p: &Palette) -> C
(AgentState::Unknown, _) => p.overlay0,
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn blocked_agent_icon_alternates_with_spinner_tick() {
let palette = Palette::catppuccin();
let (visible, visible_style) = agent_icon(AgentState::Blocked, true, 0, &palette);
let (hollow, hollow_style) = agent_icon(AgentState::Blocked, true, 8, &palette);

assert_ne!(visible, hollow);
assert_eq!(visible_style.fg, Some(palette.red));
assert_eq!(hollow_style.fg, Some(palette.red));
}

#[test]
fn non_blocked_agent_icons_keep_existing_rendering() {
let palette = Palette::catppuccin();

assert_eq!(agent_icon(AgentState::Working, true, 0, &palette).0, "⠋");
assert_eq!(agent_icon(AgentState::Working, true, 8, &palette).0, "⠙");
for (state, seen, expected) in [
(AgentState::Idle, false, "●"),
(AgentState::Idle, true, "✓"),
(AgentState::Unknown, true, "○"),
] {
assert_eq!(agent_icon(state, seen, 0, &palette).0, expected);
assert_eq!(agent_icon(state, seen, 1, &palette).0, expected);
}
}
}
10 changes: 6 additions & 4 deletions src/workspace/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ pub struct PaneDetail {
}

impl Tab {
pub fn has_working_pane(&self, terminals: &HashMap<TerminalId, TerminalState>) -> bool {
pub fn has_animated_pane(&self, terminals: &HashMap<TerminalId, TerminalState>) -> bool {
self.panes.values().any(|pane| {
terminals
.get(&pane.attached_terminal_id)
.is_some_and(|terminal| terminal.state == AgentState::Working)
.is_some_and(|terminal| {
matches!(terminal.state, AgentState::Working | AgentState::Blocked)
})
})
}

Expand Down Expand Up @@ -90,8 +92,8 @@ impl Workspace {
.unwrap_or((AgentState::Unknown, true))
}

pub fn has_working_pane(&self, terminals: &HashMap<TerminalId, TerminalState>) -> bool {
self.tabs.iter().any(|tab| tab.has_working_pane(terminals))
pub fn has_animated_pane(&self, terminals: &HashMap<TerminalId, TerminalState>) -> bool {
self.tabs.iter().any(|tab| tab.has_animated_pane(terminals))
}

pub fn pane_details(&self, terminals: &HashMap<TerminalId, TerminalState>) -> Vec<PaneDetail> {
Expand Down
Loading