diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index bea0f88..bbde2c9 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -1,4 +1,3 @@ -# cargo-dist artifact building and publishing, called by release.yml. # Based on cargo-dist's generated GitHub workflow. name: build release @@ -13,7 +12,6 @@ on: type: string jobs: - # Run 'dist plan' (or host) to determine what tasks we need to do plan: runs-on: "ubuntu-22.04" outputs: @@ -39,11 +37,6 @@ jobs: with: name: cargo-dist-cache path: ~/.cargo/bin/dist - # sure would be cool if github gave us proper conditionals... - # so here's a doubly-nested ternary-via-truthiness to try to provide the best possible - # functionality based on whether this is a pull_request, and whether it's from a fork. - # (PRs run on the *source* but secrets are usually on the *target* -- that's *good* - # but also really annoying to build CI around when it needs secrets to work right.) - id: plan run: | dist host --steps=create --tag=${{ inputs.tag }} --output-format=json > plan-dist-manifest.json @@ -56,25 +49,13 @@ jobs: name: artifacts-plan-dist-manifest path: plan-dist-manifest.json - # Build and packages all the platform-specific things build-local-artifacts: name: build-local-artifacts (${{ join(matrix.targets, ', ') }}) - # Let the initial task tell us to not run (currently very blunt) needs: - plan if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }} strategy: fail-fast: false - # Target platforms/runners are computed by dist in create-release. - # Each member of the matrix has the following arguments: - # - # - runner: the github runner - # - dist-args: cli flags to pass to dist - # - install-dist: expression to run to install dist on the runner - # - # Typically there will be: - # - 1 "global" task that builds universal installers - # - N "local" tasks that build each platform's binaries and platform-specific installers matrix: ${{ fromJson(needs.plan.outputs.val || '{"ci":{"github":{"artifacts_matrix":{"include":[]}}}}').ci.github.artifacts_matrix }} runs-on: ${{ matrix.runner }} container: ${{ matrix.container && matrix.container.image || null }} @@ -108,7 +89,6 @@ jobs: run: sudo apt-get update && sudo apt-get install --yes libxcb1-dev - name: Install dist run: ${{ matrix.install_dist.run }} - # Get the dist-manifest - name: Fetch local artifacts uses: actions/download-artifact@v7 with: @@ -120,7 +100,6 @@ jobs: ${{ matrix.packages_install }} - name: Build artifacts run: | - # Actually do builds and make zips and whatnot dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json echo "dist ran successfully" - id: cargo-dist @@ -130,7 +109,6 @@ jobs: # inconsistent syntax between shell and powershell. shell: bash run: | - # Parse out what we just built and upload it to scratch storage echo "paths<> "$GITHUB_OUTPUT" dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT" echo "EOF" >> "$GITHUB_OUTPUT" @@ -144,7 +122,6 @@ jobs: ${{ steps.cargo-dist.outputs.paths }} ${{ env.BUILD_MANIFEST_NAME }} - # Build and package all the platform-agnostic(ish) things build-global-artifacts: needs: - plan @@ -165,7 +142,6 @@ jobs: name: cargo-dist-cache path: ~/.cargo/bin/ - run: chmod +x ~/.cargo/bin/dist - # Get all the local artifacts for the global tasks to use (for e.g. checksums) - name: Fetch local artifacts uses: actions/download-artifact@v7 with: @@ -178,7 +154,6 @@ jobs: dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json echo "dist ran successfully" - # Parse out what we just built and upload it to scratch storage echo "paths<> "$GITHUB_OUTPUT" jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT" echo "EOF" >> "$GITHUB_OUTPUT" @@ -191,13 +166,11 @@ jobs: path: | ${{ steps.cargo-dist.outputs.paths }} ${{ env.BUILD_MANIFEST_NAME }} - # Determines if we should publish/announce host: needs: - plan - build-local-artifacts - build-global-artifacts - # Only run if we're "publishing", and only if plan, local and global didn't fail (skipped is fine) if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -218,7 +191,6 @@ jobs: name: cargo-dist-cache path: ~/.cargo/bin/ - run: chmod +x ~/.cargo/bin/dist - # Fetch artifacts from scratch-storage - name: Fetch artifacts uses: actions/download-artifact@v7 with: @@ -235,10 +207,8 @@ jobs: - name: "Upload dist-manifest.json" uses: actions/upload-artifact@v6 with: - # Overwrite the previous copy name: artifacts-dist-manifest path: dist-manifest.json - # Create a GitHub Release while uploading all files to it - name: "Download GitHub Artifacts" uses: actions/download-artifact@v7 with: @@ -330,7 +300,6 @@ jobs: persist-credentials: true repository: ${{ env.HOMEBREW_TAP_REPOSITORY }} token: ${{ secrets.HOMEBREW_TAP_TOKEN }} - # So we have access to the formula - name: Fetch homebrew formulae uses: actions/download-artifact@v7 with: @@ -379,7 +348,6 @@ jobs: plan: ${{ needs.plan.outputs.val }} dry_run: false secrets: inherit - # publish jobs get escalated permissions permissions: "contents": "read" @@ -392,7 +360,6 @@ jobs: with: plan: ${{ needs.plan.outputs.val }} secrets: inherit - # publish jobs get escalated permissions permissions: "contents": "read" @@ -405,7 +372,6 @@ jobs: with: plan: ${{ needs.plan.outputs.val }} secrets: inherit - # publish jobs get escalated permissions permissions: "contents": "write" diff --git a/build.rs b/build.rs index 957ee58..a0e9529 100644 --- a/build.rs +++ b/build.rs @@ -11,7 +11,6 @@ fn main() { let out_dir = env::var("OUT_DIR").unwrap(); let out = Path::new(&out_dir); - // compile RmclShim.java into a jar that gets embedded via include_bytes! let status = Command::new("javac") .arg("-source") .arg("8") @@ -25,7 +24,6 @@ fn main() { assert!(status.success(), "javac failed to compile RmclShim.java"); - // package into a jar let jar_path = out.join("rmcl-shim.jar"); let status = Command::new("jar") .arg("cfe") diff --git a/cliff.toml b/cliff.toml index 98becde..e7f6e20 100644 --- a/cliff.toml +++ b/cliff.toml @@ -1,14 +1,8 @@ -# git-cliff ~ configuration file -# https://git-cliff.org/docs/configuration - - [remote.github] owner = "objz" repo = "rmcl" [changelog] -# A Tera template to be rendered for each release in the changelog. -# See https://keats.github.io/tera/docs/#introduction body = """ {% if version %}\ ## {{ version | trim_start_matches(pat="v") }} - {{ timestamp | date(format="%Y-%m-%d") }} @@ -32,41 +26,19 @@ body = """ {% endfor %} {% endif %} """ -# Remove leading and trailing whitespaces from the changelog's body. trim = true -# Render body even when there are no releases to process. render_always = true -# An array of regex based postprocessors to modify the changelog. -postprocessors = [ - # Replace the placeholder with a URL. - #{ pattern = '', replace = "https://github.com/orhun/git-cliff" }, -] -# render body even when there are no releases to process -# render_always = true -# output file path -# output = "test.md" +postprocessors = [] [git] -# Parse commits according to the conventional commits specification. -# See https://www.conventionalcommits.org conventional_commits = true -# Exclude commits that do not match the conventional commits specification. filter_unconventional = false -# Require all commits to be conventional. -# Takes precedence over filter_unconventional. require_conventional = false -# Split commits on newlines, treating each line as an individual commit. split_commits = false -# An array of regex based parsers to modify commit messages prior to further processing. commit_preprocessors = [ - # Replace issue numbers in commit messages with links. { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/objz/rmcl/issues/${2}))" }, ] -# Prevent commits that are breaking from being excluded by commit parsers. protect_breaking_commits = false -# An array of regex based parsers for extracting data from the commit message. -# Assigns commits to groups. -# Optionally sets the commit's scope and can decide to exclude commits from further processing. commit_parsers = [ { message = "^feat", group = "features" }, { message = "^fix", group = "bug fixes" }, @@ -84,20 +56,11 @@ commit_parsers = [ { message = "^revert", group = "reverts" }, { message = ".*", group = "other changes" }, ] -# Exclude commits that are not matched by any commit parser. filter_commits = false -# Fail on a commit that is not matched by any commit parser. fail_on_unmatched_commit = false -# An array of link parsers for extracting external references, and turning them into URLs, using regex. link_parsers = [] -# Include only the tags that belong to the current branch. use_branch_tags = false -# Order releases topologically instead of chronologically. topo_order = false -# Order commits topologically instead of chronologically. topo_order_commits = true -# Order of commits in each group/release within the changelog. -# Allowed values: newest, oldest sort_commits = "oldest" -# Process submodules commits recurse_submodules = false diff --git a/dist-workspace.toml b/dist-workspace.toml index 4561c87..bdbc3ca 100644 --- a/dist-workspace.toml +++ b/dist-workspace.toml @@ -1,29 +1,16 @@ [workspace] members = ["cargo:."] -# Config for 'dist' [dist] -# The preferred dist version to use in CI (Cargo.toml SemVer syntax) cargo-dist-version = "0.31.0" -# CI backends to support ci = "github" -# The installers to generate for each app installers = ["homebrew", "msi"] -# A GitHub repo to push Homebrew formulas to tap = "objz/homebrew-tap" -# Target platforms to build apps for (Rust target-triple syntax) targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"] -# Path that installers should place binaries in install-path = "CARGO_HOME" -# Publish jobs to run in CI publish-jobs = ["homebrew", "./publish-crates", "./publish-aur", "./publish-winget"] -# Custom permissions for publish jobs github-custom-job-permissions = { publish-crates = { contents = "read" }, publish-aur = { contents = "read" }, publish-winget = { contents = "read" } } -# Extra setup steps for release artifact builders github-build-setup = "../dist-build-setup.yml" -# Where to host releases hosting = "github" -# Whether to install an updater program install-updater = false -# Allow custom edits to the generated CI file allow-dirty = ["ci", "msi"] diff --git a/src/auth/accounts.rs b/src/auth/accounts.rs index e6102c4..c749986 100644 --- a/src/auth/accounts.rs +++ b/src/auth/accounts.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// account management: persistence, switching active accounts, and offline uuid generation - use std::path::PathBuf; use serde::{Deserialize, Serialize}; diff --git a/src/auth/mod.rs b/src/auth/mod.rs index 6890662..144ec16 100644 --- a/src/auth/mod.rs +++ b/src/auth/mod.rs @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// auth module: account storage (offline + microsoft) and the oauth device code flow mod accounts; mod oauth; diff --git a/src/auth/oauth.rs b/src/auth/oauth.rs index 022e82d..7a76fa9 100644 --- a/src/auth/oauth.rs +++ b/src/auth/oauth.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// microsoft oauth device code flow for minecraft authentication. -// the flow goes: MSA device code -> MSA token -> xbox/mc token exchange -> mc profile fetch. // device code auth is used because it works without a redirect URI, which is nice for a TUI. use std::sync::{Arc, LazyLock, Mutex}; @@ -50,7 +48,6 @@ fn normalize_profile_uuid(id: &str) -> Option { }) } -// shared slot so the TUI can poll for the device code to show the user pub static DEVICE_CODE_DISPLAY: LazyLock>>> = LazyLock::new(|| Arc::new(Mutex::new(None))); @@ -92,8 +89,6 @@ async fn run_full_oauth_flow() -> Result<(String, Option), String> { Ok((ms_access_token, ms_refresh_token)) } -// kicks off auth on a background task, returns a mutex the caller can poll for the result. -// the TUI checks DEVICE_CODE_DISPLAY for the code to show, and this mutex for completion. pub fn start_microsoft_auth() -> Arc>> { let result: Arc>> = Arc::new(Mutex::new(None)); let result_clone = result.clone(); @@ -183,7 +178,6 @@ fn valid_cached_mc_token(account: &Account, now: i64) -> Option<&str> { } } -// returns (mc_access_token, new_refresh_token, new_mc_token_expires_at). // cached tokens return no expiry so callers don't rewrite the account store. pub async fn refresh_and_get_token( account: &Account, diff --git a/src/cli/account.rs b/src/cli/account.rs index e9f63ff..b630668 100644 --- a/src/cli/account.rs +++ b/src/cli/account.rs @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// cli handlers for account management (microsoft oauth + offline accounts) use std::io; use std::time::Duration; @@ -65,7 +64,6 @@ async fn add_microsoft_account() -> CliResult { let result_arc = crate::auth::start_microsoft_auth(); - // wait for the device code to become available before showing it loop { if let Ok(slot) = crate::auth::DEVICE_CODE_DISPLAY.lock() && let Some(info) = slot.as_ref() @@ -77,7 +75,6 @@ async fn add_microsoft_account() -> CliResult { tokio::time::sleep(Duration::from_millis(200)).await; } - // now wait for the user to complete auth in their browser loop { if let Ok(slot) = result_arc.lock() && let Some(result) = slot.as_ref() diff --git a/src/cli/content.rs b/src/cli/content.rs index 38b3d55..517e540 100644 --- a/src/cli/content.rs +++ b/src/cli/content.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// unified content management for mods, resource packs, and shaders. -// all three content types share the same list/enable/disable workflow, -// just with different scanner functions plugged in. use std::io; use std::path::Path; diff --git a/src/cli/import.rs b/src/cli/import.rs index 790ece1..6a7eb17 100644 --- a/src/cli/import.rs +++ b/src/cli/import.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// modpack importing from modrinth (remote slug/url) or local files (.mrpack, mmc zips). -// resolves the input, downloads if needed, then hands off to the import engine. use clap::ArgMatches; use crate::instance::InstanceManager; diff --git a/src/cli/instance.rs b/src/cli/instance.rs index a443e53..93926bf 100644 --- a/src/cli/instance.rs +++ b/src/cli/instance.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// instance lifecycle: create, delete, rename, launch, config, desktop shortcuts. -// the heaviest handler in the CLI since instances are the core concept. use std::io; use std::time::Duration; diff --git a/src/cli/log.rs b/src/cli/log.rs index 09599b5..0d16732 100644 --- a/src/cli/log.rs +++ b/src/cli/log.rs @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// viewing minecraft log files from the CLI, with optional `--follow` for tailing use std::io; use std::path::{Path, PathBuf}; use std::time::Duration; @@ -67,7 +66,6 @@ async fn show_log(matches: &ArgMatches) -> CliResult { Ok(()) } -// if no file is specified, grab the most recent log (first from the sorted scan) pub(crate) fn resolve_log_path( instances_dir: &Path, instance: &str, diff --git a/src/cli/mod.rs b/src/cli/mod.rs index e155c3c..d2e65df 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// cli entry point and clap command definitions. -// no subcommand = launch TUI, otherwise dispatch to the appropriate handler. mod account; mod content; mod import; @@ -17,9 +15,7 @@ use clap::{Arg, ArgAction, ArgGroup, Command}; pub async fn init() { let matches = build_command().get_matches(); - // no subcommand means the user just ran `rmcl` bare, so fall through to TUI mode if matches.subcommand().is_none() { - // force-init the theme so it's ready before the TUI renders let _ = &*crate::config::theme::THEME; if let Err(e) = crate::tui::show().await { tracing::error!("TUI error: {}", e); @@ -265,7 +261,6 @@ fn build_command() -> Command { ) } -// mods, resource packs, and shaders all share the same list/enable/disable shape fn build_content_command(name: &'static str, about: &'static str) -> Command { Command::new(name) .about(format!("Manage {}", about)) diff --git a/src/cli/output.rs b/src/cli/output.rs index 8041220..7f40e85 100644 --- a/src/cli/output.rs +++ b/src/cli/output.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// plain-text table rendering for CLI output. no fancy box-drawing, -// just left-aligned columns with two-space gaps. keeps it pipeable. use chrono::{DateTime, Utc}; use ratatui::text::Span; @@ -47,7 +45,6 @@ fn display_width(value: &str) -> usize { Span::raw(value).width() } -// find the widest value in each column to pad everything evenly fn column_widths(headers: &[&str], rows: &[Vec]) -> Vec { let mut widths: Vec = headers.iter().map(|header| display_width(header)).collect(); diff --git a/src/cli/utils.rs b/src/cli/utils.rs index 195a000..46c2dc1 100644 --- a/src/cli/utils.rs +++ b/src/cli/utils.rs @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// shared CLI helpers: confirmation prompts, arg extraction, instance validation use std::io::{self, Write}; use clap::ArgMatches; diff --git a/src/cli/version.rs b/src/cli/version.rs index 0968cd0..d9d6caf 100644 --- a/src/cli/version.rs +++ b/src/cli/version.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// lists available game versions, optionally filtered by mod loader support. -// fetches the mojang manifest and cross-references with loader APIs -// to show only versions that actually work with a given loader. use std::collections::HashSet; use std::io; diff --git a/src/config/mod.rs b/src/config/mod.rs index 77c657a..0406a6f 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// config loading: reads config.toml from the platform config dir, creates defaults if missing. -// everything lands in the SETTINGS static so the rest of the app can just grab it. - use config::{Config as ConfigLoader, ConfigError, File}; use std::fs; use std::io; @@ -22,7 +19,6 @@ pub fn get_config_path() -> PathBuf { .join("rmcl") } -// seeds the config file from the bundled default on first run fn ensure_config_exists() -> PathBuf { let config_path = get_config_path().join("config.toml"); if !config_path.exists() { diff --git a/src/config/settings.rs b/src/config/settings.rs index 623d47b..6e7d6dc 100644 --- a/src/config/settings.rs +++ b/src/config/settings.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// all the config structs that map to sections in config.toml. -// everything has sane defaults so a blank file (or no file) still works. - use std::{ collections::{BTreeMap, BTreeSet}, fmt, @@ -250,7 +247,6 @@ impl Default for Paths { } } -// expand ~ in paths since toml doesn't do that for us pub fn resolve_path(raw: &str) -> PathBuf { if let Some(stripped) = raw.strip_prefix("~/") { if let Some(home) = dirs_next::home_dir() { diff --git a/src/config/theme.rs b/src/config/theme.rs index 7b5cbbb..ee147a8 100644 --- a/src/config/theme.rs +++ b/src/config/theme.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// theme resolution: loads theme.toml, picks a base theme (builtin or custom file), -// then layers user color overrides on top. supports loading .toml themes from the -// config/theme/ directory or by absolute path. - use std::path::Path; use std::sync::{Arc, LazyLock, RwLock}; @@ -101,7 +97,6 @@ fn ensure_theme_exists(path: &Path) { let _ = std::fs::write(path, include_str!("../../assets/theme.toml")); } -// start from a base theme, then override individual colors if the user specified any fn resolve_app_theme(config: &ThemeConfig) -> Box { let base = load_base_theme(&config.theme); @@ -134,7 +129,6 @@ fn resolve_app_theme(config: &ThemeConfig) -> Box { }) } -// tries to find the theme: absolute path > config/theme/ > config/theme/.toml > builtin fn load_base_theme(name: &str) -> Box { let path = if Path::new(name).is_absolute() { Some(std::path::PathBuf::from(name)) diff --git a/src/feedback/errors.rs b/src/feedback/errors.rs index 29d96d5..68206bc 100644 --- a/src/feedback/errors.rs +++ b/src/feedback/errors.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// thread-safe FIFO queue for error/warning toasts displayed in the UI. -// also (ab)used for INFO toasts like "desktop shortcut created" because -// why build a separate notification system when this one works fine. -// // callers pass id: 0 and push_error assigns a real unique id. the id is // used by the render layer to track per-toast animation state. diff --git a/src/feedback/mod.rs b/src/feedback/mod.rs index 87f3b0d..5bc1730 100644 --- a/src/feedback/mod.rs +++ b/src/feedback/mod.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// application feedback shared by background work and every frontend. - use std::sync::atomic::{AtomicBool, Ordering}; pub mod errors; diff --git a/src/feedback/progress.rs b/src/feedback/progress.rs index a0e1219..20b5b5b 100644 --- a/src/feedback/progress.rs +++ b/src/feedback/progress.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// global progress state shared between background tasks and the status bar widget. -// background tasks set the action/progress, the render loop reads it every frame. - use std::collections::BTreeMap; use std::sync::LazyLock; use std::sync::atomic::{AtomicU64, Ordering}; diff --git a/src/instance/content/datapacks.rs b/src/instance/content/datapacks.rs index a090508..f65252e 100644 --- a/src/instance/content/datapacks.rs +++ b/src/instance/content/datapacks.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// data pack scanning backed by the same pack.mcmeta reader as resource packs. - use std::path::Path; use super::entry::ContentEntry; diff --git a/src/instance/content/entry.rs b/src/instance/content/entry.rs index 7434f4d..a9eb7e6 100644 --- a/src/instance/content/entry.rs +++ b/src/instance/content/entry.rs @@ -55,7 +55,6 @@ pub struct ContentEntry { pub icon_lines: Option>>, } -// enable/disable by renaming the file with/without ".disabled" suffix. pub fn toggle_entry(entry: &ContentEntry) -> Result<(), std::io::Error> { toggle_entry_path(entry).map(drop) } diff --git a/src/instance/content/icons.rs b/src/instance/content/icons.rs index 9dc88bf..c0493df 100644 --- a/src/instance/content/icons.rs +++ b/src/instance/content/icons.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// terminal icon rasterization shared by every content type and markdown. - -// a single "pixel" in a terminal icon. #[derive(Debug, Clone, Copy)] pub struct IconCell { pub symbol: char, diff --git a/src/instance/content/mod.rs b/src/instance/content/mod.rs index 919abd6..801c453 100644 --- a/src/instance/content/mod.rs +++ b/src/instance/content/mod.rs @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// scanning and toggling instance content (mods, resource packs, shaders, worlds). // minecraft uses a ".disabled" suffix convention for disabled content, so this leans on that heavily. pub mod datapacks; @@ -30,8 +29,6 @@ pub use worlds::{scan_one_world, scan_worlds}; use std::io::Read; -// figures out if a file is enabled or disabled based on the ".disabled" suffix, -// and strips the extension to get a clean stem name pub(crate) fn parse_enabled_stem(file_name: &str, ext: &str) -> Option<(bool, String)> { let disabled_ext = format!("{ext}.disabled"); if let Some(stem) = file_name.strip_suffix(&disabled_ext) { @@ -43,7 +40,6 @@ pub(crate) fn parse_enabled_stem(file_name: &str, ext: &str) -> Option<(bool, St } } -// same idea but for directories, which don't have a file extension to strip pub(crate) fn parse_enabled_stem_dir(file_name: &str) -> (bool, String) { if let Some(stem) = file_name.strip_suffix(".disabled") { (false, stem.to_string()) diff --git a/src/instance/content/mods.rs b/src/instance/content/mods.rs index 043aa25..2c67dc3 100644 --- a/src/instance/content/mods.rs +++ b/src/instance/content/mods.rs @@ -1,12 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// mod scanning and loader-specific metadata extraction. -// jar files are just zips, so it cracks them open looking for loader-specific -// metadata (fabric.mod.json, quilt.mod.json, mods.toml, mcmod.info) to get -// names, descriptions, and icons. if none of those work, falls back to common -// root-level icon paths (logo.png, icon.png, pack.png) or just the filename. - use std::io::Read; use std::path::Path; @@ -47,7 +41,6 @@ fn icon_path_from_value(value: &serde_json::Value) -> String { } } -// quilt puts its metadata under a "metadata" sub-object #[derive(Deserialize, Default)] struct QuiltModJson { #[serde(default)] @@ -142,10 +135,6 @@ pub fn scan_mods(instances_dir: &Path, instance_name: &str) -> Vec entries } -// tries each loader's metadata file to extract name, description, and icon. -// checks fabric.mod.json, quilt.mod.json, META-INF/mods.toml (forge), -// META-INF/neoforge.mods.toml, and mcmod.info (legacy forge). if none of -// those yield an icon, falls back to common root-level paths. fn read_mod_metadata(jar_path: &Path) -> (String, String, String, Option>) { let file = match std::fs::File::open(jar_path) { Ok(file) => file, @@ -197,7 +186,6 @@ fn read_mod_metadata(jar_path: &Path) -> (String, String, String, Option } } - // no recognized metadata at all, try common icon paths let icon_bytes = try_fallback_icons(&mut archive); tracing::trace!( "No recognized mod metadata in {}; fallback_icon={}", @@ -291,8 +279,6 @@ fn read_forge_toml_meta( Some((name, description, version, logo)) } -// legacy forge mcmod.info is either a bare json array of mod entries -// or an object with a "modList" key wrapping the array fn read_mcmod_info( archive: &mut zip::ZipArchive, ) -> Option<(String, String, String, String)> { diff --git a/src/instance/content/packs.rs b/src/instance/content/packs.rs index fee1567..fbb6efa 100644 --- a/src/instance/content/packs.rs +++ b/src/instance/content/packs.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// shared pack.mcmeta scanning for resource packs and shader packs. - use std::path::Path; use serde::Deserialize; diff --git a/src/instance/content/resource_packs.rs b/src/instance/content/resource_packs.rs index 162d760..9708a48 100644 --- a/src/instance/content/resource_packs.rs +++ b/src/instance/content/resource_packs.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// resource pack scanner backed by the shared pack.mcmeta reader. - use std::path::Path; use super::entry::ContentEntry; diff --git a/src/instance/content/shaders.rs b/src/instance/content/shaders.rs index 59892f3..969b243 100644 --- a/src/instance/content/shaders.rs +++ b/src/instance/content/shaders.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// shader pack scanner backed by the shared pack.mcmeta reader. - use std::path::Path; use super::entry::ContentEntry; diff --git a/src/instance/content/worlds.rs b/src/instance/content/worlds.rs index 9a844ea..532a558 100644 --- a/src/instance/content/worlds.rs +++ b/src/instance/content/worlds.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// world save scanning. worlds are always directories (never zips) and store -// their icon as icon.png. also computes an approximate size from top-level -// files + region data so the user gets some sense of how chonky their world is. - use std::{fs::File, path::Path}; use flate2::read::GzDecoder; @@ -204,7 +200,6 @@ fn dir_size_approx(path: &Path) -> u64 { } } } - // Check region folder too (main chunk data) let region = path.join("region"); if let Ok(rd) = std::fs::read_dir(region) { for entry in rd.flatten() { diff --git a/src/instance/desktop.rs b/src/instance/desktop.rs index 1846758..f0314c8 100644 --- a/src/instance/desktop.rs +++ b/src/instance/desktop.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// creates OS-native shortcuts for launching instances directly: -// .desktop files on linux, .bat on windows, .command on macos - use std::path::{Path, PathBuf}; use crate::instance::models::InstanceConfig; @@ -42,7 +39,6 @@ pub fn icon_path() -> Option { dirs_next::data_dir().map(|d| d.join("rmcl").join("icon.svg")) } -// lazily writes the bundled svg icon to disk the first time a shortcut needs it fn ensure_icon() -> Option { let path = icon_path()?; if std::fs::read(&path).ok().as_deref() == Some(ICON_BYTES) { @@ -229,7 +225,6 @@ fn quote_windows_arg(value: &str) -> String { quoted } -// replaces anything that isn't alphanumeric, dash, or underscore with _ fn sanitize(name: &str) -> String { name.chars() .map(|c| { diff --git a/src/instance/import/mmc.rs b/src/instance/import/mmc.rs index 50cdb96..8a3fe24 100644 --- a/src/instance/import/mmc.rs +++ b/src/instance/import/mmc.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// multimc / prism launcher instance import: mods and configs are bundled -// in the zip. we install the game + loader normally, then extract the -// archive contents over it. - use std::path::Path; use crate::feedback::progress; @@ -119,7 +115,6 @@ pub async fn execute_import( Ok(()) } -// extracts everything under .minecraft/ from the archive into the instance dir fn extract_mmc_archive( archive_path: &Path, minecraft_dir: &Path, @@ -239,7 +234,6 @@ fn instance_name_from_cfg(path: &Path) -> Option { None } -// finds the prefix for the archive: empty for flat zips, "DirName/" for nested fn find_archive_prefix(archive: &zip::ZipArchive) -> String { for name in archive.file_names() { if name.ends_with("mmc-pack.json") { diff --git a/src/instance/import/mod.rs b/src/instance/import/mod.rs index c61afae..6de63f8 100644 --- a/src/instance/import/mod.rs +++ b/src/instance/import/mod.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// modpack importing: parses user input, detects pack format from zip contents, -// builds a summary, and delegates the actual import to format-specific modules. - pub mod curseforge; pub mod mmc; pub mod mrpack; @@ -28,9 +25,6 @@ pub enum ImportInput { LocalFile(String), } -// figures out what the user gave us: a modrinth URL, a local pack file, -// or just a project slug. accepts a pretty wide range of inputs so users -// don't have to think about it. pub fn parse_import_input(input: &str) -> ImportInput { let input = input.trim(); @@ -78,8 +72,6 @@ pub struct ImportSummary { pub source: Option, } -// peeks inside a zip to figure out what format it is. -// checks provider manifests first, then mmc-pack.json. pub fn detect_format(path: &Path) -> Result { tracing::debug!("Detecting modpack format for {}", path.display()); let file = diff --git a/src/instance/import/mrpack.rs b/src/instance/import/mrpack.rs index 2d2d000..49d9377 100644 --- a/src/instance/import/mrpack.rs +++ b/src/instance/import/mrpack.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// modrinth .mrpack import: parse the manifest, download all the mods, -// and extract config/resource overrides from the zip - use std::collections::HashMap; use std::path::{Path, PathBuf}; @@ -43,7 +40,6 @@ pub struct MrpackFile { pub file_size: u64, } -// .mrpack is just a zip with modrinth.index.json at the root pub fn parse_mrpack(path: &Path) -> Result { tracing::debug!("Parsing .mrpack manifest from {}", path.display()); let file = std::fs::File::open(path).map_err(|e| format!("Cannot open .mrpack: {e}"))?; @@ -63,8 +59,6 @@ pub fn parse_mrpack(path: &Path) -> Result { Ok(index) } -// mrpack dependencies use keys like "fabric-loader", "forge", etc. -// checks in priority order and returns the first match. pub fn loader_from_dependencies( deps: &HashMap, ) -> (Option, Option) { @@ -132,7 +126,6 @@ pub fn build_summary(path: &Path) -> Result { }) } -// peek into the zip to count files under overrides/ and client-overrides/ fn count_overrides(mrpack_path: &Path) -> Result { let file = std::fs::File::open(mrpack_path).map_err(|e| e.to_string())?; let archive = zip::ZipArchive::new(file).map_err(|e| e.to_string())?; diff --git a/src/instance/java.rs b/src/instance/java.rs index 3d57f8d..32d04cf 100644 --- a/src/instance/java.rs +++ b/src/instance/java.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// java runtime discovery shared by launching, loader installation, and settings. - use std::{ collections::HashSet, path::{Path, PathBuf}, diff --git a/src/instance/launch/mod.rs b/src/instance/launch/mod.rs index 1fef4bd..ae038b2 100644 --- a/src/instance/launch/mod.rs +++ b/src/instance/launch/mod.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// builds the full java command line and spawns minecraft as a child process. -// handles classpath assembly, auth token injection, and log capture. -// loader-specific patches live in submodules (e.g. patches.rs for lwjgl3ify). - pub(crate) mod parser; mod patches; @@ -300,9 +296,6 @@ async fn migrate_legacy_loader_profile_if_needed( Ok(Some(refreshed)) } -// resolved auth credentials passed into the launch-invocation builder. -// keeping these as borrowed strs lets callers pass owned strings or string -// slices without forcing allocation. #[derive(Debug, Clone)] pub struct LaunchAuth<'a> { pub username: &'a str, @@ -312,9 +305,7 @@ pub struct LaunchAuth<'a> { pub user_type: &'a str, } -// everything the spawner needs to construct the java command. assembled by -// build_launch_invocation, consumed by launch(). exposed so integration tests -// can assert on the rendered invocation without spawning a real process. +// Exposed so integration tests can inspect the invocation without spawning Java. #[derive(Debug, Clone)] pub struct LaunchInvocation { pub java: String, @@ -368,11 +359,6 @@ fn validate_quick_play_world(minecraft_dir: &Path, world: &str) -> Result<(), La Ok(()) } -// builds a fully-resolved java invocation for the given instance. reads -// meta.json and the loader profile from disk, migrates legacy formats if -// needed (may hit Mojang to refetch), resolves inheritsFrom, applies -// loader-specific patches, and renders all template arguments. all I/O -// except auth resolution and process spawning happens here. pub async fn build_launch_invocation( config: &InstanceConfig, instances_dir: &Path, @@ -555,7 +541,6 @@ pub async fn build_launch_invocation( .collect::>() .join(sep); - // java resolution: instance override > global setting > auto-detect let java = config .java_path .clone() @@ -739,10 +724,6 @@ fn finish_config_sync( } } -// resolves auth credentials, then builds the launch invocation and spawns -// the java process. only thin wrapper logic lives here: token refresh, -// process spawn, child supervision. all the heavy lifting (profile loading, -// classpath assembly, template rendering) sits behind build_launch_invocation. pub async fn launch( config: &InstanceConfig, instances_dir: &Path, @@ -751,7 +732,6 @@ pub async fn launch( ) -> Result<(), LaunchError> { let name = config.name.clone(); - // resolve auth credentials, refreshing the microsoft token if needed. let mut account_store = crate::auth::AccountStore::load(); let account = select_launch_account(&account_store.accounts, config.preferred_account.as_deref()); @@ -919,8 +899,6 @@ pub async fn launch( let config_for_post_exit = config.clone(); let invocation_for_post_exit = invocation.clone(); - // spawn a background task to babysit the child process: capture stdout/stderr - // into both the TUI log viewer and a timestamped log file on disk tokio::spawn(async move { use std::io::Write; use std::sync::{Arc, Mutex}; @@ -1004,7 +982,6 @@ pub async fn launch( } drop(log_tx); - // wait for either the process to exit naturally or a kill signal from the TUI let (code, killed_by_user) = tokio::select! { _ = kill_rx => { tracing::info!("[{}] Kill requested, terminating process", name_for_task); diff --git a/src/instance/launch/parser.rs b/src/instance/launch/parser.rs index 7397ac6..f92cf90 100644 --- a/src/instance/launch/parser.rs +++ b/src/instance/launch/parser.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// live minecraft process log parser. -// // disk launch logs stay raw, but the tui needs enough structure to color and // group output sanely. this parser keeps stdout/stderr as a hint, frames // multiline java/jvm/native bursts into events, then assigns a semantic level. diff --git a/src/instance/launch/patches.rs b/src/instance/launch/patches.rs index d9d0a4a..64ce74a 100644 --- a/src/instance/launch/patches.rs +++ b/src/instance/launch/patches.rs @@ -1,11 +1,9 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// classpath and jvm patches for legacy forge on java 9+. // lwjgl3ify ships a patched launchwrapper and retrofuturabootstrap that // replace the old URLClassLoader-based launcher with one that works on -// modern java. this module handles extracting those patches, building -// the right --add-opens flags, and swapping out the broken log4j jars. +// modern java. use std::path::{Path, PathBuf}; @@ -19,12 +17,6 @@ pub struct LwjglifyPatches { pub extra_args: Vec, } -// checks if lwjgl3ify is present in the mods folder, and if so: -// 1. extracts forge patches from the lwjgl3ify jar -// 2. prepends them to the classpath so they shadow vanilla launchwrapper -// 3. parses --add-opens from the patches manifest -// 4. replaces log4j 2.0-beta9 with prism's patched builds -// 5. returns the jvm args and overridden main class pub async fn apply( minecraft_dir: &Path, lib_dir: &Path, @@ -43,7 +35,6 @@ pub async fn apply( return None; } - // prepend so patched classes shadow vanilla launchwrapper classpath.insert(0, patches_dest.clone()); let mut jvm_args = parse_add_opens(&patches_dest).unwrap_or_default(); @@ -214,7 +205,6 @@ fn add_lwjgl3(lib_dir: &Path, classpath: &mut Vec) { insert_pos += 1; } - // natives let natives = if *module == "lwjgl" { lib_dir.join(format!( "org/lwjgl/lwjgl/3.3.3/lwjgl-3.3.3-{os_classifier}.jar" @@ -234,11 +224,8 @@ fn add_lwjgl3(lib_dir: &Path, classpath: &mut Vec) { tracing::info!("Added {} LWJGL 3.3.3 jars to classpath", insert_pos - 1); } -// writes a log4j2.xml config that sets the root logger to INFO. this -// prevents LaunchClassLoader's debug() call from ever firing, which -// avoids the ThrowableProxy -> SecurityManager -> StackWalker infinite -// recursion on java 24+. the config is written to .minecraft/ and -// pointed to via -Dlog4j.configurationFile. +// Suppresses LaunchClassLoader's debug() call to avoid the +// ThrowableProxy -> SecurityManager -> StackWalker recursion on Java 24+. fn write_log4j_config(minecraft_dir: &Path, jvm_args: &mut Vec) { let config_path = minecraft_dir.join(".rmcl-log4j2.xml"); let config = r#" diff --git a/src/instance/loader/fabric.rs b/src/instance/loader/fabric.rs index 8a16782..d78eadc 100644 --- a/src/instance/loader/fabric.rs +++ b/src/instance/loader/fabric.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// fabric installation. the nice one: just fetch a profile json and download -// the libraries. no java installer nonsense required. - use std::path::Path; use async_trait::async_trait; diff --git a/src/instance/loader/forge.rs b/src/instance/loader/forge.rs index 44b9559..343fc08 100644 --- a/src/instance/loader/forge.rs +++ b/src/instance/loader/forge.rs @@ -1,9 +1,8 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// forge installation. modern forge runs a java installer, old forge (pre-1.13) -// can't run headless so we extract the profile and libraries from the jar -// directly. the installer jar gets cleaned up either way. +// Old Forge installers cannot run headless, so their profiles and libraries +// must be extracted from the jar instead. use std::path::Path; @@ -85,7 +84,6 @@ impl ModLoaderInstaller for ForgeInstaller { let profile_filename = format!("forge-{game_version}-{loader_version}.json"); if has_legacy_install_profile(&installer_jar) { - // old forge: no --installClient support, extract directly from jar tracing::debug!("Forge installer uses legacy install_profile.json path"); if let Err(e) = install_forge_from_profile(client, &installer_jar, meta_dir, &profile_filename) @@ -95,7 +93,6 @@ impl ModLoaderInstaller for ForgeInstaller { return Err(e); } } else { - // modern forge: run the java installer let java_path = java_path.map(str::to_owned).unwrap_or_else(|| { crate::config::SETTINGS .read() @@ -110,7 +107,6 @@ impl ModLoaderInstaller for ForgeInstaller { return Err(InstallError::Installer(e)); } - // extract the profile from what the installer just wrote to disk save_forge_profile(instance_dir, meta_dir, game_version, loader_version) .map_err(InstallError::Installer)?; } @@ -271,7 +267,6 @@ pub(crate) async fn install_forge_from_profile( InstallError::Installer(InstallerError::Profile("missing install.path".into())) })?; - // extract the universal jar to the correct maven location let universal_maven_path = crate::instance::loader::maven::maven_coord_to_path( install_path_coord, ) diff --git a/src/instance/loader/maven.rs b/src/instance/loader/maven.rs index 8848113..64ed46e 100644 --- a/src/instance/loader/maven.rs +++ b/src/instance/loader/maven.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// maven coordinate handling shared by loader installation and launch profiles. - #[must_use] pub fn maven_coord_to_path(coord: &str) -> Option { let parts: Vec<&str> = coord.split(':').collect(); diff --git a/src/instance/loader/mod.rs b/src/instance/loader/mod.rs index 8c52a6c..4e18c94 100644 --- a/src/instance/loader/mod.rs +++ b/src/instance/loader/mod.rs @@ -1,11 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// mod loader installation. each loader (fabric, forge, neoforge, quilt, vanilla) -// implements the same trait so the UI can treat them uniformly: pick game version, -// pick loader version, install. the actual installation strategies differ wildly -// though (fabric/quilt just download jars, forge/neoforge run a whole java installer). - mod fabric; pub mod forge; pub mod maven; @@ -83,8 +78,7 @@ pub trait ModLoaderInstaller: Send + Sync { } } -// writes raw profile JSON bytes to meta_dir/loader-profiles/. -// callers that already have the upstream bytes (fabric/quilt http fetch, +// Callers that already have the upstream bytes (fabric/quilt http fetch, // legacy forge versionInfo extract) use this directly to keep the on-disk // file byte-for-byte identical to the source. pub(crate) fn save_profile_bytes( diff --git a/src/instance/loader/neoforge.rs b/src/instance/loader/neoforge.rs index 8692423..8f16ee8 100644 --- a/src/instance/loader/neoforge.rs +++ b/src/instance/loader/neoforge.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// neoforge installation. same java installer dance as forge (they forked from it, -// after all), just with different URLs and version naming. - use std::path::Path; use async_trait::async_trait; diff --git a/src/instance/loader/quilt.rs b/src/instance/loader/quilt.rs index 940f237..aa25111 100644 --- a/src/instance/loader/quilt.rs +++ b/src/instance/loader/quilt.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// quilt installation. same clean approach as fabric (profile json + library -// downloads). they're basically fabric's cooler sibling. - use std::path::Path; use async_trait::async_trait; diff --git a/src/instance/logs/files.rs b/src/instance/logs/files.rs index cef626c..f6e37fe 100644 --- a/src/instance/logs/files.rs +++ b/src/instance/logs/files.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// per-launch log files stored under minecraft/logs/launches/ -// each launch gets its own timestamped file so you can go back and see what -// crashed last tuesday at 3am - use std::path::{Path, PathBuf}; #[derive(Debug, Clone)] diff --git a/src/instance/logs/live.rs b/src/instance/logs/live.rs index a02e2d2..0034981 100644 --- a/src/instance/logs/live.rs +++ b/src/instance/logs/live.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// in-memory ring buffer for stdout/stderr from running mc instances. -// capped at 2000 lines per instance so it doesn't eat all the RAM -// if someone leaves a server running for a week. you're welcome. - use std::collections::{HashMap, VecDeque}; use std::sync::LazyLock; use std::sync::{Arc, Mutex}; diff --git a/src/instance/manager.rs b/src/instance/manager.rs index f988a92..ad89388 100644 --- a/src/instance/manager.rs +++ b/src/instance/manager.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// CRUD for instances: create, delete, rename, load, save. -// creation is the heavy one since it downloads the game, assets, and libraries. - use std::path::PathBuf; use chrono::Utc; @@ -94,7 +91,6 @@ impl InstanceManager { .create_inner(name, game_version, loader, loader_version, &instance_dir) .await; - // clean up on failure so there's no half-baked instance left around if result.is_err() { tracing::debug!( "Cleaning up incomplete instance '{}' after creation failed", diff --git a/src/instance/mod.rs b/src/instance/mod.rs index 0265d4f..6145a76 100644 --- a/src/instance/mod.rs +++ b/src/instance/mod.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// instance management: creation, launching, importing modpacks, and all the -// bookkeeping that comes with pretending to be a real launcher - pub mod config_sync; pub mod content; pub mod desktop; diff --git a/src/instance/models.rs b/src/instance/models.rs index 323721a..88f7bdd 100644 --- a/src/instance/models.rs +++ b/src/instance/models.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// core data types for an instance: what loader it uses, what version, memory -// settings, etc. this is what gets persisted to instance.json - use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use serde_json::Value; diff --git a/src/instance/runtime.rs b/src/instance/runtime.rs index e358f26..c2d19e5 100644 --- a/src/instance/runtime.rs +++ b/src/instance/runtime.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// global tracking for running minecraft instances. everything is behind -// Arc> because the launch/monitor tasks live on separate tokio threads -// and the TUI render loop needs to read state every frame. - use chrono::{DateTime, Utc}; use std::collections::HashMap; use std::sync::LazyLock; diff --git a/src/instance/screenshots.rs b/src/instance/screenshots.rs index 461ab14..c44d4c5 100644 --- a/src/instance/screenshots.rs +++ b/src/instance/screenshots.rs @@ -3,9 +3,6 @@ use std::path::{Path, PathBuf}; -// width/height are read from the actual image file so the TUI can show -// dimensions. falls back to 1920x1080 if the file is corrupt or unreadable -// because honestly, what else are you gonna pick #[derive(Debug, Clone)] pub struct ScreenshotEntry { pub name: String, @@ -44,7 +41,6 @@ pub fn scan_screenshots(instances_dir: &Path, instance_name: &str) -> Vec PathBuf { let path = tmp.join(name); let file = std::fs::File::create(&path).unwrap(); @@ -29,7 +27,6 @@ fn strip_replaced_libs_removes_dominated_prefixes() { PathBuf::from("/libs/commons-compress-1.4.1.jar"), PathBuf::from("/libs/commons-io-2.4.jar"), PathBuf::from("/libs/guava-15.0.jar"), - // these stay PathBuf::from("/libs/log4j-core-2.0.jar"), PathBuf::from("/libs/guava-21.0.jar"), ]; @@ -130,8 +127,6 @@ fn add_lwjgl3_inserts_only_jars_that_exist() { let mut classpath = vec![PathBuf::from("/leading/forge-patches.jar")]; add_lwjgl3(lib_dir, &mut classpath); - // forge-patches stays at index 0; lwjgl core is inserted at index 1. - // none of the other modules existed so nothing else was added. assert_eq!(classpath[0], PathBuf::from("/leading/forge-patches.jar")); assert_eq!(classpath[1], core_jar); assert_eq!(classpath.len(), 2); diff --git a/src/instance/tests/runtime.rs b/src/instance/tests/runtime.rs index fc191db..09a393c 100644 --- a/src/instance/tests/runtime.rs +++ b/src/instance/tests/runtime.rs @@ -57,13 +57,6 @@ fn push_and_drain_last_played() { assert!(drained.iter().any(|(k, _)| k == "run_test_lp")); } -// Removed drain_empty_returns_empty: it relied on no other test pushing -// to LAST_PLAYED between the two drain calls, which races with the -// parallel push_and_drain_last_played test. The drain semantics are -// already covered by push_and_drain_last_played, which asserts a -// specific entry is present, and the empty-result path is exercised -// implicitly any time drain runs after that test's cleanup. - #[test] fn send_kill_returns_false_for_missing() { assert!(!send_kill("run_never_registered_xyz")); @@ -74,7 +67,6 @@ fn register_and_send_kill() { let (tx, mut rx) = tokio::sync::oneshot::channel::<()>(); register_kill("run_test_kill", tx); assert!(send_kill("run_test_kill")); - // the kill signal itself must arrive, not just report success assert!(rx.try_recv().is_ok()); } diff --git a/src/launch_profile/mod.rs b/src/launch_profile/mod.rs index 6e3bdf1..6c11dbd 100644 --- a/src/launch_profile/mod.rs +++ b/src/launch_profile/mod.rs @@ -1,11 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// primitives for parsing, merging, and rendering mojang-format launch -// profiles. consumed by the vanilla launcher and the loader install paths -// (forge/neoforge/fabric/quilt) - anything that reads a mojang-style -// version JSON. - pub mod model; pub mod render; pub mod resolve; diff --git a/src/launch_profile/model.rs b/src/launch_profile/model.rs index f30d35c..f1920ec 100644 --- a/src/launch_profile/model.rs +++ b/src/launch_profile/model.rs @@ -1,12 +1,8 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// mojang-format launch profile types. mirrors the on-disk JSON schema -// used by vanilla versions, forge installer output, neoforge installer -// output, fabric profiles, and quilt profiles. parsing is lossless for -// the fields we care about; unknown fields are silently dropped (serde -// default behavior) - which is fine because we write upstream JSON -// byte-for-byte on the install side. +// Unknown JSON fields are dropped when parsing, but installer paths write the +// upstream bytes unchanged, so this model never strips fields from the cache. use serde::{Deserialize, Serialize}; diff --git a/src/launch_profile/render.rs b/src/launch_profile/render.rs index 0c11b83..bfdb1ca 100644 --- a/src/launch_profile/render.rs +++ b/src/launch_profile/render.rs @@ -1,12 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// renders a parsed launch profile into final argv-style lists for the JVM -// and the game. resolves conditional argument shapes (`{rules, value}`), -// filters them through the rule evaluator, and substitutes mojang template -// variables. legacy `minecraftArguments` strings are tokenised on whitespace -// and treated as a list of game args. pure function; no I/O. - use super::model::{Argument, ArgumentValue, LaunchProfile}; use super::rules::{RuleContext, evaluate}; use super::templates::{TemplateContext, substitute}; diff --git a/src/launch_profile/resolve.rs b/src/launch_profile/resolve.rs index b53d34a..1ed40c8 100644 --- a/src/launch_profile/resolve.rs +++ b/src/launch_profile/resolve.rs @@ -1,12 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// resolves the `inheritsFrom` chain of a parsed `LaunchProfile`. mojang's -// version JSON allows a profile to inherit from another profile by id; the -// loaders (forge / neoforge / fabric / quilt) use this to layer their -// additions on top of a vanilla base. this module walks the chain and -// returns a single flat profile. -// // merge semantics (per the mojang launcher and the major third-party // launchers that interoperate with it): // - scalar fields: child wins if Some, else parent. @@ -15,10 +9,6 @@ // - merge_into preserves parent's inherits_from so resolve() can keep // walking; resolve() clears the final result's inherits_from after // the loop exits. -// -// pure function `merge_into` handles the field-by-field merge math. -// async `resolve` does the chain walking with cycle detection and a depth -// cap. tests cover both layers independently. use std::path::Path; @@ -68,8 +58,6 @@ pub fn merge_into(child: LaunchProfile, parent: LaunchProfile) -> LaunchProfile // version and any classifier. used as the dedup key when merging library // lists from a child profile on top of its parent. fn coord_key(name: &str) -> &str { - // mojang maven coords are `group:artifact:version[:classifier]`. take - // everything up to the second colon. let mut it = name.match_indices(':').map(|(i, _)| i); it.next(); it.next().map_or(name, |i| &name[..i]) diff --git a/src/launch_profile/rules.rs b/src/launch_profile/rules.rs index 1c7ebe7..4c003f6 100644 --- a/src/launch_profile/rules.rs +++ b/src/launch_profile/rules.rs @@ -1,11 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// mojang rule evaluation. profiles, libraries, and argument entries can -// carry conditional rules that filter them by OS, architecture, or feature -// flags. this module is the single source of truth for that semantics - -// see `evaluate` below for the exact rules. - use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)] diff --git a/src/launch_profile/system.rs b/src/launch_profile/system.rs index a8661ef..e6f834d 100644 --- a/src/launch_profile/system.rs +++ b/src/launch_profile/system.rs @@ -1,8 +1,7 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// system-detection helpers shared by launch and install paths. mojang -// names some things differently from rust's std::env::consts (e.g. macOS +// Mojang names some things differently from rust's std::env::consts (e.g. macOS // is "osx" in mojang profile rules), so this module is the single source // of truth for translating. diff --git a/src/launch_profile/templates.rs b/src/launch_profile/templates.rs index 25e9fd6..34ad1d6 100644 --- a/src/launch_profile/templates.rs +++ b/src/launch_profile/templates.rs @@ -1,15 +1,8 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// template substitution for mojang-style launch arguments. profiles use -// `${variable_name}` placeholders that the launcher fills in at launch -// time from the active session: paths, the user's account info, the -// classpath, the resolved natives directory, and so on. -// -// the full set of variables is documented in `TemplateContext`. unknown -// placeholders are left as-is and logged at `warn` level - that way if -// mojang adds a new variable in the future, the launcher fails open -// rather than silently swallowing it. +// Keep unknown placeholders and warn so future Mojang variables remain visible +// instead of silently disappearing. use std::path::Path; diff --git a/src/launch_profile/tests/model.rs b/src/launch_profile/tests/model.rs index 1c98571..68b99fc 100644 --- a/src/launch_profile/tests/model.rs +++ b/src/launch_profile/tests/model.rs @@ -95,12 +95,10 @@ fn parses_modern_arguments_object() { assert_eq!(args.game.len(), 3); assert_eq!(args.jvm.len(), 2); - // first game arg should be a literal "--username" match &args.game[0] { Argument::Literal(s) => assert_eq!(s, "--username"), _ => panic!("expected literal"), } - // third game arg should be a conditional with a single-string value match &args.game[2] { Argument::Conditional { rules, value } => { assert_eq!(rules.len(), 1); @@ -109,7 +107,6 @@ fn parses_modern_arguments_object() { } _ => panic!("expected conditional"), } - // second jvm arg should be a conditional with a multi-string value match &args.jvm[1] { Argument::Conditional { value, .. } => { assert!(matches!(value, ArgumentValue::Multiple(_))); diff --git a/src/launch_profile/tests/render.rs b/src/launch_profile/tests/render.rs index 1bb3dec..37fc962 100644 --- a/src/launch_profile/tests/render.rs +++ b/src/launch_profile/tests/render.rs @@ -239,12 +239,10 @@ async fn end_to_end_resolve_then_render_modern_forge_shape() { let fx = Fixture::new(); let rendered = render_args(&merged, &fx.rule_ctx(), &fx.template_ctx()).unwrap(); - // child main_class wins after merge assert_eq!( rendered.main_class, "cpw.mods.bootstraplauncher.BootstrapLauncher" ); - // game args: parent first then child assert_eq!( rendered.game, vec![ @@ -256,7 +254,6 @@ async fn end_to_end_resolve_then_render_modern_forge_shape() { "forge_client" ] ); - // jvm args: parent first then child assert_eq!( rendered.jvm, vec![ diff --git a/src/launch_profile/tests/resolve.rs b/src/launch_profile/tests/resolve.rs index f3bd408..2eaadaf 100644 --- a/src/launch_profile/tests/resolve.rs +++ b/src/launch_profile/tests/resolve.rs @@ -54,7 +54,6 @@ fn merge_carries_parent_inherits_from() { #[test] fn merge_with_root_parent_clears_inherits_from() { - // parent with no inherits_from means the chain ends. let mut child = empty_profile("child"); child.inherits_from = Some("parent".into()); let parent = empty_profile("parent"); @@ -109,8 +108,6 @@ fn child_library_supersedes_parent_with_same_group_artifact() { ]; let merged = merge_into(child, parent); let names: Vec<_> = merged.libraries.iter().map(|l| l.name.as_str()).collect(); - // parent's log4j-core is filtered (superseded by child); parent's - // lwjgl stays (no conflict); child's log4j and forge come last. assert_eq!( names, vec![ @@ -128,12 +125,10 @@ fn coord_key_extracts_group_artifact() { coord_key("org.apache.logging.log4j:log4j-core:2.17.0"), "org.apache.logging.log4j:log4j-core" ); - // with classifier assert_eq!( coord_key("org.lwjgl:lwjgl:3.3.1:natives-linux"), "org.lwjgl:lwjgl" ); - // malformed (no colons) - return as-is assert_eq!(coord_key("malformed"), "malformed"); } @@ -346,7 +341,6 @@ async fn resolve_errors_when_parent_is_invalid_json() { async fn resolve_multi_level_chain_merges_all_parents() { let tmp = TempDir::new().unwrap(); - // chain: grandchild -> child -> root (vanilla). let mut root = empty_profile("1.20.1"); root.main_class = Some("net.minecraft.client.main.Main".into()); root.libraries = vec![lib("vanilla-lib")]; @@ -368,7 +362,6 @@ async fn resolve_multi_level_chain_merges_all_parents() { resolved.main_class.as_deref(), Some("net.minecraft.client.main.Main") ); - // libs: root ++ child ++ grandchild (each parent prepended) let names: Vec<_> = resolved.libraries.iter().map(|l| l.name.as_str()).collect(); assert_eq!(names, vec!["vanilla-lib", "forge-lib", "modpack-lib"]); } @@ -377,7 +370,6 @@ async fn resolve_multi_level_chain_merges_all_parents() { async fn resolve_detects_circular_chain() { let tmp = TempDir::new().unwrap(); - // a -> b -> a (cycle) let mut a = empty_profile("a"); a.inherits_from = Some("b".into()); write_profile(tmp.path(), &a); @@ -386,7 +378,6 @@ async fn resolve_detects_circular_chain() { b.inherits_from = Some("a".into()); write_profile(tmp.path(), &b); - // start from a fresh "a" profile that asks to inherit from b let mut entry = empty_profile("a"); entry.inherits_from = Some("b".into()); @@ -401,8 +392,6 @@ async fn resolve_detects_circular_chain() { async fn resolve_caps_depth() { let tmp = TempDir::new().unwrap(); - // build a chain 0 -> 1 -> 2 -> ... -> 10. with cap of 8, hitting 10 - // should fail with DepthExceeded. for i in 0..=10 { let mut p = empty_profile(&format!("v{i}")); if i < 10 { diff --git a/src/launch_profile/tests/rules.rs b/src/launch_profile/tests/rules.rs index 7b10337..9a5058d 100644 --- a/src/launch_profile/tests/rules.rs +++ b/src/launch_profile/tests/rules.rs @@ -53,8 +53,6 @@ fn single_disallow_matching_os_disallows() { #[test] fn allow_without_os_match_disallows_by_default() { - // explicit allow for windows; we are on linux; nothing matches; - // default state remains disallow. let rules = vec![Rule { action: RuleAction::Allow, os: Some(OsCondition { @@ -95,7 +93,6 @@ fn last_matching_rule_wins_when_allow_then_disallow() { features: &features, }; assert!(!evaluate(&rules, &osx_ctx)); - // and on linux: only the first rule matches → still allow. let lin = linux_ctx(&features); assert!(evaluate(&rules, &lin)); } @@ -136,7 +133,6 @@ fn arch_mismatch_blocks_rule() { }]; let features = FeatureSet::default(); let ctx = linux_ctx(&features); - // we are on linux but x86_64, not arm64 → rule does not match. assert!(!evaluate(&rules, &ctx)); } diff --git a/src/lib.rs b/src/lib.rs index 958e8f7..c76783b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,12 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// crate root. main.rs is a thin wrapper that imports the two entry points -// re-exported below; everything else stays crate-private. integration tests -// in tests/ that need to reach in deeper can use `rmcl::auth`, `rmcl::net`, -// etc. directly; cli + migrate stay private because they have nothing -// general to expose. - pub mod auth; mod cli; pub mod config; diff --git a/src/net/curseforge.rs b/src/net/curseforge.rs index 8131252..a76f62d 100644 --- a/src/net/curseforge.rs +++ b/src/net/curseforge.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// curseforge api client. responses are mapped into the same app-facing -// project/version types used by discovery, so the tui stays provider-neutral. - use serde::Deserialize; use crate::instance::{ContentKind, ModLoader}; diff --git a/src/net/fabric.rs b/src/net/fabric.rs index d79d3b5..50a94b0 100644 --- a/src/net/fabric.rs +++ b/src/net/fabric.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// fabric mod loader: fetches loader metadata and downloads libraries -// from fabric's maven. structurally very similar to quilt (they forked). - use std::path::Path; use serde::{Deserialize, Serialize}; @@ -51,9 +48,6 @@ pub async fn fetch_fabric_game_versions(client: &HttpClient) -> Result, } -// forge promotions use keys like "1.20.1-recommended", "1.20.1-latest" -// so this filters by game version prefix and extracts the forge version values pub async fn fetch_forge_versions( client: &HttpClient, game_version: &str, @@ -32,7 +26,6 @@ pub async fn fetch_forge_versions( fetch_forge_versions_from(client, FORGE_PROMOTIONS_URL, game_version).await } -// same as fetch_forge_versions but lets tests point at a wiremock server. pub async fn fetch_forge_versions_from( client: &HttpClient, promotions_url: &str, @@ -58,8 +51,6 @@ pub async fn fetch_forge_versions_from( Ok(versions) } -// extracts unique game versions from the promotion keys by splitting off -// the "-recommended"/"-latest" suffix pub async fn fetch_forge_game_versions(client: &HttpClient) -> Result, NetError> { fetch_forge_game_versions_from(client, FORGE_PROMOTIONS_URL).await } diff --git a/src/net/mod.rs b/src/net/mod.rs index 2561352..0f73a06 100644 --- a/src/net/mod.rs +++ b/src/net/mod.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// networking layer: http client, file downloads, and shared utilities -// for fetching game assets from mojang, mod loaders, and modrinth. - pub mod curseforge; pub mod fabric; pub mod forge; @@ -181,9 +178,6 @@ impl HttpClient { } } -// shared retry envelope around `client.get(url).await? -> decode`. retries -// transient failures (timeouts, connect errors, 5xx) with exponential -// backoff. used by both get_json and get_bytes. async fn get_with_retry(client: &HttpClient, url: &str, decode: F) -> Result where F: Fn(reqwest::Response) -> Fut, @@ -230,9 +224,7 @@ async fn sleep_before_retry(kind: &str, url: &str, attempt: u32, err: &NetError) tokio::time::sleep(std::time::Duration::from_millis(delay)).await; } -// streams a file to disk in chunks, calling progress_cb(downloaded, total) along the way. -// total will be 0 if the server doesn't send content-length, so callers -// should handle that gracefully. retries transient failures with exponential backoff. +// total is 0 without a Content-Length; callers must handle unknown sizes. pub async fn download_file( client: &HttpClient, url: &str, @@ -265,7 +257,6 @@ pub async fn download_file( result } -// single attempt at downloading a file to disk async fn download_file_once( client: &HttpClient, url: &str, diff --git a/src/net/modrinth.rs b/src/net/modrinth.rs index e44b472..7640594 100644 --- a/src/net/modrinth.rs +++ b/src/net/modrinth.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// modrinth api client and provider file downloads. - use serde::Deserialize; use std::collections::HashMap; diff --git a/src/net/mojang.rs b/src/net/mojang.rs index 9268ae0..8c091a1 100644 --- a/src/net/mojang.rs +++ b/src/net/mojang.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// handles all downloads from mojang's servers: version manifests, -// client jars, libraries, and asset objects. this is the core of -// getting vanilla minecraft onto disk. - use std::{ collections::HashMap, path::{Path, PathBuf}, @@ -136,9 +132,6 @@ pub async fn fetch_version_manifest(client: &HttpClient) -> Result Option { use sha1::Digest; use std::io::Read; @@ -187,7 +179,6 @@ fn sha1_hex(path: &Path) -> Option { Some(format!("{:x}", hasher.finalize())) } -// true when the cached file matches mojang's recorded size + sha1. // guards against partial files left by killed downloads: those used to be // trusted forever on the strength of an exists() check alone. size is // checked first so truncated files skip the hashing cost. @@ -282,8 +273,6 @@ pub async fn download_libraries( features: &features, }; - // matches the directory launch passes as java.library.path - // (instance/launch/mod.rs). let natives_dir = crate::storage::MetadataPaths::new(meta_dir) .versions() .join(&meta.id) @@ -383,9 +372,6 @@ pub async fn download_libraries( Ok(()) } -// relative path of a library artifact inside the shared library cache. -// upstream usually records it; fall back to deriving it from the maven -// coordinate when the field is missing/empty. fn library_relative_path(library: &Library, recorded_path: &str) -> Option { if !recorded_path.is_empty() { return Some(recorded_path.to_owned()); @@ -393,8 +379,6 @@ fn library_relative_path(library: &Library, recorded_path: &str) -> Option Result<(), NetError> { let file = std::fs::File::open(jar)?; let mut archive = zip::ZipArchive::new(file) @@ -410,7 +394,6 @@ fn extract_natives(jar: &Path, dest: &Path, exclude: &[String]) -> Result<(), Ne if entry.is_dir() { continue; } - // enclosed_name is None for absolute paths / .. traversal let Some(rel) = entry.enclosed_name() else { tracing::warn!( "Skipping unsafe path in natives jar {}: {}", @@ -443,8 +426,6 @@ pub async fn download_assets( download_assets_from(client, meta, meta_dir, ASSETS_BASE_URL).await } -// same as download_assets but lets tests point at a wiremock server for the -// per-asset CDN downloads. the asset index URL still comes from meta. pub async fn download_assets_from( client: &HttpClient, meta: &VersionMeta, @@ -503,8 +484,6 @@ pub async fn download_assets_from( index }; - // assets are stored by hash with the first 2 chars as a directory prefix, - // e.g. "ab/ab1234..." - same layout mojang uses on their CDN let mut downloads = Vec::new(); for object in asset_index.objects.values() { if object.hash.len() < 2 { @@ -546,9 +525,7 @@ pub async fn download_assets_from( result } -// bounded parallel downloader. spawns up to MAX_CONCURRENT_DOWNLOADS tasks -// and feeds new ones in as each completes. collects errors but keeps going -// so it downloads as much as possible before reporting the first failure. +// Continue other downloads after one fails; report the first error afterward. async fn run_parallel_downloads( client: &HttpClient, downloads: Vec<(String, PathBuf, String)>, diff --git a/src/net/neoforge.rs b/src/net/neoforge.rs index 4fea7e3..a7f7137 100644 --- a/src/net/neoforge.rs +++ b/src/net/neoforge.rs @@ -1,11 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// neoforge: the forge fork that broke away after 1.20.1. -// uses a different versioning scheme where neoforge versions map to -// minecraft versions by dropping the "1." prefix (e.g. MC 1.21 = NF 21.x). -// like forge, installation requires running their installer jar. - use std::path::Path; use serde::Deserialize; @@ -30,15 +25,11 @@ struct NeoForgeMavenVersions { fn game_version_to_neoforge_prefix(game_version: &str) -> Option { let parts: Vec<&str> = game_version.split('.').collect(); match parts.as_slice() { - // "1.21" → prefix "21.0." ["1", minor] => Some(format!("{}.0.", minor)), - // "1.20.4" → prefix "20.4." ["1", minor, patch] => Some(format!("{}.{}.", minor, patch)), - // "26.1.2" → prefix "26.1.2." [major, minor, patch] if leading_u32(major).is_some_and(|major| major >= 26) => { Some(format!("{major}.{minor}.{patch}.")) } - // "26.1" → prefix "26.1." [major, minor] if leading_u32(major).is_some_and(|major| major >= 26) => { Some(format!("{major}.{minor}.")) } @@ -80,7 +71,6 @@ pub async fn fetch_neoforge_versions( fetch_neoforge_versions_from(client, NEOFORGE_API_BASE, game_version).await } -// same as fetch_neoforge_versions but lets tests point at a wiremock server. pub async fn fetch_neoforge_versions_from( client: &HttpClient, api_url: &str, @@ -113,8 +103,6 @@ pub async fn fetch_neoforge_versions_from( Ok(versions) } -// reverse-engineers minecraft versions from neoforge version numbers. -// e.g. neoforge "21.0.x" means MC 1.21, "20.4.x" means MC 1.20.4 pub async fn fetch_neoforge_game_versions( client: &HttpClient, ) -> Result, NetError> { diff --git a/src/net/quilt.rs b/src/net/quilt.rs index 6fed8f1..ed5e977 100644 --- a/src/net/quilt.rs +++ b/src/net/quilt.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// quilt mod loader: fabric fork with a nearly identical metadata API. -// if you're getting deja vu reading this after fabric.rs, that's why. - use std::path::Path; use serde::{Deserialize, Serialize}; @@ -48,8 +45,6 @@ pub async fn fetch_quilt_game_versions(client: &HttpClient) -> Result>>> = LazyLock::new(|| Arc::new(Mutex::new(Vec::new()))); pub(super) static COMPLETED_INSTANCE_SETTINGS_UPDATES: LazyLock>>> = @@ -78,7 +71,6 @@ pub(super) struct ProviderConflictState { pub selected: usize, } -// lifecycle of an error toast animation: slide in -> sit there -> fade out pub(super) enum ErrorEffectState { SlidingIn(Effect, std::time::Instant), Idle, diff --git a/src/tui/event.rs b/src/tui/event.rs index f441843..26930c3 100644 --- a/src/tui/event.rs +++ b/src/tui/event.rs @@ -20,7 +20,6 @@ use crate::feedback::progress; use crate::instance::InstanceManager; impl App { - /// main loop: poll async results and input at ~60Hz, drawing only when state changes pub async fn run(&mut self, terminal: &mut Tui) -> color_eyre::Result<()> { let mut last_draw = std::time::Instant::now() .checked_sub(Duration::from_secs(1)) @@ -30,7 +29,6 @@ impl App { let mut image_redraw_marker = false; while !self.exit { let redraw_requested = crate::feedback::take_redraw_request(); - // check if any popup wizard finished and wants to create/import if let Some(params) = new_instance::take_result() { self.spawn_create(params); } @@ -42,9 +40,6 @@ impl App { self.dismiss_expired_errors(); - // drain all the channels from background tasks. - // every content type has its own pending queue because they each - // get scanned/loaded on separate tokio tasks self.drain_pending_instances(); self.drain_completed_instance_settings_updates(); self.drain_failed_instance_settings_updates(); @@ -543,8 +538,6 @@ impl App { }); } - // polls for input with a 16ms timeout (~60fps). only key presses are handled, - // releases and repeats are ignored thanks to the enhanced keyboard protocol fn handle_events(&mut self) -> color_eyre::Result { match crossterm::event::poll(Duration::from_millis(16)) { Ok(true) => match event::read() { @@ -879,8 +872,6 @@ impl App { }); } - // pops errors from the front of the queue once they've been visible long enough. - // loops because multiple errors could expire in the same frame fn dismiss_expired_errors(&self) { use crate::config::SETTINGS; loop { diff --git a/src/tui/input.rs b/src/tui/input.rs index 262bc7a..f14c32e 100644 --- a/src/tui/input.rs +++ b/src/tui/input.rs @@ -1,11 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// keybindings and input dispatch. -// the general pattern: check which area is focused, give it first crack at the -// keypress, and fall through to global bindings if nobody claimed it. -// vim-style navigation (j/k/g/G) where it makes sense. - use ratatui::crossterm::event::{ KeyCode, KeyEvent, KeyModifiers, MouseButton, MouseEvent, MouseEventKind, }; @@ -415,8 +410,6 @@ impl App { } } - // content area delegates to whichever tab is active. - // worlds use the same list navigation without the toggle if self.focused == FocusedArea::Content && self.content_mode == widgets::content::ContentMode::Installed && let Some(state) = self.active_discovery_state_mut() @@ -956,7 +949,6 @@ impl App { return Ok(()); } - // global keybindings (uppercase = area switch, lowercase = action) match key_event.code { KeyCode::Char('q') => self.exit = true, KeyCode::Esc @@ -1049,7 +1041,6 @@ impl App { } } } - // shift+enter = open .minecraft folder in file manager KeyCode::Enter if self.focused == FocusedArea::Instances && !self.instances_state.search.active @@ -1066,7 +1057,6 @@ impl App { } } } - // plain enter = focus the content area for the selected instance KeyCode::Enter if self.focused == FocusedArea::Instances && !self.instances_state.search.active => @@ -1110,7 +1100,6 @@ impl App { } } } - // esc = kill running instance. brutal but effective KeyCode::Esc if self.focused == FocusedArea::Instances && !self.instances_state.search.active => diff --git a/src/tui/logging.rs b/src/tui/logging.rs index cc968ed..73539c9 100644 --- a/src/tui/logging.rs +++ b/src/tui/logging.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// sets up the tracing subscriber stack: file logging, tui-logger widget, and -// our custom StatusLayer that feeds WARN/ERROR events into the error toast system. -// also keeps an in-memory ring buffer of log lines for the log overlay viewer. - use std::fmt; use std::path::Path; use std::sync::{Arc, Mutex}; @@ -24,7 +20,6 @@ use crate::feedback::errors::{self as error_buffer, ErrorEvent}; const MINECRAFT_LOG_TARGET: &str = "mc_instance"; const DEFAULT_FILE_FILTER: &str = "warn,rmcl=trace"; -// capped at 5000 lines so it doesn't eat all the ram if something goes haywire static APP_LOG_LINES: LazyLock>>> = LazyLock::new(|| Arc::new(Mutex::new(Vec::new()))); @@ -44,8 +39,6 @@ fn push_app_log(line: String) { // returns a WorkerGuard that must be held alive for the duration of the // program, otherwise the file logging thread gets dropped immediately. -// yes, you will spend 30 minutes debugging "why aren't my logs writing" -// before you remember this. ask me how i know. pub fn init() -> WorkerGuard { let log_dir = match dirs_next::cache_dir() { Some(d) => d.join("rmcl"), @@ -118,9 +111,6 @@ fn open_log_writer(log_dir: &Path) -> (NonBlocking, WorkerGuard) { } } -// custom tracing layer that intercepts all log events: -// - everything gets appended to the in-memory log buffer for the overlay viewer -// - WARN and ERROR additionally get pushed as error toasts struct StatusLayer; impl StatusLayer { diff --git a/src/tui/mod.rs b/src/tui/mod.rs index f79d343..52fd44a 100644 --- a/src/tui/mod.rs +++ b/src/tui/mod.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// tui entrypoint: sets up the terminal, runs the app, cleans up on exit. - pub mod app; mod event; mod input; diff --git a/src/tui/render.rs b/src/tui/render.rs index 6aff581..178eea3 100644 --- a/src/tui/render.rs +++ b/src/tui/render.rs @@ -1,11 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// layout and rendering. the main frame is split into: -// left 20%: instance sidebar -// right 80%: title bar + content area + bottom bar (account / details / status) -// popups and error toasts render on top of everything. - use ratatui::{ Frame, layout::{Constraint, Direction, Layout}, @@ -165,7 +160,6 @@ impl App { widgets::popups::global_settings::render(frame, area, state); } - // error toasts stack from the top, each one below the previous let all_errors = error_buffer::peek_all_errors(); self.sync_error_effects(&all_errors); let mut next_y: u16 = 1; @@ -220,8 +214,6 @@ impl App { } } - // full-screen log viewer with search highlighting and auto-scroll. - // auto-sticks to the bottom unless the user scrolled up manually fn render_log_overlay(&mut self, frame: &mut Frame) { use crate::config::theme::{BORDER_STYLE, THEME}; use crate::tui::logging::get_app_logs; @@ -322,8 +314,6 @@ impl App { ); } - // keeps the effect map in sync with current errors: removes effects for - // dismissed errors and creates slide-in effects for new ones fn sync_error_effects(&mut self, events: &[error_buffer::ErrorEvent]) { use crate::config::theme::THEME; let theme = THEME.as_ref(); @@ -348,8 +338,6 @@ impl App { } } - // drives the slide-in / idle / slide-out state machine for each error toast. - // transitions to FadingOut at the configured slide-start time fn render_error_effect( &mut self, frame: &mut Frame, diff --git a/src/tui/tests/widgets/content/discovery.rs b/src/tui/tests/widgets/content/discovery.rs index c7c4d14..6d811a5 100644 --- a/src/tui/tests/widgets/content/discovery.rs +++ b/src/tui/tests/widgets/content/discovery.rs @@ -1428,7 +1428,6 @@ fn confirming_popup_toggles_skip_dependencies_with_s() { assert!(handle_key(&KeyEvent::from(KeyCode::Char('s')), &mut state)); assert!(!state.version_popup.as_ref().unwrap().skip_dependencies); - // Toggling is blocked while loading or installing. state.version_popup.as_mut().unwrap().loading = true; assert!(handle_key(&KeyEvent::from(KeyCode::Char('s')), &mut state)); assert!(!state.version_popup.as_ref().unwrap().skip_dependencies); @@ -1505,7 +1504,6 @@ fn installed_mode_defaults_to_any_game_version() { assert_eq!(state.filters.game_version, GameVersionFilter::Any); assert_eq!(state.active_filter_count(), 0); - // The same Any filter counts as active in discovery mode. state.set_local_mode(false); state.filters.game_version = GameVersionFilter::Any; assert_eq!(state.active_filter_count(), 1); diff --git a/src/tui/tests/widgets/search.rs b/src/tui/tests/widgets/search.rs index eea224b..a6e328a 100644 --- a/src/tui/tests/widgets/search.rs +++ b/src/tui/tests/widgets/search.rs @@ -13,7 +13,6 @@ fn confirm_keeps_query_but_deactivates() { s.confirm(); assert!(!s.active); assert_eq!(s.query, "ab"); - // filter should still match assert!(s.matches("abc")); assert!(!s.matches("xyz")); s.activate(); @@ -29,7 +28,6 @@ fn deactivate_clears_query() { s.deactivate(); assert!(!s.active); assert!(s.query.is_empty()); - // with empty query, everything matches assert!(s.matches("anything")); } diff --git a/src/tui/widgets/account.rs b/src/tui/widgets/account.rs index ff1e843..f6ce5e2 100644 --- a/src/tui/widgets/account.rs +++ b/src/tui/widgets/account.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// account management panel: list, add (microsoft/offline), delete -// microsoft auth uses the device code flow, so it polls a shared mutex -// for the result while showing the user a code to enter in their browser - use std::sync::{Arc, Mutex}; use crossterm::event::{KeyCode, KeyEvent}; @@ -196,8 +192,6 @@ pub fn handle_key(key_event: &KeyEvent, state: &mut AccountState) -> bool { } } -// the device code arrives asynchronously from the auth thread, -// so it gets pulled out of a global mutex once it's ready pub fn drain_device_code(state: &mut AccountState) { if let AddMode::DeviceCodeWaiting { info, .. } = &mut state.add_mode && info.user_code.is_empty() @@ -335,7 +329,6 @@ fn render_account_list( frame.render_stateful_widget(list, area, &mut state.list_state); } -// center a popup of given size within the terminal. nothing fancy fn popup_area(frame: &Frame, width: u16, height: u16) -> Rect { let area = frame.area(); let x = area.x + (area.width.saturating_sub(width)) / 2; diff --git a/src/tui/widgets/content/list.rs b/src/tui/widgets/content/list.rs index 2dd2c95..c4f39b6 100644 --- a/src/tui/widgets/content/list.rs +++ b/src/tui/widgets/content/list.rs @@ -1,11 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// generic scrollable list for content items (mods, resource packs, shaders, worlds). -// supports toggling items on/off by renaming files with .disabled suffix, -// search filtering, per-instance caching, and directory change detection. -// also handles minecraft's formatting codes for colored mod names/descriptions - use std::cell::RefCell; use std::collections::{HashMap, HashSet}; use std::path::Path; @@ -245,7 +240,6 @@ struct PaginationState { const REMOVAL_GRACE: std::time::Duration = std::time::Duration::from_millis(500); -// result from the notify-triggered background diff struct WatcherDiff { toggled: Vec<(String, bool, std::path::PathBuf)>, removed: Vec, @@ -292,19 +286,15 @@ pub struct ContentListState { cache: HashMap, sort_metadata: RefCell>, filtered_cache: RefCell>, - // streaming: individual entries arrive here during initial load stream_rx: Option>, stream_order: ContentStreamOrder, progressive_source_stream: bool, staged_source_updates: Option>, source_order_ready: bool, preview_count: usize, - // file watcher: notify callback spawns background work, - // precomputed diff lands here for the UI to pick up watcher_diff: Arc>>, _watcher: Option, watched_dir: Option, - // stored for the watcher to scan individual new files scan_one_fn: Option, content_ext: Option<&'static str>, pagination: Option, @@ -1175,7 +1165,6 @@ impl ContentListState { }; self.images_dirty |= update.requires_reconcile; - // apply toggles (enabled/path changes) tracing::debug!( "Applying content watcher diff for {}: toggled={} removed={} added={}", self.loaded_for.as_deref().unwrap_or(""), @@ -1214,7 +1203,6 @@ impl ContentListState { .or_insert_with(std::time::Instant::now); } - // insert new entries in sorted position for mut entry in diff.added { self.sort_metadata.get_mut().remove(&entry.path); let replacement = self.entries.iter().position(|existing| { @@ -1310,13 +1298,10 @@ impl ContentListState { removed } - // starts a notify file watcher on the given directory. changes trigger - // a background diff that lands in watcher_diff for drain_watcher to apply. pub fn watch_dir(&mut self, dir: std::path::PathBuf) { use notify::{RecursiveMode, Watcher}; use std::sync::atomic::{AtomicBool, Ordering}; - // drop previous watcher self._watcher = None; let watcher_diff = self.watcher_diff.clone(); @@ -1706,9 +1691,6 @@ impl ContentListState { } } - // saves current entries to cache before loading new ones, and restores - // from cache if this instance was seen before (avoids re-scanning). - // content_dir is the actual directory to scan (e.g. .minecraft/mods). pub fn start_load( &mut self, content_dir: &Path, @@ -1724,7 +1706,6 @@ impl ContentListState { self.pending_entry_images.clear(); self.pending_removals.clear(); - // save current entries to cache if let Some(prev) = self.loaded_for.take() && !self.entries.is_empty() { @@ -1743,7 +1724,6 @@ impl ContentListState { ); } - // try cache first // files modified while another instance was active become a real problem. if let Some(cached) = self.cache.remove(instance_name) { self.entries = cached.entries; @@ -1769,7 +1749,6 @@ impl ContentListState { return; } - // no cache, stream entries one by one as each file is scanned let stream = self.start_stream(instance_name); let dir = content_dir.to_path_buf(); @@ -2690,8 +2669,6 @@ fn searchable_spans( } } -// parses minecraft's section-sign (U+00A7) formatting codes into styled spans. -// handles colors (0-f), bold (l), strikethrough (m), underline (n), italic (o), reset (r) fn parse_mc_text(text: &str, base_style: Style) -> Vec> { let mut spans = Vec::new(); let mut current_style = base_style; @@ -2976,10 +2953,6 @@ fn watcher_event_handling(kind: ¬ify::EventKind) -> WatcherEventHandling { } } -// reads a content directory and builds a stem -> (path, enabled) map. -// used both by watch_dir to initialize known state and by the watcher -// thread to detect changes. when ext is empty (worlds), only directories -// are included. fn diff_directory( dir: &std::path::Path, ext: &str, diff --git a/src/tui/widgets/content/mod.rs b/src/tui/widgets/content/mod.rs index d580c42..9068b77 100644 --- a/src/tui/widgets/content/mod.rs +++ b/src/tui/widgets/content/mod.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// the tabbed content area: mods, resource packs, shaders, screenshots, worlds, logs - pub mod discovery; pub mod list; pub mod tabs; diff --git a/src/tui/widgets/content/tabs.rs b/src/tui/widgets/content/tabs.rs index 846b4ca..6e49e07 100644 --- a/src/tui/widgets/content/tabs.rs +++ b/src/tui/widgets/content/tabs.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// the outer frame for the content area: tab bar, keybind footer, -// and dispatching render calls to the active tab's widget. -// also renders the instance name/version header with run state indicators. - use ratatui::{ Frame, layout::{Alignment, Constraint, Direction, Layout, Margin, Rect}, @@ -357,8 +353,6 @@ pub fn render( _ => false, }; - // keybinds change depending on which tab is active and whether - // the content panel or instances panel has focus let kb: Option<&[(&str, &str)]> = if is_focused { Some(match (mode, tab) { (ContentMode::Discover, _) if discovery_unavailable => { @@ -1762,8 +1756,6 @@ fn discovery_version_label(version: &crate::net::modrinth::VersionInfo) -> Strin version.version_number.clone() } -// the header bar above the content tabs, showing instance name, loader info, -// and a spinner/error indicator when the instance is running or crashed pub fn title( frame: &mut Frame, area: Rect, diff --git a/src/tui/widgets/instances.rs b/src/tui/widgets/instances.rs index d59381d..e4ee452 100644 --- a/src/tui/widgets/instances.rs +++ b/src/tui/widgets/instances.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// the instance list on the left side of the UI. -// handles search/filter, scrollbar sync, and inline renaming. -// each row shows instance name + "last played" or current run state. - use crate::config::theme::{BORDER_STYLE, THEME}; use crossterm::event::KeyCode; use ratatui::{ diff --git a/src/tui/widgets/logs_viewer.rs b/src/tui/widgets/logs_viewer.rs index 229b8a1..8555958 100644 --- a/src/tui/widgets/logs_viewer.rs +++ b/src/tui/widgets/logs_viewer.rs @@ -1,11 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// split-pane log viewer: file list on the left, log content on the right. -// supports live log tailing when the instance is running, plus search -// filtering in both the file list and the viewer pane. -// log scanning runs on a background thread to avoid blocking the UI. - use std::path::Path; use std::sync::{Arc, Mutex}; @@ -132,7 +127,6 @@ impl LogsState { } } - // periodically re-scan log files in case new ones appeared while playing. pub fn try_rescan(&mut self) { if self.last_rescan.elapsed() < std::time::Duration::from_secs(2) { return; @@ -676,8 +670,6 @@ fn log_level_style(level: LogLevel) -> Style { } } -// color-code log lines by severity so errors actually stand out -// instead of drowning in a wall of white text fn line_level_style(line: &str) -> Style { let theme = THEME.as_ref(); let upper = line.to_uppercase(); diff --git a/src/tui/widgets/mod.rs b/src/tui/widgets/mod.rs index b00cba9..faf4607 100644 --- a/src/tui/widgets/mod.rs +++ b/src/tui/widgets/mod.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// shared widget utilities and the trait all key-handling widgets implement - use crate::config::theme::THEME; use crossterm::event::KeyEvent; use ratatui::{ diff --git a/src/tui/widgets/popups/base.rs b/src/tui/widgets/popups/base.rs index d008657..a54771c 100644 --- a/src/tui/widgets/popups/base.rs +++ b/src/tui/widgets/popups/base.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// base frame that all popups render inside. handles the border, title bar, -// keybind footer, and optional search indicator. content is injected via closure -// so each popup type only worries about its inner area. - use ratatui::{ buffer::{Buffer, CellDiffOption}, layout::{Alignment, Rect}, @@ -40,7 +36,6 @@ impl<'a> Widget for PopupFrame<'a> { }) .collect::>(); - // clear first so the popup doesn't layer on top of whatever was underneath Clear.render(area, buf); if let Some(bg) = self.bg { diff --git a/src/tui/widgets/popups/confirm.rs b/src/tui/widgets/popups/confirm.rs index 2ad0189..36906b5 100644 --- a/src/tui/widgets/popups/confirm.rs +++ b/src/tui/widgets/popups/confirm.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// "are you sure?" popup for destructive actions. uses global state so the -// confirmation target persists across render frames. - use std::sync::LazyLock; use std::sync::Mutex; diff --git a/src/tui/widgets/popups/error.rs b/src/tui/widgets/popups/error.rs index ee8cb08..7af910a 100644 --- a/src/tui/widgets/popups/error.rs +++ b/src/tui/widgets/popups/error.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// toast-style error/warning popup that auto-dismisses after a timeout. -// stacks in the top-right corner; border color changes based on severity. - use ratatui::{ buffer::Buffer, layout::Rect, @@ -66,8 +63,6 @@ impl Widget for ErrorPopup { } } -// returns None when the toast has lived past its expiry, which is -// what triggers removal from the render loop pub fn popup_area(frame_area: Rect, message: &str, base_y: u16, elapsed_ms: u128) -> Option { use super::word_wrap_size; diff --git a/src/tui/widgets/popups/global_settings.rs b/src/tui/widgets/popups/global_settings.rs index 9593c62..61a04b5 100644 --- a/src/tui/widgets/popups/global_settings.rs +++ b/src/tui/widgets/popups/global_settings.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// modal editor for launcher-wide settings. - use crossterm::event::{KeyCode, KeyEvent}; use ratatui::{ Frame, diff --git a/src/tui/widgets/popups/import_modpack/render.rs b/src/tui/widgets/popups/import_modpack/render.rs index ba6cb43..f9e40b3 100644 --- a/src/tui/widgets/popups/import_modpack/render.rs +++ b/src/tui/widgets/popups/import_modpack/render.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// rendering for the modpack import wizard. same pattern as new_instance: -// snapshot the state, pick the right step renderer, done. - use super::super::LoadState; use super::super::base::PopupFrame; use super::state::{DISCOVERY_STATE, IMPORT_STATE, ImportStep, ImportWizardState}; diff --git a/src/tui/widgets/popups/import_modpack/state.rs b/src/tui/widgets/popups/import_modpack/state.rs index 197a1b1..a49167a 100644 --- a/src/tui/widgets/popups/import_modpack/state.rs +++ b/src/tui/widgets/popups/import_modpack/state.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// state machine for the modpack import wizard. -// browses modpacks from configured providers and keeps the archive import flow -// for modrinth URLs, project slugs, version IDs, and local pack archives. - use super::super::LoadState; use crate::instance::import::{ImportInput, ImportSummary, parse_import_input}; use crate::net::modrinth::{self, VersionInfo}; @@ -387,7 +383,6 @@ fn handle_confirm_key( } } -// pushes an error toast and rewinds the wizard to a previous step fn update_current_request( state_arc: &Arc>, request_id: u64, @@ -419,8 +414,6 @@ fn begin_import_request(state: &mut ImportWizardState) -> u64 { request_id } -// parses user input to figure out what they gave us, then dispatches -// to the appropriate resolve path (slug lookup, direct version, or local file) fn start_resolve(state: &mut ImportWizardState) { let input_text = state.input.clone(); state.step = ImportStep::Fetching; @@ -559,8 +552,6 @@ fn resolve_local_file(state_arc: Arc>, request_id: u64, } } -// user picked a version from the list. download the .mrpack, -// build a summary, and move to confirm. fn start_version_download(state: &mut ImportWizardState) { let version = match selected_version(state) { Some(v) => v.clone(), diff --git a/src/tui/widgets/popups/instance_settings.rs b/src/tui/widgets/popups/instance_settings.rs index 48e0905..249dad8 100644 --- a/src/tui/widgets/popups/instance_settings.rs +++ b/src/tui/widgets/popups/instance_settings.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// modal editor for settings belonging to the selected Minecraft instance. - use crossterm::event::{KeyCode, KeyEvent}; use ratatui::{ Frame, diff --git a/src/tui/widgets/popups/mod.rs b/src/tui/widgets/popups/mod.rs index 9cf6889..890d43a 100644 --- a/src/tui/widgets/popups/mod.rs +++ b/src/tui/widgets/popups/mod.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// shared utilities for popup widgets: layout helpers, word wrapping, keybind rendering. -// individual popup types live in their own submodules. - pub mod base; pub mod confirm; pub mod error; @@ -41,8 +38,6 @@ pub(crate) fn compare_game_versions(a: &str, b: &str) -> std::cmp::Ordering { a_parts.len().cmp(&b_parts.len()) } -// figures out the (width, height) a text block will need after word wrapping. -// used to size popups before rendering so they fit their content snugly. pub fn word_wrap_size(text: &str, max_inner_width: usize) -> (usize, usize) { if text.is_empty() || max_inner_width == 0 { return (0, 1); diff --git a/src/tui/widgets/popups/new_instance/render.rs b/src/tui/widgets/popups/new_instance/render.rs index 2e50f21..ab5f2f7 100644 --- a/src/tui/widgets/popups/new_instance/render.rs +++ b/src/tui/widgets/popups/new_instance/render.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// rendering for the new instance wizard. each step gets its own render fn -// and the popup resizes itself based on which step is active. - use super::super::LoadState; use super::state::{ WIZARD_STATE, WizardState, WizardStep, clamp_loader_version_index, clamp_version_index, @@ -33,7 +30,6 @@ pub fn render(frame: &mut Frame, area: Rect, _focused: FocusedArea) { clamp_version_index(&mut state); } - // vanilla has no loader version, so skip straight to confirm if state.step == WizardStep::LoaderVersion { if state.selected_loader() == ModLoader::Vanilla { state.step = WizardStep::Confirm; @@ -141,7 +137,6 @@ fn step_keybinds(state: &WizardState) -> ratatui::text::Line<'static> { fn render_name_step(state: &WizardState, area: Rect, buf: &mut ratatui::buffer::Buffer) { let theme = THEME.as_ref(); let value = state.name_state.value(); - // \u{2588} is the full block char used as a fake blinking cursor let line = if value.is_empty() { Line::from(vec![ Span::styled("Instance name...", Style::default().fg(theme.text_dim())), diff --git a/src/tui/widgets/popups/new_instance/state.rs b/src/tui/widgets/popups/new_instance/state.rs index 7afe6aa..ac37d4c 100644 --- a/src/tui/widgets/popups/new_instance/state.rs +++ b/src/tui/widgets/popups/new_instance/state.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// state machine and input handling for the new instance wizard. -// flow: Name -> Loader -> Version -> LoaderVersion -> Confirm -// version lists are fetched lazily from the network when you reach that step. - use crate::instance::{loader::GameVersion, models::ModLoader}; use crate::tui::widgets::instances; use crossterm::event::{KeyCode, KeyEvent}; @@ -16,7 +12,6 @@ use super::super::LoadState; pub(crate) static WIZARD_STATE: LazyLock>> = LazyLock::new(|| Arc::new(Mutex::new(WizardState::default()))); -// populated on confirm, consumed by the main event loop to actually create the instance pub(crate) static WIZARD_RESULT: LazyLock>>> = LazyLock::new(|| Arc::new(Mutex::new(None))); @@ -163,7 +158,6 @@ fn handle_version_key( key_event: &KeyEvent, instances_state: &mut instances::State, ) { - // Search mode: route char input to search query if state.version_search.active { match key_event.code { KeyCode::Esc => { @@ -176,12 +170,8 @@ fn handle_version_key( clamp_version_index(state); return; } - KeyCode::Char('j') | KeyCode::Down => { - // fall through to navigation below - } - KeyCode::Char('k') | KeyCode::Up => { - // fall through to navigation below - } + KeyCode::Char('j') | KeyCode::Down => {} + KeyCode::Char('k') | KeyCode::Up => {} KeyCode::Char(c) => { state.version_search.push(c); state.version_idx = 0; // reset to top of filtered list @@ -384,8 +374,7 @@ pub(crate) fn clamp_loader_version_index(state: &mut WizardState) { } } -// only fires on the Idle -> Loading transition to avoid spamming requests. -// the spawned task writes results back into WIZARD_STATE when done. +// Spawn only on Idle -> Loading to avoid repeating network requests per frame. pub(crate) fn ensure_versions_loaded(state: &mut WizardState) { if !matches!(state.versions, LoadState::Idle) { return; diff --git a/src/tui/widgets/popups/select_list.rs b/src/tui/widgets/popups/select_list.rs index d7b3f22..fcfa8a5 100644 --- a/src/tui/widgets/popups/select_list.rs +++ b/src/tui/widgets/popups/select_list.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// Shared selection list used by the new-instance wizard and settings pickers. - use ratatui::{ buffer::Buffer, layout::Rect, diff --git a/src/tui/widgets/popups/settings_controls.rs b/src/tui/widgets/popups/settings_controls.rs index 3d0b798..921e33a 100644 --- a/src/tui/widgets/popups/settings_controls.rs +++ b/src/tui/widgets/popups/settings_controls.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// Reusable interactive controls shared by instance and launcher settings. - use std::{ collections::{BTreeMap, BTreeSet}, path::{Path, PathBuf}, diff --git a/src/tui/widgets/popups/version_lists.rs b/src/tui/widgets/popups/version_lists.rs index fdafbb5..24b7677 100644 --- a/src/tui/widgets/popups/version_lists.rs +++ b/src/tui/widgets/popups/version_lists.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// shared network loading for Minecraft and mod-loader version pickers. - use crate::instance::{ loader::{GameVersion, get_installer}, models::ModLoader, diff --git a/src/tui/widgets/screenshots_grid.rs b/src/tui/widgets/screenshots_grid.rs index 4d6bba4..21e5381 100644 --- a/src/tui/widgets/screenshots_grid.rs +++ b/src/tui/widgets/screenshots_grid.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// responsive grid of screenshot thumbnails rendered directly in the terminal. -// images load lazily on background threads as they scroll into view, -// and get converted to terminal graphics via ratatui-image protocols. - use std::collections::{HashMap, HashSet}; use std::path::Path; use std::sync::{Arc, Mutex}; @@ -23,8 +19,6 @@ use unicode_segmentation::UnicodeSegmentation; use crate::config::theme::THEME; use crate::instance::screenshots::ScreenshotEntry; -// grid cell sizing constraints in terminal columns. -// the grid auto-fits columns within these bounds depending on terminal width const TARGET_CELL_WIDTH: u16 = 34; const MIN_CELL_WIDTH: u16 = 24; const MAX_CELL_WIDTH: u16 = 52; @@ -373,9 +367,7 @@ pub fn render(frame: &mut Frame, area: Rect, state: &mut ScreenshotsState, is_fo let cols = target_cols.clamp(min_cols, max_cols); let cell_width = area.width / cols as u16; - // figure out how tall each thumbnail should be in terminal rows. - // need the font's pixel aspect ratio to keep screenshots from - // looking stretched since terminal cells aren't square + // Terminal cells are not square; use the font's aspect ratio to avoid stretching. let (img_w, img_h) = state .entries .first() diff --git a/src/tui/widgets/search.rs b/src/tui/widgets/search.rs index edc9459..4b54685 100644 --- a/src/tui/widgets/search.rs +++ b/src/tui/widgets/search.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// reusable incremental search state used across multiple widgets. -// handles case-insensitive filtering and inline match highlighting. - use crossterm::event::KeyModifiers; use ratatui::{ style::{Modifier, Style}, @@ -53,8 +50,6 @@ impl SearchState { text.to_lowercase().contains(&self.query.to_lowercase()) } - // splits text into spans, bolding+underlining the parts that match - // the query so every searchable widget can use the same styling pub fn highlight_spans(&self, text: &str, base_style: Style) -> Vec> { if self.query.is_empty() { return vec![Span::styled(text.to_owned(), base_style)]; @@ -94,7 +89,6 @@ impl SearchState { Line::from(self.highlight_spans(text, base_style)) } - // renders the "/ query█" indicator in the block title bar pub fn title_line(&self) -> Option> { if !self.active && self.query.is_empty() { return None; diff --git a/src/tui/widgets/settings.rs b/src/tui/widgets/settings.rs index 206cbe0..492e69f 100644 --- a/src/tui/widgets/settings.rs +++ b/src/tui/widgets/settings.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// settings panel: manages config profiles and shows compact instance info. -// detailed instance and launcher configuration opens in the TUI popups. - use std::path::{Path, PathBuf}; use crossterm::event::{KeyCode, KeyEvent}; diff --git a/src/tui/widgets/status.rs b/src/tui/widgets/status.rs index 2065a54..99d7cdb 100644 --- a/src/tui/widgets/status.rs +++ b/src/tui/widgets/status.rs @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// the "overview" panel showing download/install progress. -// shows a gauge when the total is known, or a spinner when it's not. - use ratatui::{ Frame, layout::{Constraint, Layout, Rect}, diff --git a/tests/content_scanners.rs b/tests/content_scanners.rs index 71ed055..9e60b39 100644 --- a/tests/content_scanners.rs +++ b/tests/content_scanners.rs @@ -1,11 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// integration tests for the public content-scanner APIs: shaders, worlds, -// and resource packs. each scanner walks an instance's minecraft subdir -// and returns ContentEntry rows; shape varies slightly per content type -// (worlds are directories only, packs and shaders accept .zip or dir, etc.). - use std::path::{Path, PathBuf}; use rmcl::instance::content::resource_packs::scan_resource_packs; diff --git a/tests/launch_pipeline.rs b/tests/launch_pipeline.rs index b51d76f..e235c78 100644 --- a/tests/launch_pipeline.rs +++ b/tests/launch_pipeline.rs @@ -1,12 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// integration tests for build_launch_invocation - the seam that takes an -// instance config plus resolved auth credentials and returns the full java -// invocation that would be spawned. these tests build the expected on-disk -// fixture layout in a tempdir, call the seam, and assert on the rendered -// LaunchInvocation. nothing here actually spawns a process. - use std::path::{Path, PathBuf}; use chrono::Utc; @@ -18,8 +12,6 @@ use rmcl::instance::launch::{ }; use rmcl::instance::models::{InstanceConfig, ModLoader}; -// ---------- helpers ---------- - const PLAYER: &str = "TestPlayer"; const PLAYER_UUID: &str = "00000000-0000-0000-0000-000000000001"; const PLAYER_TOKEN: &str = "secret-access-token"; @@ -86,11 +78,6 @@ fn fake_java(tmp: &TempDir, major: u32) -> String { path.to_string_lossy().into_owned() } -// builds the on-disk layout that build_launch_invocation expects: -// /instances//minecraft/ (instance dir, created empty) -// /meta/versions//meta.json -// /meta/cache/loaders/profiles/ (created empty) -// /meta/libraries/ (created empty) struct Fixture { _tmp: TempDir, instances_dir: PathBuf, @@ -208,8 +195,6 @@ fn platform_classpath_sep() -> &'static str { if cfg!(windows) { ";" } else { ":" } } -// ---------- vanilla ---------- - #[tokio::test] async fn vanilla_modern_builds_complete_invocation() { let fx = Fixture::new("v1", "1.20.1", modern_vanilla_meta("1.20.1")); @@ -247,12 +232,10 @@ async fn vanilla_modern_builds_complete_invocation() { inv.jvm_args ); - // working_dir is //minecraft assert_eq!( inv.working_dir, fx.instances_dir.join("v1").join("minecraft") ); - // classpath = the one vanilla lib + the vanilla client jar let slf4j = fx .meta_dir .join("cache/minecraft/libraries/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar"); @@ -339,12 +322,10 @@ async fn vanilla_legacy_args_format_substitutes_tokens() { assert_eq!(inv.main_class, "net.minecraft.launchwrapper.Launch"); - // legacy format has no upstream jvm args; jvm_args should be just Xms/Xmx assert_eq!(inv.jvm_args.len(), 2); assert!(inv.jvm_args[0].starts_with("-Xms")); assert!(inv.jvm_args[1].starts_with("-Xmx")); - // game_args should be space-split with substitutions applied let joined = inv.game_args.join(" "); assert!(joined.contains(&format!("--username {}", PLAYER))); assert!(joined.contains(&format!("--uuid {}", PLAYER_UUID))); @@ -352,8 +333,6 @@ async fn vanilla_legacy_args_format_substitutes_tokens() { assert!(joined.contains("--userType msa")); } -// ---------- forge ---------- - #[tokio::test] async fn forge_modern_includes_add_opens() { let fx = Fixture::new("f1", "1.20.1", modern_vanilla_meta("1.20.1")); @@ -444,7 +423,6 @@ async fn forge_local_lib_dir_preferred_over_meta_dir() { "expected local fmlloader on classpath: {:?}", inv.classpath ); - // and the meta-dir candidate should not appear let meta_candidate = fx .meta_dir .join("libraries/net/minecraftforge/fmlloader/1.20.1-47.2.0/fmlloader-1.20.1-47.2.0.jar"); @@ -454,8 +432,6 @@ async fn forge_local_lib_dir_preferred_over_meta_dir() { ); } -// ---------- fabric ---------- - #[tokio::test] async fn fabric_implicit_inheritsfrom_resolves() { let fx = Fixture::new("fab", "1.20.1", modern_vanilla_meta("1.20.1")); @@ -482,7 +458,6 @@ async fn fabric_implicit_inheritsfrom_resolves() { inv.main_class, "net.fabricmc.loader.impl.launch.knot.KnotClient" ); - // both fabric-loader and vanilla slf4j must appear on the merged classpath let fabric_loader = fx.meta_dir.join( "cache/minecraft/libraries/net/fabricmc/fabric-loader/0.15.0/fabric-loader-0.15.0.jar", ); @@ -501,8 +476,6 @@ async fn fabric_implicit_inheritsfrom_resolves() { ); } -// ---------- neoforge ---------- - #[tokio::test] async fn neoforge_inheritsfrom_resolves() { let fx = Fixture::new("ne", "1.20.6", modern_vanilla_meta("1.20.6")); @@ -541,8 +514,6 @@ async fn neoforge_inheritsfrom_resolves() { ); } -// ---------- template substitution ---------- - #[tokio::test] async fn auth_credentials_substituted_in_game_args() { let fx = Fixture::new("auth", "1.20.1", modern_vanilla_meta("1.20.1")); @@ -576,7 +547,6 @@ async fn auth_credentials_substituted_in_game_args() { #[tokio::test] async fn version_type_substituted() { - // type = "snapshot" in the fixture; ${version_type} should render that let mut meta = modern_vanilla_meta("1.20.1"); meta["type"] = json!("snapshot"); let fx = Fixture::new("vt", "1.20.1", meta); @@ -593,8 +563,6 @@ async fn version_type_substituted() { ); } -// ---------- classpath ---------- - #[tokio::test] async fn classpath_uses_platform_separator() { let fx = Fixture::new("cp", "1.20.1", modern_vanilla_meta("1.20.1")); @@ -604,7 +572,6 @@ async fn classpath_uses_platform_separator() { .await .unwrap(); - // with two classpath entries we should see exactly one separator assert_eq!(inv.classpath.len(), 2); let sep = platform_classpath_sep(); assert_eq!(inv.classpath_string.matches(sep).count(), 1); @@ -612,7 +579,6 @@ async fn classpath_uses_platform_separator() { #[tokio::test] async fn rule_disallow_excludes_library() { - // a library whose rule always denies must not appear on the classpath let mut meta = modern_vanilla_meta("1.20.1"); meta["libraries"] = json!([ { @@ -654,8 +620,6 @@ async fn rule_disallow_excludes_library() { ); } -// ---------- memory ---------- - #[tokio::test] async fn xms_xmx_use_config_memory() { let fx = Fixture::new("mem", "1.20.1", modern_vanilla_meta("1.20.1")); @@ -707,7 +671,6 @@ async fn instance_launch_options_are_injected() { async fn default_memory_used_when_unset() { let fx = Fixture::new("memdef", "1.20.1", modern_vanilla_meta("1.20.1")); let config = make_config("memdef", "1.20.1", ModLoader::Vanilla); - // memory_min and memory_max default to None in make_config let inv = build_launch_invocation(&config, &fx.instances_dir, &fx.meta_dir, &test_auth(), None) .await @@ -717,8 +680,6 @@ async fn default_memory_used_when_unset() { assert!(inv.jvm_args.iter().any(|a| a == "-Xmx2G")); } -// ---------- error paths ---------- - #[tokio::test] async fn meta_not_found_returns_error() { let tmp = tempfile::tempdir().unwrap(); diff --git a/tests/log_files.rs b/tests/log_files.rs index b0ee3ef..25ff954 100644 --- a/tests/log_files.rs +++ b/tests/log_files.rs @@ -1,10 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// integration tests for the public log files API. -// these tests touch the filesystem and exercise the module as an external -// consumer would. - use std::path::{Path, PathBuf}; use rmcl::instance::logs::files::{create_log_file, log_dir, read_log_file, scan_log_files}; diff --git a/tests/net_loaders.rs b/tests/net_loaders.rs index ac3383c..ab7a6f1 100644 --- a/tests/net_loaders.rs +++ b/tests/net_loaders.rs @@ -1,11 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// integration tests for the loader-specific net::* fetchers (forge, -// fabric, quilt, neoforge). each module's fetch_* function now has a -// _from variant that lets the test point the HTTP call at a wiremock -// server; the production constants stay unchanged. - use serde_json::json; use wiremock::matchers::{method, path}; use wiremock::{Mock, MockServer, ResponseTemplate}; @@ -20,8 +15,6 @@ use rmcl::net::quilt::{ fetch_quilt_game_versions_from, fetch_quilt_profile_from, fetch_quilt_versions_from, }; -// ---------- forge ---------- - #[tokio::test] async fn forge_fetch_versions_filters_by_prefix() { let server = MockServer::start().await; @@ -67,12 +60,9 @@ async fn forge_fetch_game_versions_extracts_unique() { .expect("forge game versions"); let ids: Vec<&str> = versions.iter().map(|v| v.id.as_str()).collect(); - // dedup + reverse-sort assert_eq!(ids, vec!["1.20.1", "1.19.4"]); } -// ---------- fabric ---------- - #[tokio::test] async fn fabric_fetch_game_versions_parses_response() { let server = MockServer::start().await; @@ -146,8 +136,6 @@ async fn fabric_fetch_profile_parses_libraries() { assert_eq!(profile.libraries[0].url, "https://maven.fabricmc.net/"); } -// ---------- quilt ---------- - #[tokio::test] async fn quilt_fetch_game_versions_parses_response() { let server = MockServer::start().await; @@ -208,8 +196,6 @@ async fn quilt_fetch_profile_parses_libraries() { ); } -// ---------- neoforge ---------- - #[tokio::test] async fn neoforge_fetch_versions_filters_by_prefix() { let server = MockServer::start().await; @@ -292,7 +278,6 @@ async fn neoforge_fetch_game_versions_reverse_engineers_mc_versions() { assert!(ids.contains(&"26.1.1")); assert!(ids.contains(&"1.21")); assert!(ids.contains(&"1.20.4")); - // both versions should be marked stable (no snapshot flag in maven) assert!(versions.iter().all(|v| v.stable)); } @@ -300,7 +285,6 @@ async fn neoforge_fetch_game_versions_reverse_engineers_mc_versions() { async fn neoforge_fetch_versions_rejects_invalid_game_version() { let server = MockServer::start().await; let url = format!("{}/maven-api", server.uri()); - // no mock - the function should error out before hitting the network let err = fetch_neoforge_versions_from(&HttpClient::new(), &url, "bogus") .await .expect_err("invalid game version"); diff --git a/tests/net_mojang.rs b/tests/net_mojang.rs index 4882640..afa09e4 100644 --- a/tests/net_mojang.rs +++ b/tests/net_mojang.rs @@ -1,12 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// integration tests for the public mojang fetchers. wiremock stands in for -// Mojang so tests are fast, deterministic, and don't depend on the live -// endpoint. these are different from the #[ignore = "hits live Mojang API"] -// tests in tests/live_apis.rs which verify the upstream schema hasn't drifted; -// these here verify our parsing + retry envelope on synthetic responses. - use serde_json::json; use wiremock::matchers::{method, path}; use wiremock::{Mock, MockServer, ResponseTemplate}; @@ -112,8 +106,6 @@ async fn fetch_version_meta_returns_struct_and_raw_bytes() { assert_eq!(meta.downloads.client.size, 12345); assert_eq!(meta.java_version.unwrap().major_version, 17); - // the raw bytes must parse back to the same struct - verifies the - // get_json_with_raw plumbing actually captures the upstream body intact. let reparsed: serde_json::Value = serde_json::from_slice(&raw).expect("raw is json"); assert_eq!(reparsed["id"], "1.20.1"); assert_eq!(reparsed["mainClass"], "net.minecraft.client.main.Main"); @@ -214,7 +206,6 @@ async fn download_libraries_skips_when_destination_exists() { .await .expect("noop succeeds"); - // file untouched, mock untouched (server drop will panic if it isn't) assert_eq!(std::fs::read(&existing).unwrap(), b"already there"); } diff --git a/tests/net_retry.rs b/tests/net_retry.rs index 148c706..ec2d4ec 100644 --- a/tests/net_retry.rs +++ b/tests/net_retry.rs @@ -1,12 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// integration tests for the retry envelope in src/net/mod.rs. wiremock -// stands in for live upstream APIs so we can assert that 5xx responses -// retry, 4xx responses fail fast, and the cap (MAX_RETRIES = 3, total -// 4 attempts) is honoured. these tests exercise public HttpClient methods, -// not the private retry helper directly. -// // Tokio time is paused in retrying tests so the production backoff remains // covered without adding wall-clock delay to the suite. @@ -32,14 +26,11 @@ fn client_without_timeout() -> HttpClient { reqwest::Client::builder().build().unwrap().into() } -// ---------- get_json (via get_with_retry) ---------- - #[tokio::test(start_paused = true)] async fn get_json_retries_5xx_then_succeeds() { let server = MockServer::start().await; let attempts = Arc::new(AtomicUsize::new(0)); - // first request: 503. second request: 200. Mock::given(method("GET")) .and(path("/api")) .respond_with(move |_: &wiremock::Request| { @@ -124,8 +115,6 @@ async fn get_bytes_limited_rejects_oversized_responses() { assert!(error.to_string().contains("8-byte limit")); } -// ---------- download_file ---------- - #[tokio::test(start_paused = true)] async fn download_file_retries_5xx_then_succeeds() { let server = MockServer::start().await; diff --git a/tests/screenshots.rs b/tests/screenshots.rs index 8235a20..bd26faf 100644 --- a/tests/screenshots.rs +++ b/tests/screenshots.rs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2026 Constantin Bauer // SPDX-License-Identifier: GPL-3.0-only -// integration tests for the public scan_screenshots API. - use std::path::{Path, PathBuf}; use rmcl::instance::screenshots::scan_screenshots;