fix(app): robust spaceshd discovery for tauri dev + non-fatal connect
The app is its own cargo workspace, so in 'tauri dev' the app binary lives
in app/src-tauri/target/ and spaceshd is NOT a sibling — lazy-start failed
and the .expect() crashed the window. Now: find_daemon tries SPACESHD_BIN,
sibling, repo-root target/{debug,release}, then PATH; bridge honors
SPACESH_SOCK like the daemon/CLI; setup logs instead of panicking.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,10 +10,20 @@ pub fn run() {
|
||||
let handle = app.handle().clone();
|
||||
// Connect the bridge on a tokio runtime, then manage it.
|
||||
tauri::async_runtime::block_on(async move {
|
||||
let bridge = bridge::Bridge::connect(handle.clone())
|
||||
.await
|
||||
.expect("failed to connect to spaceshd");
|
||||
handle.manage(bridge);
|
||||
match bridge::Bridge::connect(handle.clone()).await {
|
||||
Ok(bridge) => {
|
||||
handle.manage(bridge);
|
||||
}
|
||||
// Don't crash the app — open the window and log. Commands will
|
||||
// error until a daemon is reachable; start it manually
|
||||
// (./target/debug/spaceshd) or set SPACESHD_BIN / SPACESH_SOCK.
|
||||
Err(e) => {
|
||||
eprintln!(
|
||||
"spacesh: could not connect to spaceshd: {e} — \
|
||||
start it manually or set SPACESHD_BIN/SPACESH_SOCK"
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
Ok(())
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user