polyc-tui 2026.9.0

Operator cockpit TUI (pc-tui) for the polychrome control plane: fleet, transcript, approvals, and tools panes.
//! polychrome operator cockpit — library entrypoint.
//!
//! The cockpit ships two ways: as the standalone `pc-tui` binary (see
//! `main.rs`) and embedded in the `polychrome` operator CLI, which calls
//! [`run`] when invoked with no subcommand (or `polychrome tui`). Both paths
//! go through [`run`]; the binary only adds the `color-eyre` install.

mod action;
mod app;
mod components;
mod data;
mod tui;

/// Connection overrides for launching the cockpit, layered over the `PC_TUI_*`
/// environment defaults. A `None` field keeps the environment value (or its
/// built-in default).
#[derive(Debug, Default, Clone)]
pub struct Launch {
    /// Kubernetes namespace the `Conversation` CRs live in.
    pub namespace: Option<String>,
    /// `AgentService`/`ApprovalService` endpoint URL.
    pub agent_addr: Option<String>,
    /// Forensics HTTP base URL (transcript/approvals/metric panes).
    pub forensics_url: Option<String>,
}

/// Run the cockpit to completion on the current tokio runtime.
///
/// Resolves the data configuration from the environment, applies any
/// [`Launch`] overrides, enters the terminal, and drives the event loop until
/// the operator quits.
///
/// # Errors
/// Returns an error if the terminal cannot be entered or a draw fails. The
/// terminal is always restored on the way out (RAII + panic hook).
pub async fn run(launch: Launch) -> color_eyre::Result<()> {
    let config =
        data::DataConfig::resolve(launch.namespace, launch.agent_addr, launch.forensics_url);
    let mut model = app::Model::with_config(config)?;
    model.run().await
}