Skip to main content

vtcode_config/core/
desktop.rs

1//! Desktop app configuration
2//!
3//! Settings for the optional native macOS desktop app (VT Code.app), which
4//! shares the CLI's providers, configuration, and sessions.
5
6use serde::{Deserialize, Serialize};
7
8/// Desktop app configuration.
9#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
10#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
11#[serde(rename_all = "kebab-case")]
12pub struct DesktopConfig {
13    /// Suggest installing the desktop app at startup when it is missing.
14    /// Shown at most once per day; set to `false` to mute permanently.
15    #[serde(default = "default_suggest_install")]
16    pub suggest_install: bool,
17}
18
19impl Default for DesktopConfig {
20    fn default() -> Self {
21        Self { suggest_install: default_suggest_install() }
22    }
23}
24
25fn default_suggest_install() -> bool {
26    true
27}
28
29#[cfg(test)]
30mod tests {
31    use super::*;
32
33    #[test]
34    fn suggest_install_defaults_on() {
35        assert!(DesktopConfig::default().suggest_install);
36        // Missing key in a user file must also default on (opt-out).
37        let parsed: DesktopConfig = toml::from_str("").expect("empty table parses");
38        assert!(parsed.suggest_install);
39    }
40
41    #[test]
42    fn suggest_install_opt_out_parses() {
43        let parsed: DesktopConfig = toml::from_str("suggest-install = false").expect("opt-out parses");
44        assert!(!parsed.suggest_install);
45    }
46}