1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use serde::{Deserialize, Serialize};
/// How far an external AI agent (reaching GitPoulpi through the MCP server
/// or `gitpoulpi ui ...`) may move the user's window by itself.
///
/// It is chosen on the agent's side (`gitpoulpi-mcp --ui-control`, the
/// `[mcp] ui_control` setting) and travels with every view intent, so the
/// TUI that finally receives the intent can honour it:
///
/// - `ask` (the default): the window shows a chip the user confirms.
/// - `auto`: the window applies the intent unless the user is busy.
/// - `off`: the intent is refused.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum UiControl {
Auto,
#[default]
Ask,
Off,
}
impl UiControl {
pub const ALL: [UiControl; 3] = [UiControl::Auto, UiControl::Ask, UiControl::Off];
pub fn as_str(self) -> &'static str {
match self {
UiControl::Auto => "auto",
UiControl::Ask => "ask",
UiControl::Off => "off",
}
}
}
impl std::str::FromStr for UiControl {
type Err = String;
fn from_str(s: &str) -> Result<Self, String> {
match s {
"auto" => Ok(Self::Auto),
"ask" => Ok(Self::Ask),
"off" => Ok(Self::Off),
other => Err(format!("`{other}` is not one of auto, ask, off")),
}
}
}