| 14 | #[cfg(all(desktop, not(rust_analyzer)))] |
| 15 | #[cfg_attr(mobile, tauri::mobile_entry_point)] |
| 16 | pub fn run() -> Result<(), AppError> { |
| 17 | let _ = env_logger::try_init(); |
| 18 | |
| 19 | let builder = tauri::Builder::default() |
| 20 | .plugin(tauri_plugin_dialog::init()) |
| 21 | .plugin(tauri_plugin_fs::init()) |
| 22 | .plugin(tauri_plugin_opener::init()) |
| 23 | .invoke_handler(tauri::generate_handler![ |
| 24 | commands::project::create_project, |
| 25 | commands::project::list_projects, |
| 26 | commands::project::delete_project, |
| 27 | commands::session::create_session, |
| 28 | commands::session::list_sessions, |
| 29 | commands::session::delete_session, |
| 30 | commands::session::update_session_title, |
| 31 | commands::chat::get_messages, |
| 32 | commands::chat::send_message, |
| 33 | commands::chat::generate_title, |
| 34 | commands::chat::generate_excalidraw, |
| 35 | commands::chat::cancel_chat, |
| 36 | commands::provider::list_providers, |
| 37 | commands::provider::create_provider, |
| 38 | commands::provider::update_provider, |
| 39 | commands::provider::delete_provider, |
| 40 | commands::provider::set_default_provider, |
| 41 | commands::provider::toggle_provider_enabled, |
| 42 | commands::provider::list_models, |
| 43 | commands::provider::list_provider_models, |
| 44 | commands::provider::upsert_provider_model, |
| 45 | commands::provider::delete_provider_model, |
| 46 | commands::drawing::get_drawing, |
| 47 | commands::drawing::save_drawing, |
| 48 | commands::agent::list_agent_runs, |
| 49 | commands::agent::list_tool_calls, |
| 50 | commands::agent::run_agent, |
| 51 | commands::agent::cancel_agent, |
| 52 | commands::agent::get_agent_config, |
| 53 | commands::agent::upsert_agent_config, |
| 54 | commands::agent::list_agent_configs, |
| 55 | commands::agent::agent_permission_response |
| 56 | ]) |
| 57 | .setup(|app| { |
| 58 | let app_handle = app.handle().clone(); |
| 59 | |
| 60 | let data_dir = app_handle |
| 61 | .path() |
| 62 | .app_data_dir() |
| 63 | .map_err(|e| Box::new(AppError::Internal(e.to_string())))?; |
| 64 | |
| 65 | std::fs::create_dir_all(&data_dir) |
| 66 | .map_err(|e| Box::new(AppError::Io(e.to_string())))?; |
| 67 | |
| 68 | let db_path = data_dir.join("enowx.db"); |
| 69 | let db_url = format!("sqlite://{}?mode=rwc", db_path.display()); |
| 70 | |
| 71 | let (tx, rx) = std::sync::mpsc::channel::<Result<AppState, String>>(); |
| 72 | |
| 73 | std::thread::spawn(move || { |