Skip to content

feat(mac): add Preferences.ApplicationNameForUserAgent option#5261

Merged
leaanthony merged 3 commits into
wailsapp:masterfrom
vinhvoit225:feat/mac-application-name-user-agent
May 11, 2026
Merged

feat(mac): add Preferences.ApplicationNameForUserAgent option#5261
leaanthony merged 3 commits into
wailsapp:masterfrom
vinhvoit225:feat/mac-application-name-user-agent

Conversation

@vinhvoit225

@vinhvoit225 vinhvoit225 commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Allows overriding the WKWebView applicationNameForUserAgent suffix which is hard-coded to 'wails.io' by default. Empty string preserves the previous behaviour. Useful for sites (e.g. YouTube embed) that reject the default identifier.

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (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

Please paste the output of wails doctor. If you are unable to run this command, please describe your environment in as much detail as possible.

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
    • Added customizable User-Agent application name for macOS. You can now configure a custom application name to override the default "wails.io" identifier in the User-Agent string sent by the web view. This provides better control over how your application identifies itself to external web services and remote servers when making requests.

Allows overriding the WKWebView applicationNameForUserAgent suffix
which is hard-coded to 'wails.io' by default. Empty string preserves
the previous behaviour. Useful for sites (e.g. YouTube embed) that
reject the default identifier.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e90d5f62-4cac-4c8b-be5b-dc49a0f58922

📥 Commits

Reviewing files that changed from the base of the PR and between e3b472f and 9be3eb8.

📒 Files selected for processing (4)
  • v2/internal/frontend/desktop/darwin/WailsContext.h
  • v2/internal/frontend/desktop/darwin/WailsContext.m
  • v2/internal/frontend/desktop/darwin/window.go
  • v2/pkg/options/mac/preferences.go

📝 Walkthrough

Walkthrough

The changes add support for a customizable application name in the WKWebView User-Agent string for macOS applications. A new ApplicationNameForUserAgent preference field is introduced across the Go configuration, C header, and Objective-C implementation layers, with fallback to the default "wails.io" value.

Changes

Cohort / File(s) Summary
User-Agent Configuration Implementation
v2/pkg/options/mac/preferences.go, v2/internal/frontend/desktop/darwin/window.go, v2/internal/frontend/desktop/darwin/WailsContext.h, v2/internal/frontend/desktop/darwin/WailsContext.m
Adds configurable ApplicationNameForUserAgent field to macOS preferences struct. The preference flows from Go configuration through the C bridge to Objective-C, where it is applied to WKWebViewConfiguration with fallback to @"wails.io".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A user-agent name, now up to you,
No more "wails.io" if you don't want it true,
Through Go and C code, it travels so fast,
Custom branding at last, at last, at last! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description provides a clear summary of the change and its purpose, but fails to complete required checklist items and does not reference a linked issue with 'Fixes #'. Complete the required checklist items, reference a linked issue with 'Fixes #', and provide test configuration details and platform testing results.
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 (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding a new macOS preference option for customizing the WKWebView User-Agent application name.
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

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.11.4)

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.

@leaanthony

Copy link
Copy Markdown
Member

Triaged by Wails PR Reviewer

This PR has been reviewed and accepted. A test sub-issue has been created for macOS.

Head Ref OID: 9be3eb8d063ca4dd9d44c709aeb8ec091ecad272


This comment serves as a signature that this PR has been triaged. Future runs will skip this PR based on the headRefOid.

@leaanthony leaanthony enabled auto-merge (squash) May 11, 2026 13:11
@leaanthony leaanthony merged commit 4c405b6 into wailsapp:master May 11, 2026
12 of 13 checks passed
pull Bot pushed a commit to WangNingkai/wails that referenced this pull request May 11, 2026
…d Preferences.ApplicationNameForUserAgent option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants