use serde::{Deserialize, Serialize};

/// Effective (resolved) daemon configuration sent to clients.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ConfigView {
    pub default_shell: String,
    pub font_family: String,
    pub font_size: u16,
    pub theme: String,
    pub accent: String,
    /// Background-theme name (Warp-style full-window fill). "none" = solid.
    #[serde(default = "default_background")]
    pub background: String,
    /// Absolute path to a custom background image (used when background == "custom").
    #[serde(default)]
    pub background_image: String,
    /// Whether shell-command status (OSC 133) is logged; agent activity always is.
    #[serde(default)]
    pub log_shell_commands: bool,
}

fn default_background() -> String {
    "none".into()
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn config_view_round_trips() {
        let c = ConfigView {
            default_shell: "/bin/zsh".into(), font_family: "JetBrains Mono".into(),
            font_size: 13, theme: "dark".into(), accent: "blue".into(),
            background: "none".into(), background_image: String::new(),
            log_shell_commands: false,
        };
        let back: ConfigView = serde_json::from_str(&serde_json::to_string(&c).unwrap()).unwrap();
        assert_eq!(back, c);
    }
}
