use serde::{Deserialize, Serialize};
use super::env_bool_var;
use super::modes::{NotificationBackend, NotificationDeliveryMode};
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct UiNotificationsConfig {
#[serde(default = "default_notifications_enabled")]
pub enabled: bool,
#[serde(default)]
pub delivery_mode: NotificationDeliveryMode,
#[serde(default)]
pub backend: NotificationBackend,
#[serde(default = "default_notifications_suppress_when_focused")]
pub suppress_when_focused: bool,
#[serde(default)]
pub command_failure: Option<bool>,
#[serde(default = "default_notifications_tool_failure")]
pub tool_failure: bool,
#[serde(default = "default_notifications_error")]
pub error: bool,
#[serde(default = "default_notifications_completion")]
pub completion: bool,
#[serde(default)]
pub completion_success: Option<bool>,
#[serde(default)]
pub completion_failure: Option<bool>,
#[serde(default = "default_notifications_hitl")]
pub hitl: bool,
#[serde(default)]
pub policy_approval: Option<bool>,
#[serde(default)]
pub request: Option<bool>,
#[serde(default = "default_notifications_tool_success")]
pub tool_success: bool,
#[serde(default = "default_notifications_repeat_window_seconds")]
pub repeat_window_seconds: u64,
#[serde(default = "default_notifications_max_identical_in_window")]
pub max_identical_in_window: u32,
}
impl Default for UiNotificationsConfig {
fn default() -> Self {
Self {
enabled: default_notifications_enabled(),
delivery_mode: NotificationDeliveryMode::default(),
backend: NotificationBackend::default(),
suppress_when_focused: default_notifications_suppress_when_focused(),
command_failure: Some(default_notifications_command_failure()),
tool_failure: default_notifications_tool_failure(),
error: default_notifications_error(),
completion: default_notifications_completion(),
completion_success: Some(default_notifications_completion_success()),
completion_failure: Some(default_notifications_completion_failure()),
hitl: default_notifications_hitl(),
policy_approval: Some(default_notifications_policy_approval()),
request: Some(default_notifications_request()),
tool_success: default_notifications_tool_success(),
repeat_window_seconds: default_notifications_repeat_window_seconds(),
max_identical_in_window: default_notifications_max_identical_in_window(),
}
}
}
fn default_notifications_enabled() -> bool {
true
}
fn default_notifications_suppress_when_focused() -> bool {
true
}
fn default_notifications_command_failure() -> bool {
false
}
fn default_notifications_tool_failure() -> bool {
false
}
fn default_notifications_error() -> bool {
true
}
fn default_notifications_completion() -> bool {
true
}
fn default_notifications_completion_success() -> bool {
false
}
fn default_notifications_completion_failure() -> bool {
true
}
fn default_notifications_hitl() -> bool {
true
}
fn default_notifications_policy_approval() -> bool {
true
}
fn default_notifications_request() -> bool {
false
}
fn default_notifications_tool_success() -> bool {
false
}
fn default_notifications_repeat_window_seconds() -> u64 {
30
}
fn default_notifications_max_identical_in_window() -> u32 {
1
}