lib.rs
sha256:8d7f41aafae41deee70035a92f93602ef1722a290153597451e5932af503a42c
docs: queue board-identity follow-ups so they survive the session
Human
2 hours ago
| 1 | mod launcher; |
| 2 | |
| 3 | use std::sync::Mutex; |
| 4 | |
| 5 | use tauri::{Manager, RunEvent, WebviewUrl}; |
| 6 | |
| 7 | struct AppState { |
| 8 | child: Mutex<Option<launcher::OkAppChild>>, |
| 9 | } |
| 10 | |
| 11 | #[cfg_attr(mobile, tauri::mobile_entry_point)] |
| 12 | pub fn run() { |
| 13 | let kit_root = launcher::resolve_kit_root(); |
| 14 | let repo_root = launcher::resolve_repo_root(&kit_root); |
| 15 | let port = launcher::default_port(); |
| 16 | |
| 17 | let (child, banner) = match launcher::spawn_ok_app(&kit_root, &repo_root, port) { |
| 18 | Ok(result) => result, |
| 19 | Err(err) => { |
| 20 | eprintln!("desktop launcher error: {err}"); |
| 21 | std::process::exit(2); |
| 22 | } |
| 23 | }; |
| 24 | |
| 25 | let init_script = launcher::build_auth_bootstrap_script(&banner); |
| 26 | let external_url = match banner.url.parse() { |
| 27 | Ok(url) => url, |
| 28 | Err(err) => { |
| 29 | eprintln!("invalid ok app url {}: {err}", banner.url); |
| 30 | std::process::exit(2); |
| 31 | } |
| 32 | }; |
| 33 | |
| 34 | let app = tauri::Builder::default() |
| 35 | .manage(AppState { |
| 36 | child: Mutex::new(Some(child)), |
| 37 | }) |
| 38 | .setup(move |app| { |
| 39 | let _window = tauri::WebviewWindowBuilder::new( |
| 40 | app, |
| 41 | "main", |
| 42 | WebviewUrl::External(external_url), |
| 43 | ) |
| 44 | .title("Overseer Kit") |
| 45 | .inner_size(1200.0, 800.0) |
| 46 | .initialization_script(&init_script) |
| 47 | .build()?; |
| 48 | Ok(()) |
| 49 | }) |
| 50 | .build(tauri::generate_context!()) |
| 51 | .expect("error while building tauri application"); |
| 52 | |
| 53 | app.run(|app_handle, event| { |
| 54 | if let RunEvent::Exit = event { |
| 55 | if let Some(state) = app_handle.try_state::<AppState>() { |
| 56 | if let Ok(mut guard) = state.child.lock() { |
| 57 | if let Some(mut child) = guard.take() { |
| 58 | child.kill(); |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | }); |
| 64 | } |
File History
1 commit
sha256:8d7f41aafae41deee70035a92f93602ef1722a290153597451e5932af503a42c
docs: queue board-identity follow-ups so they survive the session
Human
2 hours ago