Repository navigation
Description
Context
core.WebView can replace the user agent and nothing more. Its comment at core/webview.go:26 says "UserAgent replaces the platform's.", and each host passes the string through whole: Apple calls setCustomUserAgent: with it (internal/platform/apple/web.go:233-237), Linux calls webkit_settings_set_user_agent (internal/platform/linux/web.go:217-221), and Windows put_UserAgent (internal/platform/windows/web.go:411-417). Windows already reads the platform's default at creation (internal/platform/windows/web.go:225), but only to restore it when UserAgent is empty. An app cannot add a token to the platform's own string without hardcoding the whole string for each engine and version.
WebView has nothing for sound. None of its fields (core/webview.go:19-57) is about audio, and its Ref commands are Reload, GoBack, GoForward, StopLoading, PostMessage, InjectJavaScript and SendInput (internal/driver/webview.go:139-155, core/webview.go:216-238), plus Evaluate (core/webview.go:279). core.Video has Muted/MutedFunc (core/video.go:19-20), but there is no way to mute a web page's sound.
No API clears website data either. All of an app's web views share one store, and it persists. Linux keeps one network session per app ID, with cookies in cookies.sqlite, and its comment says "Cookies outlive the app, as other website data does." (internal/platform/linux/web.go:304-325). Apple builds a plain WKWebViewConfiguration (internal/platform/apple/web.go:251), so it uses the default persistent WKWebsiteDataStore. Scope has no method that removes that data.
The roadmap row "More of a web view's loads" (docs/roadmap.md:27) and #33 cover Incognito, which keeps a view's data in memory. That solves a different problem. The app below wants the login to persist and to be erased only when the user asks. Draft PR #76 (headers, downloads, Incognito, ServeScheme, Env.HasWebView, Env.CanSendInput) does not touch muting, clearing or appending to the user agent.
Why it matters for real apps
Kando (github.com/yldm-tech/kando) is a desktop video player with a built-in browser. The user signs in to a video site in it, and the app then downloads from that site with the same cookies and user agent. Kando does three things on its current framework that NSGo has no way to do:
- Mute while hidden. The browser's web view stays mounted while another page of the app shows, so when the user comes back the page is where they left it. A video playing in it keeps playing, so the app mutes the page while it is hidden and unmutes it when the page shows again. With NSGo, nothing stops that video's sound from playing over the app's own player. A script run through
Ref.Evaluatethat setsmutedon<video>/<audio>misses Web Audio, cross-origin iframes and elements the page creates later, and the page can see the change and undo it. - "Clear sign-in data". A menu command, after a confirmation, deletes the cookies, storage and caches of the shared store, for example when the user signs out or switches accounts, then reloads the page. A page script cannot reach HttpOnly session cookies, so the page itself offers no workaround.
- Append to the user agent. A bare
WKWebViewuser agent names no browser, and some sites send it an older page or refuse its sign-in. The app appendsVersion/26.0 Safari/605.1.15on macOS only and keeps WebKit's ownMozilla/5.0 (Macintosh; ...) AppleWebKit/...prefix. WebKitGTK's and WebView2's defaults already name their browsers, so the app leaves them unchanged. Replacing the whole string means hardcoding each OS and engine version, which breaks sites that check them.
(The downloader also needs the user agent the page actually sends. That already works through Ref.Evaluate("navigator.userAgent", ...).)
Minimal repro of the user agent gap:
core.WebView{
Source: core.WebSrc("https://example.com/"),
// The only option: this becomes the whole string, losing
// "Mozilla/5.0 (Macintosh; ...) AppleWebKit/605.1.15 (KHTML, like Gecko)".
UserAgent: "Version/26.0 Safari/605.1.15",
}And of the audio gap: mount a WebView that plays a <video autoplay> with sound, then hide it while keeping it mounted, for example with Style{Display: core.DisplayNone}. No field or Ref method silences the page.
Proposal
On WebView, following Video's Muted/MutedFunc and the existing SourceFunc/StyleFunc pattern:
// UserAgentSuffix is appended, after a space, to UserAgent, or to the
// platform's own user agent when UserAgent is empty.
UserAgentSuffix string
// Muted silences everything the page plays, as a browser mutes a tab:
// media elements, Web Audio and frames of other sites, without the page
// seeing its elements muted. It lasts across navigations.
Muted bool
MutedFunc func() boolFor the stored data, a Scope method like ImageSize and NotificationPermission. It is asynchronous because every engine reports completion through a callback:
// ClearWebsiteData deletes what the app's web views stored in its shared,
// persistent store: cookies, local and session storage, IndexedDB,
// service workers and caches. Open pages keep what they hold in memory
// until they load again.
func (cx *Scope) ClearWebsiteData(done func(err error))Platform mechanisms:
- User agent suffix: Apple
WKWebViewConfiguration.applicationNameForUserAgent, set on the configurationmake()builds before the view exists, orcustomUserAgent=UserAgent+ suffix whenUserAgentis set. Windows: the default already read atinternal/platform/windows/web.go:225+ suffix. WebKitGTK: the settings' default user agent + suffix. Android:WebSettings.getDefaultUserAgent+ suffix. - Muted: WebKitGTK
webkit_web_view_set_is_muted(2.30+). WebView2ICoreWebView2_8::put_IsMuted. Apple has no public mute API. Safari mutes a tab through WebKit's-[WKWebView _setPageMuted:], which could be used behindrespondsToSelector:. If private API is not acceptable, the publicsetAllMediaPlaybackSuspended:completionHandler:(macOS 12 / iOS 15) pauses media rather than muting it, and the field's doc should say so. Targets with no mechanism at all (Android, web) should be reported inEnvor in the field's doc. - ClearWebsiteData: Apple
-[WKWebsiteDataStore removeDataOfTypes:modifiedSince:completionHandler:]withallWebsiteDataTypesanddistantPast. WebKitGTKwebkit_website_data_manager_clearon the website data manager of the app's network session. WebView2ICoreWebView2Profile2::ClearBrowsingDataAll. AndroidCookieManager.removeAllCookies+WebStorage.deleteAllData+WebView.clearCache.
Acceptance
- With
UserAgentSuffix: "Version/26.0 Safari/605.1.15"and noUserAgent,navigator.userAgenton macOS starts with WebKit's default and ends with the suffix. On Windows and Linux it is the engine's default plus the suffix. WithUserAgentset, it isUserAgentplus the suffix. - The suffix also appears in the HTTP
User-Agentrequest header, not only innavigator.userAgent. - A page playing
<video>with sound and a Web Audio oscillator is silent on Windows and Linux whileMutedFuncreturns true. It plays again whenMutedFuncreturns false and stays muted across a navigation.HTMLMediaElement.mutedstill reads false in the page. macOS meets the same check, or its documented limitation is stated. - After
ClearWebsiteDatareportsnil, a reload on all three desktops finds none of the cookies (HttpOnly included),localStorageentries or IndexedDB databases the page had set. A failure reachesdoneas an error. -
docs/architecture/native-views.mdlists, per target, which of the three are supported, and the gallery's WebView demo exercises them.
Activity
houko commentedon Nov 20, 2026
I audited #114 against the latest
origin/main. The persistent-store portion is already implemented asScope.ClearWebsiteData, with Apple, Linux, Windows, and Android backends and native tests covering cookies and website storage. Incognito storage is also present.The remaining request is UserAgentSuffix and page-level mute. A correct suffix must preserve each engine's default user agent in both
navigator.userAgentand HTTP requests, including Android and Web, while page mute needs native tab/audio controls that are unavailable on some targets and a documented capability contract. I did not submit a partial field that would replace defaults or mute only media elements. The issue remains open for those cross-target controls and their platform matrix.houko commentedon Nov 21, 2026
Rechecked main after #1792. #1013 added
UserAgentSuffix, #1247 added page mute, andScope.ClearWebsiteDataclears the shared store. The gallery exercises all three and the native-view guide states which hosts support each operation.The native tests cover the request header and the page's user agent. Linux and Windows use their engines' page-wide mute controls, and Apple suspends media through WKWebView as documented. Linux audio capture covered the media element and Web Audio before and after toggling mute, and the Windows native tests checked mute state across navigation. The Windows audio output capture remains unverified.