Skip to content

fix: wire the metalHUD + vendorSpoof Settings toggles into the Wine env#7

Open
jonx wants to merge 1 commit into
MichaelLod:mainfrom
jonx:feat/wire-settings-toggles
Open

fix: wire the metalHUD + vendorSpoof Settings toggles into the Wine env#7
jonx wants to merge 1 commit into
MichaelLod:mainfrom
jonx:feat/wire-settings-toggles

Conversation

@jonx

@jonx jonx commented Jun 22, 2026

Copy link
Copy Markdown

What

The metalHUD and vendorSpoof toggles already existed in Settings, but WineProcess.environment never read them — so they did nothing.

Changes

  • Show Metal performance HUD → sets MTL_HUD_ENABLED=1 (Apple's built-in FPS / frame-time overlay). Off by default.
  • Spoof GPU as Apple → gates the D3DM_VENDOR_ID/DEVICE_ID/DESCRIPTION block. On by default (matches the previous hardcoded behaviour).
  • Adds a Performance section footer: "Applied the next time you launch Battle.net." — they're env vars set at Wine start, not live-toggleable.

Read straight from UserDefaults since WineProcess isn't @MainActor; defaults mirror the @AppStorage defaults.

Note: leaves the syncStyle picker alone to avoid a conflicting edit to the same function — that one's handled by the separate sync-primitive PR; happy to rebase on top of it.

Testing

swift build clean; verified the HUD overlay appears when toggled on, via a local dev build.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • GPU vendor and device spoofing is now optional and configurable via settings
    • Metal HUD display can be toggled on or off
  • Style

    • Performance settings section now includes footer messaging clarifying that changes take effect on next app launch

Both toggles existed in Settings but `WineProcess.environment` never read them,
so they did nothing:
- "Show Metal performance HUD" now sets `MTL_HUD_ENABLED=1` (Apple's built-in
  FPS / frame-time overlay), off by default.
- "Spoof GPU as Apple" now gates the `D3DM_VENDOR_ID/DEVICE_ID/DESCRIPTION`
  block, on by default (matches the previous hardcoded behaviour).

Read straight from UserDefaults since WineProcess isn't @mainactor; defaults
mirror the @AppStorage defaults. Adds a Performance section footer noting the
toggles apply the next time Battle.net launches (they're env vars set at Wine
start, not live). The syncStyle picker is intentionally left to the separate
sync PR to avoid a conflicting edit to the same function.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

@jonx is attempting to deploy a commit to the michaellod's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

WineProcess.environment now reads vendorSpoof and metalHUD from UserDefaults and conditionally sets D3DM_* GPU spoofing variables and MTL_HUD_ENABLED instead of applying them unconditionally. The Settings UI "Performance" section gains a footer note that changes take effect on the next app launch.

Changes

Performance Settings Toggle & UI

Layer / File(s) Summary
Conditional env vars from UserDefaults & Settings footer
Sources/D4Mac/BNetLauncher.swift, Sources/D4Mac/Settings.swift
WineProcess reads vendorSpoof (defaulting to true) and metalHUD from UserDefaults and gates D3DM_VENDOR_ID, D3DM_DEVICE_ID, D3DM_DEVICE_DESCRIPTION, and MTL_HUD_ENABLED on those values. The Settings "Performance" Section gains an explicit header and a footer Text noting changes apply on the next launch.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐇 Hippity-hop, I check my defaults today,
Spoof the GPU vendor — or keep it away!
The HUD lights up when you flick the switch,
Next launch applies it without a hitch.
Settings got a footer, neat and bright,
Everything toggled just right! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: wiring two Settings toggles (metalHUD and vendorSpoof) into the Wine environment, which is the core objective of the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Sources/D4Mac/BNetLauncher.swift`:
- Around line 45-55: The code only sets environment variables when toggles are
enabled, but inherited variables from the parent environment are not being
cleared when toggles are disabled. Add else clauses to both the vendorSpoof and
metalHUD conditional blocks to explicitly clear the corresponding environment
variables when their toggles are off. For the vendorSpoof block, clear
D3DM_VENDOR_ID, D3DM_DEVICE_ID, and D3DM_DEVICE_DESCRIPTION by setting them to
empty strings. For the metalHUD block, clear MTL_HUD_ENABLED by setting it to an
empty string when the toggle is false.
🪄 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 Plus

Run ID: 84b27da6-db6d-47c8-b3b3-b253584dbf8c

📥 Commits

Reviewing files that changed from the base of the PR and between 09d3080 and 04beeea.

📒 Files selected for processing (2)
  • Sources/D4Mac/BNetLauncher.swift
  • Sources/D4Mac/Settings.swift

Comment on lines +45 to +55
// GPU vendor/device spoof so D4 takes the Apple-GPU path.
if vendorSpoof {
env["D3DM_VENDOR_ID"] = "0x106b"
env["D3DM_DEVICE_ID"] = "0x0209"
env["D3DM_DEVICE_DESCRIPTION"] = "Apple GPU"
}

// Apple's built-in Metal performance HUD (FPS / frame-time overlay).
if defaults.bool(forKey: "metalHUD") {
env["MTL_HUD_ENABLED"] = "1"
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Clear inherited env keys when toggles are off.

Because Line 21 seeds from the parent environment, turning a toggle off does not currently guarantee deactivation if D3DM_* or MTL_HUD_ENABLED are already set upstream.

Suggested fix
         // GPU vendor/device spoof so D4 takes the Apple-GPU path.
         if vendorSpoof {
             env["D3DM_VENDOR_ID"] = "0x106b"
             env["D3DM_DEVICE_ID"] = "0x0209"
             env["D3DM_DEVICE_DESCRIPTION"] = "Apple GPU"
+        } else {
+            env.removeValue(forKey: "D3DM_VENDOR_ID")
+            env.removeValue(forKey: "D3DM_DEVICE_ID")
+            env.removeValue(forKey: "D3DM_DEVICE_DESCRIPTION")
         }

         // Apple's built-in Metal performance HUD (FPS / frame-time overlay).
         if defaults.bool(forKey: "metalHUD") {
             env["MTL_HUD_ENABLED"] = "1"
+        } else {
+            env.removeValue(forKey: "MTL_HUD_ENABLED")
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Sources/D4Mac/BNetLauncher.swift` around lines 45 - 55, The code only sets
environment variables when toggles are enabled, but inherited variables from the
parent environment are not being cleared when toggles are disabled. Add else
clauses to both the vendorSpoof and metalHUD conditional blocks to explicitly
clear the corresponding environment variables when their toggles are off. For
the vendorSpoof block, clear D3DM_VENDOR_ID, D3DM_DEVICE_ID, and
D3DM_DEVICE_DESCRIPTION by setting them to empty strings. For the metalHUD
block, clear MTL_HUD_ENABLED by setting it to an empty string when the toggle is
false.

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.

1 participant