Skip to main content

vtcode_config/
codex.rs

1use serde::{Deserialize, Serialize};
2
3/// Editor URI scheme for clickable file citations.
4#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
5#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, Default)]
6#[serde(rename_all = "kebab-case")]
7pub enum FileOpener {
8    Cursor,
9    #[default]
10    None,
11    Vscode,
12    VscodeInsiders,
13    Windsurf,
14    /// Catch-all for unknown editors added by future versions.
15    #[serde(other)]
16    Unknown,
17}
18
19impl FileOpener {
20    pub fn scheme(self) -> Option<&'static str> {
21        match self {
22            Self::None => None,
23            Self::Vscode => Some("vscode"),
24            Self::Cursor => Some("cursor"),
25            Self::Windsurf => Some("windsurf"),
26            Self::VscodeInsiders => Some("vscode-insiders"),
27            Self::Unknown => None,
28        }
29    }
30}
31
32/// Local history persistence mode.
33#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
34#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, Default)]
35#[serde(rename_all = "snake_case")]
36pub enum HistoryPersistence {
37    #[default]
38    File,
39    None,
40    /// Catch-all for unknown persistence modes added by future versions.
41    #[serde(other)]
42    Unknown,
43}
44
45/// Codex-compatible history persistence settings.
46#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
47#[derive(Debug, Clone, Deserialize, Serialize, Default)]
48pub struct HistoryConfig {
49    #[serde(default)]
50    pub persistence: HistoryPersistence,
51    #[serde(default)]
52    pub max_bytes: Option<usize>,
53}
54
55/// Built-in TUI notification delivery method.
56#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
57#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, Default)]
58#[serde(rename_all = "snake_case")]
59pub enum TerminalNotificationMethod {
60    #[default]
61    Auto,
62    Bel,
63    Osc9,
64    /// Catch-all for unknown methods added by future versions.
65    #[serde(other)]
66    Unknown,
67}
68
69/// Alternate-screen preference for the TUI.
70#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
71#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)]
72#[serde(rename_all = "snake_case")]
73pub enum TuiAlternateScreen {
74    Always,
75    Never,
76    /// Catch-all for unknown modes added by future versions.
77    #[serde(other)]
78    Unknown,
79}
80
81/// TUI notification filters compatible with Codex config.
82#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
83#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
84#[serde(rename_all = "kebab-case")]
85pub enum TuiNotificationEvent {
86    AgentTurnComplete,
87    ApprovalRequested,
88    /// Catch-all for unknown events added by future versions.
89    #[serde(other)]
90    Unknown,
91}
92
93/// Accept either `true`/`false` or an allowlist of event names.
94#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
95#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
96#[serde(untagged)]
97pub enum TuiNotificationsConfig {
98    Enabled(bool),
99    Events(Vec<TuiNotificationEvent>),
100}
101
102/// When to deliver desktop notifications relative to terminal focus.
103#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
104#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, Default)]
105#[serde(rename_all = "snake_case")]
106pub enum NotificationCondition {
107    /// Only deliver when the terminal is unfocused (legacy behaviour).
108    #[default]
109    Unfocused,
110    /// Always deliver regardless of focus state.
111    Always,
112    /// Catch-all for unknown conditions added by future versions.
113    #[serde(other)]
114    Unknown,
115}
116
117/// Codex-compatible TUI settings.
118#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
119#[derive(Debug, Clone, Deserialize, Serialize, Default)]
120pub struct TuiConfig {
121    #[serde(default)]
122    pub notifications: Option<TuiNotificationsConfig>,
123    #[serde(default)]
124    pub notification_method: Option<TerminalNotificationMethod>,
125    /// When to deliver desktop notifications relative to terminal focus.
126    /// Defaults to `unfocused` (only deliver when terminal is not focused).
127    /// Set to `always` to deliver notifications even when the terminal is focused.
128    #[serde(default)]
129    pub notification_condition: Option<NotificationCondition>,
130    #[serde(default)]
131    pub animations: Option<bool>,
132    #[serde(default)]
133    pub alternate_screen: Option<TuiAlternateScreen>,
134    #[serde(default)]
135    pub show_tooltips: Option<bool>,
136}