Skip to main content

vtcode_ui/tui/
host.rs

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