use crate::app::agent::agent::loop_::cli::theme::{
ACCENT_CYAN, EXECUTION_DOT, SCANLINE_DARK, SCANLINE_LIGHT, SURFACE_BASE,
};
use ratatui::style::{Modifier, Style};
use ratatui::text::{Line, Span, Text};
use ratatui::widgets::Paragraph;
pub(crate) fn render_scanline_background(f: &mut ratatui::Frame<'_>, area: ratatui::layout::Rect) {
if area.width == 0 || area.height == 0 {
return;
}
let mut lines: Vec<Line> = Vec::with_capacity(area.height as usize);
let stripe = " ".repeat(area.width as usize);
for row in 0..area.height {
let bg = if row % 2 == 0 { SCANLINE_DARK } else { SCANLINE_LIGHT };
lines.push(Line::from(Span::styled(stripe.clone(), Style::default().bg(bg))));
}
f.render_widget(Paragraph::new(Text::from(lines)), area);
}
pub(crate) fn render_execution_indicator(
f: &mut ratatui::Frame<'_>,
area: ratatui::layout::Rect,
busy: bool,
spinner_idx: usize,
) {
if area.width == 0 || area.height == 0 {
return;
}
let line_area = ratatui::layout::Rect {
x: area.x,
y: area.y.saturating_add(area.height / 2), width: area.width,
height: 1, };
let bg = SURFACE_BASE;
let dot_style = Style::default().fg(EXECUTION_DOT).bg(bg);
let block_style = Style::default().fg(ACCENT_CYAN).bg(bg).add_modifier(Modifier::BOLD);
let width = line_area.width as usize;
let blank = " ".repeat(width);
if !busy {
let lines = vec![Line::from(Span::styled(blank.clone(), Style::default().bg(bg)))];
f.render_widget(Paragraph::new(Text::from(lines)), line_area);
return;
}
let _dots = ".".repeat(width);
let travel = width.saturating_sub(1).max(1);
let offset = spinner_idx % travel;
let pos_left = offset;
let mut pos_right = travel.saturating_sub(offset);
if pos_left == pos_right && width > 1 {
pos_right = (pos_right + 1) % width;
}
let mut positions = vec![pos_left, pos_right];
positions.sort_unstable();
positions.dedup();
let mut spans: Vec<Span> = Vec::new();
let mut last = 0usize;
for pos in positions {
if pos > last {
spans.push(Span::styled(".".repeat(pos - last), dot_style));
}
spans.push(Span::styled("■", block_style));
last = pos + 1;
}
if last < width {
spans.push(Span::styled(".".repeat(width - last), dot_style));
}
let lines = vec![Line::from(spans)];
f.render_widget(Paragraph::new(Text::from(lines)), line_area);
}