From 5d1aeb5fe338d3314568992747228c217fd2b8fc Mon Sep 17 00:00:00 2001 From: Vantz Stockwell Date: Wed, 25 Mar 2026 11:06:06 -0400 Subject: [PATCH] fix: log actual panic message when MCP startup fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Was logging "panicked — continuing" without the WHY. Now captures the panic payload (String, &str, or type_id) so the log shows exactly what went wrong in clone_services(). Co-Authored-By: Claude Opus 4.6 (1M context) --- src-tauri/src/lib.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 61e87d1..e633c4f 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -134,9 +134,10 @@ pub fn run() { let log_file = data_directory().join("wraith.log"); let _ = write_log(&log_file, "Setup: starting MCP and error watcher"); - if let Ok(state) = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { app.state::().inner().clone_services() })) { + Ok(state) => { let (ssh, rdp, sftp, scrollback, watcher) = state; let _ = write_log(&log_file, "Setup: cloned services OK"); @@ -151,8 +152,17 @@ pub fn run() { Err(e) => { let _ = write_log(&log_file2, &format!("MCP server FAILED: {}", e)); } } }); - } else { - let _ = write_log(&log_file, "MCP startup panicked — continuing without MCP"); + } + Err(panic) => { + let msg = if let Some(s) = panic.downcast_ref::() { + s.clone() + } else if let Some(s) = panic.downcast_ref::<&str>() { + s.to_string() + } else { + format!("{:?}", panic.type_id()) + }; + let _ = write_log(&log_file, &format!("MCP startup panicked: {}", msg)); + } } }