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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/// Application-domain events emitted by UI components.
///
/// Components translate raw key events into these semantic events,
/// which are sent via an `mpsc::Sender<AiTuiEvent>` provided through
/// eye-declare's context system. The main event loop in `inline.rs`
/// receives them and mutates `AppState` accordingly.
#[derive(Debug)]
pub(crate) enum AiTuiEvent {
/// User updated the input text
InputUpdated(String),
/// User submitted text input (Enter in Input mode)
SubmitInput(String),
/// User entered a slash command (e.g. "/help")
#[allow(unused)]
SlashCommand(String),
/// User selected a permission
SelectPermission(PermissionResult),
/// Cancel active generation or streaming (Esc during Generating/Streaming)
CancelGeneration,
/// Execute the suggested command
ExecuteCommand,
/// Insert command without executing
InsertCommand,
/// Cancel confirmation of dangerous command
CancelConfirmation,
/// Interrupt a running tool execution (Ctrl+C during ExecutingPreview)
InterruptToolExecution,
/// Retry after error
Retry,
/// Exit the application
Exit,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) enum PermissionResult {
Allow,
/// Per-file, time-limited grant scoped to the current session.
AllowFileForSession,
AlwaysAllowInDir,
AlwaysAllow,
Deny,
}
impl PermissionResult {
/// String identifier used as the SelectOption value.
pub fn as_value_str(&self) -> &'static str {
match self {
Self::Allow => "allow",
Self::AllowFileForSession => "allow-file-session",
Self::AlwaysAllowInDir => "always-allow-in-dir",
Self::AlwaysAllow => "always-allow",
Self::Deny => "deny",
}
}
/// Parse from a SelectOption value string.
pub fn from_value_str(s: &str) -> Option<Self> {
match s {
"allow" => Some(Self::Allow),
"allow-file-session" => Some(Self::AllowFileForSession),
"always-allow-in-dir" => Some(Self::AlwaysAllowInDir),
"always-allow" => Some(Self::AlwaysAllow),
"deny" => Some(Self::Deny),
_ => None,
}
}
}
|