From b751d102f158968aab681cb663d27b4c32197f62 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Tue, 2 Jun 2026 21:48:02 +0300 Subject: feat: add preview update channel --- src/config/io.rs | 16 ++++++++++++++++ src/config/model.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) (limited to 'src/config') diff --git a/src/config/io.rs b/src/config/io.rs index 2c6d78ab..1ea928a3 100644 --- a/src/config/io.rs +++ b/src/config/io.rs @@ -181,6 +181,14 @@ fn load_live_config_from_str(content: &str) -> Result> &mut invalid_sections, |section| config.session = section, ); + load_live_section( + table, + "update", + "update config", + &mut diagnostics, + &mut invalid_sections, + |section| config.update = section, + ); load_live_section( table, "ui", @@ -213,6 +221,14 @@ fn load_live_config_from_str(content: &str) -> Result> &mut invalid_sections, |section| config.experimental = section, ); + load_live_section( + table, + "remote", + "remote config", + &mut diagnostics, + &mut invalid_sections, + |section| config.remote = section, + ); Ok(LoadedConfig { config, diff --git a/src/config/model.rs b/src/config/model.rs index f815fb8d..7895341f 100644 --- a/src/config/model.rs +++ b/src/config/model.rs @@ -8,6 +8,37 @@ use super::{ DEFAULT_MOUSE_SCROLL_LINES, DEFAULT_SCROLLBACK_LIMIT_BYTES, }; +#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, Default)] +#[serde(rename_all = "lowercase")] +pub enum UpdateChannelConfig { + #[default] + Stable, + Preview, +} + +impl UpdateChannelConfig { + pub fn as_str(self) -> &'static str { + match self { + Self::Stable => "stable", + Self::Preview => "preview", + } + } +} + +#[derive(Debug, Clone, Copy, Deserialize)] +#[serde(default)] +pub struct UpdateConfig { + pub channel: UpdateChannelConfig, +} + +impl Default for UpdateConfig { + fn default() -> Self { + Self { + channel: UpdateChannelConfig::Stable, + } + } +} + #[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, Default)] #[serde(rename_all = "lowercase")] pub enum ToastDelivery { @@ -187,6 +218,7 @@ pub struct Config { pub theme: ThemeConfig, pub terminal: TerminalConfig, pub session: SessionConfig, + pub update: UpdateConfig, pub keys: KeysConfig, pub ui: UiConfig, pub worktrees: WorktreesConfig, @@ -588,6 +620,20 @@ impl Default for AdvancedConfig { mod tests { use super::*; + #[test] + fn update_channel_defaults_stable_and_parses() { + let default_config = Config::default(); + assert_eq!(default_config.update.channel, UpdateChannelConfig::Stable); + + let toml = r#" +[update] +channel = "preview" +"#; + let config: Config = toml::from_str(toml).unwrap(); + assert_eq!(config.update.channel, UpdateChannelConfig::Preview); + assert_eq!(config.update.channel.as_str(), "preview"); + } + #[test] fn terminal_default_shell_defaults_empty_and_parses() { let default_config = Config::default(); -- cgit v1.2.3