Skip to content

feat(mac/v3): extend MacWebviewPreferences with additional WKWebView config options#5549

Merged
leaanthony merged 3 commits into
masterfrom
worktree-feat+mac-v3-wkwebview-p1-options
Jun 8, 2026
Merged

feat(mac/v3): extend MacWebviewPreferences with additional WKWebView config options#5549
leaanthony merged 3 commits into
masterfrom
worktree-feat+mac-v3-wkwebview-p1-options

Conversation

@leaanthony

@leaanthony leaanthony commented Jun 7, 2026

Copy link
Copy Markdown
Member

Summary

Adds v3 parity for WKWebView configuration options, including the EnableAutoplayWithoutUserAction feature from #5512.

New fields in MacWebviewPreferences:

Field Maps to
EnableAutoplayWithoutUserAction config.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone
AllowsAirPlayForMediaPlayback config.allowsAirPlayForMediaPlayback
AllowsMagnification webView.allowsMagnification
JavaScriptCanOpenWindowsAutomatically config.preferences.javaScriptCanOpenWindowsAutomatically
MinimumFontSize config.preferences.minimumFontSize
ApplicationNameForUserAgent config.applicationNameForUserAgent (falls back to "wails.io" if empty)

Related

Closes the v3 gap for #5512.

Test plan

  • Build on macOS: go build ./v3/pkg/application/
  • Verify autoplay works without user gesture when EnableAutoplayWithoutUserAction: optional.True
  • Verify ApplicationNameForUserAgent override appears in the webview's user agent string

Summary by CodeRabbit

  • New Features
    • macOS WebView windows gain new preferences: pinch-to-zoom (magnification), AirPlay media playback, JavaScript automatic window opening, minimum font size, user-agent application-name override, and autoplay without user gesture.
  • Documentation
    • Added macOS per-window WebviewPreferences docs with examples and field-by-field explanations.

Adds v3 parity for the options introduced/planned for v2:
- EnableAutoplayWithoutUserAction → mediaTypesRequiringUserActionForPlayback
- AllowsAirPlayForMediaPlayback → config.allowsAirPlayForMediaPlayback
- AllowsMagnification → webView.allowsMagnification
- JavaScriptCanOpenWindowsAutomatically → config.preferences.javaScriptCanOpenWindowsAutomatically
- MinimumFontSize → config.preferences.minimumFontSize
- ApplicationNameForUserAgent → config.applicationNameForUserAgent (overrides "wails.io" default)
Copilot AI review requested due to automatic review settings June 7, 2026 10:59
@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c7339f55-2ff8-4536-b1b3-c06b7cffae5e

📥 Commits

Reviewing files that changed from the base of the PR and between 8c0cdee and 86ab3da.

📒 Files selected for processing (1)
  • v3/pkg/application/webview_window_darwin.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • v3/pkg/application/webview_window_darwin.go

Walkthrough

Adds six macOS WKWebView preferences (magnification, AirPlay, JS auto-window opening, minimum font size, applicationNameForUserAgent, autoplay without user gesture), threads them through Go structs and cgo to a changed C windowNew signature, and applies them in the native WKWebViewConfiguration/WKWebView setup. Documentation updated.

Changes

macOS WebView Preferences

Layer / File(s) Summary
Preferences contract and options exposure
v3/pkg/application/webview_window_options.go, v3/pkg/application/webview_window_darwin.go
MacWebviewPreferences gains six optional fields; C WebviewPreferences struct extended with corresponding pointer fields; windowNew signature updated to accept applicationNameForUserAgent.
Native preference application
v3/pkg/application/webview_window_darwin.go
windowNew applies AirPlay, autoplay policy, JavaScript automatic window opening, and minimum font size to WKWebViewConfiguration, sets config.applicationNameForUserAgent (or defaults to "wails.io"), and enables allowsMagnification on WKWebView.
Go preference population and threading
v3/pkg/application/webview_window_darwin.go
getWebviewPreferences() populates the new C preference fields (including a C.double pointer for MinimumFontSize); run() allocates ApplicationNameForUserAgent C string and passes it to C.windowNew.
Documentation update
docs/src/content/docs/features/windows/options.mdx
Adds Mac.WebviewPreferences docs with examples and per-field descriptions and macOS version notes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

  • wailsapp/wails#5261: Wires ApplicationNameForUserAgent through to native WKWebView configuration similarly.

Suggested labels

Enhancement, Documentation, MacOS, v3-alpha

Poem

🐰 A rabbit hops through preference fields so bright,
Threads of Go and C stitched into the night,
Magnify, AirPlay, fonts set just right,
User-agent singing, autoplay takes flight,
Native WebView wakes with config light.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description includes a clear summary of changes, field mappings, and a test plan, but lacks required sections from the template such as issue reference, type of change checkbox, and testing confirmation. Add 'Fixes #' reference, check relevant 'Type of change' boxes, confirm test platform checkboxes, and include 'wails doctor' output or environment details.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change: extending MacWebviewPreferences with additional WKWebView configuration options for macOS v3.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-feat+mac-v3-wkwebview-p1-options

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 and usage tips.

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

This PR extends Wails v3 macOS MacWebviewPreferences to expose additional WKWebView / WKWebViewConfiguration settings, closing feature parity gaps (notably autoplay without user action) previously addressed in v2.

Changes:

  • Added new MacWebviewPreferences fields for magnification, AirPlay, JS window-opening, minimum font size, user-agent application name, and autoplay without gesture.
  • Wired the new preferences through the macOS window creation path into WKWebViewConfiguration / WKPreferences / WKWebView.
  • Updated the native windowNew bridge to accept an applicationNameForUserAgent parameter with a "wails.io" fallback.

Reviewed changes

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

File Description
v3/pkg/application/webview_window_options.go Adds new macOS webview preference fields to the public options struct.
v3/pkg/application/webview_window_darwin.go Threads new preferences through the cgo/ObjC bridge and applies them to WKWebViewConfiguration / WKWebView.

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

Comment thread v3/pkg/application/webview_window_darwin.go Outdated
Comment thread v3/pkg/application/webview_window_darwin.go Outdated
@leaanthony leaanthony merged commit 7cc9bf0 into master Jun 8, 2026
89 checks passed
@leaanthony leaanthony deleted the worktree-feat+mac-v3-wkwebview-p1-options branch June 8, 2026 08:18
leaanthony added a commit that referenced this pull request Jun 13, 2026
Bundles content from the failed alpha.99 release (tag pushed but no
GitHub release created due to token misconfiguration) together with
the alpha.100 cycle. Includes:
- MacWebviewPreferences WKWebView extensions (#5549)
- generate bindings "Access is denied" fix on Windows (#5561)
- Linux frameless JS resize / scrollbar edge detection fix (#5368)
- Windows updater cross-volume rename fallback (#5560)
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.

2 participants