From c94fc58296213ecdfc28277f7dd1d30a670c7b4f Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Mon, 18 May 2026 15:17:56 -0700 Subject: [PATCH] feat(m1): add Tier and NotificationLevel to config --- src-tauri/src/config.rs | 54 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/config.rs b/src-tauri/src/config.rs index 82ea7f2..c26d65f 100644 --- a/src-tauri/src/config.rs +++ b/src-tauri/src/config.rs @@ -11,6 +11,22 @@ pub enum SourceOs { Unknown, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[serde(rename_all = "snake_case")] +pub enum Tier { + Free, + Paid, + Premium, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[serde(rename_all = "snake_case")] +pub enum NotificationLevel { + Off, + BadgeOnly, + BadgeAndToast, +} + #[derive(Debug, Clone, Serialize, Deserialize)] pub struct MigrationConfig { pub source_os: SourceOs, @@ -37,14 +53,14 @@ impl Default for OllamaConfig { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct DisplayConfig { - pub show_notifications: bool, + pub notification_level: NotificationLevel, pub quiet_mode: bool, } impl Default for DisplayConfig { fn default() -> Self { Self { - show_notifications: true, + notification_level: NotificationLevel::BadgeAndToast, quiet_mode: false, } } @@ -55,6 +71,7 @@ pub struct RobinConfig { pub migration: Option, pub ollama: OllamaConfig, pub display: DisplayConfig, + pub tier: Tier, } impl Default for RobinConfig { @@ -63,6 +80,7 @@ impl Default for RobinConfig { migration: None, ollama: OllamaConfig::default(), display: DisplayConfig::default(), + tier: Tier::Free, } } } @@ -136,4 +154,36 @@ mod tests { let deserialized: RobinConfig = toml::from_str(&serialized).unwrap(); assert!(!deserialized.needs_onboarding()); } + + #[test] + fn notification_level_default_is_badge_and_toast() { + let config = RobinConfig::default(); + assert!(matches!( + config.display.notification_level, + NotificationLevel::BadgeAndToast + )); + } + + #[test] + fn tier_default_is_free() { + let config = RobinConfig::default(); + assert!(matches!(config.tier, Tier::Free)); + } + + #[test] + fn notification_level_roundtrips_toml() { + let config = RobinConfig { + display: DisplayConfig { + notification_level: NotificationLevel::BadgeOnly, + quiet_mode: false, + }, + ..Default::default() + }; + let toml = toml::to_string_pretty(&config).unwrap(); + let back: RobinConfig = toml::from_str(&toml).unwrap(); + assert!(matches!( + back.display.notification_level, + NotificationLevel::BadgeOnly + )); + } }