Skip to main content

vtcode_tui/
host.rs

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