use crate::app::SlashCommandItem;
use crate::{FullscreenInteractionSettings, KeyboardProtocolSettings, SessionSurface};

/// Provides high-level workspace metadata for header rendering.
pub trait WorkspaceInfoProvider {
    fn workspace_name(&self) -> String;
    fn workspace_root(&self) -> Option<std::path::PathBuf>;
}

/// Provides notification hooks for terminal focus changes.
pub trait NotificationProvider {
    fn set_terminal_focused(&self, focused: bool);
}

/// Provides theme lookup/synchronization for dynamic UI styling.
pub trait ThemeProvider {
    fn available_themes(&self) -> Vec<String>;
    fn active_theme_name(&self) -> Option<String>;
}

/// Host-level defaults for launching a TUI session.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HostSessionDefaults {
    pub surface_preference: SessionSurface,
    pub inline_rows: u16,
    pub keyboard_protocol: KeyboardProtocolSettings,
    pub fullscreen: FullscreenInteractionSettings,
}

impl Default for HostSessionDefaults {
    fn default() -> Self {
        Self {
            surface_preference: SessionSurface::default(),
            inline_rows: crate::config::constants::ui::DEFAULT_INLINE_VIEWPORT_ROWS,
            keyboard_protocol: KeyboardProtocolSettings::default(),
            fullscreen: FullscreenInteractionSettings::default(),
        }
    }
}

/// Full host adapter contract for embedding `vtcode-tui` in other apps.
pub trait HostAdapter: WorkspaceInfoProvider + NotificationProvider + ThemeProvider {
    /// Provide host-specific defaults for TUI session startup.
    fn session_defaults(&self) -> HostSessionDefaults {
        HostSessionDefaults::default()
    }

    /// Provide slash command metadata to render in the command palette.
    fn slash_commands(&self) -> Vec<SlashCommandItem> {
        Vec::new()
    }

    /// Display name used in terminal title and lightweight UI copy.
    fn app_name(&self) -> String {
        "Agent TUI".to_string()
    }

    /// Optional hint shown when interactive TTY requirements are not met.
    fn non_interactive_hint(&self) -> Option<String> {
        None
    }
}
