Skip to content

fix(v3/windows): pass HWND to AllowDarkModeForWindow - #5877

Merged
leaanthony merged 4 commits into
masterfrom
fix/allow-dark-mode-window-abi
Aug 3, 2026
Merged

leaanthony merged 4 commits into
masterfrom
fix/allow-dark-mode-window-abi

Conversation

@leaanthony

@leaanthony leaanthony commented Aug 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow-up to #5873.

  • passes both native arguments required by ordinal 133: HWND and the allow flag
  • adds a Windows-only AST regression test that verifies the SyscallN call preserves the native ABI argument order

Why

The wrapper was declared as AllowDarkModeForWindow(HWND, bool) but invoked SyscallN with only the Boolean value. Lowering the uxtheme gate in #5873 expanded that broken call path to Windows build 17763, so this corrects the ABI immediately while keeping the original fix independently merged.

Testing

CI should exercise the Windows package and the new regression test.

Summary by CodeRabbit

  • Bug Fixes

    • Improved dark mode handling on Windows by correctly applying the setting to the selected window.
  • Tests

    • Added Windows-specific validation to ensure dark mode requests use the correct parameters.

Copilot AI review requested due to automatic review settings August 2, 2026 22:29
@coderabbitai

coderabbitai Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e5bfb859-e610-4d86-bd9c-4f3757f45475

📥 Commits

Reviewing files that changed from the base of the PR and between 6063058 and bd3e702.

📒 Files selected for processing (2)
  • v3/pkg/w32/theme.go
  • v3/pkg/w32/theme_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • v3/pkg/w32/theme.go
  • v3/pkg/w32/theme_test.go

Walkthrough

AllowDarkModeForWindow now passes the window handle to the Windows dark-mode API. A Windows-only AST test validates the argument count, identifiers, and uintptr conversions.

Changes

Windows dark-mode syscall

Layer / File(s) Summary
Pass and validate the window handle
v3/pkg/w32/theme.go, v3/pkg/w32/theme_test.go
AllowDarkModeForWindow passes hwnd before the dark-mode flag. The Windows-only AST test validates the syscall arguments and uintptr conversions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • wailsapp/wails#5793: Both changes modify Windows dark-mode handling around AllowDarkModeForWindow; this change updates arguments, while the related PR adds nil-pointer guards.
  • wailsapp/wails#5879: The native-menu policy relies on the corrected AllowDarkModeForWindow API call.

Suggested labels: Windows

Poem

A rabbit checks the window handle,
Then passes it with the flag.
Three arguments match the contract,
AST checks guard the path.
Dark mode hops on Windows. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main Windows fix: passing the HWND to AllowDarkModeForWindow.
Description check ✅ Passed The description explains the fix, motivation, issue context, and regression test, but it omits the template checklists and test configuration.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/allow-dark-mode-window-abi

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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.

Copilot AI left a comment

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.

Pull request overview

Fixes the Windows dark-mode uxtheme call ABI by passing the missing HWND argument to ordinal 133 (AllowDarkModeForWindow), and adds a Windows-only regression test to ensure the native argument order is preserved.

Changes:

  • Pass both HWND and the allow flag to syscall.SyscallN(procAllowDarkModeForWindow, ...).
  • Add a Windows-only AST-based test that asserts the SyscallN invocation uses (proc, hwnd, allowInt).

Reviewed changes

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

File Description
v3/pkg/w32/theme.go Fixes the AllowDarkModeForWindow syscall ABI by adding the missing HWND argument.
v3/pkg/w32/theme_test.go Adds a Windows-only AST regression test verifying SyscallN argument count and order.

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

Comment thread v3/pkg/w32/theme_test.go
Comment on lines +5 to +16
import (
"go/ast"
"go/parser"
"go/token"
"testing"
)

func TestAllowDarkModeForWindowPassesHWNDAndAllowFlag(t *testing.T) {
file, err := parser.ParseFile(token.NewFileSet(), "theme.go", nil, 0)
if err != nil {
t.Fatalf("parse theme.go: %v", err)
}
@roachadam

Copy link
Copy Markdown
Contributor

I was just about to file this. I have another few related issues PRs that I will open too.

@leaanthony leaanthony added this to the v3.0.0-beta.3 milestone Aug 3, 2026
@leaanthony

Copy link
Copy Markdown
Member Author

Reviewed for Beta 3. The native call fix is correct and should be included. The Windows CI failure is isolated to the new test: importing go/token as token collides with the package-level token declaration in gdiplus.go. Alias that import (for example gotoken) and rerun the Windows suite; no behavioral issue was found in the production change.

@leaanthony
leaanthony force-pushed the fix/allow-dark-mode-window-abi branch 2 times, most recently from a6f1cab to 6063058 Compare August 3, 2026 07:17
@leaanthony
leaanthony force-pushed the fix/allow-dark-mode-window-abi branch from 6063058 to bd3e702 Compare August 3, 2026 07:18
@leaanthony
leaanthony merged commit c0dc59e into master Aug 3, 2026
22 checks passed
@leaanthony
leaanthony deleted the fix/allow-dark-mode-window-abi branch August 3, 2026 07:21
leaanthony pushed a commit that referenced this pull request Aug 3, 2026
@taliesin-ai taliesin-ai added v3 and removed v3-alpha labels Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants