Skip to content

Conversation

@AkimioJR
Copy link

@AkimioJR AkimioJR commented Oct 20, 2025

Description

Support functions: WindowSetSystemDefaultTheme,WindowSetLightTheme,WindowSetDarkTheme for darwin(basing on v2.10.2) and update documents. And it test OK in my device.

Feature #4654 (issue)

Type of change

Please select the option that is relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using wails doctor.

  • Windows
  • macOS
  • Linux

If you checked Linux, please specify the distro and version.

Test Configuration

wails on  feature/4654-runtime-SetAppearance-for-darwin 
❯ wails doctor

                                
          Wails Doctor          
                                

                                                                                                                            
# Wails
Version | v2.10.2


# System
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| OS           | MacOS                                                                                                                  |
| Version      | 15.6.1                                                                                                                 |
| ID           | 24G90                                                                                                                  |
| Branding     |                                                                                                                        |
| Go Version   | go1.24.4                                                                                                               |
| Platform     | darwin                                                                                                                 |
| Architecture | arm64                                                                                                                  |
| CPU 1        | Apple M1                                                                                                               |
| CPU 2        | Apple M1                                                                                                               |
| GPU          | Chipset Model: Apple M1 Type: GPU Bus: Built-In Total Number of Cores: 8 Vendor: Apple (0x106b) Metal Support: Metal 3 |
| Memory       | 16GB                                                                                                                   |
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌────────────────────────────────────────────────────────────────────────┐
| Dependency                | Package Name | Status    | Version         |
| Xcode command line tools  | N/A          | Installed | 2410            |
| Nodejs                    | N/A          | Installed | 24.3.0          |
| npm                       | N/A          | Installed | 11.4.2          |
| *Xcode                    | N/A          | Installed | 26.0.1 (17A400) |
| *upx                      | N/A          | Available |                 |
| *nsis                     | N/A          | Available |                 |
|                                                                        |
└─────────────────────── * - Optional Dependency ────────────────────────┘

# Diagnosis
Optional package(s) installation details: 
  - upx : Available at https://upx.github.io/
  - nsis : More info at https://wails.io/docs/guides/windows-installer/

 SUCCESS  Your system is ready for Wails development!

 ♥   If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony

GO Unit Test:

wails/v2 on  feature/4654-runtime-SetAppearance-for-darwin via 🐹 v1.25.1 
❯ go test ./...
?       github.com/wailsapp/wails/v2    [no test files]
?       github.com/wailsapp/wails/v2/cmd/wails  [no test files]
?       github.com/wailsapp/wails/v2/cmd/wails/flags    [no test files]
?       github.com/wailsapp/wails/v2/cmd/wails/internal [no test files]
# github.com/wailsapp/wails/v2/internal/frontend/desktop/darwin
WailsContext.m:164:18: warning: 'setShowsBaselineSeparator:' is deprecated: first deprecated in macOS 15.0 - No longer supported [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSToolbar.h:299:16: note: property 'showsBaselineSeparator' is declared deprecated here
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSToolbar.h:299:16: note: 'setShowsBaselineSeparator:' has been explicitly marked deprecated here
ok      github.com/wailsapp/wails/v2/cmd/wails/internal/dev     0.488s
?       github.com/wailsapp/wails/v2/cmd/wails/internal/gomod   [no test files]
?       github.com/wailsapp/wails/v2/cmd/wails/internal/logutils        [no test files]
?       github.com/wailsapp/wails/v2/cmd/wails/internal/template        [no test files]
?       github.com/wailsapp/wails/v2/cmd/wails/internal/template/base   [no test files]
?       github.com/wailsapp/wails/v2/internal/app       [no test files]
ok      github.com/wailsapp/wails/v2/internal/binding   0.648s
ok      github.com/wailsapp/wails/v2/internal/binding/binding_test      1.196s
?       github.com/wailsapp/wails/v2/internal/binding/binding_test/binding_test_import   [no test files]
?       github.com/wailsapp/wails/v2/internal/binding/binding_test/binding_test_import/binding_test_nestedimport [no test files]
?       github.com/wailsapp/wails/v2/internal/binding/binding_test/binding_test_import/float_package     [no test files]
?       github.com/wailsapp/wails/v2/internal/binding/binding_test/binding_test_import/int_package       [no test files]
?       github.com/wailsapp/wails/v2/internal/binding/binding_test/binding_test_import/map_package       [no test files]
?       github.com/wailsapp/wails/v2/internal/binding/binding_test/binding_test_import/uint_package      [no test files]
?       github.com/wailsapp/wails/v2/internal/colour    [no test files]
?       github.com/wailsapp/wails/v2/internal/frontend  [no test files]
?       github.com/wailsapp/wails/v2/internal/frontend/desktop  [no test files]
?       github.com/wailsapp/wails/v2/internal/frontend/desktop/darwin   [no test files]
?       github.com/wailsapp/wails/v2/internal/frontend/dispatcher       [no test files]
ok      github.com/wailsapp/wails/v2/internal/frontend/runtime  1.363s
?       github.com/wailsapp/wails/v2/internal/frontend/runtime/wrapper  [no test files]
ok      github.com/wailsapp/wails/v2/internal/fs        1.829s
ok      github.com/wailsapp/wails/v2/internal/github    2.043s
?       github.com/wailsapp/wails/v2/internal/go-common-file-dialog/cfd [no test files]
?       github.com/wailsapp/wails/v2/internal/go-common-file-dialog/cfdutil      [no test files]
ok      github.com/wailsapp/wails/v2/internal/go-common-file-dialog/util2.430s
ok      github.com/wailsapp/wails/v2/internal/gomod     2.829s
?       github.com/wailsapp/wails/v2/internal/goversion [no test files]
?       github.com/wailsapp/wails/v2/internal/logger    [no test files]
?       github.com/wailsapp/wails/v2/internal/menumanager       [no test files]
?       github.com/wailsapp/wails/v2/internal/process   [no test files]
ok      github.com/wailsapp/wails/v2/internal/project   3.181s
?       github.com/wailsapp/wails/v2/internal/s [no test files]
ok      github.com/wailsapp/wails/v2/internal/shell     2.712s
?       github.com/wailsapp/wails/v2/internal/signal    [no test files]
ok      github.com/wailsapp/wails/v2/internal/staticanalysis    6.001s
?       github.com/wailsapp/wails/v2/internal/system    [no test files]
?       github.com/wailsapp/wails/v2/internal/system/operatingsystem    [no test files]
?       github.com/wailsapp/wails/v2/internal/system/packagemanager     [no test files]
?       github.com/wailsapp/wails/v2/internal/typescriptify     [no test files]
?       github.com/wailsapp/wails/v2/internal/webview2runtime   [no test files]
?       github.com/wailsapp/wails/v2/pkg/application    [no test files]
ok      github.com/wailsapp/wails/v2/pkg/assetserver    2.854s
?       github.com/wailsapp/wails/v2/pkg/assetserver/webview    [no test files]
?       github.com/wailsapp/wails/v2/pkg/buildassets    [no test files]
?       github.com/wailsapp/wails/v2/pkg/clilogger      [no test files]
ok      github.com/wailsapp/wails/v2/pkg/commands/bindings      8.103s
ok      github.com/wailsapp/wails/v2/pkg/commands/build 3.204s
ok      github.com/wailsapp/wails/v2/pkg/commands/buildtags     3.242s
ok      github.com/wailsapp/wails/v2/pkg/git    2.973s
?       github.com/wailsapp/wails/v2/pkg/logger [no test files]
ok      github.com/wailsapp/wails/v2/pkg/mac    3.653s
ok      github.com/wailsapp/wails/v2/pkg/menu   2.886s
?       github.com/wailsapp/wails/v2/pkg/menu/colours   [no test files]
ok      github.com/wailsapp/wails/v2/pkg/menu/keys      2.477s
ok      github.com/wailsapp/wails/v2/pkg/options        2.129s
?       github.com/wailsapp/wails/v2/pkg/options/assetserver    [no test files]
?       github.com/wailsapp/wails/v2/pkg/options/linux  [no test files]
?       github.com/wailsapp/wails/v2/pkg/options/mac    [no test files]
?       github.com/wailsapp/wails/v2/pkg/options/windows        [no test files]
?       github.com/wailsapp/wails/v2/pkg/runtime        [no test files]
ok      github.com/wailsapp/wails/v2/pkg/templates      2.613s
?       github.com/wailsapp/wails/v2/pkg/templates/base [no test files]
?       github.com/wailsapp/wails/v2/pkg/templates/generate     [no test files]
?       github.com/wailsapp/wails/v2/pkg/templates/generate/plain       [no test files]
?       github.com/wailsapp/wails/v2/pkg/templates/templates/lit        [no test files]
?       github.com/wailsapp/wails/v2/pkg/templates/templates/lit-ts     [no test files]
?       github.com/wailsapp/wails/v2/pkg/templates/templates/plain      [no test files]
?       github.com/wailsapp/wails/v2/pkg/templates/templates/preact     [no test files]
?       github.com/wailsapp/wails/v2/pkg/templates/templates/preact-ts  [no test files]
?       github.com/wailsapp/wails/v2/pkg/templates/templates/react      [no test files]
?       github.com/wailsapp/wails/v2/pkg/templates/templates/react-ts   [no test files]
?       github.com/wailsapp/wails/v2/pkg/templates/templates/svelte     [no test files]
?       github.com/wailsapp/wails/v2/pkg/templates/templates/svelte-ts  [no test files]
?       github.com/wailsapp/wails/v2/pkg/templates/templates/vanilla    [no test files]
?       github.com/wailsapp/wails/v2/pkg/templates/templates/vanilla-ts [no test files]
?       github.com/wailsapp/wails/v2/pkg/templates/templates/vue        [no test files]
?       github.com/wailsapp/wails/v2/pkg/templates/templates/vue-ts     [no test files]
?       github.com/wailsapp/wails/v2/tools/release      [no test files]

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features

    • Window theme control now available on macOS, supporting light, dark, and system default modes.
  • Documentation

    • Updated theme method documentation to reflect macOS support.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 20, 2025

Walkthrough

The pull request adds macOS support for window appearance and theme functions (WindowSetSystemDefaultTheme, WindowSetLightTheme, WindowSetDarkTheme). A new SetAppearance method is implemented across Objective-C and Go layers, routing theme settings through the Darwin-specific frontend code. Documentation is updated to reflect unsupported status on Linux instead of Windows-only.

Changes

Cohort / File(s) Summary
Objective-C C bridge layer
v2/internal/frontend/desktop/darwin/Application.h, v2/internal/frontend/desktop/darwin/Application.m
Added SetAppearance() C function that bridges inctx to WailsContext and invokes appearance setting on the main thread.
WailsContext interface
v2/internal/frontend/desktop/darwin/WailsContext.h, v2/internal/frontend/desktop/darwin/WailsContext.m
Added SetAppearance:(NSString*)appearance method to WailsContext that resolves and applies NSAppearance by name to the main window.
Go language bindings
v2/internal/frontend/desktop/darwin/frontend.go, v2/internal/frontend/desktop/darwin/window.go
Added SetAppearance() method to Window type and routed WindowSetSystemDefaultTheme, WindowSetLightTheme, and WindowSetDarkTheme calls through appearance setter.
Documentation
website/docs/reference/runtime/window.mdx
Updated theming method documentation from "Windows only." to "Linux is unsupported."

Sequence Diagram

sequenceDiagram
    participant App as Application Layer
    participant WinGo as window.go
    participant C as C Bridge (Application.m)
    participant WailsCtx as WailsContext
    participant macOS as macOS AppKit

    App->>WinGo: frontend.SetAppearance("light")
    WinGo->>WinGo: Allocate C string
    WinGo->>C: SetAppearance(ctx, "light")
    C->>C: Dispatch to main thread
    C->>WailsCtx: [ctx SetAppearance:@"light"]
    WailsCtx->>WailsCtx: Resolve NSAppearance
    WailsCtx->>macOS: window.appearance = resolved
    macOS-->>WailsCtx: ✓ Applied
    WailsCtx-->>C: ✓
    C-->>WinGo: ✓
    WinGo->>WinGo: Free C string
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

The changes follow a straightforward vertical implementation pattern: a new feature is added consistently across Objective-C header/implementation, then wrapped through Go bindings and documented. No existing logic is modified; additions are self-contained and repetitive in nature. All layers demonstrate the same pattern with minimal conditional logic.

Suggested labels

Enhancement, Documentation, MacOS

Suggested reviewers

  • leaanthony

Poem

🐰 With paws on the keyboard, I hop with delight,
macOS themes now dance—from dark into light!
No Windows-only chains, cross-platform we soar,
setAppearance() opens the Darwin door! 🍎✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "[Feature]support WindowSetSystemDefaultTheme,WindowSetLightTheme,WindowSetDarkTheme for darwin(#4654)" clearly and directly describes the main change in the PR: adding support for three window theme functions on macOS. The title is specific enough that a developer scanning the history would immediately understand the feature being added, and it accurately represents the primary objective of the changeset. While the title is somewhat lengthy and includes the issue number, it effectively communicates the key contribution.
Linked Issues Check ✅ Passed The changes directly address all three objectives from linked issue #4654. The PR implements macOS (darwin) support for WindowSetSystemDefaultTheme, WindowSetLightTheme, and WindowSetDarkTheme through a new SetAppearance abstraction layer that bridges Go runtime calls to Objective-C NSAppearance APIs. The implementation includes C function declarations (Application.h/m), Objective-C method implementations (WailsContext.h/m), Go wrapper methods (window.go), and routing logic in frontend.go that maps the three theme functions to appropriate appearance strings. Documentation has been updated to reflect the platform support change. All coding-related requirements from the linked issue have been implemented.
Out of Scope Changes Check ✅ Passed All changes in the PR are directly scoped to implementing macOS support for the three window theme functions. The modifications span the necessary layers: C interop declarations (Application.h/m), native Objective-C implementation (WailsContext.h/m), Go runtime wrappers (window.go, frontend.go), and corresponding documentation updates. Each change is essential and directly related to the feature objectives defined in issue #4654, with no extraneous modifications or unrelated code alterations present.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed The PR description addresses most of the required template sections: it provides a summary of changes (adding macOS support for three window theme functions), references an issue (Feature #4654), specifies the type of change (new feature and documentation update), and includes comprehensive testing information with wails doctor output and go test results. However, the description is somewhat brief on motivation and context, and several checklist items are left unchecked including the changelog update and addition of formal tests. Despite these gaps, the core required information is present and sufficient to understand the PR's purpose, scope, and testing status.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@sonarqubecloud
Copy link

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