Skip to content

Fix: typing space in Env Variables would lead to crash. + added variable presets for Mango#1208

Open
Catpotatos wants to merge 3 commits intoutkarshdalal:masterfrom
Catpotatos:Fix-variables-crash-spaces
Open

Fix: typing space in Env Variables would lead to crash. + added variable presets for Mango#1208
Catpotatos wants to merge 3 commits intoutkarshdalal:masterfrom
Catpotatos:Fix-variables-crash-spaces

Conversation

@Catpotatos
Copy link
Copy Markdown
Contributor

@Catpotatos Catpotatos commented Apr 13, 2026

Description

Fix: typing space in Env Variables would lead to crash.

  • Added Mango Hud variables to saved presets for fps and frame limiting.
  • Removed variable that was not working as intended for GPU spoofing.
  • Re-ordered WINEDLLOVERRIDES to top.

Added:
Search A: drive on opening "Edit Container" and populate dinput and dinput8 as native on WINEDLLOVERRIDES if dlls are found in gamedir.

Added presets for input dlls native before builtin:

"dinput8=n,b;dinput=n,b",
"xinput1_3=n,b;xinput1_4=n,b;xinput9_1_0=n,b",
"xinput9_1_0=n,b;windows.gaming.input=n,b",
"xinput1_1=n,b;xinput1_2=n,b"

WINEDLLOVERRIDES presets are now inside categories to avoid overwhelming users

Recording

screen-20260413-214813.1.mp4
Screenshot_20260413-215351 1 Screenshot_20260419-183300 1 Screenshot_20260419-183531 1

Checklist

  • If I have access to #code-changes, I have discussed this change there and it has been green-lighted. If I do not have access, I have still provided clear context in this PR. If I skip both, I accept that this change may face delays in review, may not be reviewed at all, or may be closed.
  • I have attached a recording of the change.
  • I have read and agree to the contribution guidelines in CONTRIBUTING.md.

Summary by cubic

Fixes a crash when typing spaces in Environment Variables and adds MangoHud presets for FPS display and limiting. Also removes a broken spoofing preset and moves WINEDLLOVERRIDES to the top with common suggestions.

  • Bug Fixes

    • Trim env var name/value in dialogs and settings before saving.
    • Skip empty or malformed tokens in EnvVars.putAll to avoid crashes from stray spaces.
  • New Features

    • Add MANGOHUD (toggle) and MANGOHUD_CONFIG presets (fps, fps_limit=60, fps_only).
    • Add WINEDLLOVERRIDES suggestions and place it first in the list.
    • Remove non-working DXVK_FILTER_DEVICE_NAME preset.

Written for commit ae01c35. Summary will update on new commits.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Environment variables now automatically trim excess whitespace from names and values during input and storage
    • Enhanced validation to reject malformed environment variable entries
  • New Features

    • Added Mangohud performance monitoring support with toggle and configuration options
    • Updated supported environment variables with refined audio library override presets

feat: Added Mango Hud variables to saved presets for fps and frame limiting.
removed variable that was not working for device spoofing.
Re-ordered WINEDLLOVERRIDES to top.
Copilot AI review requested due to automatic review settings April 13, 2026 21:06
@Catpotatos Catpotatos changed the title Fix: typing space in Env Variables would lead to crash. + added variable presets Fix: typing space in Env Variables would lead to crash. + added variable presets for Mango Apr 13, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 13, 2026

📝 Walkthrough

Walkthrough

Normalize and validate environment variable inputs (trim and skip malformed entries), update known env-var registry (add Mangohud entries, change WINEDLLOVERRIDES presets, remove DXVK_FILTER_DEVICE_NAME), add auto-detection/persistence of input DLL overrides in containers, and adjust suggestion dropdown rendering.

Changes

Cohort / File(s) Summary
UI input trimming
app/src/main/java/app/gamenative/ui/component/dialog/EnvironmentTab.kt, app/src/main/java/app/gamenative/ui/component/settings/SettingsEnvVars.kt
Apply trim() to env var name/value inputs before storing; minor formatting/brace adjustments in SettingsEnvVars.
Env var registry updates
app/src/main/java/com/winlator/core/envvars/EnvVarInfo.kt
Removed DXVK_FILTER_DEVICE_NAME; added MANGOHUD (TOGGLE) and MANGOHUD_CONFIG (SUGGESTIONS); reworked WINEDLLOVERRIDES presets and ordering.
Parsing validation
app/src/main/java/com/winlator/core/envvars/EnvVars.java
putAll(String) now skips empty/malformed tokens (ignores parts with no valid = or empty key).
Suggestions UI rendering
app/src/main/java/app/gamenative/ui/component/settings/SettingsTextFieldWithSuggestions.kt
Dropdown treats "---"-prefixed suggestions as non-interactive category headers with muted styling; other suggestions selectable as before.
Auto-apply input DLL overrides
app/src/main/java/app/gamenative/utils/ContainerUtils.kt, app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt
New autoApplyInputDllOverrides(container) scans A: drive (bounded depth) for dinput*.dll, prepends non-duplicate dinput/dinput8 entries to WINEDLLOVERRIDES, saves container if changed; XServerScreen now calls this during environment setup.

Sequence Diagram(s)

sequenceDiagram
  participant XServer as XServerScreen
  participant CU as ContainerUtils.autoApplyInputDllOverrides
  participant Container as Container
  participant EnvVars as EnvVars
  participant FS as A_Drive_FileSystem

  XServer->>CU: call autoApplyInputDllOverrides(container)
  CU->>Container: read mapped A: path
  Container->>FS: scan up to 3 levels for dinput*.dll
  FS-->>CU: list of found DLL filenames
  CU->>EnvVars: read WINEDLLOVERRIDES value
  CU->>EnvVars: compute/prepend new overrides (avoid duplicates)
  CU->>Container: container.saveData() if changed
  CU-->>XServer: return boolean (changed or not)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • phobos665

Poem

🐰
I hopped through files, trimmed each stray space,
Found DLLs hiding in A: drive's embrace,
Mangohud added, old GPU name undone,
WINEDLLOVERRIDES sorted—now neatly spun,
Configs march tidy, ready for the run. 🎩

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title partially addresses the main bug fix (typing spaces causing crash) but incompletely describes the full scope and misleadingly emphasizes MangoHud additions which are secondary.
Description check ✅ Passed The pull request description includes all required sections: a detailed description of changes, a recording/GIF, checklist items marked, and agrees to contribution guidelines.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes crashes when users enter spaces while editing environment variables, and expands preset/suggestion support for common env vars (including MangoHud), improving the env-var editing UX in the app.

Changes:

  • Harden EnvVars.putAll() against empty/invalid tokens when splitting persisted env-var strings.
  • Add/update known env-var presets: introduce MANGOHUD/MANGOHUD_CONFIG, move WINEDLLOVERRIDES higher, remove DXVK_FILTER_DEVICE_NAME.
  • Trim env-var name/value inputs in the settings list and creation dialog to avoid leading/trailing whitespace issues.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
app/src/main/java/com/winlator/core/envvars/EnvVars.java Skips empty/invalid tokens when parsing env var strings to prevent crashes.
app/src/main/java/com/winlator/core/envvars/EnvVarInfo.kt Updates known env var definitions: adds MangoHud vars, adjusts WINEDLLOVERRIDES, removes GPU spoofing var preset.
app/src/main/java/app/gamenative/ui/component/settings/SettingsEnvVars.kt Trims edited env-var values in the settings list UI.
app/src/main/java/app/gamenative/ui/component/dialog/EnvironmentTab.kt Trims env-var name/value in the “create env var” dialog.
Comments suppressed due to low confidence (1)

app/src/main/java/com/winlator/core/envvars/EnvVars.java:30

  • This change fixes a crash case in putAll, but there’s no unit test coverage for parsing env var strings (e.g., multiple consecutive spaces, leading/trailing spaces, or invalid tokens without =). Adding tests would help prevent regressions since EnvVars(String) is used to deserialize persisted config values.
    public void putAll(String values) {
        if (values == null || values.isEmpty()) return;
        String[] parts = values.split(" ");
        for (String part : parts) {
            int index = part.indexOf("=");
            if (part.isEmpty() || index < 1) continue;
            String name = part.substring(0, index);
            String value = part.substring(index+1);
            data.put(name, value);
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 23 to 29
String[] parts = values.split(" ");
for (String part : parts) {
int index = part.indexOf("=");
if (part.isEmpty() || index < 1) continue;
String name = part.substring(0, index);
String value = part.substring(index+1);
data.put(name, value);
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

putAll still uses values.split(" "), so any env var value containing an unescaped space (e.g. DXVK_HUD=fps, frametimes) will be split into multiple tokens and silently truncated/ignored. Consider either (a) storing env vars using toEscapedString() and teaching putAll to split on unescaped spaces + unescape \ , or (b) validating/rejecting spaces in values at input time with a user-facing error, so values aren’t corrupted.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

@Catpotatos Catpotatos Apr 13, 2026

Choose a reason for hiding this comment

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

tested, keyboard doesn't allow spaces to be typed. video shared.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/src/main/java/com/winlator/core/envvars/EnvVars.java (1)

21-29: ⚠️ Potential issue | 🔴 Critical

This still breaks env var values that contain spaces.

Skipping malformed tokens avoids the crash, but callers still persist a space-delimited flat string (EnvironmentTab.kt Line 206 uses envVars.toString()). A value like FOO=hello world now round-trips here as FOO=hello plus a skipped world token, so the crash becomes silent config corruption instead of a real fix. Please switch to a serializer/parser pair that preserves spaces consistently, e.g. escaped serialization plus matching unescape logic here, or a structured format.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/winlator/core/envvars/EnvVars.java` around lines 21 -
29, The current putAll method in EnvVars.java corrupts values containing spaces
because it splits on plain spaces; update the parser to match a safe serializer
used by EnvironmentTab.kt (do not split on spaces inside quoted values or
escaped spaces) or switch to a structured format (e.g., JSON, Properties, or
newline-separated key=value) and parse that instead; specifically, change
putAll(String values) so it decodes the same escaped/quoted format that the
corresponding envVars.toString() produces and then call data.put(name, value)
with the correctly unescaped full value for each parsed token.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@app/src/main/java/com/winlator/core/envvars/EnvVars.java`:
- Around line 21-29: The current putAll method in EnvVars.java corrupts values
containing spaces because it splits on plain spaces; update the parser to match
a safe serializer used by EnvironmentTab.kt (do not split on spaces inside
quoted values or escaped spaces) or switch to a structured format (e.g., JSON,
Properties, or newline-separated key=value) and parse that instead;
specifically, change putAll(String values) so it decodes the same escaped/quoted
format that the corresponding envVars.toString() produces and then call
data.put(name, value) with the correctly unescaped full value for each parsed
token.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ec396b53-fda9-4786-9876-e91197e54ad5

📥 Commits

Reviewing files that changed from the base of the PR and between 9a8401c and 05fe001.

📒 Files selected for processing (4)
  • app/src/main/java/app/gamenative/ui/component/dialog/EnvironmentTab.kt
  • app/src/main/java/app/gamenative/ui/component/settings/SettingsEnvVars.kt
  • app/src/main/java/com/winlator/core/envvars/EnvVarInfo.kt
  • app/src/main/java/com/winlator/core/envvars/EnvVars.java

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="app/src/main/java/app/gamenative/ui/component/dialog/EnvironmentTab.kt">

<violation number="1" location="app/src/main/java/app/gamenative/ui/component/dialog/EnvironmentTab.kt:163">
P2: Value field trims on every keystroke, causing incorrect/unnatural entry of spaced env var values.</violation>
</file>

<file name="app/src/main/java/com/winlator/core/envvars/EnvVars.java">

<violation number="1" location="app/src/main/java/com/winlator/core/envvars/EnvVars.java:26">
P2: The new guard prevents crashes on space-containing values but introduces silent data corruption: `putAll` splits on `" "`, so a value like `DXVK_HUD=fps, frametimes` becomes tokens `DXVK_HUD=fps,` and `frametimes`. The second token has no `=` and is now silently skipped, truncating the stored value. The `.trim()` calls in the UI prevent users from *typing* spaces, but `putAll` can still receive space-containing strings from previously-persisted data or programmatic callers. Consider using an escape-aware delimiter (e.g., storing/splitting on a character that doesn't appear in values, or escaping spaces) so round-tripping is lossless.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

NoExtractOutlinedTextField(
value = envVarValue,
onValueChange = { envVarValue = it },
onValueChange = { envVarValue = it.trim() },
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 13, 2026

Choose a reason for hiding this comment

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

P2: Value field trims on every keystroke, causing incorrect/unnatural entry of spaced env var values.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/src/main/java/app/gamenative/ui/component/dialog/EnvironmentTab.kt, line 163:

<comment>Value field trims on every keystroke, causing incorrect/unnatural entry of spaced env var values.</comment>

<file context>
@@ -160,7 +160,7 @@ fun EnvironmentTabContent(state: ContainerConfigState) {
                         NoExtractOutlinedTextField(
                             value = envVarValue,
-                            onValueChange = { envVarValue = it },
+                            onValueChange = { envVarValue = it.trim() },
                             label = { Text(text = stringResource(R.string.value)) },
                             singleLine = true,
</file context>
Suggested change
onValueChange = { envVarValue = it.trim() },
onValueChange = { envVarValue = it },
Fix with Cubic

String[] parts = values.split(" ");
for (String part : parts) {
int index = part.indexOf("=");
if (part.isEmpty() || index < 1) continue;
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 13, 2026

Choose a reason for hiding this comment

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

P2: The new guard prevents crashes on space-containing values but introduces silent data corruption: putAll splits on " ", so a value like DXVK_HUD=fps, frametimes becomes tokens DXVK_HUD=fps, and frametimes. The second token has no = and is now silently skipped, truncating the stored value. The .trim() calls in the UI prevent users from typing spaces, but putAll can still receive space-containing strings from previously-persisted data or programmatic callers. Consider using an escape-aware delimiter (e.g., storing/splitting on a character that doesn't appear in values, or escaping spaces) so round-tripping is lossless.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/src/main/java/com/winlator/core/envvars/EnvVars.java, line 26:

<comment>The new guard prevents crashes on space-containing values but introduces silent data corruption: `putAll` splits on `" "`, so a value like `DXVK_HUD=fps, frametimes` becomes tokens `DXVK_HUD=fps,` and `frametimes`. The second token has no `=` and is now silently skipped, truncating the stored value. The `.trim()` calls in the UI prevent users from *typing* spaces, but `putAll` can still receive space-containing strings from previously-persisted data or programmatic callers. Consider using an escape-aware delimiter (e.g., storing/splitting on a character that doesn't appear in values, or escaping spaces) so round-tripping is lossless.</comment>

<file context>
@@ -23,6 +23,7 @@ public void putAll(String values) {
         String[] parts = values.split(" ");
         for (String part : parts) {
             int index = part.indexOf("=");
+            if (part.isEmpty() || index < 1) continue;
             String name = part.substring(0, index);
             String value = part.substring(index+1);
</file context>
Fix with Cubic

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

keyboard will not allow to type spaces. several barriers in place to ensure a space, that could break the environment variable intention, won't go through.

Values should not contain spaces,
so typing "DXVK_HUD=fps, frametimes" should actually always become DXVK_HUD=fps,frametimes and parse correctly as intended.

Before this implementation, entering a space would mean a crash. now it blocks it from happening.

@utkarshdalal
Copy link
Copy Markdown
Owner

not sure the mango changes are needed, #1081 is doing fps cap in a different way

@Catpotatos
Copy link
Copy Markdown
Contributor Author

not sure the mango changes are needed, #1081 is doing fps cap in a different way

The mango does not stay as default, it's just added to the dropbox of options to choose from when clicking add new variable and clicking on the suggestion box.
Added due to some people using frequently for workarounds, so there's easy access instead of typing.

I can remove if you prefer.

Search A: drive on opening "Edit Container" and populate dinput and dinput8 as native on WINEDLLOVERRIDES if dlls are found in gamedir.

Added presets for input dlls native before builtin:

"dinput8=n,b;dinput=n,b",
"xinput1_3=n,b;xinput1_4=n,b;xinput9_1_0=n,b",
"xinput9_1_0=n,b;windows.gaming.input=n,b",
"xinput1_1=n,b;xinput1_2=n,b"

WINEDLLOVERRIDES presets are now inside categories to avoid overwhelming users
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
app/src/main/java/app/gamenative/utils/ContainerUtils.kt (1)

1351-1367: Skip symlinked directories to match scanExecutablesInADrive behavior.

scanExecutablesInADrive explicitly uses FileUtils.isSymlink(file) to avoid cycles (e.g. GOG ISI rootdir → game root, per the comment on line 1193). scanForInputDlls traverses without that guard; the maxDepth = 3 bound prevents runaway recursion but symlink loops still incur redundant I/O and may double-count DLLs reachable via multiple paths. Consider mirroring the existing guard for consistency.

♻️ Proposed refactor
         for (file in files) {
             if (file.isFile && file.name.lowercase() in targetNames) {
                 found.add(file.name.lowercase())
             } else if (file.isDirectory && currentDepth < maxDepth) {
+                if (FileUtils.isSymlink(file)) continue
                 scanForInputDlls(file, targetNames, found, maxDepth, currentDepth + 1)
             }
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/app/gamenative/utils/ContainerUtils.kt` around lines 1351 -
1367, The function scanForInputDlls currently descends into directories without
skipping symlinks which can cause redundant I/O and duplicate discovery; update
the directory-branch to skip symlinked directories by checking
FileUtils.isSymlink(file) (same approach as scanExecutablesInADrive) before
recursing into scanForInputDlls(file, targetNames, found, maxDepth, currentDepth
+ 1), ensuring symlinked directories are ignored and preserving the existing
maxDepth and found behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/src/main/java/app/gamenative/utils/ContainerUtils.kt`:
- Around line 1326-1337: The code claims to "prepend" auto-detected overrides
but builds the env value as "$existing;$toPrepend" which appends; change the
construction to place the new entries before existing (i.e.
"$toPrepend;$existing") when calling containerEnvVars.put("WINEDLLOVERRIDES",
...), and optionally rename `toPrepend` or update the inline comment near the
`containerEnvVars.put` usage so the variable name, comment and behavior match;
keep the filtering via `existingEntries` and still set `updated = true` as
currently done.
- Around line 991-995: getOrCreateContainer currently calls
autoApplyInputDllOverrides every time, causing auto-added WINEDLLOVERRIDES to be
re-applied after a user deletes them; change the flow to make this a one-time
migration by persisting a container extra flag (e.g.,
"inputDllOverridesAutoApplied") on the Container object: before calling
autoApplyInputDllOverrides in getOrCreateContainer check
container.getExtra("inputDllOverridesAutoApplied") and skip if true; after
autoApplyInputDllOverrides completes successfully set
container.setExtra("inputDllOverridesAutoApplied", true) and persist the
container; keep the existing dedup logic (the DLL-name match) but ensure the
flag prevents re-running the migration.

---

Nitpick comments:
In `@app/src/main/java/app/gamenative/utils/ContainerUtils.kt`:
- Around line 1351-1367: The function scanForInputDlls currently descends into
directories without skipping symlinks which can cause redundant I/O and
duplicate discovery; update the directory-branch to skip symlinked directories
by checking FileUtils.isSymlink(file) (same approach as scanExecutablesInADrive)
before recursing into scanForInputDlls(file, targetNames, found, maxDepth,
currentDepth + 1), ensuring symlinked directories are ignored and preserving the
existing maxDepth and found behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a2b1297e-5ce8-449d-b2db-e3ac5eaac7a5

📥 Commits

Reviewing files that changed from the base of the PR and between 05fe001 and 4d63477.

📒 Files selected for processing (4)
  • app/src/main/java/app/gamenative/ui/component/settings/SettingsTextFieldWithSuggestions.kt
  • app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt
  • app/src/main/java/app/gamenative/utils/ContainerUtils.kt
  • app/src/main/java/com/winlator/core/envvars/EnvVarInfo.kt
✅ Files skipped from review due to trivial changes (1)
  • app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/main/java/com/winlator/core/envvars/EnvVarInfo.kt

Comment on lines +991 to 995

// Auto-detect loose input DLLs in game directory and persist WINEDLLOVERRIDES
autoApplyInputDllOverrides(container)

return container
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Users cannot opt out — auto-detected overrides will be re-added after manual deletion.

autoApplyInputDllOverrides runs unconditionally every time getOrCreateContainer is called, and the dedup check at line 1327 only matches by DLL name. If a user intentionally deletes the auto-added dinput8=n,b entry from the Environment tab (e.g., because it breaks their game), the next launch will silently re-add it — the user has no way to opt out short of renaming/removing the DLL on disk.

Consider persisting a container extra (e.g., inputDllOverridesAutoApplied) that's set after the first successful apply and checked before re-running, so this behaves as a one-time migration rather than a sticky loop.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/app/gamenative/utils/ContainerUtils.kt` around lines 991 -
995, getOrCreateContainer currently calls autoApplyInputDllOverrides every time,
causing auto-added WINEDLLOVERRIDES to be re-applied after a user deletes them;
change the flow to make this a one-time migration by persisting a container
extra flag (e.g., "inputDllOverridesAutoApplied") on the Container object:
before calling autoApplyInputDllOverrides in getOrCreateContainer check
container.getExtra("inputDllOverridesAutoApplied") and skip if true; after
autoApplyInputDllOverrides completes successfully set
container.setExtra("inputDllOverridesAutoApplied", true) and persist the
container; keep the existing dedup logic (the DLL-name match) but ensure the
flag prevents re-running the migration.

Comment on lines +1326 to +1337
// Parse existing entry names — handles both "dinput8=n,b" and "dinput8=native,builtin"
val existingEntries = existing.split(";").map { it.trim().substringBefore("=") }.toSet()
val toPrepend = foundDlls
.map { it.removeSuffix(".dll") }
.filter { it !in existingEntries }
.joinToString(";") { "$it=n,b" }
if (toPrepend.isNotEmpty()) {
// Preserve existing user values; prepend auto-detected overrides in front
containerEnvVars.put("WINEDLLOVERRIDES", "$existing;$toPrepend")
updated = true
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Variable/comment say "prepend" but the code appends.

The variable is named toPrepend, the inline comment on line 1333 says "prepend auto-detected overrides in front", and the PR description states the change "prepends" auto-detected entries — but the actual expression is "$existing;$toPrepend", which places the new entries at the end. For non-duplicate names (filtered above) Wine semantics are unaffected, so this is primarily an intent/naming inconsistency rather than a functional defect, but it will confuse future readers.

🔧 Match the stated intent
             if (toPrepend.isNotEmpty()) {
                 // Preserve existing user values; prepend auto-detected overrides in front
-                containerEnvVars.put("WINEDLLOVERRIDES", "$existing;$toPrepend")
+                containerEnvVars.put("WINEDLLOVERRIDES", "$toPrepend;$existing")
                 updated = true
             }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/app/gamenative/utils/ContainerUtils.kt` around lines 1326 -
1337, The code claims to "prepend" auto-detected overrides but builds the env
value as "$existing;$toPrepend" which appends; change the construction to place
the new entries before existing (i.e. "$toPrepend;$existing") when calling
containerEnvVars.put("WINEDLLOVERRIDES", ...), and optionally rename `toPrepend`
or update the inline comment near the `containerEnvVars.put` usage so the
variable name, comment and behavior match; keep the filtering via
`existingEntries` and still set `updated = true` as currently done.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 4 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="app/src/main/java/app/gamenative/utils/ContainerUtils.kt">

<violation number="1" location="app/src/main/java/app/gamenative/utils/ContainerUtils.kt:993">
P2: This function runs unconditionally on every container creation/launch. If a user manually removes an auto-detected DLL override (e.g., because `dinput8=n,b` breaks their game), it will be silently re-added on the next launch with no way to opt out. Consider persisting a flag (e.g., `inputDllOverridesAutoApplied`) after the first successful apply so this behaves as a one-time migration rather than a recurring forced override.</violation>

<violation number="2" location="app/src/main/java/app/gamenative/utils/ContainerUtils.kt:1334">
P3: The variable name `toPrepend` and the comment say "prepend auto-detected overrides in front", but `"$existing;$toPrepend"` actually appends the new entries after existing ones. Either rename to `toAppend` and fix the comment, or swap the order to match the stated intent.</violation>

<violation number="3" location="app/src/main/java/app/gamenative/utils/ContainerUtils.kt:1363">
P2: Recursive DLL scanning recurses into directories without skipping symlinks, unlike the existing executable scan, which can cause unintended traversal/performance regressions in linked game folders.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment on lines +1363 to +1365
} else if (file.isDirectory && currentDepth < maxDepth) {
scanForInputDlls(file, targetNames, found, maxDepth, currentDepth + 1)
}
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 19, 2026

Choose a reason for hiding this comment

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

P2: Recursive DLL scanning recurses into directories without skipping symlinks, unlike the existing executable scan, which can cause unintended traversal/performance regressions in linked game folders.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/src/main/java/app/gamenative/utils/ContainerUtils.kt, line 1363:

<comment>Recursive DLL scanning recurses into directories without skipping symlinks, unlike the existing executable scan, which can cause unintended traversal/performance regressions in linked game folders.</comment>

<file context>
@@ -1272,4 +1277,92 @@ object ContainerUtils {
+        for (file in files) {
+            if (file.isFile && file.name.lowercase() in targetNames) {
+                found.add(file.name.lowercase())
+            } else if (file.isDirectory && currentDepth < maxDepth) {
+                scanForInputDlls(file, targetNames, found, maxDepth, currentDepth + 1)
+            }
</file context>
Suggested change
} else if (file.isDirectory && currentDepth < maxDepth) {
scanForInputDlls(file, targetNames, found, maxDepth, currentDepth + 1)
}
} else if (file.isDirectory && !FileUtils.isSymlink(file) && currentDepth < maxDepth) {
scanForInputDlls(file, targetNames, found, maxDepth, currentDepth + 1)
}
Fix with Cubic

}

// Auto-detect loose input DLLs in game directory and persist WINEDLLOVERRIDES
autoApplyInputDllOverrides(container)
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 19, 2026

Choose a reason for hiding this comment

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

P2: This function runs unconditionally on every container creation/launch. If a user manually removes an auto-detected DLL override (e.g., because dinput8=n,b breaks their game), it will be silently re-added on the next launch with no way to opt out. Consider persisting a flag (e.g., inputDllOverridesAutoApplied) after the first successful apply so this behaves as a one-time migration rather than a recurring forced override.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/src/main/java/app/gamenative/utils/ContainerUtils.kt, line 993:

<comment>This function runs unconditionally on every container creation/launch. If a user manually removes an auto-detected DLL override (e.g., because `dinput8=n,b` breaks their game), it will be silently re-added on the next launch with no way to opt out. Consider persisting a flag (e.g., `inputDllOverridesAutoApplied`) after the first successful apply so this behaves as a one-time migration rather than a recurring forced override.</comment>

<file context>
@@ -987,6 +988,10 @@ object ContainerUtils {
         }
+
+        // Auto-detect loose input DLLs in game directory and persist WINEDLLOVERRIDES
+        autoApplyInputDllOverrides(container)
+
         return container
</file context>
Fix with Cubic

.joinToString(";") { "$it=n,b" }
if (toPrepend.isNotEmpty()) {
// Preserve existing user values; prepend auto-detected overrides in front
containerEnvVars.put("WINEDLLOVERRIDES", "$existing;$toPrepend")
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 19, 2026

Choose a reason for hiding this comment

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

P3: The variable name toPrepend and the comment say "prepend auto-detected overrides in front", but "$existing;$toPrepend" actually appends the new entries after existing ones. Either rename to toAppend and fix the comment, or swap the order to match the stated intent.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/src/main/java/app/gamenative/utils/ContainerUtils.kt, line 1334:

<comment>The variable name `toPrepend` and the comment say "prepend auto-detected overrides in front", but `"$existing;$toPrepend"` actually appends the new entries after existing ones. Either rename to `toAppend` and fix the comment, or swap the order to match the stated intent.</comment>

<file context>
@@ -1272,4 +1277,92 @@ object ContainerUtils {
+                .joinToString(";") { "$it=n,b" }
+            if (toPrepend.isNotEmpty()) {
+                // Preserve existing user values; prepend auto-detected overrides in front
+                containerEnvVars.put("WINEDLLOVERRIDES", "$existing;$toPrepend")
+                updated = true
+            }
</file context>
Fix with Cubic

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.

3 participants