diff --git a/src-tauri/src/rdp/mod.rs b/src-tauri/src/rdp/mod.rs index a2dbb1a..11484b7 100644 --- a/src-tauri/src/rdp/mod.rs +++ b/src-tauri/src/rdp/mod.rs @@ -119,6 +119,7 @@ impl RdpService { let (ready_tx, ready_rx) = std::sync::mpsc::channel::>(); std::thread::spawn(move || { + let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { let rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() @@ -166,6 +167,18 @@ impl RdpService { info!("RDP session {} ended", sid); sessions_ref.remove(&sid); }); + })); + if let Err(panic) = result { + let msg = if let Some(s) = panic.downcast_ref::() { + s.clone() + } else if let Some(s) = panic.downcast_ref::<&str>() { + s.to_string() + } else { + "unknown panic".to_string() + }; + let _ = crate::write_log(&crate::data_directory().join("wraith.log"), &format!("RDP thread PANIC: {}", msg)); + // ready_tx is dropped here, which triggers the "died unexpectedly" error + } }); match ready_rx.recv() { @@ -176,7 +189,7 @@ impl RdpService { } Err(_) => { self.sessions.remove(&session_id); - return Err("RDP connection thread died unexpectedly".into()); + return Err("RDP connection thread panicked — check wraith.log for details".into()); } } diff --git a/src-tauri/src/ssh/session.rs b/src-tauri/src/ssh/session.rs index 3af25f1..5e1c29b 100644 --- a/src-tauri/src/ssh/session.rs +++ b/src-tauri/src/ssh/session.rs @@ -168,7 +168,7 @@ impl SshService { "__wraith_osc7() { printf '\\e]7;file://localhost/%s\\a' \"$(pwd | sed 's/ /%20/g')\"; }; ", "if [ -n \"$ZSH_VERSION\" ]; then precmd() { __wraith_osc7; }; ", "elif [ -n \"$BASH_VERSION\" ]; then PROMPT_COMMAND=__wraith_osc7; fi; ", - "stty echo; clear; cd .\n" + "stty echo; clear; cd ~\n" ); let h = handle.lock().await; let _ = h.data(channel_id, CryptoVec::from_slice(osc7_hook.as_bytes())).await;