From d2f0f330e2cdc91676aed1115b22439415892d48 Mon Sep 17 00:00:00 2001
From: Arron Ohnemus
Date: Mon, 15 Jun 2026 12:20:13 -0500
Subject: [PATCH 01/19] feat: fix wizard notifications, rework auto-update
options, and harden ASA cache/cert flows
- Fix wizard notification settings not persisting: matrix state is now
saved to notification_configs on wizard completion (not lost to failed
DB writes); Discord/SMTP credentials saved as notification_configs
entries so settings page reads them correctly
- Replace numeric auto-update intervals with semantic modes
(disabled/startup/startup_hourly) for ASA cache, LokiASAM app, and
Proton-GE; standardise 3-button selector layout across all wizard cards
- Add Proton-GE background update check to UpdateManager with
startup/hourly modes controlled by proton_ge_check_mode setting
- Guard ASA cache auto-check and dashboard update button behind
servers.length > 0 so nothing runs before a server is created
- Show spinning indicator in TopBar while ASA cache update is in progress
- Fix mod API cert installation on Linux: initialise Wine prefix via
proton run instead of bare wine64 so it works before any server starts
---
src-tauri/src/commands/certs.rs | 41 +++++--
src/app/page.tsx | 38 +++---
src/app/settings/page.tsx | 86 ++++++-------
src/components/layout/TopBar.tsx | 13 +-
src/components/layout/UpdateManager.tsx | 55 +++++++--
src/components/server/ServerCard.tsx | 2 +-
src/components/server/tabs/OverviewTab.tsx | 2 +-
src/components/shared/NotificationMatrix.tsx | 19 ++-
src/components/wizard/SetupWizard.tsx | 121 +++++++++++++------
src/lib/db.ts | 2 +-
src/lib/scheduler-sync.ts | 39 ++++--
src/lib/update-utils.ts | 35 +++++-
src/store/useAppStore.ts | 7 ++
src/store/useSetupStore.ts | 34 +-----
14 files changed, 315 insertions(+), 179 deletions(-)
diff --git a/src-tauri/src/commands/certs.rs b/src-tauri/src/commands/certs.rs
index eb19ce1..18d06a0 100644
--- a/src-tauri/src/commands/certs.rs
+++ b/src-tauri/src/commands/certs.rs
@@ -103,33 +103,48 @@ async fn install_windows(cert_path: &str) -> Result<(), String> {
#[cfg(target_os = "linux")]
async fn install_linux(cert_path: &str, proton_path: &str, prefix_path: &str) -> Result<(), String> {
- let wine_bin = format!("{proton_path}/files/bin/wine64");
- let wine_pfx = format!("{prefix_path}/pfx");
- let marker = PathBuf::from(prefix_path).join(CERT_MARKER_FILENAME);
-
- // Initialise the Wine prefix if it has not been set up yet. wineboot -u
- // creates the fake C: drive, registry hives, etc. without blocking on
- // Mono/Gecko downloads. This can take up to ~30 s on first run.
+ let proton_script = format!("{proton_path}/proton");
+ let wine_bin = format!("{proton_path}/files/bin/wine64");
+ let wine_pfx = format!("{prefix_path}/pfx");
+ let marker = PathBuf::from(prefix_path).join(CERT_MARKER_FILENAME);
+
+ // Initialise the Wine prefix if it has not been set up yet.
+ // Use the Proton run script (same mechanism as server start) rather than
+ // wine64 directly — Proton-GE's wine64 is compiled for the Steam Linux
+ // Runtime and may fail outside it. `proton run` handles environment setup.
+ // Setting STEAM_COMPAT_CLIENT_INSTALL_PATH to a dummy value prevents
+ // Proton from trying to use the Steam Runtime daemon when Steam is installed.
let system_reg = format!("{wine_pfx}/system.reg");
if !tokio::fs::try_exists(&system_reg).await.unwrap_or(false) {
- let status = Command::new(&wine_bin)
- .args(["wineboot", "-u"])
- .env("WINEPREFIX", &wine_pfx)
+ // Create parent directories so Proton can create the pfx inside.
+ tokio::fs::create_dir_all(&wine_pfx)
+ .await
+ .map_err(|e| format!("Failed to create prefix directory: {e}"))?;
+
+ let status = Command::new(&proton_script)
+ .arg("run")
+ .arg("C:\\windows\\system32\\wineboot.exe")
+ .env("STEAM_COMPAT_DATA_PATH", prefix_path)
+ .env("STEAM_COMPAT_CLIENT_INSTALL_PATH", "/")
.env("WINEDLLOVERRIDES", "mscoree,mshtml=")
.env("WINEDEBUG", "-all")
+ .env("PROTON_LOG", "0")
.status()
.await
- .map_err(|e| format!("Failed to run wineboot: {e}"))?;
+ .map_err(|e| format!("Failed to run proton wineboot: {e}"))?;
- if !status.success() {
+ // Proton may exit non-zero even on success (wineboot is a short-lived
+ // process). Check that the prefix was actually created instead.
+ if !tokio::fs::try_exists(&system_reg).await.unwrap_or(false) {
return Err(format!(
- "wineboot exited with code {}",
+ "Wine prefix initialisation failed (proton exited {}); try starting a server once first.",
status.code().unwrap_or(-1)
));
}
}
// Install the certificate into Wine's CurrentUser\Root store.
+ // At this point the prefix exists, so wine64 can run standalone.
let status = Command::new(&wine_bin)
.args(["certutil", "-addstore", "Root", cert_path])
.env("WINEPREFIX", &wine_pfx)
diff --git a/src/app/page.tsx b/src/app/page.tsx
index eafc485..de44b2c 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -19,7 +19,7 @@ import { ImportServerWizard } from "@/components/server/ImportServerWizard";
import { useServers } from "@/hooks/useServers";
import { getAppSetting, setAppSetting, updateServerStatus } from "@/lib/db";
import { tauriCmd, type UpdateCheckResult } from "@/lib/tauri-commands";
-import { runPerServerUpdateCheck, applyUpdateToServer, type ServerUpdateInfo } from "@/lib/update-utils";
+import { runAsaCacheUpdate, runPerServerUpdateCheck, applyUpdateToServer, type ServerUpdateInfo } from "@/lib/update-utils";
import { buildStartParams } from "@/lib/server-utils";
import { dispatchNotification } from "@/lib/notifications";
import { NOTIFICATION_EVENTS } from "@/data/game-data";
@@ -80,24 +80,12 @@ function UpdateStatusChip({ servers = [], onUpdateAllClick, onUpdatesFound }: Up
const handleCheck = async () => {
setChecking(true);
try {
- const [baseDir, steamcmdPath] = await Promise.all([
- getAppSetting("base_dir"),
- getAppSetting("steamcmd_path"),
- ]);
- if (!baseDir || !steamcmdPath) {
+ const oldBuild = await getAppSetting("asa_cached_build_id") ?? "";
+ const newBuild = await runAsaCacheUpdate();
+ if (!newBuild) {
toast.error("Base directory or SteamCMD not configured.");
return;
}
- const sep = baseDir.includes("\\") ? "\\" : "/";
- const cacheDir = `${baseDir.replace(/[/\\]$/, "")}${sep}lokiasam${sep}cache${sep}asa-server`;
- const oldBuild = await getAppSetting("asa_cached_build_id") ?? "";
- const newBuild = await tauriCmd.updateCache("check", cacheDir, steamcmdPath);
- const now = new Date().toISOString();
- await Promise.all([
- setAppSetting("asa_cached_build_id", newBuild),
- setAppSetting("asa_latest_build_id", newBuild),
- setAppSetting("asa_last_checked", now),
- ]);
// Manual check: silent mode suppresses per-server toasts; we show dialog.
const summary = await runPerServerUpdateCheck(true);
queryClient.invalidateQueries({ queryKey: ["servers"] });
@@ -514,14 +502,16 @@ export default function DashboardPage() {
- This is where your ASA server files will be installed. Choose a drive with at least 20 GB of free space.
+ This is where your ASA server files will be installed. Choose a drive with at least 40 GB of free space.
@@ -1602,7 +1602,7 @@ function CertStep() {
);
}
-function NotificationsStep() {
+function NotificationsStep({ matrixRef }: { matrixRef: React.RefObject }) {
const {
discordWebhook, setDiscordWebhook,
smtpHost, setSmtpHost,
@@ -1792,7 +1792,7 @@ function NotificationsStep() {
Choose which events trigger each channel. Configure credentials above to unlock Discord and SMTP columns.
Desktop notifications:
- OS desktop notifications (the pop-up alerts from your system) only appear when LokiASAM is minimized to the system tray. While the window is open or the app is fully closed, notifications are shown as in-app toasts instead.
+ OS desktop notifications (the pop-up alerts from your system) may only appear when LokiASAM is minimized to the system tray. This is dependent on your desktop environment and its notification settings, not LokiASAM itself.
@@ -531,6 +531,7 @@ export default function DashboardPage() {
+
{/* ── Needs Attention warning — only shown when servers are in a bad state ── */}
{total > 0 && servers.some((s) => s.status === "crashed" || s.status === "error") && (
@@ -1943,12 +2034,13 @@ export default function SettingsPage() {
{/* About tab */}
{activeTab === "about" && (
-
-
+
+
-
+
)}
+
);
}
From d0e9503b9bbbca6b85aa51f36940e81cffffd3f8 Mon Sep 17 00:00:00 2001
From: Arron Ohnemus
Date: Tue, 16 Jun 2026 15:54:55 -0500
Subject: [PATCH 12/19] feat: add build version tracking and fetching
functionality
- Implemented `build_version.rs` to handle fetching and caching game versions from the Steam News API and server queries.
- Added database functions for managing build version cache and installed build IDs.
- Updated server commands to record installed build IDs and trigger version fetches after installations and updates.
- Introduced a React hook `useBuildVersionCache` to manage version cache state in the frontend.
- Enhanced UI components to display human-readable game versions based on installed build IDs.
---
src-tauri/src/commands/build_version.rs | 310 +++++++++++++++++++++
src-tauri/src/commands/mod.rs | 1 +
src-tauri/src/commands/scheduler.rs | 12 +
src-tauri/src/commands/server.rs | 12 +
src-tauri/src/commands/steamcmd.rs | 28 +-
src-tauri/src/db.rs | 57 ++++
src-tauri/src/lib.rs | 2 +
src/app/clusters/detail/page.tsx | 6 +
src/app/page.tsx | 12 +-
src/app/servers/detail/page.tsx | 14 +-
src/app/settings/page.tsx | 40 ++-
src/components/server/ServerCard.tsx | 9 +
src/components/server/tabs/OverviewTab.tsx | 11 +
src/hooks/useBuildVersionCache.ts | 22 ++
src/lib/db.ts | 68 +++++
src/lib/tauri-commands.ts | 4 +
src/lib/update-utils.ts | 8 +-
17 files changed, 598 insertions(+), 18 deletions(-)
create mode 100644 src-tauri/src/commands/build_version.rs
create mode 100644 src/hooks/useBuildVersionCache.ts
diff --git a/src-tauri/src/commands/build_version.rs b/src-tauri/src/commands/build_version.rs
new file mode 100644
index 0000000..819f8a8
--- /dev/null
+++ b/src-tauri/src/commands/build_version.rs
@@ -0,0 +1,310 @@
+// build_version.rs — ASA build ID → human-readable game version (e.g. "49.23")
+//
+// Two sources, in priority order:
+// "internet" – Steam News API title parse, fetched once per build_id right
+// after SteamCMD downloads it (so the latest news matches the
+// latest build).
+// "server" – A2S_INFO Source Query against localhost once the server
+// confirms running. Always overwrites "internet".
+
+use crate::{db, state::AppState};
+use tauri::Manager;
+
+// ── Version sources ───────────────────────────────────────────────────────────
+
+const OFFICIAL_SERVER_LIST_URL: &str =
+ "https://cdn2.arkdedicated.com/servers/asa/officialserverlist.json";
+
+const PATCH_NOTES_URL: &str =
+ "https://survivetheark.com/index.php?/forums/topic/708761-asa-pc-patch-notes-client";
+
+/// Fetch the current ASA version from the official Wildcard server list.
+/// This is the same JSON the game client uses for the server browser, so it
+/// reflects the live version exactly. Returns e.g. "88.23".
+async fn fetch_version_from_official_list() -> Option {
+ #[derive(serde::Deserialize)]
+ struct Entry {
+ #[serde(rename = "BuildId")]
+ build_id: u32,
+ #[serde(rename = "MinorBuildId")]
+ minor_build_id: u32,
+ }
+
+ let client = reqwest::Client::builder()
+ .timeout(std::time::Duration::from_secs(15))
+ .user_agent("LokiASAM/1.0")
+ .build()
+ .ok()?;
+
+ let entries: Vec = client
+ .get(OFFICIAL_SERVER_LIST_URL)
+ .send()
+ .await
+ .ok()?
+ .json()
+ .await
+ .ok()?;
+
+ let first = entries.into_iter().next()?;
+ Some(format!("{}.{}", first.build_id, first.minor_build_id))
+}
+
+/// Extract "88.3" from text like "v88.3 - Major version for Servers…"
+/// Requires at least a 2-digit major so single-digit noise is skipped.
+fn extract_version_from_patch_notes(text: &str) -> Option {
+ let s = text.as_bytes();
+ let mut i = 0;
+ while i < s.len() {
+ // Require explicit 'v' / 'V' prefix so bare numbers are ignored
+ if (s[i] != b'v' && s[i] != b'V') || i + 1 >= s.len() || !s[i + 1].is_ascii_digit() {
+ i += 1;
+ continue;
+ }
+ let num_start = i + 1;
+ let mut j = num_start;
+ while j < s.len() && s[j].is_ascii_digit() { j += 1; }
+ let major_len = j - num_start;
+ if major_len < 2 || j >= s.len() || s[j] != b'.' {
+ i += 1;
+ continue;
+ }
+ j += 1; // skip dot
+ let minor_start = j;
+ while j < s.len() && s[j].is_ascii_digit() { j += 1; }
+ if j == minor_start {
+ i += 1;
+ continue;
+ }
+ // Return "MAJOR.MINOR" (drop any trailing .patch suffix)
+ return Some(text[num_start..j].to_string());
+ }
+ None
+}
+
+/// Fetch the most recent ASA version string from the survivetheark.com patch
+/// notes thread. The forum meta description always leads with the newest entry
+/// so we only need to parse those first few hundred characters.
+async fn fetch_version_from_patch_notes() -> Option {
+ let client = reqwest::Client::builder()
+ .timeout(std::time::Duration::from_secs(15))
+ .user_agent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 \
+ (KHTML, like Gecko) Chrome/125.0 Safari/537.36")
+ .build()
+ .ok()?;
+
+ let html = client.get(PATCH_NOTES_URL).send().await.ok()?.text().await.ok()?;
+
+ // The forum renders the first ~300 chars of post body as the meta description,
+ // which always starts with the most recently prepended version entry.
+ let meta_start = html.find(" Option {
+ use tokio::net::UdpSocket;
+ use tokio::time::{timeout, Duration};
+
+ let sock = UdpSocket::bind("0.0.0.0:0").await.ok()?;
+ sock.connect(format!("127.0.0.1:{port}")).await.ok()?;
+
+ let base_req: &[u8] = b"\xFF\xFF\xFF\xFF\x54Source Engine Query\x00";
+ let mut req = base_req.to_vec();
+
+ sock.send(&req).await.ok()?;
+
+ let mut buf = [0u8; 1400];
+
+ // Up to two rounds: initial send + one challenge re-send
+ for _ in 0..2u8 {
+ let n = timeout(Duration::from_secs(5), sock.recv(&mut buf))
+ .await
+ .ok()?.ok()?;
+
+ if n < 5 || buf[0..4] != [0xFF, 0xFF, 0xFF, 0xFF] {
+ return None;
+ }
+
+ match buf[4] {
+ 0x41 => {
+ // Challenge response — resend query with 4-byte challenge appended
+ if n < 9 {
+ return None;
+ }
+ let mut new_req = base_req.to_vec();
+ new_req.extend_from_slice(&buf[5..9]);
+ req = new_req;
+ sock.send(&req).await.ok()?;
+ }
+ 0x49 => {
+ // A2S_INFO response — parse for version string
+ return parse_a2s_version(&buf[5..n]);
+ }
+ _ => return None,
+ }
+ }
+ None
+}
+
+/// Parse an A2S_INFO response body (after the 0xFF×4 0x49 header) for the
+/// version string. Layout: protocol(1), name, map, folder, game (null-term
+/// strings), app_id(2), players(1), max_players(1), bots(1), server_type(1),
+/// environment(1), visibility(1), vac(1), version (null-term string).
+fn parse_a2s_version(data: &[u8]) -> Option {
+ let mut pos = 1; // skip protocol byte
+
+ // Skip four null-terminated strings: name, map, folder, game
+ for _ in 0..4 {
+ while pos < data.len() && data[pos] != 0 {
+ pos += 1;
+ }
+ pos += 1; // consume null terminator
+ }
+
+ // Skip: app_id(2) + players(1) + max_players(1) + bots(1) +
+ // server_type(1) + environment(1) + visibility(1) + vac(1) = 9 bytes
+ pos += 9;
+
+ if pos >= data.len() {
+ return None;
+ }
+
+ // Version string (null-terminated)
+ let start = pos;
+ while pos < data.len() && data[pos] != 0 {
+ pos += 1;
+ }
+ let version = std::str::from_utf8(&data[start..pos]).ok()?;
+ if version.is_empty() {
+ return None;
+ }
+
+ // Normalise to "MAJOR.MINOR" (e.g. "49.23.0" → "49.23")
+ let parts: Vec<&str> = version.split('.').collect();
+ if parts.len() >= 2 {
+ Some(format!("{}.{}", parts[0], parts[1]))
+ } else {
+ Some(version.to_string())
+ }
+}
+
+// ── Public helpers called by steamcmd.rs and server.rs ───────────────────────
+
+/// After SteamCMD downloads a new build: store the build_id against the server
+/// row and fetch the internet version if this build_id isn't cached yet.
+/// Runs the internet fetch in a background task (fire and forget).
+pub fn record_install(app: &tauri::AppHandle, server_id: &str, build_id: &str) {
+ let Some(db_path) = app.state::().get_db_path() else { return };
+ if let Ok(conn) = db::open(&db_path) {
+ let _ = db::set_server_installed_build(&conn, server_id, build_id);
+ }
+ maybe_fetch_internet(app, build_id);
+}
+
+/// Trigger an internet version fetch for a build_id unless already
+/// server-confirmed. Spawns a background task — does not block.
+/// Re-fetches on every call when source is "internet" so a failed parse
+/// (game_version = null) is retried on each update check.
+pub fn maybe_fetch_internet(app: &tauri::AppHandle, build_id: &str) {
+ let Some(db_path) = app.state::().get_db_path() else { return };
+
+ // Skip only if server-confirmed — internet entries may lack a version and
+ // should be retried until we get one (or the server query overwrites them)
+ if let Ok(conn) = db::open(&db_path) {
+ if let Some((_, src)) = db::get_build_game_version(&conn, build_id) {
+ if src == "server" {
+ return;
+ }
+ }
+ } else {
+ return;
+ }
+
+ let build_id = build_id.to_string();
+ tauri::async_runtime::spawn(async move {
+ // Try the official Wildcard server list first (real-time, structured JSON).
+ // Fall back to the survivetheark.com forum post if that fails.
+ let version = match fetch_version_from_official_list().await {
+ Some(v) => Some(v),
+ None => fetch_version_from_patch_notes().await,
+ };
+ if let Ok(conn) = db::open(&db_path) {
+ let _ = db::upsert_build_game_version(
+ &conn,
+ &build_id,
+ version.as_deref(),
+ "internet",
+ );
+ }
+ });
+}
+
+/// After a server confirms running: try A2S to get the server-confirmed version
+/// and store it (overwrites "internet" source). Fire and forget.
+pub fn maybe_capture_server_version(app: &tauri::AppHandle, server_id: &str, query_port: u16) {
+ let Some(db_path) = app.state::().get_db_path() else { return };
+
+ // Read the installed_build_id for this server
+ let build_id = {
+ let Ok(conn) = db::open(&db_path) else { return };
+ match conn.query_row(
+ "SELECT installed_build_id FROM servers WHERE id = ?1",
+ [server_id],
+ |row| row.get::<_, Option>(0),
+ ) {
+ Ok(Some(b)) => b,
+ _ => return,
+ }
+ };
+
+ // Skip if already server-confirmed
+ {
+ let Ok(conn) = db::open(&db_path) else { return };
+ if let Some((_, src)) = db::get_build_game_version(&conn, &build_id) {
+ if src == "server" {
+ return;
+ }
+ }
+ }
+
+ tauri::async_runtime::spawn(async move {
+ if let Some(version) = source_query_version(query_port).await {
+ if let Ok(conn) = db::open(&db_path) {
+ let _ = db::upsert_build_game_version(
+ &conn,
+ &build_id,
+ Some(&version),
+ "server",
+ );
+ }
+ }
+ });
+}
+
+// ── Tauri command ─────────────────────────────────────────────────────────────
+
+/// Manually trigger an internet version fetch for a build_id. Returns the
+/// game_version if now available, or None if the fetch failed / build unknown.
+#[tauri::command]
+pub async fn fetch_build_version(
+ build_id: String,
+ state: tauri::State<'_, AppState>,
+) -> Result
diff --git a/src/hooks/useBuildVersionCache.ts b/src/hooks/useBuildVersionCache.ts
new file mode 100644
index 0000000..869af4d
--- /dev/null
+++ b/src/hooks/useBuildVersionCache.ts
@@ -0,0 +1,22 @@
+import { useState, useEffect, useCallback } from "react";
+import { getBuildVersionCache, type BuildVersionRow } from "@/lib/db";
+
+// Refresh the cache when a server status event fires (server may have confirmed
+// its version via A2S after starting) or on a slow background interval.
+const REFRESH_MS = 30_000;
+
+export function useBuildVersionCache(): Map {
+ const [cache, setCache] = useState