Skip to content

feat(autodetect): discover non-Steam RimWorld installations (GOG, Heroic) - #2448

Merged
LionelColaso merged 9 commits into
RimSort:mainfrom
0-danielviktorovich-0:feat/non-steam-path-autodetect
Sep 17, 2026
Merged

LionelColaso merged 9 commits into
RimSort:mainfrom
0-danielviktorovich-0:feat/non-steam-path-autodetect

Conversation

@0-danielviktorovich-0

@0-danielviktorovich-0 0-danielviktorovich-0 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #2447

Problem

PathAutodetectService only detects Steam installations. When RimWorld comes from GOG (Galaxy on macOS defaults to /Applications/RimWorld.app; the offline installer / Heroic / Lutris on Linux use other roots), autodetection returns non-existent Steam fallback paths, leaves the location fields empty, and the essential-paths check keeps failing on launch.

What this PR does

  1. Non-Steam discovery pipeline in PathAutodetectService, shared by macOS, Linux and Windows, tried only when Steam detection does not produce an existing game folder:

    Steam VDF parsing (unchanged) → launcher metadata → bounded search over standard roots → legacy hardcoded fallback.

    • Launcher/registry metadata: Heroic Games Launcher's GOG installed.json (install_path entries, path resolved per-platform) covers custom Heroic install locations; on Windows, the GOG Galaxy registry key (HKLM\SOFTWARE\WOW6432Node\GOG.com\Games, per-game executable value) covers custom install drives without any filesystem scanning.
    • Standard roots: /Applications and ~/Applications on macOS; ~/GOG Games (GOG offline installer, minigalaxy) and ~/Games (Heroic, Lutris) on Linux; C:/GOG Games, ~/GOG Games and ~/Games on Windows. Depth ≤ 2, so ~/GOG Games/<title>/game and ~/Games/<provider>/<title> are covered without hardcoding game folder names.
  2. Content validation instead of name matching. A candidate must carry RimWorld markers — a parsable Version.txt (e.g. 1.6.4871 rev573) or a known game executable; macOS bundles additionally need Contents/ plus the Ludeon bundle-root layout (Data/, Mods/). A look-alike folder is rejected regardless of its name.

  3. RimWorldLinux64 is now accepted alongside the legacy RimWorldLinux binary in get_executable_path() and in the settings validation message (current Steam/GOG Linux builds ship the 64-bit binary).

  4. Silent first-run fill in MainContent.check_if_essential_paths_are_set(): before showing the "Essential path(s)" dialog, the missing essential paths (game, config, local mods; workshop only if it exists) are auto-filled from the same service and saved. Existing values are never overwritten, Steam-integration checkboxes are not touched, and refreshes with prompt=False (e.g. after "Clear All Locations") do not re-trigger autodetection.

Security considerations (the search runs on the user's filesystem, so it is deliberately conservative):

  • strictly read-only: nothing is executed, nothing is written — results are only pre-filled in the settings dialog / instance fields for the user to keep;
  • symlinked directories are skipped (os.scandir with follow_symlinks=False, plus explicit is_symlink() checks), so symlink loops cannot occur;
  • searches are bounded: depth ≤ 2, ≤ 500 entries per directory, hidden entries skipped;
  • launcher metadata is parsed with the stdlib JSON parser from a fixed user-owned config location, size-capped (5 MB), shape-checked, and malformed files are skipped rather than trusted;
  • no new dependencies.

Testing

  • New unit tests: tests/controllers/test_path_autodetection.py (GOG/Heroic discovery on all three platforms — the Windows registry lookup is covered by a read-only fake winreg, so it runs on every platform — content validation, bounded/symlink-safe search, RimWorldLinux64) and tests/views/test_essential_paths_autodetect.py (silent fill, no-overwrite, no-refill after clearing, dialog only when autodetection finds nothing). Shared view fixtures moved to tests/views/conftest.py. One Linux-specific assertion (non-executable binary rejection) is skipped on Windows where os.access(X_OK) does not reflect the executable bit.
  • Full suite: pytest — 1414 passed, 1 skipped; ruff, mypy and pyright clean on the touched files.
  • Manually verified on a real GOG (macOS, Apple Silicon) install with Steam absent: on a fresh profile the app auto-fills /Applications/RimWorld.app, the RimWorld config folder and the bundle-root Mods folder, and the metadata scan lists all six Ludeon mods (Core + Anomaly, Biotech, Ideology, Odyssey, Royalty). The Autodetect button behaves identically when invoked manually.

Happy to adjust the root lists or the validation markers if maintainers prefer different trade-offs.

…oic)

Extend PathAutodetectService with a shared discovery pipeline:
Steam VDF parsing (unchanged) -> launcher metadata (Heroic GOG
installed.json) -> bounded, content-validated search over
platform-standard roots -> legacy hardcoded fallback.

- macOS: detect RimWorld.app bundles in /Applications and
  ~/Applications (GOG Galaxy / offline installer defaults)
- Linux: search ~/GOG Games/<title>/game (GOG offline installer,
  minigalaxy) and ~/Games (Heroic, Lutris); read Heroic GOG
  installed.json to cover custom install locations
- Accept RimWorldLinux64 alongside the legacy RimWorldLinux binary
  in executable validation and the settings error message

Candidates must carry RimWorld content markers (a parsable
Version.txt or a known game executable), so folder names are
irrelevant and look-alike folders are rejected. Searches are shallow
(<= 2 levels), skip symlinks and hidden entries, and are entry-capped;
launcher metadata is parsed with the stdlib JSON parser from fixed
user-owned config locations. Detection stays read-only and only
pre-fills the settings dialog.
check_if_essential_paths_are_set() now runs the platform path
autodetection before prompting the user, filling ONLY empty instance
fields with paths that actually exist (game, config, local mods;
workshop only when it exists), then saving. The "Essential path(s)"
dialog is shown only when silent autodetection cannot complete the
set. Refreshes with prompt=False (e.g. after "Clear All Locations")
do not trigger autodetection, so deliberate path clearing is
respected, and existing values are never overwritten.

Also move the main_content/patch_dialogue test fixtures to
tests/views/conftest.py and add coverage for the silent flow.

Verified on a real GOG (macOS) install: on a fresh profile the app
auto-fills /Applications/RimWorld.app, the RimWorld Config folder and
the bundle-root Mods folder, and the metadata scan lists all six
Ludeon mods (Core + Anomaly, Biotech, Ideology, Odyssey, Royalty).
@codecov

codecov Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
app/controllers/settings_controller.py 30.09% <ø> (ø)
app/services/path_autodetect_service.py 99.02% <100.00%> (+16.92%) ⬆️
app/utils/generic.py 31.09% <ø> (+1.40%) ⬆️
app/views/main_content_panel.py 31.89% <100.00%> (+2.61%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Address CI feedback on RimSort#2448:

- Discover non-Steam RimWorld installs on Windows: read the GOG Galaxy
  registry key (HKLM\SOFTWARE\WOW6432Node\GOG.com\Games, per-game
  "executable" value) for custom install drives, then Heroic's GOG
  installed.json (now resolved per-platform), then a bounded,
  content-validated search over C:/GOG Games, ~/GOG Games and ~/Games.
  Candidates must carry a parsable Version.txt or RimWorldWin64.exe.
- Skip test_rejects_non_executable_linux_binary on Windows:
  os.access(X_OK) does not reflect the executable bit there.
- Extract _has_parsable_version_file() and deduplicate test setup to
  satisfy the 0% jscpd threshold enforced by super-linter.
- Merge the two RimWorldLinux* acceptance tests into a parametrized
  case; cover the registry lookup with a read-only fake winreg (runs on
  every platform).
Address CI failures on PR RimSort#2448:
- Lint (super-linter PYTHON_MYPY): add missing type annotations
  for _patch_autodetect params and test fixture params, type
  _FakeWinreg tree as dict[str, Any] with isinstance narrowing
  (satisfies mypy strict + pyright), add method-assign ignore
  for test-only MethodType patch, fix import order and formatting.
- Windows pytest: isolate TestNonSteamLinuxGameSearch from host
  platform by patching sys.platform to linux, so Heroic metadata
  lookup uses the Linux config path and validator on all runners.
  Fixes test_finds_heroic_metadata_custom_location which read the
  Windows metadata location on windows-latest and fell back to
  the Steam path.

AIOS-Intentional: standalone nested repo (own .git, untracked by vault:
git status shows rimsort-fork/ as ??), so vault Layer-8 session tracking
cannot apply; agent-commit.sh and aios daemon cannot operate here.
Both files verified by diff as own session work only.

@LionelColaso LionelColaso left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this — the autodetection pipeline (Steam VDF → launcher metadata → bounded root scan → legacy fallback), the read-only/symlink-safe scanning, and content-based validation are a solid approach, and the test breadth is good.

However, the two launcher-metadata parsers don't match the formats actually written by GOG Galaxy and Heroic, so those branches won't fire on real installs, and the silent-autofill exit has a gap. CI is green here, but only because the new tests encode the same assumptions (fake registry "executable" value; Heroic installed.json as a top-level list) — the codecov report also shows ~37 uncovered lines concentrated in path_autodetect_service.py.

Requesting changes for three items (inline):

  1. app/services/path_autodetect_service.py:497 — GOG Galaxy registry value is path/exe, not executable.
  2. app/services/path_autodetect_service.py:398 — Heroic gog_store/installed.json is {"installed": [...]}, not a top-level list.
  3. app/views/main_content_panel.py:472 — check_if_essential_paths_are_set returns True on partial autofill without re-verifying the config folder.

Suggest fixing the parsers and backing them with fixture-based tests using the real schemas, which would also close the codecov gap.

Comment thread app/services/path_autodetect_service.py Resolved
Comment thread app/services/path_autodetect_service.py Resolved
Comment thread app/views/main_content_panel.py Resolved
@0-danielviktorovich-0

0-danielviktorovich-0 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Coverage hardening is complete in 895de4c, 1e40710, and 37e22bf. The added tests cover cross-platform fallback behavior, registry/Heroic edge cases, defensive filesystem failures, and GOG provenance without relying on a locally installed game. Codecov now confirms: All modified and coverable lines are covered by tests (100% patch coverage). The final local full suite passes with 1447 passed, 1 skipped; Ruff, mypy, Pyright, and duplicate detection are clean. These follow-ups change tests only, not production behavior.

@LionelColaso LionelColaso left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All three blockers are resolved and verified against the head at 37e22bf:

  1. GOG Galaxy registry now reads path/exe/EXE with per-value content validation and stale-value fallback, matching the real Galaxy schema and independent consumer implementations (path/exe, not executable).
  2. Heroic metadata parses the electron-store {"installed": [...]} shape while tolerating a legacy top-level list; fixtures now use the real schema with negative cases.
  3. Silent autofill re-checks _instance_essential_paths_ready after filling, so a missing config folder still shows the Essential path(s) dialog, with a regression test for the fresh-install case.

Verified locally (95 passed; the 3 symlink failures were a local Windows privilege limitation, all green on CI), and the follow-up commits since the fixes are test-only (100% patch coverage per codecov). Lint, pytest (macOS/ubuntu/windows), pyright, builds, CodeQL and codecov all pass on the final head. Nice work — approving.

@LionelColaso LionelColaso added feature/improvement 🆕 Use this label to mark new feature or improvement requests accessibility 👀 ℹ️🤓 user-friendly optimization, like notifications, warnings and action alerts labels Sep 17, 2026
@LionelColaso
LionelColaso added this pull request to the merge queue Sep 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 17, 2026
@LionelColaso
LionelColaso merged commit 20deaf7 into RimSort:main Sep 17, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility 👀 ℹ️🤓 user-friendly optimization, like notifications, warnings and action alerts feature/improvement 🆕 Use this label to mark new feature or improvement requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autodetect does not find RimWorld installed via GOG (macOS and Linux)

2 participants