1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5#[serde(tag = "type", rename_all = "camelCase")]
6pub enum Action {
7 CreateSession {
9 name: String,
10 },
11 DeleteSession {
12 session_id: String,
13 },
14 SaveSession {
15 session_id: String,
16 name: Option<String>,
17 },
18
19 CreatePane {
21 session_id: String,
22 pane_type: PaneType,
23 command: Option<String>,
24 shell_type: Option<ShellType>,
25 name: Option<String>,
26 },
27 ClosePane {
28 pane_id: String,
29 },
30 ResizePane {
31 pane_id: String,
32 width: u32,
33 height: u32,
34 },
35 RenamePane {
36 pane_id: String,
37 name: String,
38 },
39
40 CreateFile {
42 path: String,
43 content: Option<String>,
44 },
45 OpenFile {
46 path: String,
47 },
48 CreateDirectory {
49 path: String,
50 },
51 DeletePath {
52 path: String,
53 permanent: bool,
54 },
55 RenamePath {
56 old_path: String,
57 new_name: String,
58 },
59 CopyPath {
60 source: String,
61 destination: String,
62 },
63 MovePath {
64 source: String,
65 destination: String,
66 },
67 MoveFiles {
68 files: Vec<String>,
69 destination: String,
70 },
71 CopyFiles {
72 files: Vec<String>,
73 destination: String,
74 },
75 GetFileTree {
76 path: Option<String>,
77 max_depth: Option<u32>,
78 },
79 SearchFiles {
80 pattern: String,
81 path: Option<String>,
82 },
83
84 SearchProject {
86 pattern: String,
87 options: Value,
88 },
89 SearchInFile {
90 file_path: String,
91 pattern: String,
92 },
93
94 SendKeys {
96 pane_id: String,
97 keys: String,
98 },
99 RunCommand {
100 pane_id: String,
101 command: String,
102 },
103 GetPaneOutput {
104 pane_id: String,
105 lines: Option<u32>,
106 },
107
108 LoadPlugin {
110 id: String,
111 config: Value,
112 },
113 UnloadPlugin {
114 id: String,
115 },
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
119#[serde(rename_all = "snake_case")]
120pub enum PaneType {
121 Terminal,
122 Editor,
123 FileTree,
124 Output,
125 Custom(String),
126}
127
128#[derive(Debug, Clone, Serialize, Deserialize)]
129#[serde(rename_all = "snake_case")]
130pub enum ShellType {
131 Bash,
132 Zsh,
133 Fish,
134 PowerShell,
135 Cmd,
136 Custom(String),
137}
138
139impl ShellType {
140 pub fn detect() -> Self {
141 if cfg!(target_os = "windows") {
142 ShellType::PowerShell
143 } else {
144 match std::env::var("SHELL") {
146 Ok(shell) if shell.contains("zsh") => ShellType::Zsh,
147 Ok(shell) if shell.contains("bash") => ShellType::Bash,
148 Ok(shell) if shell.contains("fish") => ShellType::Fish,
149 _ => ShellType::Bash, }
151 }
152 }
153}