Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

desktop: pin the Tauri CLI, fix the packaged Windows start

Niko122152d58ba32ed1
diff --git a/apps/desktop/package-lock.json b/apps/desktop/package-lock.json
new file mode 100644
index 000000000..448060e1c
--- /dev/null
+++ b/apps/desktop/package-lock.json
@@ -0,0 +1,232 @@
+{
+ "name": "strata-desktop",
+ "version": "0.1.0",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "strata-desktop",
+ "version": "0.1.0",
+ "devDependencies": {
+ "@tauri-apps/cli": "2.12.3"
+ }
+ },
+ "node_modules/@tauri-apps/cli": {
+ "version": "2.12.3",
+ "resolved": "https://registry.npmjs.org/@tauri-apps/cli/-/cli-2.12.3.tgz",
+ "integrity": "sha512-f7/LsY74SVb1ChmOPw1ajOpxii0GSzDAgmWHRci8JUYuuai04rXsSbFobpmB0sP2DdlvMD/B5ZotEn8GOGMRUg==",
+ "dev": true,
+ "license": "Apache-2.0 OR MIT",
+ "bin": {
+ "tauri": "tauri.js"
+ },
+ "engines": {
+ "node": ">= 10"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/tauri"
+ },
+ "optionalDependencies": {
+ "@tauri-apps/cli-darwin-arm64": "2.12.3",
+ "@tauri-apps/cli-darwin-x64": "2.12.3",
+ "@tauri-apps/cli-linux-arm-gnueabihf": "2.12.3",
+ "@tauri-apps/cli-linux-arm64-gnu": "2.12.3",
+ "@tauri-apps/cli-linux-arm64-musl": "2.12.3",
+ "@tauri-apps/cli-linux-riscv64-gnu": "2.12.3",
+ "@tauri-apps/cli-linux-x64-gnu": "2.12.3",
+ "@tauri-apps/cli-linux-x64-musl": "2.12.3",
+ "@tauri-apps/cli-win32-arm64-msvc": "2.12.3",
+ "@tauri-apps/cli-win32-ia32-msvc": "2.12.3",
+ "@tauri-apps/cli-win32-x64-msvc": "2.12.3"
+ }
+ },
+ "node_modules/@tauri-apps/cli-darwin-arm64": {
+ "version": "2.12.3",
+ "resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-2.12.3.tgz",
+ "integrity": "sha512-xmVNoJOOKzKLj7GLHXmXLimRby9M42aBIJa0sB80N7o24eKV5JiVmToKTRLVH9yhL05GZ/B6rSSOmbzNFJwBAA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0 OR MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">= 10"
+ }
+ },
+ "node_modules/@tauri-apps/cli-darwin-x64": {
+ "version": "2.12.3",
+ "resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-2.12.3.tgz",
+ "integrity": "sha512-URd+0usfmUQQyb5kNPiKt2OT8gp7oGU7QR+qOppB6e35mpVBFFVNhWc9oWb3p0u71fDJ09DpF4T6m9xYxoIB8g==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0 OR MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">= 10"
+ }
+ },
+ "node_modules/@tauri-apps/cli-linux-arm-gnueabihf": {
+ "version": "2.12.3",
+ "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-2.12.3.tgz",
+ "integrity": "sha512-0kwUVx2LbmOoTRlwF1oDww7th4/NSluv4ZBQ6KRZsFKg4g0TlTcIiJ0VehqkQYUeC9xIT1Mk6XtF52mI155VSQ==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "Apache-2.0 OR MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 10"
+ }
+ },
+ "node_modules/@tauri-apps/cli-linux-arm64-gnu": {
+ "version": "2.12.3",
+ "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-2.12.3.tgz",
+ "integrity": "sha512-gKSGDx6fx+HBLQmG6guChFdisbrCSdx9Yli+j5teOa64gm1CeM+C6NLru5Pj3ZkkEep05BmCFjxvX+cjqAycZQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0 OR MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 10"
+ }
+ },
+ "node_modules/@tauri-apps/cli-linux-arm64-musl": {
+ "version": "2.12.3",
+ "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.12.3.tgz",
+ "integrity": "sha512-Yr59qMy/gcvAfBuFdCGlAmGiLsYWMFDbsP4bAI6iNBzcJTGrYWZGeiQhGDo29MQwfF/NUBqyM2qljXu5tZ6wjQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0 OR MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 10"
+ }
+ },
+ "node_modules/@tauri-apps/cli-linux-riscv64-gnu": {
+ "version": "2.12.3",
+ "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-riscv64-gnu/-/cli-linux-riscv64-gnu-2.12.3.tgz",
+ "integrity": "sha512-jKr0/REBMnLKC0OwPQZkyge0mKDaNZ0b/AbfGwVyCgFfwS730EVLfVDo3nt7MUu6jJaytRq08+xSj5qfy+U1+Q==",
+ "cpu": [
+ "riscv64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0 OR MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 10"
+ }
+ },
+ "node_modules/@tauri-apps/cli-linux-x64-gnu": {
+ "version": "2.12.3",
+ "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-2.12.3.tgz",
+ "integrity": "sha512-gTkEqJAGCMROGanxHnzaJzQ+/rXl39HWVg0/hDODS1wDWBGqoceqGC6Qm1+mQbyT11xnsB8mKu/gyVID/YpFIw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0 OR MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 10"
+ }
+ },
+ "node_modules/@tauri-apps/cli-linux-x64-musl": {
+ "version": "2.12.3",
+ "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-2.12.3.tgz",
+ "integrity": "sha512-T2dTxL1svRym71fZtaW4pZYXbthbfFsEJr1NeOUg/p7laWXZbUt/8DMSZf8recu9f7+1F/Lv00HtzsEu6vDO9w==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0 OR MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 10"
+ }
+ },
+ "node_modules/@tauri-apps/cli-win32-arm64-msvc": {
+ "version": "2.12.3",
+ "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-2.12.3.tgz",
+ "integrity": "sha512-eoiQwpEZWbpsVHcM9BAzqqe4TCHszvr3rsM7pUQ4ofLK0lF1i1d/jX0Qo5DYMqcrUtwQuDdDuOCbcT0Izf1VwQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0 OR MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">= 10"
+ }
+ },
+ "node_modules/@tauri-apps/cli-win32-ia32-msvc": {
+ "version": "2.12.3",
+ "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-2.12.3.tgz",
+ "integrity": "sha512-kE+KUg6Dbbkgvcw0m99wJVIToFQzJqpMBAXah74WqxaLzssNwSTUccrHp6+QVzMhjQP330tvekFmnQF+0NbE6Q==",
+ "cpu": [
+ "ia32"
+ ],
+ "dev": true,
+ "license": "Apache-2.0 OR MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">= 10"
+ }
+ },
+ "node_modules/@tauri-apps/cli-win32-x64-msvc": {
+ "version": "2.12.3",
+ "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-2.12.3.tgz",
+ "integrity": "sha512-L7wndWAgX2mLW7alswpL3d1R0P9FN2WYBgHaQkAYEBxHHGkY4vFX9CjcRQ1LAxDAMIJxrY7/aDziFJeChS84NQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0 OR MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">= 10"
+ }
+ }
+ }
+}
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index f800c1531..2076d0af2 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -8,10 +8,13 @@
"build:ui": "npm --prefix ../host run build",
"typecheck:ui": "npm --prefix ../host run typecheck",
"test:ui": "npm --prefix ../host test",
- "tauri": "cargo tauri",
- "dev": "npm run build:ui && cargo tauri dev",
- "build": "npm run build:ui && cargo tauri build",
- "build:app": "npm run build:ui && cargo tauri build --bundles app",
- "dmg": "npm run build:ui && cargo tauri build --bundles dmg"
+ "tauri": "tauri",
+ "dev": "npm run build:ui && tauri dev",
+ "build": "npm run build:ui && tauri build",
+ "build:app": "npm run build:ui && tauri build --bundles app",
+ "dmg": "npm run build:ui && tauri build --bundles dmg"
+ },
+ "devDependencies": {
+ "@tauri-apps/cli": "2.12.3"
}
}
diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs
index b06e4fe0e..ce8c66247 100644
--- a/apps/desktop/src-tauri/src/main.rs
+++ b/apps/desktop/src-tauri/src/main.rs
@@ -50,7 +50,7 @@ fn pick_port() -> Result<u16, String> {
fn resource_dir(app: &tauri::AppHandle) -> Result<PathBuf, String> {
if let Ok(dir) = app.path().resource_dir() {
if dir.join("host").join("server").join("index.mjs").exists() {
- return Ok(dir);
+ return Ok(plain_path(dir));
}
}
// development: apps/desktop/src-tauri -> ../../host and ./resources
@@ -58,6 +58,20 @@ fn resource_dir(app: &tauri::AppHandle) -> Result<PathBuf, String> {
Ok(manifest)
}
+/// Tauri returns Windows paths in the verbatim form (`\\?\C:\...`). Node cannot take such a path as
+/// its entry script (`EISDIR ... lstat 'C:'`), so the host died at once and the window sat
+/// unresponsive until the health wait gave up. Use the ordinary drive (or UNC) form.
+fn plain_path(p: PathBuf) -> PathBuf {
+ let text = p.to_string_lossy().into_owned();
+ if let Some(rest) = text.strip_prefix(r"\\?\UNC\") {
+ return PathBuf::from(format!(r"\\{rest}"));
+ }
+ match text.strip_prefix(r"\\?\") {
+ Some(rest) => PathBuf::from(rest),
+ None => p,
+ }
+}
+
/// File name of the bundled Node runtime: `node.exe` on Windows, `node` elsewhere.
const NODE_EXE: &str = if cfg!(windows) { "node.exe" } else { "node" };
@@ -102,11 +116,19 @@ fn hide_console(cmd: &mut Command) {
fn hide_console(_cmd: &mut Command) {}
/// Wait until the host answers `/api/health`, or give up.
-fn wait_for_health(port: u16, timeout: Duration) -> Result<(), String> {
+fn wait_for_health(
+ port: u16,
+ timeout: Duration,
+ mut exited: impl FnMut() -> Option<String>,
+) -> Result<(), String> {
let deadline = Instant::now() + timeout;
let url = format!("http://127.0.0.1:{port}/api/health");
let mut last = String::from("no attempt made");
while Instant::now() < deadline {
+ // A host that already died will never answer: say so now instead of after the timeout.
+ if let Some(why) = exited() {
+ return Err(format!("the Strata App Host stopped before it became healthy: {why}"));
+ }
match ureq_get_ok(&url) {
Ok(true) => return Ok(()),
Ok(false) => last = "the host answered with a non-2xx status".into(),
@@ -194,7 +216,15 @@ fn start_host(app: &tauri::AppHandle) -> Result<u16, String> {
*app.state::<HostProcess>().0.lock().unwrap() = Some(child);
*app.state::<HostPort>().0.lock().unwrap() = Some(port);
- wait_for_health(port, Duration::from_secs(60))?;
+ let state_app = app.clone();
+ wait_for_health(port, Duration::from_secs(60), move || {
+ let state = state_app.state::<HostProcess>();
+ let mut guard = state.0.lock().unwrap();
+ match guard.as_mut().map(|c| c.try_wait()) {
+ Some(Ok(Some(status))) => Some(format!("exit status {status}")),
+ _ => None,
+ }
+ })?;
Ok(port)
}
@@ -212,6 +242,23 @@ fn stop_host(app: &tauri::AppHandle) {
}
}
+/// Where a packaged build keeps `bundle.resources`, found from the executable's own path.
+///
+/// macOS `.app`: `Contents/MacOS/<exe>` -> `Contents/Resources`. Windows NSIS: next to the exe.
+/// Linux deb/AppImage: `<prefix>/bin/<exe>` -> `<prefix>/lib/<productName>`.
+fn packaged_resource_dir(exe: &Path) -> Option<PathBuf> {
+ let dir = exe.parent()?;
+ let mut candidates = vec![dir.to_path_buf()];
+ if let Some(up) = dir.parent() {
+ candidates.push(up.join("Resources"));
+ candidates.push(up.join("lib").join("Strata"));
+ candidates.push(up.join("lib").join("strata-desktop"));
+ }
+ candidates
+ .into_iter()
+ .find(|p| p.join("host").join("server").join("index.mjs").exists())
+}
+
/// Parse `--self-test[=path]`; returns the report path when the flag is present.
fn self_test_path(args: &[String]) -> Option<String> {
for a in args.iter().skip(1) {
@@ -240,11 +287,7 @@ fn run_self_test(report_path: &str) -> i32 {
// Resolve resources the same way the real app does: `Contents/Resources` next to the
// executable when packaged, the repository layout otherwise.
let exe = std::env::current_exe().unwrap_or_default();
- let packaged_res = exe
- .parent()
- .and_then(|p| p.parent())
- .map(|p| p.join("Resources"))
- .filter(|p| p.join("host").join("server").join("index.mjs").exists());
+ let packaged_res = packaged_resource_dir(&exe);
let res = match packaged_res {
Some(p) => {
@@ -318,7 +361,10 @@ fn run_self_test(report_path: &str) -> i32 {
}
};
- let healthy = wait_for_health(port, Duration::from_secs(45));
+ let healthy = wait_for_health(port, Duration::from_secs(45), || match child.try_wait() {
+ Ok(Some(status)) => Some(format!("exit status {status}")),
+ _ => None,
+ });
record("host-healthy", healthy.is_ok(), match &healthy {
Ok(()) => format!("http://127.0.0.1:{port}/api/health answered 2xx"),
Err(e) => e.clone(),
@@ -446,6 +492,16 @@ mod tests {
let _ = std::fs::remove_dir_all(&res);
}
+ #[test]
+ fn verbatim_windows_paths_are_made_plain() {
+ assert_eq!(plain_path(PathBuf::from(r"\\?\C:\a\b")), PathBuf::from(r"C:\a\b"));
+ assert_eq!(
+ plain_path(PathBuf::from(r"\\?\UNC\srv\share\x")),
+ PathBuf::from(r"\\srv\share\x")
+ );
+ assert_eq!(plain_path(PathBuf::from("/usr/lib/Strata")), PathBuf::from("/usr/lib/Strata"));
+ }
+
#[test]
fn a_bare_node_is_not_taken_for_the_windows_runtime() {
if !cfg!(windows) {
@@ -458,4 +514,23 @@ mod tests {
assert!(node_binary(&res).is_err());
let _ = std::fs::remove_dir_all(&res);
}
+
+ #[test]
+ fn packaged_resources_are_found_for_each_platform_layout() {
+ let root = scratch("layout");
+ for (exe_rel, res_rel) in [
+ ("Contents/MacOS/strata-desktop", "Contents/Resources"),
+ ("install/strata-desktop.exe", "install"),
+ ("usr/bin/strata-desktop", "usr/lib/Strata"),
+ ] {
+ let exe = root.join(exe_rel);
+ let res = root.join(res_rel);
+ assert!(packaged_resource_dir(&exe).is_none(), "{exe_rel}");
+ let server = res.join("host").join("server");
+ std::fs::create_dir_all(&server).unwrap();
+ std::fs::write(server.join("index.mjs"), b"").unwrap();
+ assert_eq!(packaged_resource_dir(&exe), Some(res), "{exe_rel}");
+ }
+ let _ = std::fs::remove_dir_all(&root);
+ }
}