fix error on missing notifications in [tui] (#3867)

Fixes #3811.
This commit is contained in:
Jeremy Rose
2025-09-18 11:25:09 -07:00
committed by GitHub
parent 277fc6254e
commit 71038381aa
2 changed files with 15 additions and 0 deletions

View File

@@ -1163,6 +1163,7 @@ pub fn log_dir(cfg: &Config) -> std::io::Result<PathBuf> {
#[cfg(test)]
mod tests {
use crate::config_types::HistoryPersistence;
use crate::config_types::Notifications;
use super::*;
use pretty_assertions::assert_eq;
@@ -1201,6 +1202,19 @@ persistence = "none"
);
}
#[test]
fn tui_config_missing_notifications_field_defaults_to_disabled() {
let cfg = r#"
[tui]
"#;
let parsed = toml::from_str::<ConfigToml>(cfg)
.expect("TUI config without notifications should succeed");
let tui = parsed.tui.expect("config should include tui section");
assert_eq!(tui.notifications, Notifications::Enabled(false));
}
#[test]
fn test_sandbox_config_parsing() {
let sandbox_full_access = r#"

View File

@@ -94,6 +94,7 @@ impl Default for Notifications {
pub struct Tui {
/// Enable desktop notifications from the TUI when the terminal is unfocused.
/// Defaults to `false`.
#[serde(default)]
pub notifications: Notifications,
}