From 03bb6f3ccfe8c75418f718205e63a1e0a299da0a Mon Sep 17 00:00:00 2001 From: Vantz Stockwell Date: Wed, 25 Mar 2026 11:02:30 -0400 Subject: [PATCH] fix: RDP panic logging + CWD starts at home directory RDP: wrapped connection thread in catch_unwind so panics are logged to wraith.log instead of silently killing the channel. Error message now directs user to check the log. CWD: changed cd . to cd ~ after OSC 7 hook injection so SFTP starts at the user's home directory on macOS (where / requires explicit nav). Co-Authored-By: Claude Opus 4.6 (1M context) --- src-tauri/src/rdp/mod.rs | 15 ++++++++++++++- src-tauri/src/ssh/session.rs | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) 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;