Skip to main content

vtcode_tui/
host.rs

1use crate::SlashCommandItem;
2use crate::{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}
28
29impl Default for HostSessionDefaults {
30    fn default() -> Self {
31        Self {
32            surface_preference: SessionSurface::default(),
33            inline_rows: crate::config::constants::ui::DEFAULT_INLINE_VIEWPORT_ROWS,
34            keyboard_protocol: KeyboardProtocolSettings::default(),
35        }
36    }
37}
38
39/// Full host adapter contract for embedding `vtcode-tui` in other apps.
40pub trait HostAdapter: WorkspaceInfoProvider + NotificationProvider + ThemeProvider {
41    /// Provide host-specific defaults for TUI session startup.
42    fn session_defaults(&self) -> HostSessionDefaults {
43        HostSessionDefaults::default()
44    }
45
46    /// Provide slash command metadata to render in the command palette.
47    fn slash_commands(&self) -> Vec<SlashCommandItem> {
48        Vec::new()
49    }
50
51    /// Display name used in terminal title and lightweight UI copy.
52    fn app_name(&self) -> String {
53        "Agent TUI".to_string()
54    }
55
56    /// Optional hint shown when interactive TTY requirements are not met.
57    fn non_interactive_hint(&self) -> Option<String> {
58        None
59    }
60}