Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

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

Jeremy Rose71038381aa0f
diff --git a/codex-rs/core/src/config.rs b/codex-rs/core/src/config.rs
index 6a613abbba..c84d84e0ff 100644
--- a/codex-rs/core/src/config.rs
+++ b/codex-rs/core/src/config.rs
@@ -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#"
diff --git a/codex-rs/core/src/config_types.rs b/codex-rs/core/src/config_types.rs
index ec8e8e67c6..3737649871 100644
--- a/codex-rs/core/src/config_types.rs
+++ b/codex-rs/core/src/config_types.rs
@@ -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,
}