Skip to content

Commit 4693f08

Browse files
committed
fix: ui look update and window controls
1 parent ee3ad60 commit 4693f08

File tree

13 files changed

+1026
-439
lines changed

13 files changed

+1026
-439
lines changed

src-tauri/capabilities/default.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
"windows": ["main"],
66
"permissions": [
77
"core:default",
8-
"opener:default"
8+
"opener:default",
9+
"core:window:allow-minimize",
10+
"core:window:allow-toggle-maximize",
11+
"core:window:allow-maximize",
12+
"core:window:allow-unmaximize",
13+
"core:window:allow-hide",
14+
"core:window:allow-close",
15+
"core:window:allow-start-dragging",
16+
"core:window:allow-set-focus",
17+
"core:window:allow-show"
918
]
1019
}

src-tauri/src/commands.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ pub async fn add_process(
159159
name: String,
160160
command: String,
161161
args: Vec<String>,
162+
working_dir: Option<String>,
162163
state: State<'_, AppState>,
163164
) -> Result<String, String> {
164165
let mut manager = state.manager.lock().map_err(|e| e.to_string())?;
165-
166-
let id = manager.add_process(name, command, args, false);
166+
let id = manager.add_process(name, command, args, working_dir, false);
167167
Ok(id)
168168
}
169169

@@ -185,6 +185,7 @@ pub async fn update_process(
185185
process_id: String,
186186
auto_restart: Option<bool>,
187187
auto_start: Option<bool>,
188+
working_dir: Option<String>,
188189
state: State<'_, AppState>,
189190
) -> Result<(), String> {
190191
let mut manager = state.manager.lock().map_err(|e| e.to_string())?;
@@ -196,6 +197,12 @@ pub async fn update_process(
196197
if let Some(as_val) = auto_start {
197198
process.auto_start = as_val;
198199
}
200+
// empty string means "clear working dir"
201+
match working_dir {
202+
Some(ref dir) if dir.is_empty() => process.working_dir = None,
203+
Some(dir) => process.working_dir = Some(dir),
204+
None => {}
205+
}
199206
}
200207

201208
Ok(())

src-tauri/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ pub fn run() {
6262
let _tray = TrayIconBuilder::new()
6363
.icon(app.default_window_icon().unwrap().clone())
6464
.menu(&menu)
65+
.on_tray_icon_event(|tray, event| {
66+
// Single click on tray icon → show window
67+
if let tauri::tray::TrayIconEvent::Click { .. } = event {
68+
if let Some(w) = tray.app_handle().get_webview_window("main") {
69+
let _ = w.show();
70+
let _ = w.set_focus();
71+
}
72+
}
73+
})
6574
.on_menu_event(|app, event| match event.id.as_ref() {
6675
"show" => {
6776
if let Some(w) = app.get_webview_window("main") {
@@ -93,6 +102,12 @@ pub fn run() {
93102

94103
Ok(())
95104
})
105+
.on_window_event(|window, event| {
106+
if let tauri::WindowEvent::CloseRequested { api, .. } = event {
107+
let _ = window.hide();
108+
api.prevent_close();
109+
}
110+
})
96111
.invoke_handler(tauri::generate_handler![
97112
commands::get_processes,
98113
commands::start_process,

src-tauri/src/log_handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ impl LogHandler {
8484
Ok(())
8585
}
8686

87+
#[allow(dead_code)]
8788
pub fn rotate_log(&self, process_id: &str, max_size_mb: u64) -> Result<(), Box<dyn std::error::Error>> {
8889
let log_path = self.get_log_file(process_id);
8990

src-tauri/src/process_manager.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub struct ProcessInstance {
1616
pub pid: Option<u32>,
1717
pub auto_restart: bool,
1818
pub auto_start: bool,
19+
pub working_dir: Option<String>,
1920
pub start_time: Option<u64>,
2021
pub crash_count: u32,
2122
pub should_restart: Arc<AtomicBool>,
@@ -33,6 +34,7 @@ impl ProcessInstance {
3334
pid: None,
3435
auto_restart,
3536
auto_start,
37+
working_dir: None,
3638
start_time: None,
3739
crash_count: 0,
3840
should_restart: Arc::new(AtomicBool::new(false)),
@@ -50,6 +52,7 @@ impl ProcessInstance {
5052
pid: None,
5153
auto_restart: config.auto_restart,
5254
auto_start: config.auto_start,
55+
working_dir: config.working_dir.clone(),
5356
start_time: None,
5457
crash_count: 0,
5558
should_restart: Arc::new(AtomicBool::new(false)),
@@ -79,6 +82,7 @@ impl ProcessInstance {
7982
pid: self.pid,
8083
auto_restart: self.auto_restart,
8184
auto_start: self.auto_start,
85+
working_dir: self.working_dir.clone(),
8286
uptime_ms: self.get_uptime_ms(),
8387
crash_count: self.crash_count,
8488
}
@@ -92,6 +96,7 @@ impl ProcessInstance {
9296
args: self.args.clone(),
9397
auto_restart: self.auto_restart,
9498
auto_start: self.auto_start,
99+
working_dir: self.working_dir.clone(),
95100
env: None,
96101
}
97102
}
@@ -108,8 +113,9 @@ impl ProcessManager {
108113
}
109114
}
110115

111-
pub fn add_process(&mut self, name: String, command: String, args: Vec<String>, auto_restart: bool) -> String {
112-
let process = ProcessInstance::new(name, command, args, auto_restart, false);
116+
pub fn add_process(&mut self, name: String, command: String, args: Vec<String>, working_dir: Option<String>, auto_restart: bool) -> String {
117+
let mut process = ProcessInstance::new(name, command, args, auto_restart, false);
118+
process.working_dir = working_dir;
113119
let id = process.id.clone();
114120
self.processes.insert(id.clone(), process);
115121
id
@@ -145,6 +151,9 @@ impl ProcessManager {
145151
cmd.args(&process.args)
146152
.stdout(Stdio::piped())
147153
.stderr(Stdio::piped());
154+
if let Some(ref dir) = process.working_dir {
155+
cmd.current_dir(dir);
156+
}
148157

149158
match cmd.spawn() {
150159
Ok(mut child) => {

src-tauri/src/types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub struct ProcessConfig {
88
pub args: Vec<String>,
99
pub auto_restart: bool,
1010
pub auto_start: bool,
11+
pub working_dir: Option<String>,
1112
pub env: Option<std::collections::HashMap<String, String>>,
1213
}
1314

@@ -39,6 +40,7 @@ pub struct ProcessState {
3940
pub pid: Option<u32>,
4041
pub auto_restart: bool,
4142
pub auto_start: bool,
43+
pub working_dir: Option<String>,
4244
pub uptime_ms: u64,
4345
pub crash_count: u32,
4446
}

src-tauri/tauri.conf.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
"title": "Process Manager",
1616
"width": 1200,
1717
"height": 800,
18-
"minWidth": 800,
19-
"minHeight": 600
18+
"minWidth": 860,
19+
"minHeight": 540,
20+
"decorations": false
2021
}
2122
],
2223
"security": {

0 commit comments

Comments
 (0)