Skip to main content

codetether_agent/tui/ui/chat_view/
attachment.rs

1//! Attachment badge suffix for the input area title.
2//!
3//! [`attachment_suffix`] produces a short string like `| 📷 2 attached | 🧭 1 queued`
4//! reflecting pending images and steering messages.
5
6use crate::tui::app::state::App;
7
8/// Build a short suffix like `| 📷 2 attached | 🧭 1 queued` or empty.
9///
10/// Returns an empty `String` when there are no pending images or steering
11/// messages, so the input title stays clean.
12///
13/// # Examples
14///
15/// ```rust,no_run
16/// use codetether_agent::tui::ui::chat_view::attachment::attachment_suffix;
17/// # fn demo(app: &codetether_agent::tui::app::state::App) {
18/// // With no attachments the suffix is empty.
19/// let suffix = attachment_suffix(app);
20/// assert!(suffix.is_empty() || suffix.contains("📷"));
21/// # }
22/// ```
23pub fn attachment_suffix(app: &App) -> String {
24    let pending_images = app.state.pending_images.len();
25    let steering = app.state.steering_count();
26    if pending_images == 0 && steering == 0 {
27        return String::new();
28    }
29    let image_part = (pending_images > 0).then(|| format!("📷 {pending_images} attached"));
30    let steering_part = (steering > 0).then(|| format!("🧭 {steering} queued"));
31    let parts = [image_part, steering_part]
32        .into_iter()
33        .flatten()
34        .collect::<Vec<_>>()
35        .join(" | ");
36    format!(" | {parts} ")
37}