Skip to content

Commit 7103838

Browse files
fix error on missing notifications in [tui] (#3867)
Fixes #3811.
1 parent 277fc62 commit 7103838

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

codex-rs/core/src/config.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,7 @@ pub fn log_dir(cfg: &Config) -> std::io::Result<PathBuf> {
11631163
#[cfg(test)]
11641164
mod tests {
11651165
use crate::config_types::HistoryPersistence;
1166+
use crate::config_types::Notifications;
11661167

11671168
use super::*;
11681169
use pretty_assertions::assert_eq;
@@ -1201,6 +1202,19 @@ persistence = "none"
12011202
);
12021203
}
12031204

1205+
#[test]
1206+
fn tui_config_missing_notifications_field_defaults_to_disabled() {
1207+
let cfg = r#"
1208+
[tui]
1209+
"#;
1210+
1211+
let parsed = toml::from_str::<ConfigToml>(cfg)
1212+
.expect("TUI config without notifications should succeed");
1213+
let tui = parsed.tui.expect("config should include tui section");
1214+
1215+
assert_eq!(tui.notifications, Notifications::Enabled(false));
1216+
}
1217+
12041218
#[test]
12051219
fn test_sandbox_config_parsing() {
12061220
let sandbox_full_access = r#"

codex-rs/core/src/config_types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ impl Default for Notifications {
9494
pub struct Tui {
9595
/// Enable desktop notifications from the TUI when the terminal is unfocused.
9696
/// Defaults to `false`.
97+
#[serde(default)]
9798
pub notifications: Notifications,
9899
}
99100

0 commit comments

Comments
 (0)