feat: move to Rust: merge rust/full into main #351

Merged
LooperSalty merged 184 commits from upstream-pr/351 into main 2026-11-26 11:46:11 +00:00
LooperSalty commented 2026-11-26 11:05:44 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-26T11:05:44Z.


Brings the rust/full branch into main. It is up to date with main (as of #309) and includes the PRs that were waiting on it.

What it contains

  • rust/full (144 commits): root Cargo workspace crates/ replacing rust/.
    • Rust runtime DLLs xmem, kernelx, d3d12_xs, anyxboxx_tls and XCRDAPI.
    • Native launcher (#249) and GPU runner (#266) in Rust; the C++ versions stay as parity oracles.
    • RDNA 2 reference interpreter anyxboxx-rdna2-ref.
    • anyxboxx run, which replaces tools/lancer_victory.ps1 with the same settings, checked against the golden copy.
    • The graphical launcher anyxboxx-launcher (release launcher-v0.1.0).
  • #344: the Rust interpreter back to parity with the Python model (36/36).
  • #285 (Codex): xgameruntime ported to Rust and checked against the C++ DLL, which is still the one shipped.
  • #346: install guide for the launcher (docs/launcher.md, docs/fr/lanceur.md).
  • main (#342 drop Leonida, #308, #333, #309). One conflict, in AGENTS.md (the third_party/leonida row, dropped as main did).

Doc fixes made here

  • AGENTS.md: the layout names crates/ (not the removed rust/) and says what runtime/ still builds in C++. Setup now runs cargo before CMake, because rust_dlls.cmake stops a build whose Rust DLLs are missing. The game runs, so "does not run commercial games" and "blocked on a legally usable executable" are gone.
  • README (9 languages):
    • The 🦀 line now says the port is in main, with the launcher.
    • "The game is not playable" becomes "The game runs" (about 14 fps in the world, Series X mode, measured 2026-11-25).
    • Obsolete pictures removed: toy demo, SimpleTriangle and testgdk fps curves and capture, DLL bench, Python module diagram. Six image files deleted; the progress map and translation chart stay.
  • rust-full-status: the GPU runner is listed as ported, and the French page got its accents back (written as ? in #285).

Not done yet (after this PR)

  • The shipped xgameruntime.dll is still C++. Removing the C++ (runtime/, libhttpclient, oracles, CMake) comes next.
  • HLSL recompiler in Rust: #303, about 31 %. The plan says either port it or replace it with victory-shader.
  • The Python side (hle/, native/, Unicorn, tools/*.py) and moving pytest to cargo test.

Test plan

  • cargo build --release --workspace and cargo test --release --workspace: 505 passed, 0 failed (local, before the #309 merge)
  • tests/test_readme_sync.py: passes with the 9 README edits
  • Measured on the same combination (rust/full + #344 + #285 + main up to #342): pytest 1,786 passed, 1 skipped, ruff clean
  • Local re-run after the #309 merge, with the C++ runtime built (in progress)
  • CI green (pytest is the required check)
  • After merge: close #344, #346 and #285 as merged through this PR, retarget #303 to main

🤖 Generated with Claude Code

https://claude.ai/code/session_01LwHrL62nyr3m1M4tJsHRox

<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:6625280245 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/351). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-26T11:05:44Z. --- Brings the `rust/full` branch into `main`. It is up to date with `main` (as of #309) and includes the PRs that were waiting on it. ## What it contains - **`rust/full`** (144 commits): root Cargo workspace `crates/` replacing `rust/`. - Rust runtime DLLs xmem, kernelx, d3d12_xs, anyxboxx_tls and XCRDAPI. - Native launcher (#249) and GPU runner (#266) in Rust; the C++ versions stay as parity oracles. - RDNA 2 reference interpreter `anyxboxx-rdna2-ref`. - `anyxboxx run`, which replaces `tools/lancer_victory.ps1` with the same settings, checked against the golden copy. - The graphical launcher `anyxboxx-launcher` (release `launcher-v0.1.0`). - **#344**: the Rust interpreter back to parity with the Python model (36/36). - **#285** (Codex): xgameruntime ported to Rust and checked against the C++ DLL, which is still the one shipped. - **#346**: install guide for the launcher (`docs/launcher.md`, `docs/fr/lanceur.md`). - **`main`** (#342 drop Leonida, #308, #333, #309). One conflict, in `AGENTS.md` (the `third_party/leonida` row, dropped as `main` did). ## Doc fixes made here - `AGENTS.md`: the layout names `crates/` (not the removed `rust/`) and says what `runtime/` still builds in C++. Setup now runs cargo before CMake, because `rust_dlls.cmake` stops a build whose Rust DLLs are missing. The game runs, so "does not run commercial games" and "blocked on a legally usable executable" are gone. - README (9 languages): - The 🦀 line now says the port is in `main`, with the launcher. - "The game is not playable" becomes "The game runs" (about 14 fps in the world, Series X mode, measured 2026-11-25). - Obsolete pictures removed: toy demo, SimpleTriangle and testgdk fps curves and capture, DLL bench, Python module diagram. Six image files deleted; the progress map and translation chart stay. - `rust-full-status`: the GPU runner is listed as ported, and the French page got its accents back (written as `?` in #285). ## Not done yet (after this PR) - The shipped `xgameruntime.dll` is still C++. Removing the C++ (`runtime/`, libhttpclient, oracles, CMake) comes next. - HLSL recompiler in Rust: #303, about 31 %. The plan says either port it or replace it with victory-shader. - The Python side (`hle/`, `native/`, Unicorn, `tools/*.py`) and moving pytest to cargo test. ## Test plan - [x] `cargo build --release --workspace` and `cargo test --release --workspace`: 505 passed, 0 failed (local, before the #309 merge) - [x] `tests/test_readme_sync.py`: passes with the 9 README edits - [x] Measured on the same combination (`rust/full` + #344 + #285 + `main` up to #342): pytest 1,786 passed, 1 skipped, ruff clean - [ ] Local re-run after the #309 merge, with the C++ runtime built (in progress) - [ ] CI green (`pytest` is the required check) - [ ] After merge: close #344, #346 and #285 as merged through this PR, retarget #303 to `main` 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01LwHrL62nyr3m1M4tJsHRox
chatgpt-codex-connector[bot] commented 2026-11-26 11:05:58 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T11:05:58Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T11:09:16.797985Z d2248c2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7190263359 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/351#issuecomment-7190263359). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T11:05:58Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"d2248c20072173448c6b3889d391907ce423ca20","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-26T11:09:16.797985Z">2026-11-26T11:09:16.797985Z</relative-time> | `d2248c2` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
chatgpt-codex-connector[bot] commented 2026-11-26 11:09:13 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T11:09:13Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d2248c2007

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:LooperSalty/AnyXboxX:review:6073079860 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/351#pullrequestreview-6073079860). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T11:09:13Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `d2248c2007` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
chatgpt-codex-connector[bot] commented 2026-11-26 11:09:13 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T11:09:13Z.

Code review location: crates/anyxboxx-launcher/src/app.rs; line 358

@@ -0,0 +1,391 @@
+//! The window's state and the actions behind its buttons. Long work (folder checks, VIctory's
+//! translate and game) runs on threads; this module drains their results once per frame.
+
+use std::collections::VecDeque;
+use std::path::PathBuf;
+use std::sync::Arc;
+use std::sync::atomic::AtomicBool;
+use std::sync::mpsc::{self, Receiver};
+use std::time::Instant;
+
+use crate::app_check::ManifestState;
+use crate::app_launch::Banner;
+use crate::cache;
+use crate::host::{self, Adapter, GpuVendor, Host};
+use crate::job::{self, Event, Step};
+use crate::launch;
+use crate::launch_progress::{self, Stage, Tracker};
+use crate::manifest::Outcome;
+use crate::picker::{self, Pick};
+use crate::processes::Tasklist;
+use crate::profile::{Profile, Profiles};
+use crate::progress::{Progress, Summary};
+use crate::session::{self, Settings};
+use crate::setup::{self, Item};
+use crate::splash::Splash;
+use crate::store::{self, Stored};
+use crate::toast::Toasts;
+use crate::verify::Report;
+
+/// Lines kept in the log view.
+const LOG_CAPACITY: usize = 2000;
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Tab {
+    Home,
+    Setup,
+    Files,
+    Shaders,
+    Play,
+}
+
+/// The game folder check.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum Verify {
+    NotRun,
+    Running,
+    Done(Report),
+    Failed(String),
+}
+
+/// A job running on its thread, whether it is the shader step, its stages and its cancel switch.
+pub struct Running {
+    pub events: Receiver<Event>,
+    pub shaders_only: bool,
+    pub stages: Vec<Stage>,
+    pub cancel: Arc<AtomicBool>,
+}
+
+pub struct App {
+    pub repo: Option<PathBuf>,
+    pub profiles: Profiles,
+    pub host: Host,
+    pub gpu: GpuVendor,
+    pub adapter_name: Option<String>,
+    adapters: Option<Vec<Adapter>>,
+    pub setup: Vec<Item>,
+    pub settings: Settings,
+    pub tab: Tab,
+    pub verify: Verify,
+    pub(crate) verify_rx: Option<Receiver<Result<Report, String>>>,
+    pub(crate) verify_started: Option<std::time::Instant>,
+    /// The optional SHA-256 manifest job; it never gates PLAY.
+    pub manifest: ManifestState,
+    pub(crate) manifest_rx: Option<Receiver<Outcome>>,
+    pub running: Option<Running>,
+    pub log: VecDeque<String>,
+    pub summary: Summary,
+    pub notice: Option<String>,
+    /// Set when the game is up and the launcher may close (see `keep_open_after_launch`).
+    pub close_requested: bool,
+    pub confirm_clean: bool,
+    pub cache_dir: Option<PathBuf>,
+    pub splash: Splash,
+    pub toasts: Toasts,
+    /// The step the running job is on (`Building VIctory`, `Running the game`...).
+    pub step: Option<String>,
+    pub drawer_open: bool,
+    /// Whether the shader cache folder holds something (looked at every couple of seconds).
+    pub cache_ready: bool,
+    pub cache_checked_at: f64,
+    /// When the page on screen was switched to, in egui seconds (for the page transition).
+    pub tab_changed_at: f64,
+    pub shown_tab: Tab,
+    /// Start the game as soon as the folder check passes (PLAY pressed before it ended).
+    pub launch_when_ready: bool,
+    /// The launch screen's model: stage, progress, pace.
+    pub tracker: Tracker,
+    /// The outcome of the last job, shown as a card until dismissed or replaced.
+    pub banner: Option<Banner>,
+    /// Shows the launch screen without running anything (`--preview-launch`, debug builds only).
+    pub preview_launch: bool,
+    pub(crate) clock: Instant,
+    pick_rx: Option<Receiver<(Pick, Option<PathBuf>)>>,
+    settings_path: Option<PathBuf>,
+    last_saved: Stored,
+}
+
+/// The checklist as the machine is now; `adapters` is what DXGI listed (None when it failed).
+fn read_setup(adapters: Option<&[crate::host::Adapter]>) -> Vec<Item> {
+    let system_root = std::env::var_os("SystemRoot").unwrap_or_else(|| "C:\\Windows".into());
+    let program_files = std::env::var_os("ProgramFiles(x86)")
+        .map_or_else(|| PathBuf::from("C:\\Program Files (x86)"), PathBuf::from);
+    let kits = program_files.join("Windows Kits").join("10").join("bin");
+    let facts = setup::probe(
+        &PathBuf::from(system_root),
+        &kits,
+        adapters.map(<[_]>::to_vec),
+    );
+    setup::checklist(&facts)
+}
+
+impl App {
+    /// The window's first state: the setup checklist, the GPU and the host are read now.
+    pub fn new() -> Result<Self, String> {
+        let profiles = Profiles::embedded().map_err(|e| e.to_string())?;
+        let settings_path = store::current_path();
+        let settings = settings_path
+            .as_deref()
+            .and_then(store::load)
+            .map(Stored::into_settings)
+            .unwrap_or_default();
+        let settings_copy = settings.clone();
+        let host = host::detect_host();
+        let adapters = host::enumerate_adapters().ok();
+        let gpu = adapters
+            .as_deref()
+            .map_or(GpuVendor::Unknown, host::vendor_of);
+        let adapter_name = adapters
+            .as_deref()
+            .and_then(host::main_adapter)
+            .map(|a| a.name.clone());
+        let mut app = App {
+            repo: anyxboxx::run::find_repo(None),
+            profiles,
+            host,
+            gpu,
+            adapter_name,
+            setup: read_setup(adapters.as_deref()),
+            adapters,
+            settings,
+            tab: Tab::Home,
+            verify: Verify::NotRun,
+            verify_rx: None,
+            verify_started: None,
+            manifest: ManifestState::NotRun,
+            manifest_rx: None,
+            running: None,
+            log: VecDeque::new(),
+            summary: Summary::default(),
+            notice: None,
+            close_requested: false,
+            confirm_clean: false,
+            cache_dir: cache::current_cache_dir(),
+            splash: Splash::new(),
+            toasts: Toasts::default(),
+            step: None,
+            drawer_open: false,
+            cache_ready: false,
+            cache_checked_at: 0.0,
+            tab_changed_at: 0.0,
+            shown_tab: Tab::Home,
+            last_saved: Stored::from_settings(&settings_copy),
+            launch_when_ready: false,
+            tracker: Tracker::default(),
+            banner: None,
+            preview_launch: false,
+            clock: Instant::now(),
+            pick_rx: None,
+            settings_path,
+        };
+        app.find_game_folder();
+        if app.settings.game_path().is_some() {
+            app.start_verify();
+        }
+        Ok(app)
+    }
+
+    /// Keeps the saved game folder when it still holds the game, else looks for one next to the
+    /// launcher and in its parents.
+    fn find_game_folder(&mut self) {
+        let last = self.settings.game_path();
+        let launcher = picker::launcher_dir();
+        let found = picker::detect(launcher.as_deref(), last.as_deref());
+        if let Some(dir) = found {
+            self.settings.game_dir = dir.display().to_string();
+        }
+    }
+
+    /// Opens the folder dialog on its own thread.
+    pub fn pick_game_folder(&mut self) {
+        self.open_dialog(Pick::GameFolder);
+    }
+
+    /// Opens the file dialog for the xg_xs.dll.
+    pub fn pick_xg_library(&mut self) {
+        self.open_dialog(Pick::XgLibrary);
+    }
+
+    fn open_dialog(&mut self, kind: Pick) {
+        if self.pick_rx.is_some() {
+            return;
+        }
+        let start = match kind {
+            Pick::GameFolder => self.settings.game_path(),
+            Pick::XgLibrary => PathBuf::from(self.settings.xg_dll.trim())
+                .parent()
+                .map(PathBuf::from),
+        };
+        self.pick_rx = Some(picker::open(kind, start));
+    }
+
+    /// Uses `dir` as the game folder when it is one (error toast otherwise), then checks it.
+    pub fn set_game_folder(&mut self, dir: &std::path::Path) {
+        match picker::validate_game_folder(dir) {
+            Ok(()) => {
+                self.settings.game_dir = dir.display().to_string();
+                self.manifest = ManifestState::NotRun;
+                self.notice = Some(format!("Game folder saved: {}", dir.display()));
+                self.start_verify();
+            }
+            Err(reason) => self.notice = Some(format!("Cannot use this folder: {reason}")),
+        }
+    }
+
+    /// Takes the answer of a dialog, if one came.
+    fn poll_dialog(&mut self) {
+        let Some(rx) = &self.pick_rx else {
+            return;
+        };
+        let Ok((kind, chosen)) = rx.try_recv() else {
+            return;
+        };
+        self.pick_rx = None;
+        let Some(path) = chosen else {
+            return;
+        };
+        match kind {
+            Pick::GameFolder => self.set_game_folder(&path),
+            Pick::XgLibrary => self.settings.xg_dll = path.display().to_string(),
+        }
+    }
+
+    /// A folder (or a file of it) dropped on the window becomes the game folder.
+    pub fn handle_drops(&mut self, ctx: &eframe::egui::Context) {
+        let dropped = ctx.input(|i| i.raw.dropped_files.first().and_then(|f| f.path.clone()));
+        if let Some(path) = dropped {
+            self.set_game_folder(&picker::folder_of_drop(&path));
+        }
+    }
+
+    /// The profile for this host and GPU.
+    pub fn profile(&self) -> &Profile {
+        self.profiles.select(self.host, self.gpu)
+    }
+
+    /// Reads the checklist again (after the user installed something).
+    pub fn refresh_setup(&mut self) {
+        self.setup = read_setup(self.adapters.as_deref());
+    }
+
+    /// The repository folder, or an empty path when none was found (the plan is then only shown).
+    pub fn repo_or_empty(&self) -> PathBuf {
+        self.repo.clone().unwrap_or_default()
+    }
+
+    /// Where VIctory keeps saves and data: `VICTORY_DATA_DIR`, else `%LOCALAPPDATA%\victory\data`.
+    pub fn data_dir_label(&self) -> String {
+        let data = std::env::var_os("VICTORY_DATA_DIR")
+            .filter(|v| !v.is_empty())
+            .map(PathBuf::from)
+            .or_else(|| {
+                std::env::var_os("LOCALAPPDATA")
+                    .map(|l| PathBuf::from(l).join("victory").join("data"))
+            });
+        data.map_or("unknown".to_string(), |d| d.display().to_string())
+    }
+
+    pub fn is_busy(&self) -> bool {
+        self.running.is_some() || matches!(self.verify, Verify::Running)
+    }
+
+    /// The last progress report of the translate, for the bar.
+    pub fn progress(&self) -> Option<&Progress> {
+        self.summary.last_progress.as_ref()
+    }
+
+    /// Starts the play steps, or the shader preloading alone; refused while a game runs.
+    pub fn start(&mut self, precompile_only: bool) {
+        if self.is_busy() {
+            return;
+        }
+        if let Err(error) = session::guard(&self.settings, &Tasklist) {
+            self.notice = Some(error.to_string());
+            return;
+        }
+        let profile = self.profile().clone();
+        let Some(repo) = self.repo.clone() else {
+            self.notice = Some(
+                "AnyXboxX folder not found: run the launcher from the repository (target\\release).".to_string(),
+            );
+            return;
+        };
+        let plan = match session::make_plan(&self.settings, &repo, &profile) {
+            Ok(plan) => plan,
+            Err(error) => {
+                self.notice = Some(error.to_string());
+                return;
+            }
+        };
+        let steps: Result<Vec<Step>, anyxboxx::run::RunError> = if precompile_only {
+            launch::precompile_steps(&plan)
+        } else {
+            launch::play_steps(&plan, self.settings.options.warm_first)
+        };
+        match steps {
+            Ok(steps) => self.spawn_steps(steps, precompile_only),
+            Err(error) => self.notice = Some(error.to_string()),
+        }
+    }
+
+    fn spawn_steps(&mut self, steps: Vec<Step>, shaders_only: bool) {
+        let labels: Vec<String> = steps.iter().map(|s| s.label.clone()).collect();
+        let (tx, rx) = mpsc::channel();
+        let cancel = Arc::new(AtomicBool::new(false));
+        job::spawn_cancellable(steps, tx, Arc::clone(&cancel));
+        self.running = Some(Running {
+            events: rx,
+            shaders_only,
+            stages: launch_progress::stages_of(&labels),
+            cancel,
+        });
+        self.step = None;
+        self.summary = Summary::default();
+        self.tracker = Tracker::start(self.now_secs());
+        self.banner = None;
+        self.notice = None;
+    }
+
+    /// Cleans the shader cache after the user confirmed.
+    pub fn clean_cache(&mut self) {
+        self.confirm_clean = false;
+        let Some(dir) = self.cache_dir.clone() else {
+            self.notice = Some("No cache folder: LOCALAPPDATA is not set.".to_string());
+            return;
+        };
+        self.notice = Some(match cache::clean_cache(&dir) {
+            Ok(cache::CleanOutcome::Removed) => format!("Shader cache removed: {}", dir.display()),
+            Ok(cache::CleanOutcome::NothingToClean) => "No shader cache to remove.".to_string(),

P2 Badge Invalidate the warm marker when cleaning the shader cache

After a successful warm, choosing “Clean shader cache” deletes the cache but leaves %LOCALAPPDATA%\AnyXboxX\launcher\warm-state.txt intact. On the next launch with unchanged settings, warm_check() produces the same fingerprint and skips warming, even though the cache is now empty. Invalidate the marker after successful removal (and when the cache is already absent), so the normal Play flow rebuilds the cache rather than starting cold.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:review-comment:4707494362 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/351#discussion_r4707494362). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T11:09:13Z. **Code review location:** `crates/anyxboxx-launcher/src/app.rs`; line 358 ~~~~diff @@ -0,0 +1,391 @@ +//! The window's state and the actions behind its buttons. Long work (folder checks, VIctory's +//! translate and game) runs on threads; this module drains their results once per frame. + +use std::collections::VecDeque; +use std::path::PathBuf; +use std::sync::Arc; +use std::sync::atomic::AtomicBool; +use std::sync::mpsc::{self, Receiver}; +use std::time::Instant; + +use crate::app_check::ManifestState; +use crate::app_launch::Banner; +use crate::cache; +use crate::host::{self, Adapter, GpuVendor, Host}; +use crate::job::{self, Event, Step}; +use crate::launch; +use crate::launch_progress::{self, Stage, Tracker}; +use crate::manifest::Outcome; +use crate::picker::{self, Pick}; +use crate::processes::Tasklist; +use crate::profile::{Profile, Profiles}; +use crate::progress::{Progress, Summary}; +use crate::session::{self, Settings}; +use crate::setup::{self, Item}; +use crate::splash::Splash; +use crate::store::{self, Stored}; +use crate::toast::Toasts; +use crate::verify::Report; + +/// Lines kept in the log view. +const LOG_CAPACITY: usize = 2000; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Tab { + Home, + Setup, + Files, + Shaders, + Play, +} + +/// The game folder check. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Verify { + NotRun, + Running, + Done(Report), + Failed(String), +} + +/// A job running on its thread, whether it is the shader step, its stages and its cancel switch. +pub struct Running { + pub events: Receiver<Event>, + pub shaders_only: bool, + pub stages: Vec<Stage>, + pub cancel: Arc<AtomicBool>, +} + +pub struct App { + pub repo: Option<PathBuf>, + pub profiles: Profiles, + pub host: Host, + pub gpu: GpuVendor, + pub adapter_name: Option<String>, + adapters: Option<Vec<Adapter>>, + pub setup: Vec<Item>, + pub settings: Settings, + pub tab: Tab, + pub verify: Verify, + pub(crate) verify_rx: Option<Receiver<Result<Report, String>>>, + pub(crate) verify_started: Option<std::time::Instant>, + /// The optional SHA-256 manifest job; it never gates PLAY. + pub manifest: ManifestState, + pub(crate) manifest_rx: Option<Receiver<Outcome>>, + pub running: Option<Running>, + pub log: VecDeque<String>, + pub summary: Summary, + pub notice: Option<String>, + /// Set when the game is up and the launcher may close (see `keep_open_after_launch`). + pub close_requested: bool, + pub confirm_clean: bool, + pub cache_dir: Option<PathBuf>, + pub splash: Splash, + pub toasts: Toasts, + /// The step the running job is on (`Building VIctory`, `Running the game`...). + pub step: Option<String>, + pub drawer_open: bool, + /// Whether the shader cache folder holds something (looked at every couple of seconds). + pub cache_ready: bool, + pub cache_checked_at: f64, + /// When the page on screen was switched to, in egui seconds (for the page transition). + pub tab_changed_at: f64, + pub shown_tab: Tab, + /// Start the game as soon as the folder check passes (PLAY pressed before it ended). + pub launch_when_ready: bool, + /// The launch screen's model: stage, progress, pace. + pub tracker: Tracker, + /// The outcome of the last job, shown as a card until dismissed or replaced. + pub banner: Option<Banner>, + /// Shows the launch screen without running anything (`--preview-launch`, debug builds only). + pub preview_launch: bool, + pub(crate) clock: Instant, + pick_rx: Option<Receiver<(Pick, Option<PathBuf>)>>, + settings_path: Option<PathBuf>, + last_saved: Stored, +} + +/// The checklist as the machine is now; `adapters` is what DXGI listed (None when it failed). +fn read_setup(adapters: Option<&[crate::host::Adapter]>) -> Vec<Item> { + let system_root = std::env::var_os("SystemRoot").unwrap_or_else(|| "C:\\Windows".into()); + let program_files = std::env::var_os("ProgramFiles(x86)") + .map_or_else(|| PathBuf::from("C:\\Program Files (x86)"), PathBuf::from); + let kits = program_files.join("Windows Kits").join("10").join("bin"); + let facts = setup::probe( + &PathBuf::from(system_root), + &kits, + adapters.map(<[_]>::to_vec), + ); + setup::checklist(&facts) +} + +impl App { + /// The window's first state: the setup checklist, the GPU and the host are read now. + pub fn new() -> Result<Self, String> { + let profiles = Profiles::embedded().map_err(|e| e.to_string())?; + let settings_path = store::current_path(); + let settings = settings_path + .as_deref() + .and_then(store::load) + .map(Stored::into_settings) + .unwrap_or_default(); + let settings_copy = settings.clone(); + let host = host::detect_host(); + let adapters = host::enumerate_adapters().ok(); + let gpu = adapters + .as_deref() + .map_or(GpuVendor::Unknown, host::vendor_of); + let adapter_name = adapters + .as_deref() + .and_then(host::main_adapter) + .map(|a| a.name.clone()); + let mut app = App { + repo: anyxboxx::run::find_repo(None), + profiles, + host, + gpu, + adapter_name, + setup: read_setup(adapters.as_deref()), + adapters, + settings, + tab: Tab::Home, + verify: Verify::NotRun, + verify_rx: None, + verify_started: None, + manifest: ManifestState::NotRun, + manifest_rx: None, + running: None, + log: VecDeque::new(), + summary: Summary::default(), + notice: None, + close_requested: false, + confirm_clean: false, + cache_dir: cache::current_cache_dir(), + splash: Splash::new(), + toasts: Toasts::default(), + step: None, + drawer_open: false, + cache_ready: false, + cache_checked_at: 0.0, + tab_changed_at: 0.0, + shown_tab: Tab::Home, + last_saved: Stored::from_settings(&settings_copy), + launch_when_ready: false, + tracker: Tracker::default(), + banner: None, + preview_launch: false, + clock: Instant::now(), + pick_rx: None, + settings_path, + }; + app.find_game_folder(); + if app.settings.game_path().is_some() { + app.start_verify(); + } + Ok(app) + } + + /// Keeps the saved game folder when it still holds the game, else looks for one next to the + /// launcher and in its parents. + fn find_game_folder(&mut self) { + let last = self.settings.game_path(); + let launcher = picker::launcher_dir(); + let found = picker::detect(launcher.as_deref(), last.as_deref()); + if let Some(dir) = found { + self.settings.game_dir = dir.display().to_string(); + } + } + + /// Opens the folder dialog on its own thread. + pub fn pick_game_folder(&mut self) { + self.open_dialog(Pick::GameFolder); + } + + /// Opens the file dialog for the xg_xs.dll. + pub fn pick_xg_library(&mut self) { + self.open_dialog(Pick::XgLibrary); + } + + fn open_dialog(&mut self, kind: Pick) { + if self.pick_rx.is_some() { + return; + } + let start = match kind { + Pick::GameFolder => self.settings.game_path(), + Pick::XgLibrary => PathBuf::from(self.settings.xg_dll.trim()) + .parent() + .map(PathBuf::from), + }; + self.pick_rx = Some(picker::open(kind, start)); + } + + /// Uses `dir` as the game folder when it is one (error toast otherwise), then checks it. + pub fn set_game_folder(&mut self, dir: &std::path::Path) { + match picker::validate_game_folder(dir) { + Ok(()) => { + self.settings.game_dir = dir.display().to_string(); + self.manifest = ManifestState::NotRun; + self.notice = Some(format!("Game folder saved: {}", dir.display())); + self.start_verify(); + } + Err(reason) => self.notice = Some(format!("Cannot use this folder: {reason}")), + } + } + + /// Takes the answer of a dialog, if one came. + fn poll_dialog(&mut self) { + let Some(rx) = &self.pick_rx else { + return; + }; + let Ok((kind, chosen)) = rx.try_recv() else { + return; + }; + self.pick_rx = None; + let Some(path) = chosen else { + return; + }; + match kind { + Pick::GameFolder => self.set_game_folder(&path), + Pick::XgLibrary => self.settings.xg_dll = path.display().to_string(), + } + } + + /// A folder (or a file of it) dropped on the window becomes the game folder. + pub fn handle_drops(&mut self, ctx: &eframe::egui::Context) { + let dropped = ctx.input(|i| i.raw.dropped_files.first().and_then(|f| f.path.clone())); + if let Some(path) = dropped { + self.set_game_folder(&picker::folder_of_drop(&path)); + } + } + + /// The profile for this host and GPU. + pub fn profile(&self) -> &Profile { + self.profiles.select(self.host, self.gpu) + } + + /// Reads the checklist again (after the user installed something). + pub fn refresh_setup(&mut self) { + self.setup = read_setup(self.adapters.as_deref()); + } + + /// The repository folder, or an empty path when none was found (the plan is then only shown). + pub fn repo_or_empty(&self) -> PathBuf { + self.repo.clone().unwrap_or_default() + } + + /// Where VIctory keeps saves and data: `VICTORY_DATA_DIR`, else `%LOCALAPPDATA%\victory\data`. + pub fn data_dir_label(&self) -> String { + let data = std::env::var_os("VICTORY_DATA_DIR") + .filter(|v| !v.is_empty()) + .map(PathBuf::from) + .or_else(|| { + std::env::var_os("LOCALAPPDATA") + .map(|l| PathBuf::from(l).join("victory").join("data")) + }); + data.map_or("unknown".to_string(), |d| d.display().to_string()) + } + + pub fn is_busy(&self) -> bool { + self.running.is_some() || matches!(self.verify, Verify::Running) + } + + /// The last progress report of the translate, for the bar. + pub fn progress(&self) -> Option<&Progress> { + self.summary.last_progress.as_ref() + } + + /// Starts the play steps, or the shader preloading alone; refused while a game runs. + pub fn start(&mut self, precompile_only: bool) { + if self.is_busy() { + return; + } + if let Err(error) = session::guard(&self.settings, &Tasklist) { + self.notice = Some(error.to_string()); + return; + } + let profile = self.profile().clone(); + let Some(repo) = self.repo.clone() else { + self.notice = Some( + "AnyXboxX folder not found: run the launcher from the repository (target\\release).".to_string(), + ); + return; + }; + let plan = match session::make_plan(&self.settings, &repo, &profile) { + Ok(plan) => plan, + Err(error) => { + self.notice = Some(error.to_string()); + return; + } + }; + let steps: Result<Vec<Step>, anyxboxx::run::RunError> = if precompile_only { + launch::precompile_steps(&plan) + } else { + launch::play_steps(&plan, self.settings.options.warm_first) + }; + match steps { + Ok(steps) => self.spawn_steps(steps, precompile_only), + Err(error) => self.notice = Some(error.to_string()), + } + } + + fn spawn_steps(&mut self, steps: Vec<Step>, shaders_only: bool) { + let labels: Vec<String> = steps.iter().map(|s| s.label.clone()).collect(); + let (tx, rx) = mpsc::channel(); + let cancel = Arc::new(AtomicBool::new(false)); + job::spawn_cancellable(steps, tx, Arc::clone(&cancel)); + self.running = Some(Running { + events: rx, + shaders_only, + stages: launch_progress::stages_of(&labels), + cancel, + }); + self.step = None; + self.summary = Summary::default(); + self.tracker = Tracker::start(self.now_secs()); + self.banner = None; + self.notice = None; + } + + /// Cleans the shader cache after the user confirmed. + pub fn clean_cache(&mut self) { + self.confirm_clean = false; + let Some(dir) = self.cache_dir.clone() else { + self.notice = Some("No cache folder: LOCALAPPDATA is not set.".to_string()); + return; + }; + self.notice = Some(match cache::clean_cache(&dir) { + Ok(cache::CleanOutcome::Removed) => format!("Shader cache removed: {}", dir.display()), + Ok(cache::CleanOutcome::NothingToClean) => "No shader cache to remove.".to_string(), ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Invalidate the warm marker when cleaning the shader cache** After a successful warm, choosing “Clean shader cache” deletes the cache but leaves `%LOCALAPPDATA%\AnyXboxX\launcher\warm-state.txt` intact. On the next launch with unchanged settings, `warm_check()` produces the same fingerprint and skips warming, even though the cache is now empty. Invalidate the marker after successful removal (and when the cache is already absent), so the normal Play flow rebuilds the cache rather than starting cold. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot] commented 2026-11-26 11:09:13 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T11:09:13Z.

Code review location: crates/anyxboxx-launcher/src/session.rs; line 94

@@ -0,0 +1,251 @@
+//! What the window asks for, turned into a launch plan or a refusal. The window keeps text
+//! fields; this module reads them, so the rules are tested without any window.
+
+use std::path::{Path, PathBuf};
+
+use anyxboxx::run::XgMode;
+
+use crate::detached;
+use crate::env::{self, EnvError, Xg};
+use crate::launch::Plan;
+use crate::options::LaunchOptions;
+use crate::processes::{self, GuardError, ProcessSource};
+use crate::profile::Profile;
+use crate::warm_state;
+use anyxboxx::run::Victory;
+
+/// The window's fields, as typed.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Settings {
+    pub game_dir: String,
+    /// The advanced panel: one `KEY=VALUE` per line.
+    pub overrides: String,
+    /// Path of the user's own `xg_xs.dll`, empty for none.
+    pub xg_dll: String,
+    pub xg_mode: XgMode,
+    /// Worker threads of the translate step; 0 means every core.
+    pub jobs: u32,
+    /// The advanced panel's override of the one-game guard (for hosts without `tasklist`).
+    pub skip_process_check: bool,
+    /// The Play page's launch options.
+    pub options: LaunchOptions,
+    /// Keep the launcher open after the game started (off: it closes once the game is up).
+    pub keep_open_after_launch: bool,
+    /// "Always re-warm before launch": the shader warm runs even when the marker is current.
+    pub always_rewarm: bool,
+}
+
+impl Default for Settings {
+    fn default() -> Self {
+        Settings {
+            game_dir: String::new(),
+            overrides: String::new(),
+            xg_dll: String::new(),
+            xg_mode: XgMode::Real,
+            jobs: 0,
+            skip_process_check: false,
+            options: LaunchOptions::default(),
+            keep_open_after_launch: false,
+            always_rewarm: false,
+        }
+    }
+}
+
+#[derive(Debug, thiserror::Error)]
+pub enum SessionError {
+    #[error("choose the game folder first (the one holding game_scarlett_master.exe)")]
+    NoGameFolder,
+    #[error(transparent)]
+    Env(#[from] EnvError),
+}
+
+impl Settings {
+    /// The game folder as a path, when one was typed.
+    pub fn game_path(&self) -> Option<PathBuf> {
+        let trimmed = self.game_dir.trim().trim_matches('"');
+        (!trimmed.is_empty()).then(|| PathBuf::from(trimmed))
+    }
+
+    /// The jobs limit, `None` for every core.
+    pub fn jobs_limit(&self) -> Option<usize> {
+        (self.jobs > 0).then_some(self.jobs as usize)
+    }
+}
+
+/// The launch plan for `profile`, with the user's overrides and XG library applied.
+pub fn make_plan(
+    settings: &Settings,
+    repo: &Path,
+    profile: &Profile,
+) -> Result<Plan, SessionError> {
+    let game_dir = settings.game_path().ok_or(SessionError::NoGameFolder)?;
+    let mut overrides = settings.options.env_pairs();
+    overrides.extend(env::parse_overrides(&settings.overrides)?);
+    let xg_text = settings.xg_dll.trim().trim_matches('"');
+    let xg = (!xg_text.is_empty()).then(|| Xg {
+        dll: PathBuf::from(xg_text),
+        mode: settings.xg_mode,
+    });
+    let env = env::build_env(&game_dir, profile, &overrides, xg.as_ref())?;
+    let warm = Victory::locate(repo, false).ok().and_then(|victory| {
+        let marker = warm_state::marker_path(std::env::var_os("LOCALAPPDATA").as_deref());
+        crate::launch::warm_check(
+            &victory.exe,
+            &env,

P2 Badge Check the warm fingerprint after building VIctory

When VIctory sources change after a previously warmed launch, this check still reads the old victory.exe, whose fingerprint matches the saved marker. play_steps() consequently omits the warm step, then rebuilds VIctory and immediately launches the new executable against the old cache. The change is only detected on the following launch. Recompute the build identity and warm decision after the build succeeds, and save that post-build fingerprint when warming completes.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:review-comment:4707494372 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/351#discussion_r4707494372). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T11:09:13Z. **Code review location:** `crates/anyxboxx-launcher/src/session.rs`; line 94 ~~~~diff @@ -0,0 +1,251 @@ +//! What the window asks for, turned into a launch plan or a refusal. The window keeps text +//! fields; this module reads them, so the rules are tested without any window. + +use std::path::{Path, PathBuf}; + +use anyxboxx::run::XgMode; + +use crate::detached; +use crate::env::{self, EnvError, Xg}; +use crate::launch::Plan; +use crate::options::LaunchOptions; +use crate::processes::{self, GuardError, ProcessSource}; +use crate::profile::Profile; +use crate::warm_state; +use anyxboxx::run::Victory; + +/// The window's fields, as typed. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Settings { + pub game_dir: String, + /// The advanced panel: one `KEY=VALUE` per line. + pub overrides: String, + /// Path of the user's own `xg_xs.dll`, empty for none. + pub xg_dll: String, + pub xg_mode: XgMode, + /// Worker threads of the translate step; 0 means every core. + pub jobs: u32, + /// The advanced panel's override of the one-game guard (for hosts without `tasklist`). + pub skip_process_check: bool, + /// The Play page's launch options. + pub options: LaunchOptions, + /// Keep the launcher open after the game started (off: it closes once the game is up). + pub keep_open_after_launch: bool, + /// "Always re-warm before launch": the shader warm runs even when the marker is current. + pub always_rewarm: bool, +} + +impl Default for Settings { + fn default() -> Self { + Settings { + game_dir: String::new(), + overrides: String::new(), + xg_dll: String::new(), + xg_mode: XgMode::Real, + jobs: 0, + skip_process_check: false, + options: LaunchOptions::default(), + keep_open_after_launch: false, + always_rewarm: false, + } + } +} + +#[derive(Debug, thiserror::Error)] +pub enum SessionError { + #[error("choose the game folder first (the one holding game_scarlett_master.exe)")] + NoGameFolder, + #[error(transparent)] + Env(#[from] EnvError), +} + +impl Settings { + /// The game folder as a path, when one was typed. + pub fn game_path(&self) -> Option<PathBuf> { + let trimmed = self.game_dir.trim().trim_matches('"'); + (!trimmed.is_empty()).then(|| PathBuf::from(trimmed)) + } + + /// The jobs limit, `None` for every core. + pub fn jobs_limit(&self) -> Option<usize> { + (self.jobs > 0).then_some(self.jobs as usize) + } +} + +/// The launch plan for `profile`, with the user's overrides and XG library applied. +pub fn make_plan( + settings: &Settings, + repo: &Path, + profile: &Profile, +) -> Result<Plan, SessionError> { + let game_dir = settings.game_path().ok_or(SessionError::NoGameFolder)?; + let mut overrides = settings.options.env_pairs(); + overrides.extend(env::parse_overrides(&settings.overrides)?); + let xg_text = settings.xg_dll.trim().trim_matches('"'); + let xg = (!xg_text.is_empty()).then(|| Xg { + dll: PathBuf::from(xg_text), + mode: settings.xg_mode, + }); + let env = env::build_env(&game_dir, profile, &overrides, xg.as_ref())?; + let warm = Victory::locate(repo, false).ok().and_then(|victory| { + let marker = warm_state::marker_path(std::env::var_os("LOCALAPPDATA").as_deref()); + crate::launch::warm_check( + &victory.exe, + &env, ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Check the warm fingerprint after building VIctory** When VIctory sources change after a previously warmed launch, this check still reads the old `victory.exe`, whose fingerprint matches the saved marker. `play_steps()` consequently omits the warm step, then rebuilds VIctory and immediately launches the new executable against the old cache. The change is only detected on the following launch. Recompute the build identity and warm decision after the build succeeds, and save that post-build fingerprint when warming completes. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
LooperSalty commented 2026-11-26 11:41:07 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-26T11:41:07Z.

Code review location: crates/anyxboxx-launcher/src/app.rs; line 358

@@ -0,0 +1,391 @@
+//! The window's state and the actions behind its buttons. Long work (folder checks, VIctory's
+//! translate and game) runs on threads; this module drains their results once per frame.
+
+use std::collections::VecDeque;
+use std::path::PathBuf;
+use std::sync::Arc;
+use std::sync::atomic::AtomicBool;
+use std::sync::mpsc::{self, Receiver};
+use std::time::Instant;
+
+use crate::app_check::ManifestState;
+use crate::app_launch::Banner;
+use crate::cache;
+use crate::host::{self, Adapter, GpuVendor, Host};
+use crate::job::{self, Event, Step};
+use crate::launch;
+use crate::launch_progress::{self, Stage, Tracker};
+use crate::manifest::Outcome;
+use crate::picker::{self, Pick};
+use crate::processes::Tasklist;
+use crate::profile::{Profile, Profiles};
+use crate::progress::{Progress, Summary};
+use crate::session::{self, Settings};
+use crate::setup::{self, Item};
+use crate::splash::Splash;
+use crate::store::{self, Stored};
+use crate::toast::Toasts;
+use crate::verify::Report;
+
+/// Lines kept in the log view.
+const LOG_CAPACITY: usize = 2000;
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Tab {
+    Home,
+    Setup,
+    Files,
+    Shaders,
+    Play,
+}
+
+/// The game folder check.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum Verify {
+    NotRun,
+    Running,
+    Done(Report),
+    Failed(String),
+}
+
+/// A job running on its thread, whether it is the shader step, its stages and its cancel switch.
+pub struct Running {
+    pub events: Receiver<Event>,
+    pub shaders_only: bool,
+    pub stages: Vec<Stage>,
+    pub cancel: Arc<AtomicBool>,
+}
+
+pub struct App {
+    pub repo: Option<PathBuf>,
+    pub profiles: Profiles,
+    pub host: Host,
+    pub gpu: GpuVendor,
+    pub adapter_name: Option<String>,
+    adapters: Option<Vec<Adapter>>,
+    pub setup: Vec<Item>,
+    pub settings: Settings,
+    pub tab: Tab,
+    pub verify: Verify,
+    pub(crate) verify_rx: Option<Receiver<Result<Report, String>>>,
+    pub(crate) verify_started: Option<std::time::Instant>,
+    /// The optional SHA-256 manifest job; it never gates PLAY.
+    pub manifest: ManifestState,
+    pub(crate) manifest_rx: Option<Receiver<Outcome>>,
+    pub running: Option<Running>,
+    pub log: VecDeque<String>,
+    pub summary: Summary,
+    pub notice: Option<String>,
+    /// Set when the game is up and the launcher may close (see `keep_open_after_launch`).
+    pub close_requested: bool,
+    pub confirm_clean: bool,
+    pub cache_dir: Option<PathBuf>,
+    pub splash: Splash,
+    pub toasts: Toasts,
+    /// The step the running job is on (`Building VIctory`, `Running the game`...).
+    pub step: Option<String>,
+    pub drawer_open: bool,
+    /// Whether the shader cache folder holds something (looked at every couple of seconds).
+    pub cache_ready: bool,
+    pub cache_checked_at: f64,
+    /// When the page on screen was switched to, in egui seconds (for the page transition).
+    pub tab_changed_at: f64,
+    pub shown_tab: Tab,
+    /// Start the game as soon as the folder check passes (PLAY pressed before it ended).
+    pub launch_when_ready: bool,
+    /// The launch screen's model: stage, progress, pace.
+    pub tracker: Tracker,
+    /// The outcome of the last job, shown as a card until dismissed or replaced.
+    pub banner: Option<Banner>,
+    /// Shows the launch screen without running anything (`--preview-launch`, debug builds only).
+    pub preview_launch: bool,
+    pub(crate) clock: Instant,
+    pick_rx: Option<Receiver<(Pick, Option<PathBuf>)>>,
+    settings_path: Option<PathBuf>,
+    last_saved: Stored,
+}
+
+/// The checklist as the machine is now; `adapters` is what DXGI listed (None when it failed).
+fn read_setup(adapters: Option<&[crate::host::Adapter]>) -> Vec<Item> {
+    let system_root = std::env::var_os("SystemRoot").unwrap_or_else(|| "C:\\Windows".into());
+    let program_files = std::env::var_os("ProgramFiles(x86)")
+        .map_or_else(|| PathBuf::from("C:\\Program Files (x86)"), PathBuf::from);
+    let kits = program_files.join("Windows Kits").join("10").join("bin");
+    let facts = setup::probe(
+        &PathBuf::from(system_root),
+        &kits,
+        adapters.map(<[_]>::to_vec),
+    );
+    setup::checklist(&facts)
+}
+
+impl App {
+    /// The window's first state: the setup checklist, the GPU and the host are read now.
+    pub fn new() -> Result<Self, String> {
+        let profiles = Profiles::embedded().map_err(|e| e.to_string())?;
+        let settings_path = store::current_path();
+        let settings = settings_path
+            .as_deref()
+            .and_then(store::load)
+            .map(Stored::into_settings)
+            .unwrap_or_default();
+        let settings_copy = settings.clone();
+        let host = host::detect_host();
+        let adapters = host::enumerate_adapters().ok();
+        let gpu = adapters
+            .as_deref()
+            .map_or(GpuVendor::Unknown, host::vendor_of);
+        let adapter_name = adapters
+            .as_deref()
+            .and_then(host::main_adapter)
+            .map(|a| a.name.clone());
+        let mut app = App {
+            repo: anyxboxx::run::find_repo(None),
+            profiles,
+            host,
+            gpu,
+            adapter_name,
+            setup: read_setup(adapters.as_deref()),
+            adapters,
+            settings,
+            tab: Tab::Home,
+            verify: Verify::NotRun,
+            verify_rx: None,
+            verify_started: None,
+            manifest: ManifestState::NotRun,
+            manifest_rx: None,
+            running: None,
+            log: VecDeque::new(),
+            summary: Summary::default(),
+            notice: None,
+            close_requested: false,
+            confirm_clean: false,
+            cache_dir: cache::current_cache_dir(),
+            splash: Splash::new(),
+            toasts: Toasts::default(),
+            step: None,
+            drawer_open: false,
+            cache_ready: false,
+            cache_checked_at: 0.0,
+            tab_changed_at: 0.0,
+            shown_tab: Tab::Home,
+            last_saved: Stored::from_settings(&settings_copy),
+            launch_when_ready: false,
+            tracker: Tracker::default(),
+            banner: None,
+            preview_launch: false,
+            clock: Instant::now(),
+            pick_rx: None,
+            settings_path,
+        };
+        app.find_game_folder();
+        if app.settings.game_path().is_some() {
+            app.start_verify();
+        }
+        Ok(app)
+    }
+
+    /// Keeps the saved game folder when it still holds the game, else looks for one next to the
+    /// launcher and in its parents.
+    fn find_game_folder(&mut self) {
+        let last = self.settings.game_path();
+        let launcher = picker::launcher_dir();
+        let found = picker::detect(launcher.as_deref(), last.as_deref());
+        if let Some(dir) = found {
+            self.settings.game_dir = dir.display().to_string();
+        }
+    }
+
+    /// Opens the folder dialog on its own thread.
+    pub fn pick_game_folder(&mut self) {
+        self.open_dialog(Pick::GameFolder);
+    }
+
+    /// Opens the file dialog for the xg_xs.dll.
+    pub fn pick_xg_library(&mut self) {
+        self.open_dialog(Pick::XgLibrary);
+    }
+
+    fn open_dialog(&mut self, kind: Pick) {
+        if self.pick_rx.is_some() {
+            return;
+        }
+        let start = match kind {
+            Pick::GameFolder => self.settings.game_path(),
+            Pick::XgLibrary => PathBuf::from(self.settings.xg_dll.trim())
+                .parent()
+                .map(PathBuf::from),
+        };
+        self.pick_rx = Some(picker::open(kind, start));
+    }
+
+    /// Uses `dir` as the game folder when it is one (error toast otherwise), then checks it.
+    pub fn set_game_folder(&mut self, dir: &std::path::Path) {
+        match picker::validate_game_folder(dir) {
+            Ok(()) => {
+                self.settings.game_dir = dir.display().to_string();
+                self.manifest = ManifestState::NotRun;
+                self.notice = Some(format!("Game folder saved: {}", dir.display()));
+                self.start_verify();
+            }
+            Err(reason) => self.notice = Some(format!("Cannot use this folder: {reason}")),
+        }
+    }
+
+    /// Takes the answer of a dialog, if one came.
+    fn poll_dialog(&mut self) {
+        let Some(rx) = &self.pick_rx else {
+            return;
+        };
+        let Ok((kind, chosen)) = rx.try_recv() else {
+            return;
+        };
+        self.pick_rx = None;
+        let Some(path) = chosen else {
+            return;
+        };
+        match kind {
+            Pick::GameFolder => self.set_game_folder(&path),
+            Pick::XgLibrary => self.settings.xg_dll = path.display().to_string(),
+        }
+    }
+
+    /// A folder (or a file of it) dropped on the window becomes the game folder.
+    pub fn handle_drops(&mut self, ctx: &eframe::egui::Context) {
+        let dropped = ctx.input(|i| i.raw.dropped_files.first().and_then(|f| f.path.clone()));
+        if let Some(path) = dropped {
+            self.set_game_folder(&picker::folder_of_drop(&path));
+        }
+    }
+
+    /// The profile for this host and GPU.
+    pub fn profile(&self) -> &Profile {
+        self.profiles.select(self.host, self.gpu)
+    }
+
+    /// Reads the checklist again (after the user installed something).
+    pub fn refresh_setup(&mut self) {
+        self.setup = read_setup(self.adapters.as_deref());
+    }
+
+    /// The repository folder, or an empty path when none was found (the plan is then only shown).
+    pub fn repo_or_empty(&self) -> PathBuf {
+        self.repo.clone().unwrap_or_default()
+    }
+
+    /// Where VIctory keeps saves and data: `VICTORY_DATA_DIR`, else `%LOCALAPPDATA%\victory\data`.
+    pub fn data_dir_label(&self) -> String {
+        let data = std::env::var_os("VICTORY_DATA_DIR")
+            .filter(|v| !v.is_empty())
+            .map(PathBuf::from)
+            .or_else(|| {
+                std::env::var_os("LOCALAPPDATA")
+                    .map(|l| PathBuf::from(l).join("victory").join("data"))
+            });
+        data.map_or("unknown".to_string(), |d| d.display().to_string())
+    }
+
+    pub fn is_busy(&self) -> bool {
+        self.running.is_some() || matches!(self.verify, Verify::Running)
+    }
+
+    /// The last progress report of the translate, for the bar.
+    pub fn progress(&self) -> Option<&Progress> {
+        self.summary.last_progress.as_ref()
+    }
+
+    /// Starts the play steps, or the shader preloading alone; refused while a game runs.
+    pub fn start(&mut self, precompile_only: bool) {
+        if self.is_busy() {
+            return;
+        }
+        if let Err(error) = session::guard(&self.settings, &Tasklist) {
+            self.notice = Some(error.to_string());
+            return;
+        }
+        let profile = self.profile().clone();
+        let Some(repo) = self.repo.clone() else {
+            self.notice = Some(
+                "AnyXboxX folder not found: run the launcher from the repository (target\\release).".to_string(),
+            );
+            return;
+        };
+        let plan = match session::make_plan(&self.settings, &repo, &profile) {
+            Ok(plan) => plan,
+            Err(error) => {
+                self.notice = Some(error.to_string());
+                return;
+            }
+        };
+        let steps: Result<Vec<Step>, anyxboxx::run::RunError> = if precompile_only {
+            launch::precompile_steps(&plan)
+        } else {
+            launch::play_steps(&plan, self.settings.options.warm_first)
+        };
+        match steps {
+            Ok(steps) => self.spawn_steps(steps, precompile_only),
+            Err(error) => self.notice = Some(error.to_string()),
+        }
+    }
+
+    fn spawn_steps(&mut self, steps: Vec<Step>, shaders_only: bool) {
+        let labels: Vec<String> = steps.iter().map(|s| s.label.clone()).collect();
+        let (tx, rx) = mpsc::channel();
+        let cancel = Arc::new(AtomicBool::new(false));
+        job::spawn_cancellable(steps, tx, Arc::clone(&cancel));
+        self.running = Some(Running {
+            events: rx,
+            shaders_only,
+            stages: launch_progress::stages_of(&labels),
+            cancel,
+        });
+        self.step = None;
+        self.summary = Summary::default();
+        self.tracker = Tracker::start(self.now_secs());
+        self.banner = None;
+        self.notice = None;
+    }
+
+    /// Cleans the shader cache after the user confirmed.
+    pub fn clean_cache(&mut self) {
+        self.confirm_clean = false;
+        let Some(dir) = self.cache_dir.clone() else {
+            self.notice = Some("No cache folder: LOCALAPPDATA is not set.".to_string());
+            return;
+        };
+        self.notice = Some(match cache::clean_cache(&dir) {
+            Ok(cache::CleanOutcome::Removed) => format!("Shader cache removed: {}", dir.display()),
+            Ok(cache::CleanOutcome::NothingToClean) => "No shader cache to remove.".to_string(),

Fixed in a33c5f41: cleaning the shader cache now deletes the warm marker, and a warm listed after "Building VIctory" checks the fingerprint of the rebuilt victory.exe before it runs (marker written with that fingerprint). Tests added in warm_state.rs, job.rs and launch.rs.

🤖 Generated with Claude Code

<!-- greyfinch-sync:LooperSalty/AnyXboxX:review-comment:4707855041 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/351#discussion_r4707855041). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-26T11:41:07Z. **Code review location:** `crates/anyxboxx-launcher/src/app.rs`; line 358 ~~~~diff @@ -0,0 +1,391 @@ +//! The window's state and the actions behind its buttons. Long work (folder checks, VIctory's +//! translate and game) runs on threads; this module drains their results once per frame. + +use std::collections::VecDeque; +use std::path::PathBuf; +use std::sync::Arc; +use std::sync::atomic::AtomicBool; +use std::sync::mpsc::{self, Receiver}; +use std::time::Instant; + +use crate::app_check::ManifestState; +use crate::app_launch::Banner; +use crate::cache; +use crate::host::{self, Adapter, GpuVendor, Host}; +use crate::job::{self, Event, Step}; +use crate::launch; +use crate::launch_progress::{self, Stage, Tracker}; +use crate::manifest::Outcome; +use crate::picker::{self, Pick}; +use crate::processes::Tasklist; +use crate::profile::{Profile, Profiles}; +use crate::progress::{Progress, Summary}; +use crate::session::{self, Settings}; +use crate::setup::{self, Item}; +use crate::splash::Splash; +use crate::store::{self, Stored}; +use crate::toast::Toasts; +use crate::verify::Report; + +/// Lines kept in the log view. +const LOG_CAPACITY: usize = 2000; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Tab { + Home, + Setup, + Files, + Shaders, + Play, +} + +/// The game folder check. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Verify { + NotRun, + Running, + Done(Report), + Failed(String), +} + +/// A job running on its thread, whether it is the shader step, its stages and its cancel switch. +pub struct Running { + pub events: Receiver<Event>, + pub shaders_only: bool, + pub stages: Vec<Stage>, + pub cancel: Arc<AtomicBool>, +} + +pub struct App { + pub repo: Option<PathBuf>, + pub profiles: Profiles, + pub host: Host, + pub gpu: GpuVendor, + pub adapter_name: Option<String>, + adapters: Option<Vec<Adapter>>, + pub setup: Vec<Item>, + pub settings: Settings, + pub tab: Tab, + pub verify: Verify, + pub(crate) verify_rx: Option<Receiver<Result<Report, String>>>, + pub(crate) verify_started: Option<std::time::Instant>, + /// The optional SHA-256 manifest job; it never gates PLAY. + pub manifest: ManifestState, + pub(crate) manifest_rx: Option<Receiver<Outcome>>, + pub running: Option<Running>, + pub log: VecDeque<String>, + pub summary: Summary, + pub notice: Option<String>, + /// Set when the game is up and the launcher may close (see `keep_open_after_launch`). + pub close_requested: bool, + pub confirm_clean: bool, + pub cache_dir: Option<PathBuf>, + pub splash: Splash, + pub toasts: Toasts, + /// The step the running job is on (`Building VIctory`, `Running the game`...). + pub step: Option<String>, + pub drawer_open: bool, + /// Whether the shader cache folder holds something (looked at every couple of seconds). + pub cache_ready: bool, + pub cache_checked_at: f64, + /// When the page on screen was switched to, in egui seconds (for the page transition). + pub tab_changed_at: f64, + pub shown_tab: Tab, + /// Start the game as soon as the folder check passes (PLAY pressed before it ended). + pub launch_when_ready: bool, + /// The launch screen's model: stage, progress, pace. + pub tracker: Tracker, + /// The outcome of the last job, shown as a card until dismissed or replaced. + pub banner: Option<Banner>, + /// Shows the launch screen without running anything (`--preview-launch`, debug builds only). + pub preview_launch: bool, + pub(crate) clock: Instant, + pick_rx: Option<Receiver<(Pick, Option<PathBuf>)>>, + settings_path: Option<PathBuf>, + last_saved: Stored, +} + +/// The checklist as the machine is now; `adapters` is what DXGI listed (None when it failed). +fn read_setup(adapters: Option<&[crate::host::Adapter]>) -> Vec<Item> { + let system_root = std::env::var_os("SystemRoot").unwrap_or_else(|| "C:\\Windows".into()); + let program_files = std::env::var_os("ProgramFiles(x86)") + .map_or_else(|| PathBuf::from("C:\\Program Files (x86)"), PathBuf::from); + let kits = program_files.join("Windows Kits").join("10").join("bin"); + let facts = setup::probe( + &PathBuf::from(system_root), + &kits, + adapters.map(<[_]>::to_vec), + ); + setup::checklist(&facts) +} + +impl App { + /// The window's first state: the setup checklist, the GPU and the host are read now. + pub fn new() -> Result<Self, String> { + let profiles = Profiles::embedded().map_err(|e| e.to_string())?; + let settings_path = store::current_path(); + let settings = settings_path + .as_deref() + .and_then(store::load) + .map(Stored::into_settings) + .unwrap_or_default(); + let settings_copy = settings.clone(); + let host = host::detect_host(); + let adapters = host::enumerate_adapters().ok(); + let gpu = adapters + .as_deref() + .map_or(GpuVendor::Unknown, host::vendor_of); + let adapter_name = adapters + .as_deref() + .and_then(host::main_adapter) + .map(|a| a.name.clone()); + let mut app = App { + repo: anyxboxx::run::find_repo(None), + profiles, + host, + gpu, + adapter_name, + setup: read_setup(adapters.as_deref()), + adapters, + settings, + tab: Tab::Home, + verify: Verify::NotRun, + verify_rx: None, + verify_started: None, + manifest: ManifestState::NotRun, + manifest_rx: None, + running: None, + log: VecDeque::new(), + summary: Summary::default(), + notice: None, + close_requested: false, + confirm_clean: false, + cache_dir: cache::current_cache_dir(), + splash: Splash::new(), + toasts: Toasts::default(), + step: None, + drawer_open: false, + cache_ready: false, + cache_checked_at: 0.0, + tab_changed_at: 0.0, + shown_tab: Tab::Home, + last_saved: Stored::from_settings(&settings_copy), + launch_when_ready: false, + tracker: Tracker::default(), + banner: None, + preview_launch: false, + clock: Instant::now(), + pick_rx: None, + settings_path, + }; + app.find_game_folder(); + if app.settings.game_path().is_some() { + app.start_verify(); + } + Ok(app) + } + + /// Keeps the saved game folder when it still holds the game, else looks for one next to the + /// launcher and in its parents. + fn find_game_folder(&mut self) { + let last = self.settings.game_path(); + let launcher = picker::launcher_dir(); + let found = picker::detect(launcher.as_deref(), last.as_deref()); + if let Some(dir) = found { + self.settings.game_dir = dir.display().to_string(); + } + } + + /// Opens the folder dialog on its own thread. + pub fn pick_game_folder(&mut self) { + self.open_dialog(Pick::GameFolder); + } + + /// Opens the file dialog for the xg_xs.dll. + pub fn pick_xg_library(&mut self) { + self.open_dialog(Pick::XgLibrary); + } + + fn open_dialog(&mut self, kind: Pick) { + if self.pick_rx.is_some() { + return; + } + let start = match kind { + Pick::GameFolder => self.settings.game_path(), + Pick::XgLibrary => PathBuf::from(self.settings.xg_dll.trim()) + .parent() + .map(PathBuf::from), + }; + self.pick_rx = Some(picker::open(kind, start)); + } + + /// Uses `dir` as the game folder when it is one (error toast otherwise), then checks it. + pub fn set_game_folder(&mut self, dir: &std::path::Path) { + match picker::validate_game_folder(dir) { + Ok(()) => { + self.settings.game_dir = dir.display().to_string(); + self.manifest = ManifestState::NotRun; + self.notice = Some(format!("Game folder saved: {}", dir.display())); + self.start_verify(); + } + Err(reason) => self.notice = Some(format!("Cannot use this folder: {reason}")), + } + } + + /// Takes the answer of a dialog, if one came. + fn poll_dialog(&mut self) { + let Some(rx) = &self.pick_rx else { + return; + }; + let Ok((kind, chosen)) = rx.try_recv() else { + return; + }; + self.pick_rx = None; + let Some(path) = chosen else { + return; + }; + match kind { + Pick::GameFolder => self.set_game_folder(&path), + Pick::XgLibrary => self.settings.xg_dll = path.display().to_string(), + } + } + + /// A folder (or a file of it) dropped on the window becomes the game folder. + pub fn handle_drops(&mut self, ctx: &eframe::egui::Context) { + let dropped = ctx.input(|i| i.raw.dropped_files.first().and_then(|f| f.path.clone())); + if let Some(path) = dropped { + self.set_game_folder(&picker::folder_of_drop(&path)); + } + } + + /// The profile for this host and GPU. + pub fn profile(&self) -> &Profile { + self.profiles.select(self.host, self.gpu) + } + + /// Reads the checklist again (after the user installed something). + pub fn refresh_setup(&mut self) { + self.setup = read_setup(self.adapters.as_deref()); + } + + /// The repository folder, or an empty path when none was found (the plan is then only shown). + pub fn repo_or_empty(&self) -> PathBuf { + self.repo.clone().unwrap_or_default() + } + + /// Where VIctory keeps saves and data: `VICTORY_DATA_DIR`, else `%LOCALAPPDATA%\victory\data`. + pub fn data_dir_label(&self) -> String { + let data = std::env::var_os("VICTORY_DATA_DIR") + .filter(|v| !v.is_empty()) + .map(PathBuf::from) + .or_else(|| { + std::env::var_os("LOCALAPPDATA") + .map(|l| PathBuf::from(l).join("victory").join("data")) + }); + data.map_or("unknown".to_string(), |d| d.display().to_string()) + } + + pub fn is_busy(&self) -> bool { + self.running.is_some() || matches!(self.verify, Verify::Running) + } + + /// The last progress report of the translate, for the bar. + pub fn progress(&self) -> Option<&Progress> { + self.summary.last_progress.as_ref() + } + + /// Starts the play steps, or the shader preloading alone; refused while a game runs. + pub fn start(&mut self, precompile_only: bool) { + if self.is_busy() { + return; + } + if let Err(error) = session::guard(&self.settings, &Tasklist) { + self.notice = Some(error.to_string()); + return; + } + let profile = self.profile().clone(); + let Some(repo) = self.repo.clone() else { + self.notice = Some( + "AnyXboxX folder not found: run the launcher from the repository (target\\release).".to_string(), + ); + return; + }; + let plan = match session::make_plan(&self.settings, &repo, &profile) { + Ok(plan) => plan, + Err(error) => { + self.notice = Some(error.to_string()); + return; + } + }; + let steps: Result<Vec<Step>, anyxboxx::run::RunError> = if precompile_only { + launch::precompile_steps(&plan) + } else { + launch::play_steps(&plan, self.settings.options.warm_first) + }; + match steps { + Ok(steps) => self.spawn_steps(steps, precompile_only), + Err(error) => self.notice = Some(error.to_string()), + } + } + + fn spawn_steps(&mut self, steps: Vec<Step>, shaders_only: bool) { + let labels: Vec<String> = steps.iter().map(|s| s.label.clone()).collect(); + let (tx, rx) = mpsc::channel(); + let cancel = Arc::new(AtomicBool::new(false)); + job::spawn_cancellable(steps, tx, Arc::clone(&cancel)); + self.running = Some(Running { + events: rx, + shaders_only, + stages: launch_progress::stages_of(&labels), + cancel, + }); + self.step = None; + self.summary = Summary::default(); + self.tracker = Tracker::start(self.now_secs()); + self.banner = None; + self.notice = None; + } + + /// Cleans the shader cache after the user confirmed. + pub fn clean_cache(&mut self) { + self.confirm_clean = false; + let Some(dir) = self.cache_dir.clone() else { + self.notice = Some("No cache folder: LOCALAPPDATA is not set.".to_string()); + return; + }; + self.notice = Some(match cache::clean_cache(&dir) { + Ok(cache::CleanOutcome::Removed) => format!("Shader cache removed: {}", dir.display()), + Ok(cache::CleanOutcome::NothingToClean) => "No shader cache to remove.".to_string(), ~~~~ --- Fixed in a33c5f41: cleaning the shader cache now deletes the warm marker, and a warm listed after "Building VIctory" checks the fingerprint of the rebuilt victory.exe before it runs (marker written with that fingerprint). Tests added in warm_state.rs, job.rs and launch.rs. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
LooperSalty commented 2026-11-26 11:41:11 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-26T11:41:11Z.

Code review location: crates/anyxboxx-launcher/src/session.rs; line 94

@@ -0,0 +1,251 @@
+//! What the window asks for, turned into a launch plan or a refusal. The window keeps text
+//! fields; this module reads them, so the rules are tested without any window.
+
+use std::path::{Path, PathBuf};
+
+use anyxboxx::run::XgMode;
+
+use crate::detached;
+use crate::env::{self, EnvError, Xg};
+use crate::launch::Plan;
+use crate::options::LaunchOptions;
+use crate::processes::{self, GuardError, ProcessSource};
+use crate::profile::Profile;
+use crate::warm_state;
+use anyxboxx::run::Victory;
+
+/// The window's fields, as typed.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Settings {
+    pub game_dir: String,
+    /// The advanced panel: one `KEY=VALUE` per line.
+    pub overrides: String,
+    /// Path of the user's own `xg_xs.dll`, empty for none.
+    pub xg_dll: String,
+    pub xg_mode: XgMode,
+    /// Worker threads of the translate step; 0 means every core.
+    pub jobs: u32,
+    /// The advanced panel's override of the one-game guard (for hosts without `tasklist`).
+    pub skip_process_check: bool,
+    /// The Play page's launch options.
+    pub options: LaunchOptions,
+    /// Keep the launcher open after the game started (off: it closes once the game is up).
+    pub keep_open_after_launch: bool,
+    /// "Always re-warm before launch": the shader warm runs even when the marker is current.
+    pub always_rewarm: bool,
+}
+
+impl Default for Settings {
+    fn default() -> Self {
+        Settings {
+            game_dir: String::new(),
+            overrides: String::new(),
+            xg_dll: String::new(),
+            xg_mode: XgMode::Real,
+            jobs: 0,
+            skip_process_check: false,
+            options: LaunchOptions::default(),
+            keep_open_after_launch: false,
+            always_rewarm: false,
+        }
+    }
+}
+
+#[derive(Debug, thiserror::Error)]
+pub enum SessionError {
+    #[error("choose the game folder first (the one holding game_scarlett_master.exe)")]
+    NoGameFolder,
+    #[error(transparent)]
+    Env(#[from] EnvError),
+}
+
+impl Settings {
+    /// The game folder as a path, when one was typed.
+    pub fn game_path(&self) -> Option<PathBuf> {
+        let trimmed = self.game_dir.trim().trim_matches('"');
+        (!trimmed.is_empty()).then(|| PathBuf::from(trimmed))
+    }
+
+    /// The jobs limit, `None` for every core.
+    pub fn jobs_limit(&self) -> Option<usize> {
+        (self.jobs > 0).then_some(self.jobs as usize)
+    }
+}
+
+/// The launch plan for `profile`, with the user's overrides and XG library applied.
+pub fn make_plan(
+    settings: &Settings,
+    repo: &Path,
+    profile: &Profile,
+) -> Result<Plan, SessionError> {
+    let game_dir = settings.game_path().ok_or(SessionError::NoGameFolder)?;
+    let mut overrides = settings.options.env_pairs();
+    overrides.extend(env::parse_overrides(&settings.overrides)?);
+    let xg_text = settings.xg_dll.trim().trim_matches('"');
+    let xg = (!xg_text.is_empty()).then(|| Xg {
+        dll: PathBuf::from(xg_text),
+        mode: settings.xg_mode,
+    });
+    let env = env::build_env(&game_dir, profile, &overrides, xg.as_ref())?;
+    let warm = Victory::locate(repo, false).ok().and_then(|victory| {
+        let marker = warm_state::marker_path(std::env::var_os("LOCALAPPDATA").as_deref());
+        crate::launch::warm_check(
+            &victory.exe,
+            &env,

Fixed in a33c5f41: cleaning the shader cache now deletes the warm marker, and a warm listed after "Building VIctory" checks the fingerprint of the rebuilt victory.exe before it runs (marker written with that fingerprint). Tests added in warm_state.rs, job.rs and launch.rs.

🤖 Generated with Claude Code

<!-- greyfinch-sync:LooperSalty/AnyXboxX:review-comment:4707855600 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/351#discussion_r4707855600). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-26T11:41:11Z. **Code review location:** `crates/anyxboxx-launcher/src/session.rs`; line 94 ~~~~diff @@ -0,0 +1,251 @@ +//! What the window asks for, turned into a launch plan or a refusal. The window keeps text +//! fields; this module reads them, so the rules are tested without any window. + +use std::path::{Path, PathBuf}; + +use anyxboxx::run::XgMode; + +use crate::detached; +use crate::env::{self, EnvError, Xg}; +use crate::launch::Plan; +use crate::options::LaunchOptions; +use crate::processes::{self, GuardError, ProcessSource}; +use crate::profile::Profile; +use crate::warm_state; +use anyxboxx::run::Victory; + +/// The window's fields, as typed. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Settings { + pub game_dir: String, + /// The advanced panel: one `KEY=VALUE` per line. + pub overrides: String, + /// Path of the user's own `xg_xs.dll`, empty for none. + pub xg_dll: String, + pub xg_mode: XgMode, + /// Worker threads of the translate step; 0 means every core. + pub jobs: u32, + /// The advanced panel's override of the one-game guard (for hosts without `tasklist`). + pub skip_process_check: bool, + /// The Play page's launch options. + pub options: LaunchOptions, + /// Keep the launcher open after the game started (off: it closes once the game is up). + pub keep_open_after_launch: bool, + /// "Always re-warm before launch": the shader warm runs even when the marker is current. + pub always_rewarm: bool, +} + +impl Default for Settings { + fn default() -> Self { + Settings { + game_dir: String::new(), + overrides: String::new(), + xg_dll: String::new(), + xg_mode: XgMode::Real, + jobs: 0, + skip_process_check: false, + options: LaunchOptions::default(), + keep_open_after_launch: false, + always_rewarm: false, + } + } +} + +#[derive(Debug, thiserror::Error)] +pub enum SessionError { + #[error("choose the game folder first (the one holding game_scarlett_master.exe)")] + NoGameFolder, + #[error(transparent)] + Env(#[from] EnvError), +} + +impl Settings { + /// The game folder as a path, when one was typed. + pub fn game_path(&self) -> Option<PathBuf> { + let trimmed = self.game_dir.trim().trim_matches('"'); + (!trimmed.is_empty()).then(|| PathBuf::from(trimmed)) + } + + /// The jobs limit, `None` for every core. + pub fn jobs_limit(&self) -> Option<usize> { + (self.jobs > 0).then_some(self.jobs as usize) + } +} + +/// The launch plan for `profile`, with the user's overrides and XG library applied. +pub fn make_plan( + settings: &Settings, + repo: &Path, + profile: &Profile, +) -> Result<Plan, SessionError> { + let game_dir = settings.game_path().ok_or(SessionError::NoGameFolder)?; + let mut overrides = settings.options.env_pairs(); + overrides.extend(env::parse_overrides(&settings.overrides)?); + let xg_text = settings.xg_dll.trim().trim_matches('"'); + let xg = (!xg_text.is_empty()).then(|| Xg { + dll: PathBuf::from(xg_text), + mode: settings.xg_mode, + }); + let env = env::build_env(&game_dir, profile, &overrides, xg.as_ref())?; + let warm = Victory::locate(repo, false).ok().and_then(|victory| { + let marker = warm_state::marker_path(std::env::var_os("LOCALAPPDATA").as_deref()); + crate::launch::warm_check( + &victory.exe, + &env, ~~~~ --- Fixed in a33c5f41: cleaning the shader cache now deletes the warm marker, and a warm listed after "Building VIctory" checks the fingerprint of the rebuilt victory.exe before it runs (marker written with that fingerprint). Tests added in warm_state.rs, job.rs and launch.rs. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LooperSalty/AnyXboxX!351
No description provided.