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

View File

@@ -92,6 +92,23 @@ impl AdminApi {
Ok(c.get_or_insert_with(|| Controller::new(ServicesHost::new(dir.path().to_path_buf()))).clone())
}
/// Stop the services (and cancel a start) when the app closes, so nothing it started (the
/// worker, Strata) keeps running.
pub async fn shutdown(&self) {
let controller = self.controller.lock().unwrap().clone();
if let Some(c) = controller {
if matches!(c.state(), State::Running | State::Starting) {
let _ = c.stop().await;
}
// A cancelled start finishes in the background: wait for it (Strata's stop takes up to
// two minutes) before the app exits.
let until = std::time::Instant::now() + std::time::Duration::from_secs(150);
while matches!(c.state(), State::Starting | State::Stopping) && std::time::Instant::now() < until {
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
}
}
}
pub async fn call(&self, command: &str, args: Value) -> Result<Value, String> {
crate::debug_log!("admin", "command {command}");
match command {
@@ -306,6 +323,16 @@ mod tests {
assert!(a.call("service_stop", json!({})).await.is_err());
}
#[tokio::test]
async fn closing_the_app_while_starting_waits_until_everything_is_stopped() {
let (a, base) = api("api5");
a.shutdown().await; // nothing chosen or started yet
a.call("folder_choose", json!({"path": base.join("d").to_string_lossy()})).await.unwrap();
a.call("service_start", json!({})).await.unwrap();
a.shutdown().await;
assert_eq!(a.call("dashboard", json!({})).await.unwrap()["state"], json!("stopped"));
}
#[tokio::test]
async fn a_start_is_starting_when_it_answers_so_a_stop_right_after_it_is_not_refused() {
let (a, base) = api("api4");