Skip to content

fix: recognize RSI Launcher index bundles - #355

Merged
xkeyC merged 1 commit into
mainfrom
fix/launcher-2.15.2-index-bundle
Jul 29, 2026
Merged

fix: recognize RSI Launcher index bundles#355
xkeyC merged 1 commit into
mainfrom
fix/launcher-2.15.2-index-bundle

Conversation

@xkeyC

@xkeyC xkeyC commented Jul 28, 2026

Copy link
Copy Markdown
Member

Summary

  • recognize the current app/launcher/static/js/index.<hash>.js layout in the Rust ASAR patch path
  • retain deterministic fallbacks for both historical main bundle layouts
  • use the same restricted bundle-name rules in the Dart UI when extracting the dynamic launcher hash
  • add synthetic, no-network regression tests; no launcher artifact or hash download is performed by the test suite

Validation

  • cargo test api::asar_api --lib (3 passed, 0 ignored)
  • cargo fmt --check
  • cargo clippy --lib -- -D warnings
  • flutter test test/rsi_launcher_bundle_test.dart (2 passed)

Closes #354

Summary by Sourcery

Recognize current RSI Launcher index bundle layout while preserving compatibility with historical main bundle structures and aligning hash extraction across Rust and Dart.

Bug Fixes:

  • Fix RSI Launcher ASAR parsing to correctly detect the current index..js bundle layout instead of only legacy main..js bundles.

Enhancements:

  • Add deterministic selection logic for launcher main bundle paths across multiple historical layouts.
  • Introduce a shared RSI launcher bundle hash extractor utility used by the Dart UI to enforce consistent bundle-name rules.

Tests:

  • Add Rust unit tests and Flutter tests to validate bundle selection and hash extraction without relying on downloaded launcher artifacts.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@sourcery-ai

sourcery-ai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Reviewer's Guide

Extends RSI Launcher bundle detection to support the new index..js layout while preserving deterministic selection among legacy main bundles, and aligns the Dart UI hash extraction logic and tests with the updated Rust ASAR scanning behavior.

Sequence diagram for updated RSI Launcher bundle detection and hash extraction

sequenceDiagram
    actor User
    participant RsiLauncherEnhanceDialogUI
    participant asar_api
    participant select_rsi_launcher_main_js_path
    participant extractRsiLauncherBundleHash

    User->>RsiLauncherEnhanceDialogUI: open dialog
    RsiLauncherEnhanceDialogUI->>asar_api: getRsiLauncherAsarData(asarPath)
    asar_api->>asar_api: AsarReader::new
    asar_api->>asar_api: collect file paths
    asar_api->>select_rsi_launcher_main_js_path: select_rsi_launcher_main_js_path(paths)
    select_rsi_launcher_main_js_path-->>asar_api: main_js_path
    asar_api->>asar_api: read main_js_content
    asar_api-->>RsiLauncherEnhanceDialogUI: RsiLauncherAsarData

    RsiLauncherEnhanceDialogUI->>extractRsiLauncherBundleHash: extractRsiLauncherBundleHash(mainJsPath)
    extractRsiLauncherBundleHash-->>RsiLauncherEnhanceDialogUI: bundleHash
    RsiLauncherEnhanceDialogUI->>RsiLauncherEnhanceDialogUI: _readScriptState(mainJsString)
    RsiLauncherEnhanceDialogUI-->>User: show enhanced launcher state
Loading

File-Level Changes

Change Details Files
Make ASAR scanner deterministically select the preferred RSI Launcher JS bundle (index/main) and expose its path/content.
  • Expanded launcher JS prefixes to include app/launcher/static/js/index..js alongside existing main bundle layouts.
  • Introduced rsi_launcher_main_js_priority to rank candidate paths by prefix priority and normalize path separators.
  • Added select_rsi_launcher_main_js_path to choose the best-matching bundle path deterministically, preferring index over launcher main over legacy main and using lexicographical tie-breaking.
  • Refactored get_rsi_launcher_asar_data to first collect all file paths, select the main bundle path via the new helper, and then fetch its content, defaulting to empty values if none match.
rust/src/api/asar_api.rs
Add Rust unit tests to lock in bundle selection behavior for current and historical layouts.
  • Added tests verifying that launcher index bundles are preferred over legacy main bundles.
  • Added tests ensuring both historical main bundle layouts remain supported individually.
  • Added tests confirming unrelated index bundles are ignored by the selector.
rust/src/api/asar_api.rs
Unify bundle hash extraction in Dart with the Rust-side bundle selection rules and add regression tests.
  • Created extractRsiLauncherBundleHash utility to normalize paths, restrict to the same launcher/legacy patterns, and require lowercase hex hashes.
  • Updated RsiLauncherEnhanceDialogUI to use the new helper instead of a simple main..js regex, renaming the variable to bundleHash and logging accordingly while still storing it in the version field.
  • Added Flutter tests verifying hash extraction from current index and historical main bundles, and rejection of unrelated bundles and invalid hashes.
lib/common/utils/rsi_launcher_bundle.dart
lib/ui/tools/dialogs/rsi_launcher_enhance_dialog_ui.dart
test/rsi_launcher_bundle_test.dart

Assessment against linked issues

Issue Objective Addressed Explanation
#354 Update the Rust ASAR scanner to recognize RSI Launcher 2.15.2's app/launcher/static/js/index..js bundle while preserving both historical main..js layouts and avoiding selection of non-launcher index bundles (loader/overlay/guide-system).
#354 Update the Dart UI logic to extract the launcher bundle hash from both main..js and index..js launcher bundles, using a restricted pattern that ignores unrelated bundles and correctly displays/uses the hash value.

Possibly linked issues

  • #unknown: PR implements the issue’s requested index bundle recognition, restricted matching, hash extraction change, and compatibility with legacy bundles.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In get_rsi_launcher_asar_data/select_rsi_launcher_main_js_path, you currently collect all file paths into a Vec<String> and then iterate a second time to find the content; consider selecting the target path and its data in a single pass over asar.files() to avoid extra allocation and traversal.
  • In extractRsiLauncherBundleHash, the regular expression is created on every call; it may be worth lifting this into a static final RegExp so the compiled pattern can be reused instead of reallocated each time.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `get_rsi_launcher_asar_data`/`select_rsi_launcher_main_js_path`, you currently collect all file paths into a `Vec<String>` and then iterate a second time to find the content; consider selecting the target path and its data in a single pass over `asar.files()` to avoid extra allocation and traversal.
- In `extractRsiLauncherBundleHash`, the regular expression is created on every call; it may be worth lifting this into a `static final` `RegExp` so the compiled pattern can be reused instead of reallocated each time.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9627025227

ℹ️ About Codex in GitHub

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

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

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

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

Comment thread rust/src/api/asar_api.rs
Comment on lines +17 to +18
normalized_path.starts_with(prefix)
&& normalized_path.ends_with(RSI_LAUNCHER_MAIN_JS_SUFFIX)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject non-hash bundle names during Rust selection

When an ASAR contains a same-directory file such as app/launcher/static/js/index.not-a-hash.js alongside a valid historical main.<hash>.js, this prefix/suffix-only check accepts the invalid index file and gives it higher priority. The Dart extractRsiLauncherBundleHash helper then rejects that selected path, causing _readState to abort even though a usable bundle exists. Validate the segment between the prefix and .js with the same lowercase-hex rule used by Dart before assigning priority.

Useful? React with 👍 / 👎.

@xkeyC
xkeyC merged commit 2cea806 into main Jul 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

修复:识别 RSI Launcher 2.15.2 的渲染层入口 app/launcher/static/js/index.*.js

1 participant