zc2 0.0.27

P2P compute broker with credit-based billing, WAL, and broker mesh support
//! The REPL status line (mode + context bar).
//!
//! Phase 3 of the terminal refactor (see `docs/TERMINAL_REFACTOR.md`).

#![allow(dead_code)]

use ratatui::layout::Rect;
use ratatui::style::{Color, Modifier, Style};
use ratatui::text::{Line, Span};
use ratatui::widgets::Paragraph;
use ratatui::Frame;

use crate::tui::theme::Theme;

/// What the event loop is currently doing — shown as a badge.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Mode {
    /// Awaiting the ZAKURO_API_KEY before the shell unlocks.
    Login,
    /// Editing at the prompt.
    Normal,
    /// The slash-command palette is open.
    Palette,
    /// A command is running on a worker thread.
    Busy,
}

impl Mode {
    fn label(self) -> &'static str {
        match self {
            Mode::Login => " LOGIN ",
            Mode::Normal => " READY ",
            Mode::Palette => " PALETTE ",
            Mode::Busy => " RUNNING ",
        }
    }
}

/// Render the status bar across `area`.
pub fn render(frame: &mut Frame, area: Rect, theme: &Theme, mode: Mode, hint: &str) {
    let badge_bg = match mode {
        Mode::Login => theme.warning,
        Mode::Normal => theme.accent,
        Mode::Palette => theme.warning,
        Mode::Busy => theme.success,
    };

    let spans = vec![
        Span::styled(
            mode.label(),
            Style::default()
                .bg(badge_bg)
                .fg(Color::Black)
                .add_modifier(Modifier::BOLD),
        ),
        Span::raw(" "),
        Span::styled(
            format!("zc · theme:{}", theme.name),
            Style::default().fg(theme.muted),
        ),
        Span::raw("   "),
        Span::styled(hint.to_string(), Style::default().fg(theme.muted)),
    ];

    frame.render_widget(Paragraph::new(Line::from(spans)), area);
}