feat(app): Tauri window and the Windows build

M5 step 5, first part. app/shell is a Tauri 2 crate (jarvis.exe): one
window over app/ui whose invoke("admin") goes to AdminApi::call. Its
WebView2 data sits next to the location file; closing the window stops
the services and waits for a cancelled start (AdminApi::shutdown).

app/shell/package.sh cross-builds it on Linux (x86_64-pc-windows-gnu)
and lays out Jarvis/ with WebView2Loader.dll and python-src/
(voice_worker, jarvis). The worker's default sources are python-src next
to the executable when present, else the repository's src/.

The bot screen now shows the masked token right after saving.

Checked on the win-ci VM: the window and wizard, PC check, uv and worker
venv installed, a cancel leaving no uv/Python process, the token stored
DPAPI-encrypted, a start failing with its reason, logs, error copy, zip
export, closing the window ending the process, nothing under %APPDATA% or
%LOCALAPPDATA%; the core's unit tests on Windows (156/157, the one
Linux-path assumption fixed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 18:16:02 +09:00
parent 81ba5e3521
commit ac8c30022d
17 changed files with 7752 additions and 7 deletions

62
app/shell/src/main.rs Normal file
View File

@@ -0,0 +1,62 @@
//! Jarvis management app: one Tauri 2 window over the app core (`app/src/admin.spec.md`, "Screens").
//! The screens (`app/ui`) call `invoke("admin", {command, args})`, passed to the same `AdminApi` the
//! development server uses. Closing the window stops the services the app started.
//!
//! jarvis [--location FILE]
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use std::path::PathBuf;
use std::sync::Arc;
use jarvis_app::admin_api::AdminApi;
use serde_json::Value;
use tauri::{Manager, RunEvent, WebviewUrl, WebviewWindowBuilder};
struct Api(Arc<AdminApi>);
#[tauri::command]
async fn admin(api: tauri::State<'_, Api>, command: String, args: Option<Value>) -> Result<Value, String> {
api.0.call(&command, args.unwrap_or(Value::Null)).await
}
fn arg(name: &str) -> Option<String> {
let args: Vec<String> = std::env::args().collect();
args.iter().position(|a| a == name).and_then(|i| args.get(i + 1).cloned())
}
fn main() {
let location = arg("--location").map(PathBuf::from).or_else(jarvis_app::datadir::default_location_file)
.expect("no location file path: pass --location");
// Log files go to the data folder once there is one; until then memory only.
let logs = jarvis_app::datadir::DataDir::locate(&location).map(|d| d.logs());
let hub = jarvis_app::logs::LogHub::new(logs.as_deref());
jarvis_app::logs::install(hub.clone());
let api = Arc::new(AdminApi::new(&location, hub));
// The window's own browser data sits next to the location file, not in a folder of its own.
let webview_data = location.parent().map(|p| p.join("webview"));
let app = tauri::Builder::default()
.manage(Api(api.clone()))
.invoke_handler(tauri::generate_handler![admin])
.setup(move |app| {
let mut w = WebviewWindowBuilder::new(app, "main", WebviewUrl::App("index.html".into()))
.title("Jarvis 관리")
.inner_size(1200.0, 820.0)
.min_inner_size(900.0, 600.0);
if let Some(dir) = webview_data.clone() {
w = w.data_directory(dir);
}
w.build()?;
Ok(())
})
.build(tauri::generate_context!())
.expect("the window did not start");
app.run(move |handle, event| {
if let RunEvent::ExitRequested { .. } = event {
jarvis_app::info_log!("app", "window closed: stopping the services");
let api = handle.state::<Api>().0.clone();
tauri::async_runtime::block_on(api.shutdown());
}
});
}