Files
spaceshell/app/src-tauri/src/lib.rs
T
vasyansk 92706c0780 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>
2026-06-09 23:31:52 +07:00

54 lines
1.9 KiB
Rust

mod bridge;
use tauri::Manager;
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_notification::init())
.setup(|app| {
let handle = app.handle().clone();
// Connect the bridge on a tokio runtime, then manage it.
tauri::async_runtime::block_on(async move {
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(())
})
.invoke_handler(tauri::generate_handler![
bridge::open,
bridge::new_surface,
bridge::input,
bridge::resize,
bridge::attach,
bridge::detach,
bridge::status,
bridge::close_surface,
bridge::split_surface,
bridge::set_ratios,
bridge::move_surface,
bridge::apply_preset,
bridge::restart_surface,
bridge::close_workspace,
bridge::set_workspace_meta,
bridge::create_group,
bridge::set_group,
bridge::delete_group,
bridge::focus,
])
.run(tauri::generate_context!())
.expect("error while running spacesh");
}