Skip to main content

agentmux_srv_core/backend/notify/
shutdown_buttons.rs

1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! The two buttons of a countdown's toast: the cancel and the do-it-now
5//! (`SPEC_COUNTDOWN_BUTTONS_AND_BATCH_AGENT_ACTIONS_2026_10_28.md` ยง3).
6
7use super::policy::{keep_label, NotifyAction, ShutdownInfo};
8
9/// The id of the cancel button (the first of the two): Keep running, or a sensitive operation's veto.
10pub const ACTION_KEEP: &str = "keep";
11/// The id of the do-it-now button: Close now, or a sensitive operation's approve-now.
12pub const ACTION_NOW: &str = "now";
13
14/// The cancel and do-it-now words of an agent close: "Keep running" or "Keep open", and "Close now"
15/// (a close of a tab or a pane) or "Stop now" (a stop alone).
16pub fn labels(effect: &str, running: bool) -> (String, String) {
17    let now = if effect == "stop" { "Stop now" } else { "Close now" };
18    (keep_label(running).to_string(), now.to_string())
19}
20
21/// The two buttons of a countdown's toast: the countdown's own words if it has them, else the agent close's.
22pub(super) fn actions(info: &ShutdownInfo) -> Vec<NotifyAction> {
23    let (cancel, now) = info.labels.clone().unwrap_or_else(|| labels(info.effect, info.running));
24    vec![NotifyAction { id: ACTION_KEEP.to_string(), label: cancel }, NotifyAction { id: ACTION_NOW.to_string(), label: now }]
25}