codetether_agent/tui/ui/chat_view/auto_apply.rs
1//! Auto-apply ON/OFF badge spans.
2
3use ratatui::{
4 style::{Color, Style},
5 text::Span,
6};
7
8use crate::tui::app::state::App;
9
10/// `auto-apply: ON/OFF` badge with color coding.
11///
12/// # Examples
13///
14/// ```rust,no_run
15/// use codetether_agent::tui::ui::chat_view::auto_apply::auto_apply_spans;
16/// # fn demo(app: &codetether_agent::tui::app::state::App) {
17/// let spans = auto_apply_spans(app);
18/// assert!(spans.len() >= 3);
19/// # }
20/// ```
21pub fn auto_apply_spans(app: &App) -> Vec<Span<'static>> {
22 vec![
23 Span::styled("auto-apply", Style::default().fg(Color::DarkGray)),
24 Span::raw(": "),
25 Span::styled(
26 if app.state.auto_apply_edits {
27 "ON"
28 } else {
29 "OFF"
30 },
31 Style::default().fg(if app.state.auto_apply_edits {
32 Color::Green
33 } else {
34 Color::Yellow
35 }),
36 ),
37 ]
38}