Skip to main content

oxicode_vtui/tui/
host.rs

1// [oxicode: cut app module]
2use crate::tui::options::{
3    FullscreenInteractionSettings, KeyboardProtocolSettings, SessionSurface,
4};
5use oxicode_vtui_compat::ui_protocol::SlashCommandItem;
6
7/// Provides high-level workspace metadata for header rendering.
8pub trait WorkspaceInfoProvider {
9    fn workspace_name(&self) -> String;
10    fn workspace_root(&self) -> Option<std::path::PathBuf>;
11}
12
13/// Provides notification hooks for terminal focus changes.
14pub trait NotificationProvider {
15    fn set_terminal_focused(&self, focused: bool);
16}
17
18/// Provides theme lookup/synchronization for dynamic UI styling.
19pub trait ThemeProvider {
20    fn available_themes(&self) -> Vec<String>;
21    fn active_theme_name(&self) -> Option<String>;
22}
23
24/// Host-level defaults for launching a TUI session.
25#[derive(Debug, Clone, PartialEq, Eq)]
26pub struct HostSessionDefaults {
27    pub(crate) surface_preference: SessionSurface,
28    pub(crate) inline_rows: u16,
29    pub(crate) keyboard_protocol: KeyboardProtocolSettings,
30    pub(crate) fullscreen: FullscreenInteractionSettings,
31}
32
33impl Default for HostSessionDefaults {
34    fn default() -> Self {
35        Self {
36            surface_preference: SessionSurface::default(),
37            inline_rows: crate::tui::config::constants::ui::DEFAULT_INLINE_VIEWPORT_ROWS,
38            keyboard_protocol: KeyboardProtocolSettings::default(),
39            fullscreen: FullscreenInteractionSettings::default(),
40        }
41    }
42}
43
44/// Full host adapter contract for embedding `vtcode-ui` in other apps.
45pub trait HostAdapter: WorkspaceInfoProvider + NotificationProvider + ThemeProvider {
46    /// Provide host-specific defaults for TUI session startup.
47    fn session_defaults(&self) -> HostSessionDefaults {
48        HostSessionDefaults::default()
49    }
50
51    /// Provide slash command metadata to render in the command palette.
52    fn slash_commands(&self) -> Vec<SlashCommandItem> {
53        Vec::new()
54    }
55
56    /// Display name used in terminal title and lightweight UI copy.
57    fn app_name(&self) -> String {
58        "Agent TUI".to_string()
59    }
60
61    /// Optional hint shown when interactive TTY requirements are not met.
62    fn non_interactive_hint(&self) -> Option<String> {
63        None
64    }
65}