fix: RDP panic logging + CWD starts at home directory
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 3m16s

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) <noreply@anthropic.com>
This commit is contained in:
Vantz Stockwell 2026-03-25 11:02:30 -04:00
parent 83b746df0e
commit 03bb6f3ccf
2 changed files with 15 additions and 2 deletions

View File

@ -119,6 +119,7 @@ impl RdpService {
let (ready_tx, ready_rx) = std::sync::mpsc::channel::<Result<(), String>>();
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::<String>() {
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());
}
}

View File

@ -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;