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

2
app/shell/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
target/
gen/

7531
app/shell/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

26
app/shell/Cargo.toml Normal file
View File

@@ -0,0 +1,26 @@
[package]
name = "jarvis-shell"
version = "0.1.0"
edition = "2021"
rust-version = "1.85"
description = "Jarvis v2 management app window (Tauri 2 over the app core's AdminApi)"
license = "MIT"
publish = false
[[bin]]
name = "jarvis"
path = "src/main.rs"
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
jarvis-app = { path = ".." }
tauri = { version = "2", features = [] }
serde_json = "1"
tokio = { version = "1", features = ["full"] }
[profile.release]
lto = "thin"
codegen-units = 4
strip = "symbols"

3
app/shell/build.rs Normal file
View File

@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}

View File

@@ -0,0 +1,7 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "The management window: core only (the app's own `admin` command needs no permission).",
"windows": ["main"],
"permissions": ["core:default"]
}

BIN
app/shell/icons/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
app/shell/icons/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

20
app/shell/package.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/sh
# Build the Windows management app from Linux and lay it out ready to zip (admin.spec.md, "Windows build"):
# Jarvis/jarvis.exe, Jarvis/WebView2Loader.dll, Jarvis/python-src/{voice_worker,jarvis}
# Needs the x86_64-pc-windows-gnu Rust target, mingw-w64 and cmake (for Opus).
# app/shell/package.sh <output folder>
set -eu
here=$(cd "$(dirname "$0")" && pwd)
out=${1:?output folder}
target=${CARGO_TARGET_DIR:-$here/target}
cargo build --release --locked --target x86_64-pc-windows-gnu --manifest-path "$here/Cargo.toml"
rel="$target/x86_64-pc-windows-gnu/release"
rm -rf "$out/Jarvis"
mkdir -p "$out/Jarvis/python-src"
cp "$rel/jarvis.exe" "$rel/WebView2Loader.dll" "$out/Jarvis/"
# The worker and brain sources only (the worker venv gets its packages from the requirement files).
for pkg in voice_worker jarvis; do
(cd "$here/../../src" && find "$pkg" -name __pycache__ -prune -o -name '*.spec.md' -prune -o -type f -print) |
while read -r f; do mkdir -p "$out/Jarvis/python-src/$(dirname "$f")"; cp "$here/../../src/$f" "$out/Jarvis/python-src/$f"; done
done
echo "$out/Jarvis"

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());
}
});
}

20
app/shell/tauri.conf.json Normal file
View File

@@ -0,0 +1,20 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "Jarvis",
"version": "0.1.0",
"identifier": "kr.jarvis.manager",
"build": {
"frontendDist": "../ui"
},
"app": {
"withGlobalTauri": true,
"windows": [],
"security": {
"csp": "default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src ipc: http://ipc.localhost"
}
},
"bundle": {
"active": false,
"icon": ["icons/icon.ico", "icons/icon.png"]
}
}