diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a08671e..1d30467 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,22 +70,47 @@ jobs: ### What's new in ${{ github.ref_name }} - This is a bug-fix release focused on custom/mod map handling and a couple of server-lifecycle edge cases. + A big polish release: new server-management features, a guided tour, and a long list of fixes from a full review of the app. - **Fix: Custom mod maps not working** - A server created (or switched) to a custom mod map now actually launches on that map. Previously the launch arguments silently fell back to The Island, the server details page showed a garbled internal ID instead of the map's name, and custom maps didn't appear in the Settings map dropdown at all — all four were symptoms of the same missing wiring between the custom maps table and the rest of the app, which is now fixed everywhere it was needed (launch args, backups, the scheduler, display labels, and the dropdown). + > **First launch after updating:** existing server configs are migrated automatically — settings that older versions wrote to the wrong place (join password, PvE mode, Game.ini-only settings, crossplay) are moved to where the game actually reads them. Your INI files are patched key by key; nothing else in them changes. - **Fix: Map's required mod not enforced on an existing server** - Changing a server's map in Settings now properly adds and locks the new map's required mod (so it can't be disabled or removed while that map is selected) and removes the previous map's mod — matching what already happened correctly during server creation. + **New: Hide Server Window** + Run servers with no console window. On Windows this uses the native no-console flag. On Linux servers run on an invisible display using Xvfb (recommended) or gamescope's headless mode — the app detects what's installed, prefers Xvfb, and can install it for you (Config → Advanced, the creation wizard, or the first-time setup). If a hidden server hits a startup error such as a failed mod download, it's closed automatically so the normal retry runs. - **Fix: Copying mods from another server could drop the current map's required mod** - The server creation wizard's "copy from server" step now merges the copied mod list instead of replacing it outright, so a mod map's required mod picked earlier in the wizard survives the copy. + **New: Guided tour** + An interactive tour of the app (offered at the end of setup, or from the **?** in the sidebar), plus a short tour for each server tab the first time you open it. Restart them any time from Settings. - **Fix: Map mod display name and ordering** - A map's required mod now shows the map's own name in the Mods tab instead of "Unknown Mod", and always sorts to the top of the installed mods list. + **New: Server Identity card** (Config tab) + Edit a server's name, join/admin passwords, ports and max players after creation. Changes go to both the app and the game's INI files together, with port-conflict checks and an offer to open new ports in the firewall. - **Fix: Servers stuck on "Updating…" after a stopped server's auto-update** - A scheduled or startup-triggered auto-update on a stopped server would apply successfully but leave the server's status stuck showing the update-in-progress spinner, requiring a manual Cancel + Reinstall to clear. The status now correctly resets once the update finishes. + **New: Clone Server, rebuilt** + Cloning now runs through the creation wizard: new name and ports suggested, fresh INI files with the clone's own identity, and optional copying of schedules, warning settings, auto-start, hidden window and save data. + + **New: Config History** + A snapshot is taken before every config save. Browse snapshots, see exactly which settings each would change, and restore one (the current config is snapshotted first, so a restore can be undone). + + **New: Admins & Whitelist editor** (Config → Advanced) + Edit the admin list, exclusive-join whitelist and join-bypass list from the app, with the `-exclusivejoin` switch alongside. + + **New: Save checks** + Before saving config you're warned about anything that would break the server or the app: RCON disabled, a blank admin password, a clashing RCON port, a setting missing its required launch flag, or exclusive join with an empty whitelist. + + **New: Auto-Start in the Automation tab and wizard**, **Server Platform selector** (`-ServerPlatform=`, replacing the old non-working crossplay toggles), **Message of the Day editor**, **Memory-Limit Restart** now warns players first, and **Scheduled Restart / Memory-Limit Restart notifications**. + + **Fixes** + - Quick Setup, INI import and paste no longer wipe `[ServerSettings]` (admin password, RCON settings) — settings are merged key by key and server identity is never overwritten. Quick Setup now applies the same presets as the creation wizard. + - Imported servers no longer open a blank Config tab, and saving can no longer replace their real INI files. + - Breeding, spoiling, decomposition and other Game.ini-only sliders now actually take effect (they were written to GameUserSettings.ini). The PvE toggle now sets `ServerPVE`, and the join password is written to `[ServerSettings]`. + - Restart warnings chosen in the creation wizard now apply (they were silently ignored); `{time}` is the placeholder. + - Clusters: data no longer nests an extra `clusters/` folder deep, and `-NoTransferFromFiltering` is applied automatically to every cluster member. + - Copying mods (wizard, clone, Mods tab) no longer brings another map's mod along — previously it could even be locked on the target. + - Mod reorder arrows now work, and reordering keeps your scroll position. + - Notifications: every toggle in Settings now works (backend events like "server online" ignored them), switching a column off no longer turns everything on, email now works for all events, and the bell shows the exact unread count. + - Force Stop / Force Stop All / Restart All Now are clickable immediately instead of only after navigating away. + - Proton-GE installs with the new `-x86_64` folder naming now complete, and update checks recognize them. + - Active events now load via their mod only (the obsolete `-ActiveEvent` flag is no longer passed). + - Server operations (backups, updates, restarts) queue behind each other instead of failing when one is already running. + - Theme: accent colors and theme presets now apply everywhere, and dropdowns use the app's styled menus instead of the system's. ### Installation diff --git a/package.json b/package.json index 00dfb31..cf34a1a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lokiasam", - "version": "0.14.2", + "version": "0.15.0", "private": true, "scripts": { "dev": "next dev", @@ -27,6 +27,7 @@ "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cron-parser": "^5.5.0", + "driver.js": "^1.14.0", "framer-motion": "^12.40.0", "lucide-react": "^1.16.0", "next": "16.2.6", diff --git a/packaging/arch/PKGBUILD b/packaging/arch/PKGBUILD index 6c939b2..af49522 100644 --- a/packaging/arch/PKGBUILD +++ b/packaging/arch/PKGBUILD @@ -1,6 +1,6 @@ # Maintainer: Arron Ohnemus pkgname=lokiasam -pkgver=0.14.2 +pkgver=0.15.0 pkgrel=1 pkgdesc="Loki ARK Survival Ascended Server Manager — a desktop app for managing dedicated ASA servers" arch=("x86_64") diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7332b73..f4b21bf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -59,6 +59,9 @@ importers: cron-parser: specifier: ^5.5.0 version: 5.5.0 + driver.js: + specifier: ^1.14.0 + version: 1.14.0 framer-motion: specifier: ^12.40.0 version: 12.40.0(react-dom@19.2.4(react@19.2.4))(react@19.2.4) @@ -67,7 +70,7 @@ importers: version: 1.16.0(react@19.2.4) next: specifier: 16.2.6 - version: 16.2.6(@babel/core@7.29.0)(react-dom@19.2.4(react@19.2.4))(react@19.2.4) + version: 16.2.6(@babel/core@7.29.0(supports-color@7.2.0))(react-dom@19.2.4(react@19.2.4))(react@19.2.4) radix-ui: specifier: ^1.4.3 version: 1.4.3(@types/react-dom@19.2.3(@types/react@19.2.15))(@types/react@19.2.15)(react-dom@19.2.4(react@19.2.4))(react@19.2.4) @@ -85,7 +88,7 @@ importers: version: 3.8.1(@types/react@19.2.15)(react-dom@19.2.4(react@19.2.4))(react-is@16.13.1)(react@19.2.4)(redux@5.0.1) shadcn: specifier: ^4.8.0 - version: 4.8.0(@types/node@20.19.41)(typescript@5.9.3) + version: 4.8.0(@types/node@20.19.41)(supports-color@7.2.0)(typescript@5.9.3) sonner: specifier: ^2.0.7 version: 2.0.7(react-dom@19.2.4(react@19.2.4))(react@19.2.4) @@ -119,10 +122,10 @@ importers: version: 19.2.3(@types/react@19.2.15) eslint: specifier: ^9 - version: 9.39.4(jiti@2.7.0) + version: 9.39.4(jiti@2.7.0)(supports-color@7.2.0) eslint-config-next: specifier: 16.2.6 - version: 16.2.6(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3))(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3) + version: 16.2.6(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) tailwindcss: specifier: ^4 version: 4.3.0 @@ -2304,6 +2307,9 @@ packages: resolution: {integrity: sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==} engines: {node: '>=12'} + driver.js@1.14.0: + resolution: {integrity: sha512-BnCFuNU8QO2rrYiDra43Ortx6D6chqMvEMF1q3fWQfsC3xNyCX4T1P1vZDTXTxGdtcXh2v5r11hxSpNLF3DJVw==} + dunder-proto@1.0.1: resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} engines: {node: '>= 0.4'} @@ -2485,6 +2491,7 @@ packages: eslint@9.39.4: resolution: {integrity: sha512-XoMjdBOwe/esVgEvLmNsD3IRHkm7fbKIUGvrleloJXUZgDHig2IPWNniv+GwjyJXzuNqVjlr5+4yVUZjycJwfQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options. hasBin: true peerDependencies: jiti: '*' @@ -4183,20 +4190,20 @@ snapshots: '@babel/compat-data@7.29.3': {} - '@babel/core@7.29.0': + '@babel/core@7.29.0(supports-color@7.2.0)': dependencies: '@babel/code-frame': 7.29.0 '@babel/generator': 7.29.1 '@babel/helper-compilation-targets': 7.28.6 - '@babel/helper-module-transforms': 7.28.6(@babel/core@7.29.0) + '@babel/helper-module-transforms': 7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0) '@babel/helpers': 7.29.2 '@babel/parser': 7.29.3 '@babel/template': 7.28.6 - '@babel/traverse': 7.29.0 + '@babel/traverse': 7.29.0(supports-color@7.2.0) '@babel/types': 7.29.0 '@jridgewell/remapping': 2.3.5 convert-source-map: 2.0.0 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -4223,41 +4230,41 @@ snapshots: lru-cache: 5.1.1 semver: 6.3.1 - '@babel/helper-create-class-features-plugin@7.29.3(@babel/core@7.29.0)': + '@babel/helper-create-class-features-plugin@7.29.3(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)': dependencies: - '@babel/core': 7.29.0 + '@babel/core': 7.29.0(supports-color@7.2.0) '@babel/helper-annotate-as-pure': 7.27.3 - '@babel/helper-member-expression-to-functions': 7.28.5 + '@babel/helper-member-expression-to-functions': 7.28.5(supports-color@7.2.0) '@babel/helper-optimise-call-expression': 7.27.1 - '@babel/helper-replace-supers': 7.28.6(@babel/core@7.29.0) - '@babel/helper-skip-transparent-expression-wrappers': 7.27.1 - '@babel/traverse': 7.29.0 + '@babel/helper-replace-supers': 7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0) + '@babel/helper-skip-transparent-expression-wrappers': 7.27.1(supports-color@7.2.0) + '@babel/traverse': 7.29.0(supports-color@7.2.0) semver: 6.3.1 transitivePeerDependencies: - supports-color '@babel/helper-globals@7.28.0': {} - '@babel/helper-member-expression-to-functions@7.28.5': + '@babel/helper-member-expression-to-functions@7.28.5(supports-color@7.2.0)': dependencies: - '@babel/traverse': 7.29.0 + '@babel/traverse': 7.29.0(supports-color@7.2.0) '@babel/types': 7.29.0 transitivePeerDependencies: - supports-color - '@babel/helper-module-imports@7.28.6': + '@babel/helper-module-imports@7.28.6(supports-color@7.2.0)': dependencies: - '@babel/traverse': 7.29.0 + '@babel/traverse': 7.29.0(supports-color@7.2.0) '@babel/types': 7.29.0 transitivePeerDependencies: - supports-color - '@babel/helper-module-transforms@7.28.6(@babel/core@7.29.0)': + '@babel/helper-module-transforms@7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)': dependencies: - '@babel/core': 7.29.0 - '@babel/helper-module-imports': 7.28.6 + '@babel/core': 7.29.0(supports-color@7.2.0) + '@babel/helper-module-imports': 7.28.6(supports-color@7.2.0) '@babel/helper-validator-identifier': 7.28.5 - '@babel/traverse': 7.29.0 + '@babel/traverse': 7.29.0(supports-color@7.2.0) transitivePeerDependencies: - supports-color @@ -4267,18 +4274,18 @@ snapshots: '@babel/helper-plugin-utils@7.28.6': {} - '@babel/helper-replace-supers@7.28.6(@babel/core@7.29.0)': + '@babel/helper-replace-supers@7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)': dependencies: - '@babel/core': 7.29.0 - '@babel/helper-member-expression-to-functions': 7.28.5 + '@babel/core': 7.29.0(supports-color@7.2.0) + '@babel/helper-member-expression-to-functions': 7.28.5(supports-color@7.2.0) '@babel/helper-optimise-call-expression': 7.27.1 - '@babel/traverse': 7.29.0 + '@babel/traverse': 7.29.0(supports-color@7.2.0) transitivePeerDependencies: - supports-color - '@babel/helper-skip-transparent-expression-wrappers@7.27.1': + '@babel/helper-skip-transparent-expression-wrappers@7.27.1(supports-color@7.2.0)': dependencies: - '@babel/traverse': 7.29.0 + '@babel/traverse': 7.29.0(supports-color@7.2.0) '@babel/types': 7.29.0 transitivePeerDependencies: - supports-color @@ -4298,43 +4305,43 @@ snapshots: dependencies: '@babel/types': 7.29.0 - '@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0)': + '@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0(supports-color@7.2.0))': dependencies: - '@babel/core': 7.29.0 + '@babel/core': 7.29.0(supports-color@7.2.0) '@babel/helper-plugin-utils': 7.28.6 - '@babel/plugin-syntax-typescript@7.28.6(@babel/core@7.29.0)': + '@babel/plugin-syntax-typescript@7.28.6(@babel/core@7.29.0(supports-color@7.2.0))': dependencies: - '@babel/core': 7.29.0 + '@babel/core': 7.29.0(supports-color@7.2.0) '@babel/helper-plugin-utils': 7.28.6 - '@babel/plugin-transform-modules-commonjs@7.28.6(@babel/core@7.29.0)': + '@babel/plugin-transform-modules-commonjs@7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)': dependencies: - '@babel/core': 7.29.0 - '@babel/helper-module-transforms': 7.28.6(@babel/core@7.29.0) + '@babel/core': 7.29.0(supports-color@7.2.0) + '@babel/helper-module-transforms': 7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0) '@babel/helper-plugin-utils': 7.28.6 transitivePeerDependencies: - supports-color - '@babel/plugin-transform-typescript@7.28.6(@babel/core@7.29.0)': + '@babel/plugin-transform-typescript@7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)': dependencies: - '@babel/core': 7.29.0 + '@babel/core': 7.29.0(supports-color@7.2.0) '@babel/helper-annotate-as-pure': 7.27.3 - '@babel/helper-create-class-features-plugin': 7.29.3(@babel/core@7.29.0) + '@babel/helper-create-class-features-plugin': 7.29.3(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0) '@babel/helper-plugin-utils': 7.28.6 - '@babel/helper-skip-transparent-expression-wrappers': 7.27.1 - '@babel/plugin-syntax-typescript': 7.28.6(@babel/core@7.29.0) + '@babel/helper-skip-transparent-expression-wrappers': 7.27.1(supports-color@7.2.0) + '@babel/plugin-syntax-typescript': 7.28.6(@babel/core@7.29.0(supports-color@7.2.0)) transitivePeerDependencies: - supports-color - '@babel/preset-typescript@7.28.5(@babel/core@7.29.0)': + '@babel/preset-typescript@7.28.5(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)': dependencies: - '@babel/core': 7.29.0 + '@babel/core': 7.29.0(supports-color@7.2.0) '@babel/helper-plugin-utils': 7.28.6 '@babel/helper-validator-option': 7.27.1 - '@babel/plugin-syntax-jsx': 7.28.6(@babel/core@7.29.0) - '@babel/plugin-transform-modules-commonjs': 7.28.6(@babel/core@7.29.0) - '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.0) + '@babel/plugin-syntax-jsx': 7.28.6(@babel/core@7.29.0(supports-color@7.2.0)) + '@babel/plugin-transform-modules-commonjs': 7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0) + '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0) transitivePeerDependencies: - supports-color @@ -4344,7 +4351,7 @@ snapshots: '@babel/parser': 7.29.3 '@babel/types': 7.29.0 - '@babel/traverse@7.29.0': + '@babel/traverse@7.29.0(supports-color@7.2.0)': dependencies: '@babel/code-frame': 7.29.0 '@babel/generator': 7.29.1 @@ -4352,7 +4359,7 @@ snapshots: '@babel/parser': 7.29.3 '@babel/template': 7.28.6 '@babel/types': 7.29.0 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) transitivePeerDependencies: - supports-color @@ -4420,17 +4427,17 @@ snapshots: tslib: 2.8.1 optional: true - '@eslint-community/eslint-utils@4.9.1(eslint@9.39.4(jiti@2.7.0))': + '@eslint-community/eslint-utils@4.9.1(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))': dependencies: - eslint: 9.39.4(jiti@2.7.0) + eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0) eslint-visitor-keys: 3.4.3 '@eslint-community/regexpp@4.12.2': {} - '@eslint/config-array@0.21.2': + '@eslint/config-array@0.21.2(supports-color@7.2.0)': dependencies: '@eslint/object-schema': 2.1.7 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) minimatch: 3.1.5 transitivePeerDependencies: - supports-color @@ -4443,10 +4450,10 @@ snapshots: dependencies: '@types/json-schema': 7.0.15 - '@eslint/eslintrc@3.3.5': + '@eslint/eslintrc@3.3.5(supports-color@7.2.0)': dependencies: ajv: 6.15.0 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) espree: 10.4.0 globals: 14.0.0 ignore: 5.3.2 @@ -4651,18 +4658,18 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.5 - '@modelcontextprotocol/sdk@1.29.0(zod@3.25.76)': + '@modelcontextprotocol/sdk@1.29.0(supports-color@7.2.0)(zod@3.25.76)': dependencies: '@hono/node-server': 1.19.14(hono@4.12.22) ajv: 8.20.0 - ajv-formats: 3.0.1(ajv@8.20.0) + ajv-formats: 3.0.1 content-type: 1.0.5 cors: 2.8.6 cross-spawn: 7.0.6 eventsource: 3.0.7 eventsource-parser: 3.0.8 - express: 5.2.1 - express-rate-limit: 8.5.2(express@5.2.1) + express: 5.2.1(supports-color@7.2.0) + express-rate-limit: 8.5.2(express@5.2.1(supports-color@7.2.0)) hono: 4.12.22 jose: 6.2.3 json-schema-typed: 8.0.2 @@ -5745,15 +5752,15 @@ snapshots: '@types/validate-npm-package-name@4.0.2': {} - '@typescript-eslint/eslint-plugin@8.59.4(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3))(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3)': + '@typescript-eslint/eslint-plugin@8.59.4(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)': dependencies: '@eslint-community/regexpp': 4.12.2 - '@typescript-eslint/parser': 8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3) + '@typescript-eslint/parser': 8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) '@typescript-eslint/scope-manager': 8.59.4 - '@typescript-eslint/type-utils': 8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3) - '@typescript-eslint/utils': 8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3) + '@typescript-eslint/type-utils': 8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + '@typescript-eslint/utils': 8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) '@typescript-eslint/visitor-keys': 8.59.4 - eslint: 9.39.4(jiti@2.7.0) + eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0) ignore: 7.0.5 natural-compare: 1.4.0 ts-api-utils: 2.5.0(typescript@5.9.3) @@ -5761,23 +5768,23 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3)': + '@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)': dependencies: '@typescript-eslint/scope-manager': 8.59.4 '@typescript-eslint/types': 8.59.4 - '@typescript-eslint/typescript-estree': 8.59.4(typescript@5.9.3) + '@typescript-eslint/typescript-estree': 8.59.4(supports-color@7.2.0)(typescript@5.9.3) '@typescript-eslint/visitor-keys': 8.59.4 - debug: 4.4.3 - eslint: 9.39.4(jiti@2.7.0) + debug: 4.4.3(supports-color@7.2.0) + eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0) typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/project-service@8.59.4(typescript@5.9.3)': + '@typescript-eslint/project-service@8.59.4(supports-color@7.2.0)(typescript@5.9.3)': dependencies: '@typescript-eslint/tsconfig-utils': 8.59.4(typescript@5.9.3) '@typescript-eslint/types': 8.59.4 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -5791,13 +5798,13 @@ snapshots: dependencies: typescript: 5.9.3 - '@typescript-eslint/type-utils@8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3)': + '@typescript-eslint/type-utils@8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)': dependencies: '@typescript-eslint/types': 8.59.4 - '@typescript-eslint/typescript-estree': 8.59.4(typescript@5.9.3) - '@typescript-eslint/utils': 8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3) - debug: 4.4.3 - eslint: 9.39.4(jiti@2.7.0) + '@typescript-eslint/typescript-estree': 8.59.4(supports-color@7.2.0)(typescript@5.9.3) + '@typescript-eslint/utils': 8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + debug: 4.4.3(supports-color@7.2.0) + eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0) ts-api-utils: 2.5.0(typescript@5.9.3) typescript: 5.9.3 transitivePeerDependencies: @@ -5805,13 +5812,13 @@ snapshots: '@typescript-eslint/types@8.59.4': {} - '@typescript-eslint/typescript-estree@8.59.4(typescript@5.9.3)': + '@typescript-eslint/typescript-estree@8.59.4(supports-color@7.2.0)(typescript@5.9.3)': dependencies: - '@typescript-eslint/project-service': 8.59.4(typescript@5.9.3) + '@typescript-eslint/project-service': 8.59.4(supports-color@7.2.0)(typescript@5.9.3) '@typescript-eslint/tsconfig-utils': 8.59.4(typescript@5.9.3) '@typescript-eslint/types': 8.59.4 '@typescript-eslint/visitor-keys': 8.59.4 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) minimatch: 10.2.5 semver: 7.8.1 tinyglobby: 0.2.16 @@ -5820,13 +5827,13 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3)': + '@typescript-eslint/utils@8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)': dependencies: - '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.4(jiti@2.7.0)) + '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0)) '@typescript-eslint/scope-manager': 8.59.4 '@typescript-eslint/types': 8.59.4 - '@typescript-eslint/typescript-estree': 8.59.4(typescript@5.9.3) - eslint: 9.39.4(jiti@2.7.0) + '@typescript-eslint/typescript-estree': 8.59.4(supports-color@7.2.0)(typescript@5.9.3) + eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0) typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -5919,8 +5926,8 @@ snapshots: agent-base@7.1.4: {} - ajv-formats@3.0.1(ajv@8.20.0): - optionalDependencies: + ajv-formats@3.0.1: + dependencies: ajv: 8.20.0 ajv@6.15.0: @@ -6044,11 +6051,11 @@ snapshots: baseline-browser-mapping@2.10.32: {} - body-parser@2.2.2: + body-parser@2.2.2(supports-color@7.2.0): dependencies: bytes: 3.1.2 content-type: 1.0.5 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) http-errors: 2.0.1 iconv-lite: 0.7.2 on-finished: 2.4.1 @@ -6251,13 +6258,17 @@ snapshots: es-errors: 1.3.0 is-data-view: 1.0.2 - debug@3.2.7: + debug@3.2.7(supports-color@7.2.0): dependencies: ms: 2.1.3 + optionalDependencies: + supports-color: 7.2.0 - debug@4.4.3: + debug@4.4.3(supports-color@7.2.0): dependencies: ms: 2.1.3 + optionalDependencies: + supports-color: 7.2.0 decimal.js-light@2.5.1: {} @@ -6302,6 +6313,8 @@ snapshots: dotenv@17.4.2: {} + driver.js@1.14.0: {} + dunder-proto@1.0.1: dependencies: call-bind-apply-helpers: 1.0.2 @@ -6452,18 +6465,18 @@ snapshots: escape-string-regexp@4.0.0: {} - eslint-config-next@16.2.6(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3))(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3): + eslint-config-next@16.2.6(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3): dependencies: '@next/eslint-plugin-next': 16.2.6 - eslint: 9.39.4(jiti@2.7.0) - eslint-import-resolver-node: 0.3.10 - eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.4(jiti@2.7.0)) - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)) - eslint-plugin-jsx-a11y: 6.10.2(eslint@9.39.4(jiti@2.7.0)) - eslint-plugin-react: 7.37.5(eslint@9.39.4(jiti@2.7.0)) - eslint-plugin-react-hooks: 7.1.1(eslint@9.39.4(jiti@2.7.0)) + eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0) + eslint-import-resolver-node: 0.3.10(supports-color@7.2.0) + eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) + eslint-plugin-jsx-a11y: 6.10.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0)) + eslint-plugin-react: 7.37.5(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0)) + eslint-plugin-react-hooks: 7.1.1(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) globals: 16.4.0 - typescript-eslint: 8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3) + typescript-eslint: 8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) optionalDependencies: typescript: 5.9.3 transitivePeerDependencies: @@ -6472,52 +6485,52 @@ snapshots: - eslint-plugin-import-x - supports-color - eslint-import-resolver-node@0.3.10: + eslint-import-resolver-node@0.3.10(supports-color@7.2.0): dependencies: - debug: 3.2.7 + debug: 3.2.7(supports-color@7.2.0) is-core-module: 2.16.2 resolve: 2.0.0-next.7 transitivePeerDependencies: - supports-color - eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.4(jiti@2.7.0)): + eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0): dependencies: '@nolyfill/is-core-module': 1.0.39 - debug: 4.4.3 - eslint: 9.39.4(jiti@2.7.0) + debug: 4.4.3(supports-color@7.2.0) + eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0) get-tsconfig: 4.14.0 is-bun-module: 2.0.0 stable-hash: 0.0.5 tinyglobby: 0.2.16 unrs-resolver: 1.12.2 optionalDependencies: - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) transitivePeerDependencies: - supports-color - eslint-module-utils@2.12.1(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3))(eslint-import-resolver-node@0.3.10)(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)): + eslint-module-utils@2.12.1(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint-import-resolver-node@0.3.10(supports-color@7.2.0))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0): dependencies: - debug: 3.2.7 + debug: 3.2.7(supports-color@7.2.0) optionalDependencies: - '@typescript-eslint/parser': 8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3) - eslint: 9.39.4(jiti@2.7.0) - eslint-import-resolver-node: 0.3.10 - eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.4(jiti@2.7.0)) + '@typescript-eslint/parser': 8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0) + eslint-import-resolver-node: 0.3.10(supports-color@7.2.0) + eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) transitivePeerDependencies: - supports-color - eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)): + eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.9 array.prototype.findlastindex: 1.2.6 array.prototype.flat: 1.3.3 array.prototype.flatmap: 1.3.3 - debug: 3.2.7 + debug: 3.2.7(supports-color@7.2.0) doctrine: 2.1.0 - eslint: 9.39.4(jiti@2.7.0) - eslint-import-resolver-node: 0.3.10 - eslint-module-utils: 2.12.1(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3))(eslint-import-resolver-node@0.3.10)(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)) + eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0) + eslint-import-resolver-node: 0.3.10(supports-color@7.2.0) + eslint-module-utils: 2.12.1(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint-import-resolver-node@0.3.10(supports-color@7.2.0))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) hasown: 2.0.3 is-core-module: 2.16.2 is-glob: 4.0.3 @@ -6529,13 +6542,13 @@ snapshots: string.prototype.trimend: 1.0.9 tsconfig-paths: 3.15.0 optionalDependencies: - '@typescript-eslint/parser': 8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3) + '@typescript-eslint/parser': 8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) transitivePeerDependencies: - eslint-import-resolver-typescript - eslint-import-resolver-webpack - supports-color - eslint-plugin-jsx-a11y@6.10.2(eslint@9.39.4(jiti@2.7.0)): + eslint-plugin-jsx-a11y@6.10.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0)): dependencies: aria-query: 5.3.2 array-includes: 3.1.9 @@ -6545,7 +6558,7 @@ snapshots: axobject-query: 4.1.0 damerau-levenshtein: 1.0.8 emoji-regex: 9.2.2 - eslint: 9.39.4(jiti@2.7.0) + eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0) hasown: 2.0.3 jsx-ast-utils: 3.3.5 language-tags: 1.0.9 @@ -6554,18 +6567,18 @@ snapshots: safe-regex-test: 1.1.0 string.prototype.includes: 2.0.1 - eslint-plugin-react-hooks@7.1.1(eslint@9.39.4(jiti@2.7.0)): + eslint-plugin-react-hooks@7.1.1(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0): dependencies: - '@babel/core': 7.29.0 + '@babel/core': 7.29.0(supports-color@7.2.0) '@babel/parser': 7.29.3 - eslint: 9.39.4(jiti@2.7.0) + eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0) hermes-parser: 0.25.1 zod: 4.4.3 zod-validation-error: 4.0.2(zod@4.4.3) transitivePeerDependencies: - supports-color - eslint-plugin-react@7.37.5(eslint@9.39.4(jiti@2.7.0)): + eslint-plugin-react@7.37.5(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0)): dependencies: array-includes: 3.1.9 array.prototype.findlast: 1.2.5 @@ -6573,7 +6586,7 @@ snapshots: array.prototype.tosorted: 1.1.4 doctrine: 2.1.0 es-iterator-helpers: 1.3.2 - eslint: 9.39.4(jiti@2.7.0) + eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0) estraverse: 5.3.0 hasown: 2.0.3 jsx-ast-utils: 3.3.5 @@ -6598,14 +6611,14 @@ snapshots: eslint-visitor-keys@5.0.1: {} - eslint@9.39.4(jiti@2.7.0): + eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0): dependencies: - '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.4(jiti@2.7.0)) + '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0)) '@eslint-community/regexpp': 4.12.2 - '@eslint/config-array': 0.21.2 + '@eslint/config-array': 0.21.2(supports-color@7.2.0) '@eslint/config-helpers': 0.4.2 '@eslint/core': 0.17.0 - '@eslint/eslintrc': 3.3.5 + '@eslint/eslintrc': 3.3.5(supports-color@7.2.0) '@eslint/js': 9.39.4 '@eslint/plugin-kit': 0.4.1 '@humanfs/node': 0.16.8 @@ -6615,7 +6628,7 @@ snapshots: ajv: 6.15.0 chalk: 4.1.2 cross-spawn: 7.0.6 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) escape-string-regexp: 4.0.0 eslint-scope: 8.4.0 eslint-visitor-keys: 4.2.1 @@ -6696,25 +6709,25 @@ snapshots: strip-final-newline: 4.0.0 yoctocolors: 2.1.2 - express-rate-limit@8.5.2(express@5.2.1): + express-rate-limit@8.5.2(express@5.2.1(supports-color@7.2.0)): dependencies: - express: 5.2.1 + express: 5.2.1(supports-color@7.2.0) ip-address: 10.2.0 - express@5.2.1: + express@5.2.1(supports-color@7.2.0): dependencies: accepts: 2.0.0 - body-parser: 2.2.2 + body-parser: 2.2.2(supports-color@7.2.0) content-disposition: 1.1.0 content-type: 1.0.5 cookie: 0.7.2 cookie-signature: 1.2.2 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) depd: 2.0.0 encodeurl: 2.0.0 escape-html: 1.0.3 etag: 1.8.1 - finalhandler: 2.1.1 + finalhandler: 2.1.1(supports-color@7.2.0) fresh: 2.0.0 http-errors: 2.0.1 merge-descriptors: 2.0.0 @@ -6725,9 +6738,9 @@ snapshots: proxy-addr: 2.0.7 qs: 6.15.2 range-parser: 1.2.1 - router: 2.2.0 - send: 1.2.1 - serve-static: 2.2.1 + router: 2.2.0(supports-color@7.2.0) + send: 1.2.1(supports-color@7.2.0) + serve-static: 2.2.1(supports-color@7.2.0) statuses: 2.0.2 type-is: 2.1.0 vary: 1.1.2 @@ -6793,9 +6806,9 @@ snapshots: dependencies: to-regex-range: 5.0.1 - finalhandler@2.1.1: + finalhandler@2.1.1(supports-color@7.2.0): dependencies: - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) encodeurl: 2.0.0 escape-html: 1.0.3 on-finished: 2.4.1 @@ -6971,10 +6984,10 @@ snapshots: statuses: 2.0.2 toidentifier: 1.0.1 - https-proxy-agent@7.0.6: + https-proxy-agent@7.0.6(supports-color@7.2.0): dependencies: agent-base: 7.1.4 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) transitivePeerDependencies: - supports-color @@ -7398,7 +7411,7 @@ snapshots: negotiator@1.0.0: {} - next@16.2.6(@babel/core@7.29.0)(react-dom@19.2.4(react@19.2.4))(react@19.2.4): + next@16.2.6(@babel/core@7.29.0(supports-color@7.2.0))(react-dom@19.2.4(react@19.2.4))(react@19.2.4): dependencies: '@next/env': 16.2.6 '@swc/helpers': 0.5.15 @@ -7407,7 +7420,7 @@ snapshots: postcss: 8.4.31 react: 19.2.4 react-dom: 19.2.4(react@19.2.4) - styled-jsx: 5.1.6(@babel/core@7.29.0)(react@19.2.4) + styled-jsx: 5.1.6(@babel/core@7.29.0(supports-color@7.2.0))(react@19.2.4) optionalDependencies: '@next/swc-darwin-arm64': 16.2.6 '@next/swc-darwin-x64': 16.2.6 @@ -7845,9 +7858,9 @@ snapshots: reusify@1.1.0: {} - router@2.2.0: + router@2.2.0(supports-color@7.2.0): dependencies: - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) depd: 2.0.0 is-promise: 4.0.0 parseurl: 1.3.3 @@ -7888,9 +7901,9 @@ snapshots: semver@7.8.1: {} - send@1.2.1: + send@1.2.1(supports-color@7.2.0): dependencies: - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) encodeurl: 2.0.0 escape-html: 1.0.3 etag: 1.8.1 @@ -7904,12 +7917,12 @@ snapshots: transitivePeerDependencies: - supports-color - serve-static@2.2.1: + serve-static@2.2.1(supports-color@7.2.0): dependencies: encodeurl: 2.0.0 escape-html: 1.0.3 parseurl: 1.3.3 - send: 1.2.1 + send: 1.2.1(supports-color@7.2.0) transitivePeerDependencies: - supports-color @@ -7939,14 +7952,14 @@ snapshots: setprototypeof@1.2.0: {} - shadcn@4.8.0(@types/node@20.19.41)(typescript@5.9.3): + shadcn@4.8.0(@types/node@20.19.41)(supports-color@7.2.0)(typescript@5.9.3): dependencies: - '@babel/core': 7.29.0 + '@babel/core': 7.29.0(supports-color@7.2.0) '@babel/parser': 7.29.3 - '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.0) - '@babel/preset-typescript': 7.28.5(@babel/core@7.29.0) + '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0) + '@babel/preset-typescript': 7.28.5(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0) '@dotenvx/dotenvx': 1.67.0 - '@modelcontextprotocol/sdk': 1.29.0(zod@3.25.76) + '@modelcontextprotocol/sdk': 1.29.0(supports-color@7.2.0)(zod@3.25.76) '@types/validate-npm-package-name': 4.0.2 browserslist: 4.28.2 commander: 14.0.3 @@ -7958,7 +7971,7 @@ snapshots: fast-glob: 3.3.3 fs-extra: 11.3.5 fuzzysort: 3.1.0 - https-proxy-agent: 7.0.6 + https-proxy-agent: 7.0.6(supports-color@7.2.0) kleur: 4.1.5 msw: 2.14.6(@types/node@20.19.41)(typescript@5.9.3) node-fetch: 3.3.2 @@ -8160,12 +8173,12 @@ snapshots: strip-json-comments@3.1.1: {} - styled-jsx@5.1.6(@babel/core@7.29.0)(react@19.2.4): + styled-jsx@5.1.6(@babel/core@7.29.0(supports-color@7.2.0))(react@19.2.4): dependencies: client-only: 0.0.1 react: 19.2.4 optionalDependencies: - '@babel/core': 7.29.0 + '@babel/core': 7.29.0(supports-color@7.2.0) supports-color@7.2.0: dependencies: @@ -8277,13 +8290,13 @@ snapshots: possible-typed-array-names: 1.1.0 reflect.getprototypeof: 1.0.10 - typescript-eslint@8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3): + typescript-eslint@8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3): dependencies: - '@typescript-eslint/eslint-plugin': 8.59.4(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3))(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3) - '@typescript-eslint/parser': 8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3) - '@typescript-eslint/typescript-estree': 8.59.4(typescript@5.9.3) - '@typescript-eslint/utils': 8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3) - eslint: 9.39.4(jiti@2.7.0) + '@typescript-eslint/eslint-plugin': 8.59.4(@typescript-eslint/parser@8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + '@typescript-eslint/parser': 8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + '@typescript-eslint/typescript-estree': 8.59.4(supports-color@7.2.0)(typescript@5.9.3) + '@typescript-eslint/utils': 8.59.4(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0) typescript: 5.9.3 transitivePeerDependencies: - supports-color diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 2dd59eb..24e1c48 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2762,7 +2762,7 @@ dependencies = [ [[package]] name = "lokiasam" -version = "0.14.2" +version = "0.15.0" dependencies = [ "flate2", "junction", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index b0596be..c888a5e 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lokiasam" -version = "0.14.2" +version = "0.15.0" description = "Loki Ark Survival Ascended Server Manager" authors = ["Loki"] license = "GPL-3.0-or-later" diff --git a/src-tauri/src/commands/backup.rs b/src-tauri/src/commands/backup.rs index 778ebed..15301d6 100644 --- a/src-tauri/src/commands/backup.rs +++ b/src-tauri/src/commands/backup.rs @@ -865,6 +865,23 @@ pub async fn create_ini_backup( fs::rename(¤t, &archive_folder).map_err(|e| e.to_string())?; } + // Keep the newest MAX_INI_SNAPSHOTS archived snapshots; a snapshot is + // taken on every config save, so without a cap this grows forever. + const MAX_INI_SNAPSHOTS: usize = 50; + if let Ok(rd) = fs::read_dir(&ini_base) { + let mut archived: Vec = rd + .filter_map(|e| e.ok()) + .map(|e| e.path()) + .filter(|p| p.is_dir() && p.file_name().map(|n| n != "current").unwrap_or(false)) + .collect(); + archived.sort(); + if archived.len() > MAX_INI_SNAPSHOTS { + for old in &archived[..archived.len() - MAX_INI_SNAPSHOTS] { + let _ = fs::remove_dir_all(old); + } + } + } + fs::create_dir_all(¤t).map_err(|e| e.to_string())?; for src in &sources { @@ -1171,6 +1188,11 @@ pub async fn list_ini_backups( // Timestamps sort lexicographically as newest last; reverse for newest first. folders.sort(); folders.reverse(); + // "current" is the most recent snapshot — list it first so it can be + // previewed/restored like any other. + if ini_base.join("current").is_dir() { + folders.insert(0, "current".to_string()); + } Ok(folders) } diff --git a/src-tauri/src/commands/backup_manager.rs b/src-tauri/src/commands/backup_manager.rs index 768f4c8..bcfc22c 100644 --- a/src-tauri/src/commands/backup_manager.rs +++ b/src-tauri/src/commands/backup_manager.rs @@ -480,19 +480,42 @@ pub async fn execute_tick(app: &AppHandle) { let servers = db::get_servers(&conn); let pool = app.state::(); - for server in &servers { - if !running_ids.contains(&server.id) { - continue; - } + // (server, deferred) — a server busy with a restart/update/stop when its + // turn comes is pushed to the back of the queue instead of being skipped + // until next hour, so every other server's backup goes ahead first and + // the busy one is backed up as soon as that operation finishes. + let mut queue: std::collections::VecDeque<(&db::ServerRow, bool)> = servers.iter() + .filter(|s| running_ids.contains(&s.id)) + .map(|s| (s, false)) + .collect(); - // Skip a server currently undergoing a scheduled restart/update — - // reading its files while they're mid-overwrite could produce a - // silently incomplete archive. Picked up again on the next hourly - // tick. Held for the rest of this iteration. + while let Some((server, deferred)) = queue.pop_front() { + // Reading a server's files while a restart/update is overwriting them + // could produce a silently incomplete archive, so the lock is held + // for the rest of this iteration. let app_state = app.state::(); - let Some(_lock) = app_state.try_lock_server(&server.id) else { - eprintln!("[backup_manager] Skipping backup for {} — restart/update in progress", server.id); - continue; + let _lock = if deferred { + let guard = app_state.lock_server(&server.id).await; + // Whatever we waited on may have stopped or restarted the server — + // only back up one that's still fully up (a fresh boot after an + // update gets its backup on the next hourly tick). + let still_up = app_state.running_servers.lock().unwrap() + .get(&server.id) + .is_some_and(|rs| rs.confirmed_running); + if !still_up { + eprintln!("[backup_manager] Skipping backup for {} — no longer running after waiting", server.id); + continue; + } + guard + } else { + match app_state.try_lock_server(&server.id) { + Some(guard) => guard, + None => { + eprintln!("[backup_manager] Deferring backup for {} — another operation is in progress", server.id); + queue.push_back((server, true)); + continue; + } + } }; let schedules = db::get_server_schedules(&conn, &server.id); diff --git a/src-tauri/src/commands/certs.rs b/src-tauri/src/commands/certs.rs index 96a34af..1e3fb56 100644 --- a/src-tauri/src/commands/certs.rs +++ b/src-tauri/src/commands/certs.rs @@ -75,7 +75,7 @@ pub async fn install_amazon_root_ca( .as_deref() .filter(|s| !s.is_empty()) .ok_or("Wine prefix path is required on Linux")?; - install_linux(&cert_path, proton, prefix).await?; + install_linux(&cert_path, proton, prefix, None).await?; } // Suppress "unused variable" warnings on each platform. @@ -101,8 +101,11 @@ async fn install_windows(cert_path: &str) -> Result<(), String> { Ok(()) } +/// `display`: run Wine on this X display instead of the user's session — used +/// for the hidden-server prefix, whose first boot must happen on the +/// invisible display it'll be tied to. #[cfg(target_os = "linux")] -async fn install_linux(cert_path: &str, proton_path: &str, prefix_path: &str) -> Result<(), String> { +async fn install_linux(cert_path: &str, proton_path: &str, prefix_path: &str, display: Option<&str>) -> Result<(), String> { let proton_script = format!("{proton_path}/proton"); // Wine 10 (GE-Proton 11+) unified wine64 into a single wine binary. // Fall back to wine if wine64 is absent. @@ -126,14 +129,18 @@ async fn install_linux(cert_path: &str, proton_path: &str, prefix_path: &str) -> .await .map_err(|e| format!("Failed to create prefix directory: {e}"))?; - let status = Command::new(&proton_script) - .arg("run") + let mut boot = Command::new(&proton_script); + boot.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") + .env("PROTON_LOG", "0"); + if let Some(d) = display { + crate::commands::server::apply_virtual_display_env(&mut boot, d); + } + let status = boot .status() .await .map_err(|e| format!("Failed to run proton wineboot: {e}"))?; @@ -150,10 +157,15 @@ async fn install_linux(cert_path: &str, proton_path: &str, prefix_path: &str) -> // 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) + let mut certutil = Command::new(&wine_bin); + certutil .args(["certutil", "-addstore", "Root", cert_path]) .env("WINEPREFIX", &wine_pfx) - .env("WINEDEBUG", "-all") + .env("WINEDEBUG", "-all"); + if let Some(d) = display { + crate::commands::server::apply_virtual_display_env(&mut certutil, d); + } + let status = certutil .status() .await .map_err(|e| format!("Failed to run wine certutil: {e}"))?; @@ -178,6 +190,27 @@ async fn install_linux(cert_path: &str, proton_path: &str, prefix_path: &str) -> Ok(()) } +/// Copy the Amazon Root CA (needed for mod downloads) into the hidden-server +/// prefix, if the normal prefix has it and the hidden one doesn't yet. Runs on +/// the invisible display so the prefix's first boot is tied to it. Failures +/// are logged, not fatal: the server still runs; only mod downloads could be +/// affected. +#[cfg(target_os = "linux")] +pub async fn ensure_hidden_prefix(proton_path: &str, main_prefix: &str, hidden_prefix: &str, display: &str) { + let has_cert = |p: &str| PathBuf::from(p).join(CERT_MARKER_FILENAME).exists(); + if !has_cert(main_prefix) || has_cert(hidden_prefix) { + return; + } + let tmp = std::env::temp_dir().join("lokiasam-certs"); + let result = async { + let cert = download_amazon_root_ca(tmp.to_string_lossy().into_owned()).await?; + install_linux(&cert, proton_path, hidden_prefix, Some(display)).await + }.await; + if let Err(e) = result { + eprintln!("[certs] hidden prefix certificate setup failed: {e}"); + } +} + // ── Check ───────────────────────────────────────────────────────────────────── /// Returns `true` if the Amazon Root CA 1 certificate is already installed. diff --git a/src-tauri/src/commands/config.rs b/src-tauri/src/commands/config.rs index 63cfc7c..b31a4e4 100644 --- a/src-tauri/src/commands/config.rs +++ b/src-tauri/src/commands/config.rs @@ -141,6 +141,166 @@ pub async fn write_server_config( Ok(()) } +/// Parse the `GameUserSettings.ini` / `Game.ini` pair stored in an arbitrary +/// folder — used to preview an INI backup snapshot before restoring it. +#[tauri::command] +pub async fn read_ini_folder(folder_path: String) -> Result { + let base = PathBuf::from(&folder_path); + Ok(ServerConfigJson { + game_user_settings: parse_ini_file(&base.join("GameUserSettings.ini"))?, + game_ini: parse_ini_file(&base.join("Game.ini"))?, + launch_args: Value::Object(Map::new()), + }) +} + +/// A single key edit applied in place by `patch_server_ini`. +/// `value: None` removes the key from the section. +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct IniPatchOp { + /// "gus" (GameUserSettings.ini) or "game" (Game.ini) + pub file: String, + pub section: String, + pub key: String, + pub value: Option, +} + +/// Apply `ops` to INI text line by line. Everything the ops don't touch — +/// comments, ordering, and repeated keys (Game.ini relies on those for +/// entries like OverrideNamedEngramEntries) — is left exactly as it was, +/// which a full parse → serialize round-trip can't guarantee. +fn patch_ini_text(content: &str, ops: &[&IniPatchOp]) -> String { + let mut lines: Vec = content.lines().map(|l| l.to_string()).collect(); + + let section_of = |line: &str| -> Option { + let t = line.trim(); + (t.starts_with('[') && t.ends_with(']')).then(|| t[1..t.len() - 1].to_string()) + }; + let key_of = |line: &str| -> Option { + let t = line.trim(); + if t.starts_with(';') || t.starts_with('#') { return None; } + t.find('=').map(|i| t[..i].trim().to_string()) + }; + + for op in ops { + // Locate every line of the target key inside the target section, and + // the last line belonging to that section (insertion point). + let mut current: Option = None; + let mut hits: Vec = Vec::new(); + let mut section_end: Option = None; + for (i, line) in lines.iter().enumerate() { + if let Some(s) = section_of(line) { + current = Some(s); + continue; + } + let in_target = current + .as_deref() + .map(|s| s.eq_ignore_ascii_case(&op.section)) + .unwrap_or(false); + if !in_target { continue; } + if !line.trim().is_empty() { section_end = Some(i); } + if key_of(line).map(|k| k.eq_ignore_ascii_case(&op.key)).unwrap_or(false) { + hits.push(i); + } + } + let section_header = lines.iter().position(|l| { + section_of(l).map(|s| s.eq_ignore_ascii_case(&op.section)).unwrap_or(false) + }); + + match &op.value { + Some(v) => { + let new_line = format!("{}={}", op.key, v); + if let Some(&first) = hits.first() { + lines[first] = new_line; + // Single-valued key: drop any later duplicates in the section. + for &i in hits.iter().skip(1).rev() { lines.remove(i); } + } else if let Some(header) = section_header { + let at = section_end.unwrap_or(header) + 1; + lines.insert(at, new_line); + } else { + if lines.last().map(|l| !l.trim().is_empty()).unwrap_or(false) { + lines.push(String::new()); + } + lines.push(format!("[{}]", op.section)); + lines.push(new_line); + } + } + None => { + for &i in hits.iter().rev() { lines.remove(i); } + } + } + } + + let mut out = lines.join("\n"); + out.push('\n'); + out +} + +/// Set or remove individual INI keys on disk without rewriting the rest of +/// the file. Used for targeted edits (identity changes, migrations that move +/// a key between sections/files) where a full rewrite could lose content. +#[tauri::command] +pub async fn patch_server_ini(install_path: String, ops: Vec) -> Result<(), String> { + let base = config_dir(Path::new(&install_path)); + tokio::fs::create_dir_all(&base) + .await + .map_err(|e| format!("Failed to create config directory: {e}"))?; + + for (file_id, file_name) in [("gus", "GameUserSettings.ini"), ("game", "Game.ini")] { + let file_ops: Vec<&IniPatchOp> = ops.iter().filter(|o| o.file == file_id).collect(); + if file_ops.is_empty() { continue; } + let path = base.join(file_name); + let content = tokio::fs::read_to_string(&path).await.unwrap_or_default(); + let patched = patch_ini_text(&content, &file_ops); + if patched != content { + tokio::fs::write(&path, patched) + .await + .map_err(|e| format!("Failed to write {file_name}: {e}"))?; + } + } + Ok(()) +} + +/// Player access-list files ASA reads, keyed by the id the frontend passes. +/// Only these paths can be read or written through the commands below. +fn access_list_path(install_path: &Path, list: &str) -> Result { + let rel: &[&str] = match list { + // EOS IDs granted admin without entering the admin password. + "admins" => &["ShooterGame", "Saved", "AllowedCheaterAccountIDs.txt"], + // Whitelist used by -exclusivejoin / UseExclusiveList. + "exclusive_join" => &["ShooterGame", "Binaries", "Win64", "PlayersExclusiveJoinList.txt"], + // Players allowed to bypass the server's join checks (e.g. when full). + "join_no_check" => &["ShooterGame", "Binaries", "Win64", "PlayersJoinNoCheckList.txt"], + other => return Err(format!("Unknown access list: {other}")), + }; + Ok(rel.iter().fold(install_path.to_path_buf(), |p, part| p.join(part))) +} + +/// Read one of the player access-list files. A missing file reads as empty. +#[tauri::command] +pub async fn read_server_text_file(install_path: String, list: String) -> Result { + let path = access_list_path(Path::new(&install_path), &list)?; + match tokio::fs::read_to_string(&path).await { + Ok(s) => Ok(s), + Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(String::new()), + Err(e) => Err(format!("Failed to read {}: {e}", path.display())), + } +} + +/// Overwrite one of the player access-list files, creating parent folders. +#[tauri::command] +pub async fn write_server_text_file(install_path: String, list: String, content: String) -> Result<(), String> { + let path = access_list_path(Path::new(&install_path), &list)?; + if let Some(parent) = path.parent() { + tokio::fs::create_dir_all(parent) + .await + .map_err(|e| format!("Failed to create {}: {e}", parent.display()))?; + } + tokio::fs::write(&path, content) + .await + .map_err(|e| format!("Failed to write {}: {e}", path.display())) +} + /// Parse existing `GameUserSettings.ini` and `Game.ini` files provided by the user /// (e.g., imported from an existing ASA install) and return the structured JSON. /// Used in the "Import from existing config files" preset option in the creation wizard. @@ -159,3 +319,45 @@ pub async fn import_ini_files( }) } + +#[cfg(test)] +mod tests { + use super::*; + + fn op(file: &str, section: &str, key: &str, value: Option<&str>) -> IniPatchOp { + IniPatchOp { file: file.into(), section: section.into(), key: key.into(), value: value.map(Into::into) } + } + + #[test] + fn replaces_existing_key_and_keeps_everything_else() { + let src = "; comment\n[ServerSettings]\nXPMultiplier=1.0\nServerPassword=old\n\n[Other]\nA=1\n"; + let o = op("gus", "serversettings", "ServerPassword", Some("new")); + let out = patch_ini_text(src, &[&o]); + assert_eq!(out, "; comment\n[ServerSettings]\nXPMultiplier=1.0\nServerPassword=new\n\n[Other]\nA=1\n"); + } + + #[test] + fn inserts_into_existing_section_and_creates_missing_section() { + let src = "[ServerSettings]\nXPMultiplier=1.0\n\n[Other]\nA=1\n"; + let a = op("gus", "ServerSettings", "ServerPVE", Some("True")); + let b = op("gus", "MessageOfTheDay", "Message", Some("hi")); + let out = patch_ini_text(src, &[&a, &b]); + assert_eq!(out, "[ServerSettings]\nXPMultiplier=1.0\nServerPVE=True\n\n[Other]\nA=1\n\n[MessageOfTheDay]\nMessage=hi\n"); + } + + #[test] + fn removes_key_only_from_target_section() { + let src = "[SessionSettings]\nSessionName=X\nServerPassword=p\n[ServerSettings]\nServerPassword=p\n"; + let o = op("gus", "SessionSettings", "ServerPassword", None); + let out = patch_ini_text(src, &[&o]); + assert_eq!(out, "[SessionSettings]\nSessionName=X\n[ServerSettings]\nServerPassword=p\n"); + } + + #[test] + fn leaves_repeated_keys_in_other_sections_untouched() { + let src = "[/script/shootergame.shootergamemode]\nOverrideNamedEngramEntries=(a)\nOverrideNamedEngramEntries=(b)\n"; + let o = op("game", "/script/shootergame.shootergamemode", "BabyMatureSpeedMultiplier", Some("5.0")); + let out = patch_ini_text(src, &[&o]); + assert_eq!(out, "[/script/shootergame.shootergamemode]\nOverrideNamedEngramEntries=(a)\nOverrideNamedEngramEntries=(b)\nBabyMatureSpeedMultiplier=5.0\n"); + } +} diff --git a/src-tauri/src/commands/countdown.rs b/src-tauri/src/commands/countdown.rs index 2561168..694ae79 100644 --- a/src-tauri/src/commands/countdown.rs +++ b/src-tauri/src/commands/countdown.rs @@ -286,19 +286,18 @@ pub async fn start_graceful_restart( // Fail fast if a backup/update is already in progress for this server — // held for the whole operation, including the countdown, since a backup // that started mid-countdown and was still running when doexit fires - // would hit the same race this guards against. Not a `ServerLockGuard` - // (RAII) since that can't cross into the spawned 'static task below — - // released manually on every exit path instead, the same way - // `stopping_servers`/`countdowns` already span this spawn boundary. - if !state.busy_servers.lock().unwrap().insert(params.server_id.clone()) { + // would hit the same race this guards against. The guard is owned, so it + // moves into the spawned task below and is released when that finishes. + let Some(server_lock) = state.try_lock_server(¶ms.server_id) else { deregister_countdown(&state, ¶ms.server_id); return Err(format!("An operation is already in progress for {} — try again in a moment", params.server_id)); - } + }; let app2 = app.clone(); // Spawn so the command returns immediately. tauri::async_runtime::spawn(async move { + let _server_lock = server_lock; let state2 = app2.state::(); let result = run_countdown( &app2, @@ -335,7 +334,6 @@ pub async fn start_graceful_restart( error: None, }); } - state2.busy_servers.lock().unwrap().remove(¶ms.server_id); }); Ok(()) @@ -373,24 +371,18 @@ pub async fn start_graceful_update( let mut rx = try_register_countdown(&state, ¶ms.server_id)?; // Fail fast if a backup/restart is already in progress for this server — - // see start_graceful_restart's comment for why this can't be a - // `ServerLockGuard` (RAII) across the spawn boundary below. Released by - // `ReleaseBusyOnDrop` inside the spawned task instead, since that task - // has several early-return exit points this needs to cover uniformly. - if !state.busy_servers.lock().unwrap().insert(params.server_id.clone()) { + // see start_graceful_restart. Moved into the spawned task below, which + // releases it on whichever of its exit paths it takes. + let Some(server_lock) = state.try_lock_server(¶ms.server_id) else { deregister_countdown(&state, ¶ms.server_id); return Err(format!("An operation is already in progress for {} — try again in a moment", params.server_id)); - } + }; let app2 = app.clone(); tauri::async_runtime::spawn(async move { + let _server_lock = server_lock; let state2 = app2.state::(); - struct ReleaseBusyOnDrop<'a> { state: &'a AppState, server_id: &'a str } - impl Drop for ReleaseBusyOnDrop<'_> { - fn drop(&mut self) { self.state.busy_servers.lock().unwrap().remove(self.server_id); } - } - let _release_busy = ReleaseBusyOnDrop { state: &state2, server_id: ¶ms.server_id }; // Only run countdown if server is actually running. let proceed = if was_running { @@ -435,23 +427,38 @@ pub async fn start_graceful_update( error: None, }); - // Run SteamCMD update. + // Sync the shared cache into the server directory. The cache was + // already brought current by the update check that flagged this + // server — running SteamCMD again here (as this used to) meant one + // SteamCMD process per server against the same shared cache dir, + // which isn't safe when several updates overlap. let channel = format!("steamcmd://output/{}", params.server_id); - if let Err(e) = tokio::fs::create_dir_all(¶ms.cache_dir).await { - eprintln!("Failed to create cache dir: {e}"); - } - - let update_result = crate::commands::steamcmd::steamcmd_app_update( - &app2, - ¶ms.steamcmd_path, - ¶ms.cache_dir, - false, - &channel, - None, - ).await; - - if let Err(e) = update_result { - eprintln!("Scheduled update SteamCMD failed: {e}"); + let sync_result: Result<(), String> = async { + tokio::fs::create_dir_all(¶ms.cache_dir).await + .map_err(|e| format!("Failed to create cache dir: {e}"))?; + let _cache_guard = state2.asa_cache_lock.clone().read_owned().await; + let cache_path = std::path::PathBuf::from(¶ms.cache_dir); + let server_path = std::path::PathBuf::from(¶ms.install_path); + let app_clone = app2.clone(); + let channel_clone = channel.clone(); + tokio::task::spawn_blocking(move || { + // Not individually cancellable from this countdown-triggered path — a never-set flag is correct here. + let no_abort = std::sync::atomic::AtomicBool::new(false); + crate::commands::steamcmd::sync_cache_to_server(&cache_path, &server_path, &app_clone, &channel_clone, &no_abort) + }) + .await + .map_err(|e| format!("Sync task panicked: {e}"))? + .map_err(|e| format!("Failed to sync server files: {e}")) + }.await; + + if let Err(e) = sync_result { + // Leave update_available set — the update did NOT happen. + crate::commands::notifications::dispatch_notification( + &app2, "update_failed", Some(¶ms.server_id), ¶ms.server_name, + "Server Update Failed", + &format!("Failed to update {}: {e}", params.server_name), + "error", + ).await; emit_status(&app2, &ServerStatus { server_id: params.server_id.clone(), status: "stopped".into(), @@ -462,29 +469,28 @@ pub async fn start_graceful_update( return; } - // Sync updated cache to server directory. - let cache_path = std::path::PathBuf::from(¶ms.cache_dir); - let server_path = std::path::PathBuf::from(¶ms.install_path); - let app_clone = app2.clone(); - let channel_clone = channel.clone(); - if let Err(e) = tokio::task::spawn_blocking(move || { - // Not individually cancellable from this countdown-triggered path — a never-set flag is correct here. - let no_abort = std::sync::atomic::AtomicBool::new(false); - crate::commands::steamcmd::sync_cache_to_server(&cache_path, &server_path, &app_clone, &channel_clone, &no_abort) - }).await.map_err(|e| e.to_string()).and_then(|r| r.map_err(|e| e.to_string())) { - eprintln!("Cache sync failed: {e}"); + let acf = std::path::Path::new(¶ms.install_path).join(crate::commands::steamcmd::ACF_REL_PATH); + if let Some(build_id) = crate::commands::steamcmd::read_acf_build_id(&acf) { + crate::commands::build_version::record_install(&app2, ¶ms.server_id, &build_id); } - // Emit update-available cleared. - let _ = app2.emit(crate::events::ASA_UPDATE_CHECK, serde_json::json!({ - "updateApplied": true, - "serverId": params.server_id, - })); + // Clear the flag before announcing it, so the frontend's refresh on + // this event reads the cleared value. if let Some(db_path) = state2.get_db_path() { if let Ok(conn) = crate::db::open(&db_path) { crate::db::clear_update_available(&conn, ¶ms.server_id); } } + let _ = app2.emit(crate::events::ASA_UPDATE_CHECK, serde_json::json!({ + "updateApplied": true, + "serverId": params.server_id, + })); + crate::commands::notifications::dispatch_notification( + &app2, "server_updated", Some(¶ms.server_id), ¶ms.server_name, + "Server Updated", + &format!("{} has been updated successfully.", params.server_name), + "success", + ).await; // Restart if requested — hand off to the staggered startup queue // rather than starting directly, same as the scheduler's post-update diff --git a/src-tauri/src/commands/mod.rs b/src-tauri/src/commands/mod.rs index 38045a3..4340728 100644 --- a/src-tauri/src/commands/mod.rs +++ b/src-tauri/src/commands/mod.rs @@ -17,3 +17,4 @@ pub mod stats; pub mod steamcmd; pub mod system; pub mod utils; +pub mod virtual_display; diff --git a/src-tauri/src/commands/notifications.rs b/src-tauri/src/commands/notifications.rs index bce64aa..42765ab 100644 --- a/src-tauri/src/commands/notifications.rs +++ b/src-tauri/src/commands/notifications.rs @@ -53,9 +53,10 @@ pub async fn dispatch_notification( // Track which channels we've processed (per-server configs take precedence). let mut seen_channels = std::collections::HashSet::new(); - let mut in_app_enabled = true; // default: show toast - let mut bell_enabled = true; // default: show unread badge - let mut desktop_active = false; + // Defaults when no config row exists for a channel: toast + bell on, + // everything else off (matches the frontend dispatcher and the matrix). + let mut in_app_enabled = true; + let mut bell_enabled = true; for cfg in &configs { let channel = cfg.channel.as_str(); @@ -63,17 +64,16 @@ pub async fn dispatch_notification( // Per-server configs "own" the channel; global configs only apply if no per-server row. if cfg.server_id.is_some() { seen_channels.insert(channel.to_string()); } - if !event_enabled(&cfg.events_json, event_type) { continue; } + // A channel is on for this event only when the channel is enabled AND + // the event is ticked for it. (In-App/Bell used to skip this check for + // unticked events, leaving them at their "on" default — so backend + // events like "server online" ignored the matrix toggles.) + let on = cfg.enabled == 1 && event_enabled(&cfg.events_json, event_type); match channel { - "in_app" => { - in_app_enabled = cfg.enabled == 1; - } - "bell" => { - bell_enabled = cfg.enabled == 1; - } - "desktop" if cfg.enabled == 1 => { - desktop_active = true; + "in_app" => in_app_enabled = on, + "bell" => bell_enabled = on, + "desktop" if on => { let app2 = app.clone(); let title = title.to_string(); let body = body.to_string(); @@ -86,7 +86,7 @@ pub async fn dispatch_notification( .show(); }); } - "discord" if cfg.enabled == 1 => { + "discord" if on => { let cfg_json: serde_json::Value = serde_json::from_str(&cfg.config_json).unwrap_or_default(); if let Some(url) = cfg_json.get("webhookUrl").and_then(|u| u.as_str()) { @@ -99,13 +99,36 @@ pub async fn dispatch_notification( }); } } + "email" if on => { + let c: serde_json::Value = serde_json::from_str(&cfg.config_json).unwrap_or_default(); + let s = |k: &str| c.get(k).and_then(|v| v.as_str()).unwrap_or_default().to_string(); + let (host, to_address) = (s("host"), s("toAddress")); + if !host.is_empty() && !to_address.is_empty() { + let smtp = SmtpConfig { + host, + port: c.get("port").and_then(|v| v.as_u64().or_else(|| v.as_str().and_then(|p| p.parse().ok()))).unwrap_or(587) as u16, + username: s("username"), + password: s("password"), + from_address: Some(s("fromAddress")).filter(|f| !f.is_empty()).unwrap_or_else(|| "noreply@lokiasam".into()), + to_address, + use_tls: c.get("useTls").and_then(|v| v.as_bool()).unwrap_or(false), + }; + let payload = EmailPayload { subject: title.to_string(), body: body.to_string() }; + tauri::async_runtime::spawn(async move { + if let Err(e) = send_email_notification(smtp, payload).await { + eprintln!("[notify] email failed: {e}"); + } + }); + } + } _ => {} } } // ── Log to in_app_notifications ──────────────────────────────────────── - let visible_channel_active = in_app_enabled || desktop_active; - let show_unread = bell_enabled && visible_channel_active; + // Always archived; unread in the bell exactly when the Bell column is + // ticked for this event (independent of the toast/desktop columns). + let show_unread = bell_enabled; let id = uuid::Uuid::new_v4().to_string(); let _ = db::log_notification(&conn, &db::NotifInsert { @@ -161,9 +184,14 @@ fn severity_color(severity: &str) -> u32 { } } +/// The channel row lists exactly the events it's on for — an empty list means +/// none (migration 025 rewrote legacy "[]" rows, which meant "all", into an +/// explicit list). Unparseable JSON falls back to on rather than silencing. fn event_enabled(events_json: &str, event_type: &str) -> bool { - let events: Vec = serde_json::from_str(events_json).unwrap_or_default(); - events.is_empty() || events.iter().any(|e| e == event_type) + match serde_json::from_str::>(events_json) { + Ok(events) => events.iter().any(|e| e == event_type), + Err(_) => true, + } } #[derive(Debug, Serialize, Deserialize, Clone)] diff --git a/src-tauri/src/commands/proton.rs b/src-tauri/src/commands/proton.rs index 9e396c0..f3d8166 100644 --- a/src-tauri/src/commands/proton.rs +++ b/src-tauri/src/commands/proton.rs @@ -30,6 +30,16 @@ fn is_valid_proton_dir(p: &Path) -> bool { && (p.join("files/bin/wine64").exists() || p.join("files/bin/wine").exists()) } +/// Strip the architecture suffix newer GE-Proton archives append to the +/// extracted folder name (e.g. "GE-Proton11-14-x86_64" -> "GE-Proton11-14") +/// so it can be compared against the release tag. +fn strip_arch_suffix(name: &str) -> &str { + name.strip_suffix("-x86_64") + .or_else(|| name.strip_suffix("_x86_64")) + .or_else(|| name.strip_suffix("-x86-64")) + .unwrap_or(name) +} + fn emit_download_line(app: &AppHandle, msg: &str) { let _ = app.emit( "proton://output/download", @@ -250,7 +260,7 @@ async fn download_proton_ge_inner( let target_clone = target.clone(); let tag_clone = tag.clone(); let abort_extract = std::sync::Arc::clone(abort); - tokio::task::spawn_blocking(move || { + let dir_name = tokio::task::spawn_blocking(move || { use flate2::read::GzDecoder; use tar::Archive; @@ -258,6 +268,10 @@ async fn download_proton_ge_inner( // abort check — funnels through the same cleanup below instead of // leaving the downloaded archive (and any partially-extracted files) // behind on a genuine extraction error. + // Name of the archive's top-level directory. Older releases extract to + // "{tag}/", newer ones to "{tag}-x86_64/", so read it from the archive + // instead of assuming. + let mut top_dir: Option = None; let result: Result<(), String> = (|| { let f = std::fs::File::open(&tar_path_clone) .map_err(|e| format!("Failed to open archive: {e}"))?; @@ -271,12 +285,23 @@ async fn download_proton_ge_inner( return Err("Aborted".into()); } let mut entry = entry.map_err(|e| format!("Archive entry error: {e}"))?; + if top_dir.is_none() { + if let Ok(p) = entry.path() { + if let Some(std::path::Component::Normal(first)) = p + .components() + .find(|c| !matches!(c, std::path::Component::CurDir)) + { + top_dir = Some(first.to_string_lossy().into_owned()); + } + } + } entry .unpack_in(&target_clone) .map_err(|e| format!("Failed to extract entry: {e}"))?; } Ok(()) })(); + let dir_name = top_dir.unwrap_or_else(|| tag_clone.clone()); match &result { Ok(()) => { @@ -286,17 +311,17 @@ async fn download_proton_ge_inner( // Covers both "Aborted" and a genuine extraction error — // either way the archive and any partial extraction are junk. let _ = std::fs::remove_file(&tar_path_clone); - let _ = std::fs::remove_dir_all(target_clone.join(&tag_clone)); + let _ = std::fs::remove_dir_all(target_clone.join(&dir_name)); } } - result + result.map(|()| dir_name) }) .await .map_err(|e| format!("Extraction task error: {e}"))??; - let extracted_path = target.join(&tag); + let extracted_path = target.join(&dir_name); - if !extracted_path.exists() { + if !is_valid_proton_dir(&extracted_path) { return Err(format!( "Extraction finished but expected directory not found: {}", extracted_path.display() @@ -362,7 +387,8 @@ pub async fn check_proton_ge_update(current_path: String) -> Result, state: tauri::State<'_, SchedulerState>, ) -> Result<(), String> { - let now = now_ms(); + let in_flight = state.in_flight.lock().unwrap().clone(); let mut store = state.entries.lock().unwrap(); let mut updated = entries; for entry in updated.iter_mut() { - if let Some(existing) = store.iter().find(|e| e.schedule_id == entry.schedule_id) { - if existing.next_run_ms == u64::MAX && entry.next_run_ms <= now { - // Entry is in-flight and this push still looks stale — keep the guard. - entry.next_run_ms = u64::MAX; - } + if in_flight.contains(&entry.schedule_id) { + entry.next_run_ms = u64::MAX; } } *store = updated; @@ -126,25 +118,49 @@ async fn fire_wipe_dinos(app: &AppHandle, entry: &crate::state::scheduler::Sched Ok(()) } +/// Wait for this server's operation lock, queueing behind whatever backup / +/// restart / update / stop already holds it. Returns the guard plus whether +/// we actually had to wait (i.e. something else ran on this server first). +async fn queue_for_server(app: &AppHandle, server_id: &str) -> (crate::state::ServerLockGuard, bool) { + let state = app.state::(); + if let Some(guard) = state.try_lock_server(server_id) { + return (guard, false); + } + (state.lock_server(server_id).await, true) +} + +fn is_confirmed_running(app: &AppHandle, server_id: &str) -> bool { + let state = app.state::(); + let registry = state.running_servers.lock().unwrap(); + registry.get(server_id).map(|rs| rs.confirmed_running).unwrap_or(false) +} + async fn fire_restart(app: &AppHandle, entry: &crate::state::scheduler::ScheduleEntry) -> Result<(), String> { if !super::server::is_server_running(app, &entry.server_id) { return Ok(()); } - // Mid-boot (spawned but not yet RCON-confirmed) — see fire_update for why - // this skips the countdown/graceful handshake entirely. - let is_confirmed_running = { - let state = app.state::(); - let registry = state.running_servers.lock().unwrap(); - registry.get(&entry.server_id).map(|rs| rs.confirmed_running).unwrap_or(false) - }; - // Refuse to restart a server whose hourly backup is currently in - // progress — killing the process mid-backup can produce a silently - // incomplete archive. The restart will fire again at its next scheduled - // occurrence. + // Queue behind any backup / update / stop already in progress on this + // server rather than failing — killing the process mid-backup could + // produce a silently incomplete archive, but dropping the restart until + // its next occurrence (as this used to) isn't what anyone wants either. + let (_lock, waited) = queue_for_server(app, &entry.server_id).await; let state = app.state::(); - let _lock = state.try_lock_server(&entry.server_id) - .ok_or_else(|| format!("A backup is currently in progress for {} — restart will retry next time", entry.server_id))?; + + // Re-evaluate now that we hold the lock — whatever we waited on may have + // stopped or restarted the server already. + if !super::server::is_server_running(app, &entry.server_id) { + return Ok(()); + } + // Mid-boot (spawned but not yet RCON-confirmed) — see fire_update for why + // this skips the countdown/graceful handshake entirely. + let is_confirmed_running = is_confirmed_running(app, &entry.server_id); + if waited && !is_confirmed_running { + // We queued behind something (typically an update) that already + // restarted this server — it's booting fresh right now, so a second + // restart would only throw that boot away. + return Ok(()); + } if is_confirmed_running { let cfg: serde_json::Value = serde_json::from_str(&entry.config_json).unwrap_or_default(); @@ -154,12 +170,9 @@ async fn fire_restart(app: &AppHandle, entry: &crate::state::scheduler::Schedule let (tx, mut rx) = tokio::sync::mpsc::channel::(1); { - let state = app.state::(); let mut cd = state.countdowns.lock().unwrap(); - // Refuse to start a second countdown for this server — otherwise a - // restart and an update schedule (or two restarts) becoming due in - // the same tick would silently overwrite each other's countdown - // handle and both run their own stop/start sequence concurrently. + // A countdown not started under this server's lock (shouldn't + // happen, but never clobber another task's cancel handle). if cd.contains_key(&entry.server_id) { return Err(format!("A countdown is already in progress for {}", entry.server_id)); } @@ -178,10 +191,7 @@ async fn fire_restart(app: &AppHandle, entry: &crate::state::scheduler::Schedule &mut rx, ).await; - { - let state = app.state::(); - state.countdowns.lock().unwrap().remove(&entry.server_id); - } + state.countdowns.lock().unwrap().remove(&entry.server_id); if matches!(result, super::countdown::CountdownResult::Cancel) { return Ok(()); @@ -204,6 +214,13 @@ async fn fire_restart(app: &AppHandle, entry: &crate::state::scheduler::Schedule state.wait_for_stop_handoff(&entry.server_id, notify).await; } + crate::commands::notifications::dispatch_notification( + app, "scheduled_restart", Some(&entry.server_id), &entry.server_name, + &format!("{} restarting", entry.server_name), + "Scheduled restart — the server will be back up shortly.", + "info", + ).await; + // Hand off to the frontend's staggered startup queue instead of starting // directly, so a batch of same-time restart schedules doesn't cold-boot // several servers at once — the "server://any-change" listener re-enqueues @@ -239,6 +256,11 @@ async fn fire_global_update_check( .unwrap_or_else(|| "0".to_string()); let state = app.state::(); + // A manual check is running right now — skip this tick silently (before + // announcing anything to the UI); the next scheduled tick will retry. + if state.abort_flags.lock().unwrap().contains_key(crate::commands::steamcmd::ASA_CACHE_CHECK_KEY) { + return Ok(()); + } let _ = app.emit(crate::events::ASA_UPDATE_CHECK_RUNNING, serde_json::json!({ "running": true })); let result = crate::commands::steamcmd::update_cache_inner( crate::commands::steamcmd::ASA_CACHE_CHECK_KEY, @@ -273,23 +295,61 @@ async fn fire_global_update_check( } async fn fire_update(app: &AppHandle, entry: &crate::state::scheduler::ScheduleEntry) -> Result<(), String> { + use crate::commands::server::{emit_status, ServerStatus}; + use crate::commands::steamcmd::{get_cache_build_id, read_acf_build_id, ACF_REL_PATH}; + let cfg: serde_json::Value = serde_json::from_str(&entry.config_json).unwrap_or_default(); let sep = if entry.base_dir.contains('\\') { '\\' } else { '/' }; let cache_dir = format!("{}{sep}lokiasam{sep}cache{sep}asa-server", entry.base_dir); - let is_running = super::server::is_server_running(app, &entry.server_id); + let warn_minutes = if cfg["broadcastWarning"].as_bool().unwrap_or(false) { cfg["warningMinutes"].as_u64().unwrap_or(0) } else { 0 }; + let skip_if_players = cfg["skipIfPlayersOnline"].as_bool().unwrap_or(false); + let restart_after = cfg["restartAfterUpdate"].as_bool().unwrap_or(true); + // When false, restart_after applies even if the server was stopped before + // the update (used by per-server Auto-Update automation's "Only restart if + // server was already running" toggle — unchecked means "always end up + // running after an update"). + let only_if_running = cfg["onlyIfRunning"].as_bool().unwrap_or(true); + let message = cfg["message"].as_str().unwrap_or("Server going down for update in {time}.").to_string(); + let cancel_msg = cfg["cancelMessage"].as_str().unwrap_or("").to_string(); + + // Queue behind any backup / restart / stop / manual update already + // running on this server instead of failing — overwriting files + // mid-backup could produce a silently incomplete archive, so we wait our + // turn and then pick up wherever that operation left the server. + let (_lock, _waited) = queue_for_server(app, &entry.server_id).await; + let state = app.state::(); + + // Whatever we waited on may already have applied this exact update + // (e.g. the user clicked Update All, or a manual update ran) — if the + // server's installed build already matches the cache, there's nothing to + // do, and stopping/restarting it would just kick players for no reason. + let installed_build = read_acf_build_id(&std::path::Path::new(&entry.install_path).join(ACF_REL_PATH)); + let cache_build = get_cache_build_id(&cache_dir); + if installed_build.is_some() && installed_build == cache_build { + if let Some(db_path) = state.get_db_path() { + if let Ok(conn) = crate::db::open(&db_path) { + crate::db::clear_update_available(&conn, &entry.server_id); + } + } + let _ = app.emit(crate::events::ASA_UPDATE_CHECK, serde_json::json!({ + "updateApplied": true, + "serverId": entry.server_id, + })); + return Ok(()); + } + + // Evaluated only now, after the wait — the server's state may have + // changed completely while we were queued. + let is_running = super::server::is_server_running(app, &entry.server_id); // Distinguish "fully up and joinable" from "spawned but still mid-boot" — // the confirmed_running flag on the running_servers entry tells them apart. - let is_confirmed_running = { - let state = app.state::(); - let registry = state.running_servers.lock().unwrap(); - registry.get(&entry.server_id).map(|rs| rs.confirmed_running).unwrap_or(false) - }; + let is_confirmed_running = is_confirmed_running(app, &entry.server_id); // A server that hadn't even been spawned yet, but was sitting in the // startup queue, isn't caught by is_running at all — read the live DB // status directly to catch that case too. - let was_queued_for_startup = app.state::().get_db_path() + let was_queued_for_startup = state.get_db_path() .and_then(|p| crate::db::open(&p).ok()) .and_then(|conn| crate::db::get_server_status(&conn, &entry.server_id)) .as_deref() == Some("startup_queued"); @@ -298,16 +358,6 @@ async fn fire_update(app: &AppHandle, entry: &crate::state::scheduler::ScheduleE // branch below for why that always finishes the launch regardless of // only_if_running, and does so via the startup queue rather than directly. let interrupted_startup = (is_running && !is_confirmed_running) || was_queued_for_startup; - let warn_minutes = if cfg["broadcastWarning"].as_bool().unwrap_or(false) { cfg["warningMinutes"].as_u64().unwrap_or(0) } else { 0 }; - let skip_if_players = cfg["skipIfPlayersOnline"].as_bool().unwrap_or(false); - let restart_after = cfg["restartAfterUpdate"].as_bool().unwrap_or(true); - // When false, restart_after applies even if the server was stopped before - // the update (used by per-server Auto-Update automation's "Only restart if - // server was already running" toggle — unchecked means "always end up - // running after an update"). - let only_if_running = cfg["onlyIfRunning"].as_bool().unwrap_or(true); - let message = cfg["message"].as_str().unwrap_or("Server going down for update in {time}.").to_string(); - let cancel_msg = cfg["cancelMessage"].as_str().unwrap_or("").to_string(); // Skip entirely if players are online and the schedule says to. if is_running && skip_if_players { @@ -320,15 +370,6 @@ async fn fire_update(app: &AppHandle, entry: &crate::state::scheduler::ScheduleE } } - // Refuse to update a server whose hourly backup is currently reading its - // files — overwriting them mid-backup can produce a silently incomplete - // archive. The per-server auto-update entry is regenerated on the next - // schedule sync as long as update_available stays set, so this retries - // shortly rather than being lost. - let state = app.state::(); - let _lock = state.try_lock_server(&entry.server_id) - .ok_or_else(|| format!("A backup is currently in progress for {} — update will retry shortly", entry.server_id))?; - if is_running && !is_confirmed_running { // Mid-boot: the process is spawned but RCON isn't up yet, so there's no // world state to save and no players to warn — the countdown and the @@ -347,11 +388,8 @@ async fn fire_update(app: &AppHandle, entry: &crate::state::scheduler::ScheduleE } else if is_confirmed_running { let (tx, mut rx) = tokio::sync::mpsc::channel::(1); { - let state = app.state::(); let mut cd = state.countdowns.lock().unwrap(); - // See fire_restart — refuse to clobber a countdown already in - // progress for this server (e.g. a restart schedule racing this - // update schedule in the same tick). + // See fire_restart — never clobber another task's cancel handle. if cd.contains_key(&entry.server_id) { return Err(format!("A countdown is already in progress for {}", entry.server_id)); } @@ -370,10 +408,7 @@ async fn fire_update(app: &AppHandle, entry: &crate::state::scheduler::ScheduleE &mut rx, ).await; - { - let state = app.state::(); - state.countdowns.lock().unwrap().remove(&entry.server_id); - } + state.countdowns.lock().unwrap().remove(&entry.server_id); if matches!(result, super::countdown::CountdownResult::Cancel) { return Ok(()); @@ -387,8 +422,14 @@ async fn fire_update(app: &AppHandle, entry: &crate::state::scheduler::ScheduleE state.wait_for_stop_handoff(&entry.server_id, notify).await; } + crate::commands::notifications::dispatch_notification( + app, "update_started", Some(&entry.server_id), &entry.server_name, + "Auto-Update Started", + &format!("Applying ASA server update to {}…", entry.server_name), + "info", + ).await; + // Emit "updating" so the server card shows the spinner. - use crate::commands::server::{emit_status, ServerStatus}; emit_status(app, &ServerStatus { server_id: entry.server_id.clone(), status: "updating".into(), @@ -402,52 +443,67 @@ async fn fire_update(app: &AppHandle, entry: &crate::state::scheduler::ScheduleE // brought current by the global check that flagged this server as // outdated in the first place (same as the manual/bulk apply path, which // only ever calls apply_cache_to_server, never steamcmd_app_update). - // Re-running a full SteamCMD app_update per server was not just redundant - // but actively unsafe: when several servers' "When Found" automation - // fires in the same tick, each spawned its own SteamCMD process against - // this same shared cache directory concurrently, which SteamCMD does not - // handle safely (lock contention/hangs between instances) — this was the - // actual cause of updates appearing to stall the startup queue. + // Re-running SteamCMD per server would mean several SteamCMD processes + // against the same shared cache directory at once, which SteamCMD does + // not handle safely. let channel = format!("steamcmd://output/{}", entry.server_id); - tokio::fs::create_dir_all(&cache_dir) + let sync_result: Result<(), String> = async { + tokio::fs::create_dir_all(&cache_dir) + .await + .map_err(|e| format!("Failed to create cache dir: {e}"))?; + + // Read half of the cache lock — several servers may sync at once, but + // never while an update check has SteamCMD rewriting the cache. + let _cache_guard = state.asa_cache_lock.clone().read_owned().await; + let cache_path = std::path::PathBuf::from(&cache_dir); + let server_path = std::path::PathBuf::from(&entry.install_path); + let app_clone = app.clone(); + let channel_clone = channel.clone(); + tokio::task::spawn_blocking(move || { + // Scheduled updates aren't individually cancellable — a never-set flag is correct here. + let no_abort = std::sync::atomic::AtomicBool::new(false); + crate::commands::steamcmd::sync_cache_to_server(&cache_path, &server_path, &app_clone, &channel_clone, &no_abort) + }) .await - .map_err(|e| format!("Failed to create cache dir: {e}"))?; - - // Sync updated files to the server directory (preserving Saved/). - let cache_path = std::path::PathBuf::from(&cache_dir); - let server_path = std::path::PathBuf::from(&entry.install_path); - let app_clone = app.clone(); - let channel_clone = channel.clone(); - tokio::task::spawn_blocking(move || { - // Scheduled updates aren't individually cancellable — a never-set flag is correct here. - let no_abort = std::sync::atomic::AtomicBool::new(false); - crate::commands::steamcmd::sync_cache_to_server(&cache_path, &server_path, &app_clone, &channel_clone, &no_abort) - }) - .await - .map_err(|e| format!("Sync task panicked: {e}"))? - .map_err(|e| format!("Failed to sync server files: {e}"))?; + .map_err(|e| format!("Sync task panicked: {e}"))? + .map_err(|e| format!("Failed to sync server files: {e}")) + } + .await; - // Record updated build ID and trigger internet version fetch - let acf = std::path::Path::new(&entry.install_path) - .join(crate::commands::steamcmd::ACF_REL_PATH); - if let Some(build_id) = crate::commands::steamcmd::read_acf_build_id(&acf) { - crate::commands::build_version::record_install(app, &entry.server_id, &build_id); + if let Err(e) = sync_result { + // Never leave the server stuck on the "updating" spinner — the + // update_available flag stays set so it's retried / visible. + emit_status(app, &ServerStatus { + server_id: entry.server_id.clone(), + status: "stopped".into(), + pid: None, + uptime_seconds: None, + error: Some(e.clone()), + }); + return Err(e); } - let _ = app.emit(crate::events::ASA_UPDATE_CHECK, serde_json::json!({ - "updateApplied": true, - "serverId": entry.server_id, - })); + // Record updated build ID and trigger internet version fetch + let acf = std::path::Path::new(&entry.install_path).join(ACF_REL_PATH); + let new_build = read_acf_build_id(&acf); + if let Some(build_id) = &new_build { + crate::commands::build_version::record_install(app, &entry.server_id, build_id); + } // Clear the per-server update flag — otherwise the UI keeps showing // "Update Available" and, for "immediately" mode, the next scheduler // sync would generate this same auto-update entry all over again. - if let Some(db_path) = app.state::().get_db_path() { + if let Some(db_path) = state.get_db_path() { if let Ok(conn) = crate::db::open(&db_path) { crate::db::clear_update_available(&conn, &entry.server_id); } } + let _ = app.emit(crate::events::ASA_UPDATE_CHECK, serde_json::json!({ + "updateApplied": true, + "serverId": entry.server_id, + })); + // Restart if requested — either the server was already fully running, the // schedule says to bring it up regardless (only_if_running = false), or it // was on its way up (mid-boot or queued) when this update interrupted it. @@ -459,31 +515,28 @@ async fn fire_update(app: &AppHandle, entry: &crate::state::scheduler::ScheduleE // starting directly — several servers restarting after the same update // check shouldn't all cold-boot at once. The "server://any-change" // listener re-enqueues on this status. - if restart_after && (is_confirmed_running || !only_if_running || interrupted_startup) { - use crate::commands::server::{emit_status, ServerStatus}; - emit_status(app, &ServerStatus { - server_id: entry.server_id.clone(), - status: "startup_queued".into(), - pid: None, - uptime_seconds: None, - error: None, - }); - } else { - // No restart is coming — the server was already stopped and the - // automation config says to leave it that way (or restart_after is - // off). Nothing else ever clears the "updating" status set above for - // this case, so without this the server sits stuck showing the - // in-progress spinner (Overview/dashboard) until the user manually - // Cancels and Reinstalls, even though the update itself succeeded. - use crate::commands::server::{emit_status, ServerStatus}; - emit_status(app, &ServerStatus { - server_id: entry.server_id.clone(), - status: "stopped".into(), - pid: None, - uptime_seconds: None, - error: None, - }); - } + let restarting = restart_after && (is_confirmed_running || !only_if_running || interrupted_startup); + emit_status(app, &ServerStatus { + server_id: entry.server_id.clone(), + // No restart coming → explicitly "stopped"; nothing else would ever + // clear the "updating" status set above for this case. + status: if restarting { "startup_queued" } else { "stopped" }.into(), + pid: None, + uptime_seconds: None, + error: None, + }); + + crate::commands::notifications::dispatch_notification( + app, "server_updated", Some(&entry.server_id), &entry.server_name, + "Server Auto-Updated", + &format!( + "{} was updated{}{}.", + entry.server_name, + new_build.map(|b| format!(" to build {b}")).unwrap_or_default(), + if restarting { " and is restarting" } else { "" }, + ), + "success", + ).await; Ok(()) } @@ -504,6 +557,12 @@ pub fn tick_scheduler(app: &AppHandle) { due.push(entry.clone()); } } + // Registered under the entries lock so a concurrent sync_schedules + // can't slip in between and re-arm one of these. + let mut in_flight = scheduler.in_flight.lock().unwrap(); + for entry in &due { + in_flight.insert(entry.schedule_id.clone()); + } due }; @@ -539,6 +598,19 @@ pub fn tick_scheduler(app: &AppHandle) { _ => (false, Some(format!("Unknown schedule type: {schedule_type}"))), }; + if schedule_type == "update" && !success { + crate::commands::notifications::dispatch_notification( + &app, "update_failed", Some(&server_id), &server_name, + "Auto-Update Failed", + &format!("{server_name}: {}", error.as_deref().unwrap_or("unknown error")), + "error", + ).await; + } + + // Cleared before emitting `scheduler://fired`, so the resync the + // frontend runs in response is allowed to re-arm this entry. + app.state::().in_flight.lock().unwrap().remove(&schedule_id); + let _ = app.emit( "scheduler://fired", SchedulerFiredPayload { diff --git a/src-tauri/src/commands/server.rs b/src-tauri/src/commands/server.rs index 092dc9b..f35b816 100644 --- a/src-tauri/src/commands/server.rs +++ b/src-tauri/src/commands/server.rs @@ -116,6 +116,34 @@ pub struct StartServerParams { pub proton_path: Option, /// Linux only: WINEPREFIX path where Proton creates its fake C: drive. pub prefix_path: Option, + /// Run without a visible server window. Windows: no console window. + /// Linux: on an invisible X display (Xvfb or headless gamescope — see + /// virtual_display.rs) in a separate "{prefix}-hidden" prefix. Either way + /// the server also gets -unattended, and a startup watchdog kills it if it + /// logs a fatal error but doesn't exit (nobody can click an error dialog + /// on an invisible display) so the normal retry/crash flow runs. +#[serde(default)] + pub hide_window: bool, +} + +/// Point a Proton/Wine command at the invisible X display (and away from the +/// user's Wayland session, which Wine would otherwise prefer). +pub fn apply_virtual_display_env(cmd: &mut tokio::process::Command, display: &str) { + cmd.env("DISPLAY", display); + cmd.env_remove("WAYLAND_DISPLAY"); +} + +/// The prefix a server runs in. Hidden servers use a sibling prefix: Wine +/// ties a prefix to the display its first process used, so a shared prefix +/// would show or hide every server depending on which started first. +/// ("-hidden", not the earlier "-headless" prefix, which was configured for +/// Wine's null graphics driver — that left ASA hung at startup.) +pub fn effective_prefix(prefix: &str, hide_window: bool) -> String { + if hide_window && !prefix.is_empty() { + format!("{}-hidden", prefix.trim_end_matches('/')) + } else { + prefix.to_string() + } } // --------------------------------------------------------------------------- @@ -310,6 +338,11 @@ async fn inner_start_server_with_state( // Passwords, RCON, MaxPlayers, and all gameplay settings are read by the // server from GameUserSettings.ini — they must NOT be duplicated on the CLI // or they will override INI values on every restart. + // Whether this start is actually hidden — on Linux it falls back to a + // visible window if no virtual display can be started. + #[allow(unused_mut)] + let mut hidden = params.hide_window; + let query_string = format!( "{}?listen?Port={}?QueryPort={}", params.map_path, @@ -322,10 +355,19 @@ async fn inner_start_server_with_state( // Linux: run via Proton-GE (`{proton}/proton run {Win64 exe}`). // The Win64 binary is the only shipping binary for ASA — there is no native Linux exe. #[cfg(target_os = "windows")] - let mut cmd = tokio::process::Command::new(format!( - "{}\\ShooterGame\\Binaries\\Win64\\ArkAscendedServer.exe", - params.install_path - )); + let mut cmd = { + let mut c = tokio::process::Command::new(format!( + "{}\\ShooterGame\\Binaries\\Win64\\ArkAscendedServer.exe", + params.install_path + )); + if params.hide_window { + // CREATE_NO_WINDOW — no console window. Nothing is lost: the app + // reads ShooterGame.log, not the console. + const CREATE_NO_WINDOW: u32 = 0x0800_0000; + c.creation_flags(CREATE_NO_WINDOW); + } + c + }; #[cfg(not(target_os = "windows"))] let mut cmd = { @@ -337,10 +379,36 @@ async fn inner_start_server_with_state( "proton_not_configured: Linux requires Proton-GE. Configure it in the setup wizard or Settings.".to_string() })?; - let prefix_path = params.prefix_path.clone().unwrap_or_default(); + let main_prefix = params.prefix_path.clone().unwrap_or_default(); + let virtual_display = if hidden { + let started = tokio::task::spawn_blocking(crate::commands::virtual_display::ensure_display) + .await + .unwrap_or_else(|e| Err(format!("virtual display task failed: {e}"))); + match started { + Ok((_, display)) => Some(display), + Err(reason) => { + // Start visibly rather than not at all. + let _ = app_handle.emit("notification://toast", serde_json::json!({ + "severity": "warning", + "title": format!("{} started with its window visible", params.server_name), + "body": format!("Hide Server Window needs a virtual display: {reason}"), + })); + None + } + } + } else { + None + }; + hidden = virtual_display.is_some(); + + let prefix_path = effective_prefix(&main_prefix, hidden); if !prefix_path.is_empty() { let _ = tokio::fs::create_dir_all(&prefix_path).await; } + if let Some(display) = virtual_display.as_deref() { + // Copy the mod-download certificate into the hidden prefix (once). + crate::commands::certs::ensure_hidden_prefix(proton_path, &main_prefix, &prefix_path, display).await; + } let exe_path = format!( "{}/ShooterGame/Binaries/Win64/ArkAscendedServer.exe", @@ -355,11 +423,19 @@ async fn inner_start_server_with_state( c.env("STEAM_COMPAT_DATA_PATH", &prefix_path); } c.env("STEAM_COMPAT_CLIENT_INSTALL_PATH", ¶ms.install_path); + if let Some(display) = virtual_display.as_deref() { + apply_virtual_display_env(&mut c, display); + } c }; cmd.arg(&query_string); cmd.args(["-server", "-log"]); + if hidden { + // Never wait on a dialog: with no visible window nobody can click it, + // so a fatal error (e.g. a failed mod download) must exit instead. + cmd.arg("-unattended"); + } if !params.mod_ids.is_empty() { cmd.arg(format!("-mods={}", params.mod_ids.join(","))); } @@ -678,6 +754,7 @@ async fn inner_start_server_with_state( let confirmed2 = Arc::clone(&confirmed_running); let cfcore2 = Arc::clone(&cfcore_unreachable); + let hidden2 = hidden; tauri::async_runtime::spawn(async move { use std::io::SeekFrom; use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncSeekExt, BufReader}; @@ -689,6 +766,27 @@ async fn inner_start_server_with_state( const TIMEOUT: Duration = Duration::from_secs(20 * 60); // 20 min absolute max let deadline = Instant::now() + TIMEOUT; + let started = Instant::now(); + + // ── Hidden-server watchdog ─────────────────────────────────────────── + // A hidden server can't show an error dialog, so if it gets stuck it + // stays stuck. Kill it (hard, NOT marked as an intentional stop) so the + // exit watcher runs the usual flow: CurseForge failures retry silently + // via server://cfcore-error, anything else reports start-failed. + const NO_LOG_LIMIT: Duration = Duration::from_secs(3 * 60); + const FATAL_GRACE: Duration = Duration::from_secs(20); + let kill_stuck = |handle: &tauri::AppHandle, sid: &str, why: &str| { + let target = { + let state = handle.state::(); + let registry = state.running_servers.lock().unwrap(); + registry.get(sid).map(|rs| (rs.pid, rs.install_path.clone())) + }; + if let Some((pid, install_path)) = target { + eprintln!("[server] hidden server {sid} stuck ({why}) — killing so it can be retried"); + kill_process_tree(pid, false, &install_path); + } + }; + let mut fatal_seen_at: Option = None; // Mark the server as confirmed-running, read its PID/uptime, and emit "running". // Sets confirmed_running = true so the crash monitor emits "crashed" (not @@ -744,7 +842,13 @@ async fn inner_start_server_with_state( match tokio::fs::File::open(&log_path2).await { Ok(f) => break f, - Err(_) => sleep(Duration::from_secs(1)).await, + Err(_) => { + if hidden2 && started.elapsed() >= NO_LOG_LIMIT { + kill_stuck(&handle2, &sid2, "no log file after 3 minutes"); + return; + } + sleep(Duration::from_secs(1)).await + } } }; @@ -765,6 +869,10 @@ async fn inner_start_server_with_state( .unwrap() .contains_key(&sid2); if !still_tracked { return; } + if hidden2 && fatal_seen_at.is_some_and(|t| t.elapsed() >= FATAL_GRACE) { + kill_stuck(&handle2, &sid2, "fatal error logged but process didn't exit"); + return; + } sleep(Duration::from_millis(200)).await; } Ok(_) => { @@ -778,6 +886,10 @@ async fn inner_start_server_with_state( } if buf.contains("Error querying server mods: ApiError: Failed (serverUnreachable)") { cfcore2.store(true, Ordering::Relaxed); + fatal_seen_at.get_or_insert_with(Instant::now); + } + if buf.contains("LowLevelFatalError") || buf.contains("Fatal error:") { + fatal_seen_at.get_or_insert_with(Instant::now); } buf.clear(); } @@ -1050,6 +1162,7 @@ pub async fn scan_running_servers( mod_ids: vec![], proton_path: None, prefix_path: None, + hide_window: false, }; registry.insert( entry.server_id.clone(), @@ -1410,9 +1523,10 @@ pub async fn graceful_stop_server( // Held for the whole operation (including the player-warning countdown, // which can run for several minutes) so a scheduled backup can't start - // mid-shutdown and produce a truncated archive. - let _lock = state.try_lock_server(&server_id) - .ok_or_else(|| format!("An operation is already in progress for {server_id} — try again in a moment"))?; + // mid-shutdown and produce a truncated archive. Queues behind a backup + // that's already running rather than failing — the stop simply happens + // once the backup has finished reading the server's files. + let _lock = state.lock_server(&server_id).await; let (pid, install_path, server_name) = { let registry = state.running_servers.lock().unwrap(); diff --git a/src-tauri/src/commands/steamcmd.rs b/src-tauri/src/commands/steamcmd.rs index 6ee9240..f110266 100644 --- a/src-tauri/src/commands/steamcmd.rs +++ b/src-tauri/src/commands/steamcmd.rs @@ -504,6 +504,7 @@ pub async fn install_server( let channel = format!("{}/{}", events::STEAMCMD_OUTPUT, server_id); let result = async { + let _cache_guard = state.asa_cache_lock.clone().write_owned().await; emit_line(&app_handle, &channel, "stdout", &format!("Ensuring server cache at: {cache_dir}"))?; tokio::fs::create_dir_all(&cache_dir).await @@ -565,6 +566,7 @@ pub async fn update_server( let channel = format!("{}/{}", events::STEAMCMD_OUTPUT, server_id); let result = async { + let _cache_guard = state.asa_cache_lock.clone().write_owned().await; emit_line(&app_handle, &channel, "stdout", "Checking for updates (cache)…")?; tokio::fs::create_dir_all(&cache_dir).await .map_err(|e| format!("Failed to ensure cache directory: {e}"))?; @@ -613,8 +615,12 @@ pub async fn validate_server_files( cache_dir: String, steamcmd_path: String, app_handle: tauri::AppHandle, + state: tauri::State<'_, crate::state::AppState>, ) -> Result<(), String> { let channel = format!("{}/{}", events::STEAMCMD_OUTPUT, server_id); + // Overwrites this server's files — queue behind any backup reading them. + let _lock = state.lock_server(&server_id).await; + let _cache_guard = state.asa_cache_lock.clone().write_owned().await; emit_line(&app_handle, &channel, "stdout", "Validating server files in cache…")?; tokio::fs::create_dir_all(&cache_dir).await @@ -742,6 +748,10 @@ pub async fn update_cache_inner( let abort = state.register_abort(server_id); let result: Result = async { + // Exclusive access to the cache while SteamCMD rewrites it — waits for + // any in-progress cache→server syncs (auto-update/apply) to finish + // first, and holds off new ones until the check is done. + let _cache_guard = state.asa_cache_lock.clone().write_owned().await; emit_line(app_handle, &channel, "stdout", "Updating server cache from Steam…")?; tokio::fs::create_dir_all(&cache_dir) .await @@ -792,14 +802,26 @@ pub async fn apply_cache_to_server( // Auto-Update landing on the same server around the same moment — both // used to sync the cache into the same install directory concurrently // with no coordination at all. - let _lock = state.try_lock_server(&server_id) - .ok_or_else(|| format!("An operation is already in progress for {server_id} — try again in a moment"))?; + // + // Queues (rather than failing) behind a backup or other operation that's + // already running on this server, so "Update All" doesn't fail a server + // just because its hourly backup happened to be mid-way through. + let channel = format!("{}/{}", events::STEAMCMD_OUTPUT, server_id); + let _lock = match state.try_lock_server(&server_id) { + Some(guard) => guard, + None => { + let _ = emit_line(&app_handle, &channel, "stdout", + "Waiting for another operation on this server (e.g. a backup) to finish…"); + state.lock_server(&server_id).await + } + }; let op_key = format!("server_{server_id}"); let abort = state.register_abort(&op_key); - let channel = format!("{}/{}", events::STEAMCMD_OUTPUT, server_id); let result = async { + // Never copy from the cache while an update check is rewriting it. + let _cache_guard = state.asa_cache_lock.clone().read_owned().await; emit_line(&app_handle, &channel, "stdout", "Syncing updated files to server (preserving Saved/ data)…")?; @@ -856,8 +878,12 @@ pub async fn detect_server_install(install_path: String) -> Result Option { - ini.get(section)?.get(key).cloned() + ini.iter() + .find(|(name, _)| name.eq_ignore_ascii_case(section)) + .and_then(|(_, kv)| kv.get(key).cloned()) + .filter(|v| !v.is_empty()) }; Ok(DetectedServerConfig { @@ -869,8 +895,11 @@ pub async fn detect_server_install(install_path: String) -> Result