Add TUI notification condition config (#17175)

Problem: TUI desktop notifications are hard-gated on terminal focus, so
terminal/IDE hosts that want in-focus notifications cannot opt in.

Solution: Add a flat `[tui] notification_condition` setting (`unfocused`
by default, `always` opt-in), carry grouped TUI notification settings
through runtime config, apply method + condition together in the TUI,
and regenerate the config schema.
This commit is contained in:
Eric Traut
2026-04-08 21:50:02 -07:00
committed by GitHub
parent 2f9090be62
commit 6dc5391c7c
8 changed files with 191 additions and 48 deletions

View File

@@ -472,6 +472,44 @@ impl fmt::Display for NotificationMethod {
}
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, Default)]
#[serde(rename_all = "lowercase")]
pub enum NotificationCondition {
/// Emit TUI notifications only while the terminal is unfocused.
#[default]
Unfocused,
/// Emit TUI notifications regardless of terminal focus.
Always,
}
impl fmt::Display for NotificationCondition {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
NotificationCondition::Unfocused => write!(f, "unfocused"),
NotificationCondition::Always => write!(f, "always"),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, JsonSchema)]
#[schemars(deny_unknown_fields)]
pub struct TuiNotificationSettings {
/// Enable desktop notifications from the TUI.
/// Defaults to `true`.
#[serde(default, rename = "notifications")]
pub notifications: Notifications,
/// Notification method to use for terminal notifications.
/// Defaults to `auto`.
#[serde(default, rename = "notification_method")]
pub method: NotificationMethod,
/// Controls whether TUI notifications are delivered only when the terminal is unfocused or
/// regardless of focus. Defaults to `unfocused`.
#[serde(default, rename = "notification_condition")]
pub condition: NotificationCondition,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, JsonSchema)]
#[schemars(deny_unknown_fields)]
pub struct ModelAvailabilityNuxConfig {
@@ -484,15 +522,8 @@ pub struct ModelAvailabilityNuxConfig {
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default, JsonSchema)]
#[schemars(deny_unknown_fields)]
pub struct Tui {
/// Enable desktop notifications from the TUI when the terminal is unfocused.
/// Defaults to `true`.
#[serde(default)]
pub notifications: Notifications,
/// Notification method to use for unfocused terminal notifications.
/// Defaults to `auto`.
#[serde(default)]
pub notification_method: NotificationMethod,
#[serde(default, flatten)]
pub notification_settings: TuiNotificationSettings,
/// Enable animations (welcome screen, shimmer effects, spinners).
/// Defaults to `true`.