Skip to content

feat(v3/darwin): native macOS window chrome - #6130

Draft
taliesin-ai wants to merge 46 commits into
masterfrom
feat/macos-window-chrome
Draft

taliesin-ai wants to merge 46 commits into
masterfrom
feat/macos-window-chrome

Conversation

@taliesin-ai

@taliesin-ai taliesin-ai commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

Native macOS chrome for Wails v3

This branch gives Wails v3 a native AppKit application structure around the WebView: a real NSToolbar, an NSSplitViewController layout with semantic sidebar, content list, primary and inspector items, an NSOutlineView source list, a typed inspector, native titlebar and split-item accessories, a native sharing provider, window tab groups, and an experimental WebView-free NativeWindow.

What is in this PR

Chrome model

  • MacToolbar: buttons, search (recents, scope menu, incremental), share, item groups, menu items (NSMenuToolbarItem), fixed and flexible spaces, centred items, sidebar and inspector toggles with tracking separators, SF Symbols, badges, visibility priority, navigational items, live insert/remove/move after attachment, user customisation with autosave and stable persistence keys.
  • MacSplitView: sidebar, content list, primary WebView or text editor, inspector; thickness, priority, collapse, autosave; edge-to-edge or below-toolbar content layout.
  • MacSidebar: sections, nested rows, symbols, badges, trailing accessories, tint, single and multi-selection, context menus, inline rename, drag reordering, removal.
  • MacContentList: the Finder and Mail middle column, as rich rows or a multi-column table, with selection, activation, sorting, context menus, styles and an empty-state label.
  • MacInspector: label, text field, checkbox, popup, slider, stepper, segmented, colour well, date picker and button controls; collapsible sections; removal and reordering.
  • MacAccessory: native search, segmented, button, menu button, label and spacer controls in an NSTitlebarAccessoryViewController, or an NSSplitViewItemAccessoryViewController on macOS 26+.
  • Window tab groups: AddTab, TabGroup() with selection, tab bar and overview toggles, detach, merge and tab titles.

Runtime and options

  • Split views and toolbars can be installed on windows created after App.Run, or atomically through MacWindow.SplitView and MacWindow.Toolbar.
  • NativeWindow applies every meaningful MacWindow option (backdrop, Liquid Glass, shadow, corners, appearance, level, collection behaviour, tabbing, panels, content layout) and Run() returns errors.
  • Chrome callback loops register from their own files instead of App.Run.
  • The CGO_ENABLED=0 -tags server cross-build compiles again.

Platform integration (Tier 2 of the audit, 47 of 48 items)

  • Windows: represented file, document-edited dot, subtitle, cascading, frame autosave, traffic-light offset, critical attention, print options, PDF and PNG export, sheets, popovers, presentation options, state restoration with WebKit interaction state.
  • Menus and Dock: SF Symbols, badges, section headers, palettes, mixed state, alternates, indentation, dock menu, Open Recent, dock progress.
  • Dialogs: suppression checkbox, help button, text prompts, content-type filters, save formats and tags, colour and font panels.
  • Status items and feedback: tooltip, symbol icons, removable items, popovers, haptics, sounds, speech synthesis and recognition.
  • Clipboard and drag: images, files, HTML, RTF and custom types with change notifications, drag out with file promises, text, URL and image drops.
  • System: permissions (and the cross-platform Permissions option now honoured for WebKit capture), sleep prevention, power and thermal state, termination control, accessibility settings, keyboard layout and locale with events, Services menu provider with a services: config passthrough, Handoff and universal links, workspace helpers and default handlers, Apple Events with an sdef, Quick Look previews and thumbnails, Spotlight indexing.
  • Trackpad gestures are left for feat(v3/darwin): prepare AppKit layer for macOS 27 compatibility #5760, which already adds gesture recognisers.

Docs and examples

  • New guides: guides/macos-native-chrome.mdx and guides/macos-platform-integration.mdx.
  • Examples: mac-toolbar (four-pane notes app), mac-titlebar-accessory, mac-window-tabs, mac-native-editor, mac-menus-dock, mac-dialogs, mac-feedback, mac-clipboard-drag, mac-system, mac-windows-extra, mac-integration, mac-search-preview.
  • v3/wep/proposals/macos-window-chrome/ holds the branch review with resolutions and an 85-item audit of further macOS features Wails could expose.

Verification

Check Result
go build ./pkg/..., go vet pass
go test ./pkg/application/ (default and wails_native) pass
go test -race on the chrome packages pass
-tags wails_native, -tags server, -tags private_mac_apis pass
CGO_ENABLED=0 GOOS=linux and GOOS=windows with -tags server pass
Docs site build (astro build, 196 pages, links valid) pass
All twelve example launches on macOS 26.4.1 clean
Runtime probes per area (AppKit state read back through cgo, including a quit-and-relaunch restoration check) all pass

Known limits

  • Popovers host native controls; a WebView popover is a follow-up.

  • Speech recognition, Services, Handoff, Apple Events from other processes and Spotlight results need a bundled and signed app, so those were verified in-process and are staged for a manual pass.

  • Windows and Linux get no-op or not-supported stubs for the new managers; the Windows sound and dock progress paths are cross-compile checked only.

  • Split-item accessories need macOS 26; titlebar accessories work on all supported versions.

  • Accessory controls must be added before attaching (toolbars support live mutation, accessories do not yet).

  • Without -tags private_mac_apis, the split view's WebView keeps drawing its own background, per feat(v3): gate private macOS APIs behind private_mac_apis #6087.

  • The interactive behaviours (customisation sheet, drag reorder, rename, tab overview) had launch and probe coverage, not a human pass yet.

Replaces the current empty-spacer NSToolbar with real NSToolbarItems:
buttons, segmented groups, a search field, flexible space, and a
sidebar-toggle item (tracking-separator wiring lands with split windows).
Follows the existing menu-item id-tagged-object + //export click bridge +
channel + dispatcher pattern. macOS only; no-op on every other platform.

Verified: go build ./pkg/application/... is clean, an isolated AppKit
spike proves the click bridge end-to-end, and a smoke-test app runs
without crashing or introducing warnings beyond this session's existing
baseline (no interactive WindowServer access here, confirmed against a
toolbar-free control app showing the same IsVisible()=false behavior).
SetToolbar silently no-op'd when called between NewWithOptions and
app.Run() (w.impl is nil until run()), which is exactly how the API
reads most naturally. Stash the toolbar on WebviewWindow and apply it
during run(), after the placeholder toolbar UseToolbar may attach, so
construction-time calls work the same as post-Run() calls.
Notes-style app demonstrating MacToolbar end to end: an Edit/Preview
segmented group, a flexible space, a native search field whose query
round-trips through Go, a bordered Share button, and a
bordered+prominent+tinted Info button whose BadgeCount is bumped by
rebuilding the toolbar and calling SetToolbar again (there's no
per-item update method). Every interaction is logged in an on-page
activity panel so each Go callback firing is visible without a
debugger. Also exercises the just-fixed construction-time SetToolbar
path (called before app.Run()).

Verified: go build/vet clean, binary launches and serves assets
without crashing.
NewSplitWindow builds a real NSSplitViewController-backed window: the
underlying window is a genuine *WebviewWindow (constructed the normal
way), so it gets full chrome -- toolbar, standard titlebar behaviour,
etc. -- for free. Only the content area is replaced with a split view.

Pane 0 reuses the window's own already-built WKWebView (reparented
into the first NSSplitViewItem) rather than creating a new one, so all
of windowNew's existing wiring (execJS, setURL, zoom, the runtime-core
injection hook) keeps targeting a real on-screen webview instead of
one silently orphaned by the contentViewController swap. Panes 1..N
get freshly built webviews that reuse the window's existing
WebviewWindowDelegate instance (same windowId) for the wails://
scheme handler and the "external" script message handler -- asset
loading and Call/Events/Clipboard IPC from any pane route exactly
like they do from the window's main webview, with no separate
per-pane identity and no changes to the core window registry,
getTargetWindow, or the Window interface. Documented tradeoff: a pane
finishing navigation also fires the window's WebViewDidFinishNavigation
event, same as the main webview finishing.

Sidebar/ContentList/Inspector panes use the matching NSSplitViewItem
factory method (sidebarWithViewController: etc.), so they get AppKit's
standard glass/vibrancy and default sizing with no extra code.
AutosaveName persists divider positions via NSSplitView's own
NSUserDefaults-backed autosave. ToolbarSidebarToggle from the earlier
MacToolbar work needs no new plumbing: NSSplitViewController already
implements toggleSidebar: and AppKit's responder chain finds it.

Scoped for this pass: MacWebviewContent only (native text/PDF/
QuickLook pane kinds are a follow-up), construction-time panes only
(no AddPane/RemovePane yet), and MacWebviewPane's SetURL/Reload/ExecJS
guard on native-handle-readiness with a logged no-op rather than the
stash-and-apply-in-run() treatment SetToolbar got, since no example
needs post-construction pane mutation yet.

Also fixes both webview_window_toolbar_darwin.m/.h from the prior
commit missing their own //go:build darwin && !ios && !server line:
.h build tags are decorative (never #include'd standalone by the Go
toolchain), but a cgo-adjacent .m file needs the tag on itself to be
excluded from a build -- filename suffix (_darwin.m) alone isn't
enough. Without it both new .m files were being pulled into ios
builds and failing on a missing Cocoa.h. Caught by cross-compiling
for ios, not by the darwin build (which never exercises exclusion).

Verified: go build/vet clean for darwin, windows (CGO_ENABLED=0),
linux+server (CGO_ENABLED=0), and a real ios cross-compile against
the iOS SDK (zero errors, only pre-existing unrelated deprecation
warnings in other files).
Reader app demonstrating NewSplitWindow with three independent webview
panes: a sidebar (PaneBehaviorSidebar) article list, a content pane
(PaneBehaviorDefault) showing the selected article, and an inspector
pane (PaneBehaviorInspector) showing its metadata. A toolbar
ToolbarSidebarToggle item collapses/expands the sidebar via AppKit's
built-in toggleSidebar: responder-chain action -- no pane-tracking
code needed. AutosaveName persists divider drag positions. Selecting
an article emits a reader:select event that the other two panes'
independent webviews pick up via the normal app-wide Events bus.

Building this surfaced two real bugs in the split-window core from the
previous commit, both fixed here:

1. New pane webviews (panes 1..N; pane 0 reuses the window's own) were
   built with an NSZeroRect starting frame. WKWebView silently
   suspends loading from a zero-size frame -- it never even reaches
   the scheme handler, no error anywhere. Fixed by starting at a
   non-degenerate size (200x200), matching windowNew's own webview,
   since the split view resizes it once installed anyway.

2. Pane content URLs (e.g. "/content.html") were passed straight to
   NSURL URLWithString:, producing a URL with no scheme -- WKWebView
   has nothing to route to the wails:// custom scheme handler, so the
   load silently goes nowhere. windowNew's own webview never hit this
   because run() resolves options.URL through
   assetserver.GetStartURL() first. installSplitPanes and
   MacWebviewPane.SetURL now do the same resolution before handing the
   URL to the native side.

Both were invisible from a clean build: only running the example and
checking the asset-server log for content.html/inspector.html
requests (not just sidebar.html) surfaced them.

Verified: go build/vet clean for darwin, windows (CGO_ENABLED=0), and
linux+server (CGO_ENABLED=0). Ran the built binary: asset-server log
shows all three panes' distinct URLs being requested independently,
and a temporary Go-side listener (removed before this commit)
confirmed the sidebar pane's reader:select Events.Emit reaches Go
with the right payload -- proving cross-pane IPC actually round-trips,
not just that each pane's HTML loads.
NewSplitWindow always constructs with Hidden:true (to avoid flashing
an unsplit window before installSplitPanes runs), meaning the window
must always be shown explicitly via MacSplitWindow.Show() -- exactly
what the mac-split-sidebar example does, immediately after
NewSplitWindow, before app.Run().

WebviewWindow.Show() has two branches: if the native window already
ran, it clears options.Hidden and shows it; if not (impl nil, the
case here since Run() is deferred until app.Run() starts), it just
triggers Run() and returns -- without ever clearing Hidden. Run()'s
show-on-navigation-finished gate then reads options.Hidden as still
true and skips showing the window. The window gets built with a
correct split view and never appears.

Same shape as the SetToolbar-before-Run() bug fixed earlier this
session; fixed the same way, but scoped to MacSplitWindow.Show()
rather than touching the shared WebviewWindow.Show() used everywhere
else in the framework.

Caught by re-reading Show()'s exact branches after the pane-loading
bugs in the previous commit, not by anything the asset-server log
could show -- log-based pane-load verification proves content
reaches each webview, not that the window is ever ordered front.
Lea ran the example and called it out directly: it looked confused
and didn't look native at all. Two real bugs, both in code from the
previous two commits:

1. Sidebar/inspector panes set their HTML background to transparent,
   which only affects the page's own background -- WKWebView still
   paints its own opaque white backing underneath unless told
   otherwise. So instead of the automatic AppKit vibrancy the
   PaneBehaviorSidebar/Inspector factory methods are supposed to give
   for free, both panes just rendered as flat white boxes with no
   visual distinction from the content pane. Fixed by setting
   underPageBackgroundColor = clear on any pane whose behavior
   implies a system material background (sidebar/contentList/
   inspector); left alone for Default-behavior panes, which are
   correctly opaque in real apps (Mail's message body, Notes' editor).

2. The example's own HTML had debug labels baked into the visible UI
   -- headers literally reading "PaneBehaviorDefault" and
   "PaneBehaviorInspector", an activity log printing lines like "own
   WKWebView + wails:// scheme handler". These were verification aids
   for a screenshot-less environment that never got stripped before
   the example was called done. Removed.

Also extracted the WKWebView-construction helper (wails:// scheme
handler, "external" message handler, nav/UI delegate, reusing the
window's own WebviewWindowDelegate) out of webview_window_split_darwin.m
into a shared buildAuxiliaryWebview in webview_window_darwin.m/.h --
it was about to be needed a second time for titlebar accessories, and
copy-pasting a third near-identical WKWebViewConfiguration block
wasn't worth it.

Verified: go build/vet clean; ran the binary and visually inspected --
sidebar and inspector now show the real translucent material, no
debug text visible anywhere in the UI.
WebviewWindow.AddTitlebarAccessory adds an NSTitlebarAccessoryViewController
pinned AccessoryLeading/AccessoryTrailing, hosting its own independent
WKWebView built via the buildAuxiliaryWebview helper extracted in the
previous commit -- same windowId-keyed wails:// and IPC routing as the
window's main webview and any split panes, no new registry. Works on
a plain WebviewWindow with no toolbar and no split layout, and safe
to call before app.Run(): AddTitlebarAccessory queues on the window
when impl is nil and darwin's run() drains the queue, the same
stash-and-apply-in-run() pattern SetToolbar and MacSplitWindow already
use for exactly this construction-before-Run() gap.

Unlike a split pane, a titlebar accessory always sits directly on the
titlebar's own background rather than against a material-backed
NSVisualEffectView, so its webview always gets
underPageBackgroundColor cleared -- not conditionally on pane
behavior like the split-window fix in the previous commit, since
there's no "opaque content" case here the way there is for a
Default-behavior split pane.

Cross-platform surface (MacTitlebarAccessoryPosition,
MacTitlebarAccessoryOptions, MacTitlebarAccessory.SetURL/ExecJS) lives
in webview_window_titlebar_accessory.go with no build tag, matching
MacToolbar; a same-signature no-op stub covers every non-macOS
platform.

Also adds v3/examples/mac-titlebar-accessory: a plain single-webview
window with a Ping button pinned leading and a status pill pinned
trailing, the pill cycling Idle/Syncing/Synced on a timer entirely
via Go-driven ExecJS with nothing in the main window's content aware
of it -- proving both accessories render and update independently.
Learned from the split-sidebar example's feedback: no debug/API-name
text anywhere in the visible UI this time.

Verified: go build/vet clean for darwin, windows (CGO_ENABLED=0),
linux+server (CGO_ENABLED=0), and a real ios cross-compile. Ran the
built binary: asset-server log shows the main window and both
accessories' distinct URLs (/, /leading.html, /trailing.html) loading
independently, with no errors or warnings.
Writes up the toolbar/split-window/titlebar-accessory/tab-window work
on this branch as a formal WEP, following the existing
v3/wep/proposals/0001-titlebar-buttons precedent rather than leaving
the design only as ephemeral chat artifacts. Covers the full proposed
API (including the two pieces not yet built: native pane content
kinds and MacTabWindow), notes where the implementation diverged from
the original draft (HoldingPriority became a plain float64; the
separate LiquidGlass option field was dropped in favor of the
existing Backdrop enum), and is explicit in the Test Plan about what
"verified" has actually meant in this environment -- build/vet across
platforms, asset-server log checks, one IPC round-trip check, one
view-hierarchy check -- none of which is a substitute for looking at
the window, which is exactly how the split-sidebar example shipped
once already with a real visual defect no build check caught.
- port event payload store, GoStream middleware and runtime prelude into
  configureFrontend; move serveEventPayload next to the store
- add Context() and a tagged cancel wrapper to webViewAssetRequest
- exclude panel/notch Objective-C and master's new transport tests from
  wails_native builds
- route split-view WebView transparency through the private API bridge
Menu toolbar items, fixed spaces, centred items, visibility priority and
navigational semantics, live insert/remove/move after attachment, user
customisation with autosave and stable persistence keys, and search recents,
scope menus, incremental mode and placeholders.
Sidebar: nested rows, badges, trailing accessories, tint, multi-selection,
removal, context menus, inline rename and drag reordering. Inspector: slider,
stepper, segmented, colour well, date picker and button controls, collapsible
sections, and removal and reordering of sections and controls.
MacWindowTabGroup handle with selection, tab bar and overview toggles, plus
AddTab, AddNativeTab, MoveTabToNewWindow, MergeAllWindows and tab titles on
WebviewWindow. The mac-window-tabs example demonstrates each operation.
MacAccessory hosts native search, segmented, button, menu button, label,
spacer and raw-view controls in an NSTitlebarAccessoryViewController or, on
macOS 26+, an NSSplitViewItemAccessoryViewController. Attach points on
WebviewWindow, NativeWindow and MacSplitPane work before and after the
native window exists. Also switch the toolbar's macOS 26 availability guards
to __MAC_OS_X_VERSION_MAX_ALLOWED, since the legacy macro caps at 14.
MacContentList is an NSTableView installed with the contentList split-item
role: rich rows with title, subtitle, detail, symbol and badge, or a
multi-column table; selection, activation, sorting, context menus, styles and
an empty-state label. The mac-toolbar example gains a notes column.
…at runtime

SetSplitView now installs immediately when the native window already
exists, MacWindow and NativeWindowOptions gain SplitView and Toolbar fields
for atomic construction, NativeWindow.Run returns errors and New() yields a
deferred window that is created once it has content. Replacing an installed
layout is rejected with ErrMacSplitViewAlreadyInstalled.
…ndows

Backdrop (normal, transparent, translucent, Liquid Glass), shadow, corners,
appearance, window level, collection behaviour, tabbing mode, escape in
fullscreen, panel class with panel preferences, content layout and the full
titlebar struct now apply to WebView-free windows through shared NSWindow
helpers. The option contract is documented and the native editor example
gains a floating Quick Note panel.
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

@github-actions github-actions Bot added the Enhancement New feature or request label Sep 16, 2026
… and export

Represented file, document-edited indicator, subtitle, cascading initial
position and CascadeFrom, frame autosave, traffic-light offset, critical
attention requests, PrintWithOptions, ExportPDF and Snapshot.
…ility, keyboard and locale events

Honours WebviewWindowOptions.Permissions for WebKit media capture on macOS.
Adds six events and rebuilds the bundled runtime with the pinned esbuild.
…toration

Window-modal sheets with completion codes, MacPopover hosting native
accessory controls anchored to rects, toolbar items and the status item,
application presentation options with validation, and NSWindowRestoration
with a Go OnRestore hook, restoration data and WebKit interaction state.
…pace helpers

Register Services handlers with Info.plist generation and a services config
passthrough in build assets, publish and continue NSUserActivity for Handoff
and universal links, open with a chosen app, list handlers, activate apps and
read or set default handlers.
? "<tr><td>No applications found</td></tr>"
: apps.map((app) =>
`<tr><td>${escape(app.name)}</td><td>${escape(app.bundleID)}</td>` +
`<td class="actions"><button data-open="${escape(app.bundleID || app.path)}">Open with</button> ` +
: apps.map((app) =>
`<tr><td>${escape(app.name)}</td><td>${escape(app.bundleID)}</td>` +
`<td class="actions"><button data-open="${escape(app.bundleID || app.path)}">Open with</button> ` +
`<button data-activate="${escape(app.bundleID)}">Activate</button></td></tr>`).join("");
Merge the validated #6137 baseline 7b0f6dc, port authored macOS documentation and navigation, and translate the scoped changes into all nine locales. Preserve implementation and leave translation compatibility state to the upstream task.
@taliesin-ai
taliesin-ai changed the base branch from master to codex/mpress-markdown September 18, 2026 11:54
@taliesin-ai

Copy link
Copy Markdown
Collaborator Author

Ported this PR's authored documentation to M-Press, including all nine locales (de, fr, id, ja, ko, pt, ru, zh-cn, zh-tw).

Dependency: stacked on #6137 using the validated 7b0f6dc094bfe7bf693df0320338a9bfc5f86ec8 baseline. The migration branch has since advanced to e59d1c71cae1f11c2c5aed262b2f763d88614303 through the external #5778 merge; that history was left untouched, as requested.

Scope: 50 documentation/navigation files relative to the validated migration baseline. Ported the permissions and customising-windows changes and both new macOS guides, removed the restored Starlight configuration/sources, and retained the original implementation. Corrected the documentation's nonexistent PermissionPrompt name to PermissionDefault and the camera/microphone support-matrix cells to match the implementation. Translation audit configuration and sidecars are unchanged.

Validation:

  • Pinned M-Press v1.0.17 strict build: PASS, 2,030 pages (--strict --no-purge-css).
  • M-Press link/asset check: PASS.
  • Rendered-site check: PASS, 2,031 HTML files including the error page, all ten language routes, no errors.
  • Translation coverage: PASS. All 224 translated prose segments per locale checked; all 65 fenced code blocks per locale match English exactly. API identifiers, links, heading levels, tables and lists were checked; the repeated SetNavigational identifier in Japanese/Korean was manually verified as a grammatical restatement, not an API change.
  • Both complete Go programs from the chrome guide compile against this checkout. Nine referenced example packages pass/compile; the separate mac-window-tabs module also passes after generating its bindings and building its frontend.
  • Focused macOS/toolbar/permissions tests: PASS. Application and dock tests: PASS with only TestX11GlobalShortcutEndToEnd excluded; the full run failed that local synthesized-key callback test.
  • Native AppKit behavior cannot be exercised on this Linux host. The native-editor example is Darwin-only; the wails_native Linux compilation attempt also encounters platform-symbol errors. Implementation was not changed to address these.

Known migration gate: the strict translation audit remains failing (10,481 findings versus 7,678 on the baseline). There are zero missing translations and zero added/removed findings outside the touched page/navigation families. The new pages expose the existing line-segmentation/formatting compatibility limitations; the upstream translation task owns that work. No gate was disabled and no sidecar state was rewritten.

Review: the required coderabbit --plain attempt was rejected as unsupported by the installed CLI. The single narrow fallback hit the shared OSS review limit. No credits were used, no quota polling/retry was performed; scoped manual diff review and the checks above were completed instead. Inherited migration whitespace findings were distinguished from the port's clean documentation diff.

Base automatically changed from codex/mpress-markdown to master September 20, 2026 08:14
@leaanthony leaanthony added this to the v3.1.0 milestone Oct 13, 2026
@taliesin-ai taliesin-ai modified the milestones: v3.1.0, Future Oct 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Documentation Improvements or additions to documentation Enhancement New feature or request Linux MacOS runtime templates v3 Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants