* fix(v3/linux): fix crash on panic in JS-bound Go methods
WebKit2GTK installs signal handlers after gtk_main() starts, overriding
our SA_ONSTACK fix. This causes Go panics (e.g., nil pointer dereference)
in JS-bound methods to crash with 'non-Go code set up signal handler
without SA_ONSTACK flag'.
Fix by deferring signal handler installation via g_idle_add() to run
after GTK main loop starts, ensuring we fix handlers AFTER WebKit
has installed its own.
Fixes#3965
* test(v3/linux): add test case for signal handler fix
Adds a test application that can trigger panics from JS-bound Go methods
to verify the signal handler fix for issue #3965 works correctly.
The test app has buttons to:
- Trigger a panic in a goroutine
- Trigger an immediate panic
- Call a safe method
Before the fix, clicking 'Trigger Panic' would crash the app.
After the fix, panics are recovered and logged.
* chore: remove test case from PR
* fix(linux): call signal handler fix after WebKit init, not in idle callback
Move install_signal_handlers() call to after webkit_web_view_new_with_user_content_manager()
to ensure WebKit has finished setting up its signal handlers before we add SA_ONSTACK.
The previous g_idle_add approach was still too early - WebKit initialization continues
after GTK init. This matches the v2 approach which waits for actual webview creation.
Also add documentation about the known Go limitation (golang/go#7227) where signals
may still be delivered on the wrong stack in some C interop scenarios.
* fix(v3): replace various debug logs from Info to Debug
* fix(v3): fixed logging on linux as well as windows
* fix(v3): add format directive for warning log argument
---------
Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
* fix(v3): warm up dialog types in go-json cache to prevent Windows panic
Add FileFilter, OpenFileDialogOptions, SaveFileDialogOptions, and
MessageDialogOptions to the init() warmup to prevent index out of bounds
panic on Windows when these types are first unmarshaled.
Fixes goccy/go-json#474 for Wails internal dialog types.
* fix(v3): revert goccy/go-json to stdlib encoding/json to fix Windows panic
goccy/go-json has a type address calculation bug on Windows that causes
index out of bounds panic when decoding user-defined types for the first time.
This reverts all runtime usages of goccy/go-json back to stdlib encoding/json.
Test and benchmark files are left unchanged.
Partially reverts PR #4843.
* fix(v3): use correct JSON field names for drop coordinates in example
The DropTargetDetails struct uses lowercase JSON tags (x, y), but the
example frontend was accessing uppercase (X, Y).
* docs(v3): add coordinates fix to changelog
fix(v3): fix macOS mkdir when APP_NAME contains spaces
Replace brace expansion {MacOS,Resources} with two separate mkdir commands.
Brace expansion doesn't work inside quoted strings and is shell-dependent.
Adds integration test to verify mkdir works with spaces in paths.
The SaveFileDialog.SetFilename() option had no effect on Linux because
the filename was never passed to the GTK file chooser.
This adds a currentName parameter to runChooserDialog and calls
gtk_file_chooser_set_current_name() for save dialogs when a filename
is specified.
Changes:
- linux_cgo.go: Add currentName parameter and GTK call
- linux_purego.go: Add gtkFileChooserSetCurrentName binding and same fix
Fixes the Linux implementation to match the behaviour on Windows and macOS.
Co-authored-by: sas229 <sas229@cam.ac.uk>
Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
- Wrap `<=8` in backticks in changelog.mdx to prevent MDX interpreting
`<` as JSX element start
- Remove unsupported {#custom-id} syntax from heading in linux.mdx as
Starlight/Astro auto-generates heading IDs
This fixes the docs build failure in the Deploy to GitHub Pages workflow.
* feat(linux): add libpath package for finding native library paths
Add a new internal/libpath package that locates shared libraries (.so files)
on Linux systems. Supports multiple distributions and package managers.
Features:
- Multi-tier search: pkg-config -> ldconfig -> filesystem scanning
- Parallel search using goroutines for faster lookups
- Cached dynamic path discovery for Flatpak, Snap, and Nix
- Support for Debian/Ubuntu, Fedora/RHEL, Arch, openSUSE, NixOS
- Context-aware cancellation for graceful shutdown
Performance:
- Library found: ~1.4ms (parallel search)
- Library not found: ~46ms (was 84ms sequential)
- Cached path discovery: 14ns (was 15ms uncached)
* feat(libpath): add multi-library parallel search functions
Add functions to search for multiple library candidates in parallel:
- FindFirstLibrary: Search multiple libs in parallel, return first found
- FindFirstLibraryOrdered: Search in order of preference (for version priority)
- FindAllLibraries: Find all available libraries from a list
Useful when the exact library version is unknown, e.g.:
match, _ := FindFirstLibrary("webkit2gtk-4.1", "webkit2gtk-4.0", "webkit2gtk-6.0")
Also adds findLibraryPathCtx for context-aware searching used by the
multi-library functions.
* refactor(libpath): split into separate files and fix race condition
Split libpath_linux.go into smaller, focused files:
- cache_linux.go: Path cache with thread-safe init/invalidate
- flatpak_linux.go: Flatpak runtime path discovery
- snap_linux.go: Snap package path discovery
- nix_linux.go: Nix/NixOS path discovery
- libpath_linux.go: Core search functions
Fixes:
- Fix data race between init() and invalidate() by holding mutex
during cache writes inside sync.Once.Do (CodeRabbit review)
- Fix FindLibraryPathWithOptions not searching dynamic paths
(Flatpak/Snap/Nix) - now uses GetAllLibPaths() (CodeRabbit review)
* fix(v3): overhaul drag-and-drop for Linux reliability and simplify Windows
This commit fixes drag-and-drop reliability on Linux and simplifies the
Windows implementation.
## Linux
- Rewrite GTK drag handlers to properly intercept external file drops
- Fix HTML5 internal drag-and-drop being broken when file drop enabled
- Add hover effects during file drag operations
- Fix multiple app instances interfering with each other
## Windows
- Remove native IDropTarget in favor of JavaScript approach (matches v2)
- File drops now handled via chrome.webview.postMessageWithAdditionalObjects
## All Platforms
- Rename EnableDragAndDrop to EnableFileDrop
- Rename data-wails-drop-target to data-file-drop-target
- Rename wails-drop-target-active to file-drop-target-active
- Add comprehensive drag-and-drop documentation
## Breaking Changes
- EnableDragAndDrop -> EnableFileDrop
- data-wails-dropzone -> data-file-drop-target
- wails-dropzone-hover -> file-drop-target-active
- DropZoneDetails -> DropTargetDetails
- Remove WindowDropZoneFilesDropped event (use WindowFilesDropped)
* feat(macos): optimize drag event performance with debouncing and caching
- Add 50ms debouncing to limit drag events to 20/sec (was 120/sec)
- Implement window implementation caching to avoid repeated lookups
- Maintain existing 5-pixel threshold for immediate response
- Keep zero-allocation path with pre-allocated buffers
- Rename linuxDragActive to nativeDragActive for clarity
- Update IMPLEMENTATION.md with optimization details and Windows guidance
Performance improvements:
- 83% reduction in event frequency
- ~6x reduction in CPU/memory usage during drag operations
- Maintains smooth visual feedback with InvokeSync for timer callbacks
* fix(windows): implement proper file drop support for Windows
- Remove incorrect AllowExternalDrag(false) call that was blocking file drops
- Fix message prefix from 'FilesDropped' to 'file:drop:' to match JS runtime
- Fix coordinate parsing for 'file:drop:x:y' format (indices 2,3 not 1,2)
- Add enableFileDrop flag injection to JS runtime during navigation
- Update JS runtime to check enableFileDrop flag before processing drops
- Always call preventDefault() to stop browser navigation on file drags
- Show 'no drop' cursor when file drops are disabled
- Update example to filter file drags from HTML drop zone handlers
- Add documentation for combining file drop with HTML drag-and-drop
* fix(v3): block file drops on Linux when EnableFileDrop is false
- Add disableDND() to intercept and reject external file drags at GTK level
- Show 'no drop' cursor when files are dragged over window
- Allow internal HTML5 drag-and-drop to work normally
- Initialize _wails.flags object in runtime core to prevent undefined errors
- Inject enableFileDrop flag on Linux and macOS (matching Windows)
- Fix bare _wails reference to use window._wails
- Update docs with info about blocked drops and combining with HTML DnD
* fix(darwin): add missing fmt import in webview_window_darwin.go
* fix(macOS): implement hover effects for file drag-and-drop with optimizations
- Added draggingUpdated: handler to track mouse movement during drag operations
- Implemented macosOnDragEnter/Exit/Over export functions for real-time hover state
- Fixed JS function call from '_wails.handlePlatformFileDrop' to correct 'wails.Window.HandlePlatformFileDrop'
- Added EnableFileDrop flag checks to prevent hover effects when file drops are disabled
- Renamed linuxDragActive to nativeDragActive for cross-platform consistency
Performance optimizations:
- Added 50ms debounce to reduce event frequency from ~120/sec to ~20/sec
- Implemented 5-pixel movement threshold for immediate response
- Added window caching with sync.Map to avoid repeated lookups
- Zero-allocation JavaScript calls with pre-allocated 128-byte buffer
- Reduced memory usage to ~18 bytes per event (6x reduction)
Build improvements:
- Updated runtime Taskfile to include documentation generation
- Added docs:build task to runtime build process
- Fixed build order: events → docs → runtime
Documentation:
- Added IMPLEMENTATION.md with optimization details
- Included guidance for Windows implementation
* chore(v3/examples): remove html-dnd-api example
The drag-n-drop example now demonstrates both external file drops
and internal HTML5 drag-and-drop, making this separate example redundant.
* docs(v3): move drag-and-drop implementation details to runtime-internals
- Add drag-and-drop section to contributing/runtime-internals.mdx
- Remove IMPLEMENTATION.md from example (content now in proper docs)
- Covers platform differences, debugging tips, and key files
* fix(v3): remove html-dnd-api from example build list
* fix(v3): remove duplicate json import in application_darwin.go
* fix(v3): address CodeRabbit review feedback
- Fix docs to use app.Window.NewWithOptions() instead of deprecated API
- Add mutex protection to dragOverJSBuffer to prevent race conditions
- Add mutex protection to dragThrottleState fields for thread safety
* docs: add coderabbit pre-push requirement to AGENTS.md
* fix(v3/test): use correct CSS class name file-drop-target-active
* chore(v3/test): remove dnd-test directory
This was a development test file that shouldn't be in the PR.
The drag-n-drop example serves as the proper test case.
* docs(v3): update Windows file drop comment to reflect implemented fix
Remove stale TODO - enableFileDrop flag is now injected in navigationCompleted
* refactor(v3): make handleDragAndDropMessage unexported
Internal method only called by application event loop, not part of public API.
* fix: improve darwin build commands to accommodate spaces in APP_NAME
* fix: improve android build commands to accommodate spaces in APP_NAME
* fix: improve ios build commands to accommodate spaces in APP_NAME
* fix: improve linux build commands to accommodate spaces in APP_NAME
* fix: improve windows build commands to accommodate spaces in APP_NAME
* docs: update `v3/UNRELEASED_CHANGELOG.md`
* fix(docs): correct changelog
* fix: remove quotes around GO_CACHE_MOUNT and REPLACE_MOUNTS
---------
Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
* perf(v3): optimize JSON processing and reduce allocations in hot paths
- Switch to goccy/go-json for method binding, events, and HTTP transport
(21-63% faster, 40-60% less memory for method calls)
- Optimize BoundMethod struct layout to reduce padding (144 -> 136 bytes)
- Cache isVariadic flag at registration to avoid reflect call per invocation
- Use stack-allocated buffer for method arguments (<=8 args)
- Optimize result collection to avoid slice allocation for single return values
- Use sync.Map for MIME cache to improve concurrent read performance
- Use buffer pool for HTTP transport request body reading
- Lazily allocate CloseNotify channel in content type sniffer
- Remove debug CSS logging from asset server
- Add comprehensive benchmark tests (build tag: bench)
Performance improvements for BoundMethod.Call:
- SimpleCall: 1290ns -> 930ns (28% faster), 240B -> 80B (67% less memory)
- ComplexCall: 10500ns -> 3900ns (63% faster), 1192B -> 1020B (14% less)
- VariadicCall: 3460ns -> 1600ns (54% faster), 512B -> 289B (44% less)
* perf(v3): add max size limit to buffer pool to prevent memory bloat
Buffers larger than 512KB are not returned to the pool, allowing GC
to reclaim memory after large requests (e.g., base64 encoded images).
* perf(v3): remove mimetype library dependency, saving ~208KB binary size
- Replace github.com/wailsapp/mimetype with expanded extension map + stdlib
- Expand MIME type map from 16 to 50+ common web formats (fonts, audio, video, etc.)
- Add comprehensive test suite validating MIME detection for all web formats
- Use http.DetectContentType as fallback for unknown extensions
- Actual binary size reduction: 1.2MB (11MB -> 9.8MB in test app)
* perf(v3): migrate all runtime code to goccy/go-json
Migrate remaining encoding/json usages to goccy/go-json in:
- pkg/application (android, darwin, ios, single_instance, webview_window)
- pkg/services (kvstore, notifications on all platforms)
- internal/assetserver/webview (request/response handling)
- internal/runtime and internal/capabilities
Note: encoding/json (110KB) remains in binary because:
1. goccy/go-json imports it for interface compatibility (json.Marshaler, etc.)
2. log/slog (stdlib) uses it for JSON output
The performance benefit is in the hot paths which now use the faster library.
* perf(v3): replace gopkg.in/ini.v1 with minimal .desktop file parser
Replace the gopkg.in/ini.v1 dependency with a purpose-built minimal parser
for Linux .desktop files.
The new parser:
- Only extracts the Exec key from [Desktop Entry] section (all we need)
- Follows the Desktop Entry Specification
- Has comprehensive test coverage (40 tests) including:
- All major file managers (Nautilus, Dolphin, Thunar, PCManFM, Caja, Nemo)
- Edge cases (UTF-8, special chars, comments, empty files, etc.)
- Buffer limit handling
Binary size reduction: 45KB (10.22MB -> 10.18MB)
* perf(v3): remove samber/lo from runtime code, saving ~310KB binary size
Replace samber/lo with Go 1.21+ stdlib slices package and minimal internal
helpers in all runtime code paths. This removes 80 transitive dependencies
from the production binary.
Changes:
- Create internal/sliceutil package with Unique and FindMapKey helpers
- Replace lo.Without with slices.DeleteFunc in event handling
- Replace lo.Ternary with inline if/else in Windows code
- Replace lo.Uniq with sliceutil.Unique for feature flags
- Replace lo.FindKey with sliceutil.FindMapKey for method aliases
- Replace lo.Filter with slices.DeleteFunc in event listeners
- Replace lo.Must with inline panic in w32 package
Binary size: 10.18MB -> 9.87MB (~310KB / 3% reduction)
Note: CLI tools still use samber/lo since they don't affect
production binary size. The application_debug.go file also
retains lo usage as it has //go:build !production tag.
* fix: address CodeRabbit review comments
- Use application/x-typescript MIME type (not IANA-registered text/typescript)
- Fix potential panic in mimetype_stdlib_test.go for short MIME strings
- Use cached isVariadic flag in bindings_optimized_bench_test.go
* fix: initialize goccy/go-json decoder early to fix Windows test failure
On Windows, goccy/go-json's type address calculation can fail if the
decoder is first invoked during test execution rather than at init time.
Force early initialization by unmarshaling a []int during package init.
See: https://github.com/goccy/go-json/issues/474
* 📝 Add docstrings to `v3/performance-improvements` (#4844)
* fix: initialize goccy/go-json decoder early to fix Windows test failure
On Windows, goccy/go-json's type address calculation can fail if the
decoder is first invoked during test execution rather than at init time.
Force early initialization by unmarshaling a []int during package init.
See: https://github.com/goccy/go-json/issues/474
* 📝 Add docstrings to `v3/performance-improvements`
Docstrings generation was requested by @leaanthony.
* https://github.com/wailsapp/wails/pull/4843#issuecomment-3703472562
The following files were modified:
* `v3/internal/assetserver/common.go`
* `v3/internal/assetserver/content_type_sniffer.go`
* `v3/internal/assetserver/mimecache.go`
* `v3/internal/fileexplorer/desktopfile.go`
* `v3/internal/fileexplorer/fileexplorer_linux.go`
* `v3/internal/sliceutil/sliceutil.go`
* `v3/pkg/application/application_ios.go`
* `v3/pkg/application/bindings.go`
* `v3/pkg/application/ios_runtime_ios.go`
* `v3/pkg/w32/window.go`
---------
Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* feat(macos): add CollectionBehavior option to MacWindow (#4756)
Add configurable NSWindowCollectionBehavior support for macOS windows,
allowing control over window behavior across Spaces and fullscreen.
New options include:
- MacWindowCollectionBehaviorCanJoinAllSpaces
- MacWindowCollectionBehaviorFullScreenAuxiliary
- MacWindowCollectionBehaviorMoveToActiveSpace
- And more...
This enables building Spotlight-like apps that appear on all Spaces
or overlay fullscreen applications.
Closes#4756🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Potential fix for code scanning alert no. 140: Workflow does not contain permissions
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
* Potential fix for code scanning alert no. 139: Workflow does not contain permissions
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
* feat(examples): add spotlight example for CollectionBehavior
Demonstrates creating a Spotlight-like launcher window that:
- Appears on all macOS Spaces
- Floats above other windows
- Uses accessory activation policy (no Dock icon)
- Has frameless translucent design
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat(macos): support bitwise OR for CollectionBehavior options
Update CollectionBehavior to use actual NSWindowCollectionBehavior
bitmask values, allowing multiple behaviors to be combined:
```go
CollectionBehavior: application.MacWindowCollectionBehaviorCanJoinAllSpaces |
application.MacWindowCollectionBehaviorFullScreenAuxiliary,
```
Changes:
- Update Go constants to use actual bitmask values (1<<0, 1<<1, etc.)
- Simplify C function to pass through combined bitmask directly
- Add ParticipatesInCycle, IgnoresCycle, FullScreenDisallowsTiling options
- Update documentation with combined behavior examples
- Update spotlight example to demonstrate combining behaviors
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
* Clean up debug output in webView URL scheme handler
Removed debug print statements for CSS requests in web view.
* Add changelog entry for #4834
* Fix Changelog
---------
Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
* test(v3): add comprehensive unit tests for pkg/application
Add 11 new test files to improve test coverage of the pkg/application
package from 13.6% to 17.7%.
New test files:
- context_test.go: Context struct operations
- services_test.go: Service management and lifecycle
- parameter_test.go: Parameter and CallError types
- dialogs_test.go: Dialog utilities and button methods
- webview_window_options_test.go: Window options and constants
- application_options_test.go: ChainMiddleware and app config
- keys_test.go: Keyboard accelerator parsing
- single_instance_test.go: Single instance management and encryption
- menuitem_internal_test.go: Menu item internal functions
- menu_internal_test.go: Menu internal functions
- screenmanager_internal_test.go: Screen geometry and transformations
The 40% target was not fully achievable because ~50% of the codebase
is platform-specific code that can only be tested on respective
platforms. Tests focus on pure Go logic, utility functions, and
data structures that can be tested cross-platform.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review comments
- dialogs_test.go: improve ID recycling test to verify either recycled
ID (id3 == id1) or new unique ID (id3 > id2)
- keys_test.go: make accelerator String() tests platform-agnostic by
checking suffix patterns rather than exact platform-specific strings
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: normalize temp dir path for macOS compatibility in test
os.TempDir() returns a trailing slash on macOS, causing path comparison
to fail. Use filepath.Clean() to normalize both paths.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore: remove REVIEW.md
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore: simplify changelog entry
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* docs: fix custom protocol association documentation
The documentation was incorrectly referencing `wails.json` with JSON format
when the actual configuration file is `build/config.yml` using YAML format.
Changes:
- Update config file reference from `wails.json` to `build/config.yml`
- Change format from JSON to YAML in code examples
- Fix structure: `protocols` is at root level, not nested under `info`
- Correct template variable references from `{{.Info.Protocols}}` to `{{.Protocols}}`
- Update Info.plist example to show actual generated format (`wails.com.scheme`)
- Add note about running `wails3 task common:update:build-assets` after changes
- Clean up redundant file path references in platform-specific sections
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* docs: consolidate custom protocol docs and add Universal Links
- Remove duplicate custom-protocol-association.mdx
- Add Universal Links section to macOS tab
- Add Web-to-App Linking section to Windows tab
- Keep the more comprehensive distribution/custom-protocols.mdx
Addresses review comment about duplicate documentation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(windows): add custom protocol support to MSIX packaging
- Add uap3 namespace and protocol extension to MSIX template
- Protocols defined in build/config.yml are now automatically
registered when building MSIX packages
- Update docs with MSIX section and clarify Web-to-App linking
requires manual manifest configuration
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
Add guard against concurrent TrackPopupMenuEx calls using atomic.Bool
to prevent race condition when user clicks systray icon repeatedly.
Change TrackPopupMenuEx failure from fatal to debug log with early
return so the application gracefully handles failed menu display
attempts instead of crashing.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Vibe Kanban <noreply@vibekanban.com>
Co-authored-by: Claude <noreply@anthropic.com>
* Enhance bindings generation documentation
Added TypeScript option and help command for bindings generation.
* Update UNRELEASED_CHANGELOG with new events and docs
Updated the changelog to include new WebKit2 load-change events and additional documentation for frontend bindings.
---------
Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
* Refactor asset-server documentation for clarity
Updated references from 'frontend/Taskfile.yml' to 'build/Taskfile.yml' and adjusted environment variable names for clarity. Enhanced the explanation of how the dev proxy works and clarified the roles of the tasks in the templates.
* Update changelog
* Apply suggestion from @coderabbitai[bot]
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
---------
Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* All the documentation files have been updated. Here's a summary of the changes I made:
## Summary of Documentation Updates
### Key API Corrections Made:
1. **Dialog Creation**:
- Changed `app.InfoDialog()` → `application.InfoDialog()` (package-level functions)
- Also documented `app.Dialog.Info()` via DialogManager
2. **Question Dialog Buttons**:
- Removed non-existent `SetButtons("Save", "Don't Save", "Cancel")` method
- Now uses `AddButton("label")` which returns a `*Button`
- Button callbacks via `button.OnClick(func() { ... })`
3. **Default/Cancel Buttons**:
- Changed `SetDefaultButton("Cancel")` (string) → `SetDefaultButton(cancelBtn)` (`*Button`)
- Changed `SetCancelButton("Cancel")` (string) → `SetCancelButton(cancelBtn)` (`*Button`)
- Also documented fluent `SetAsDefault()` and `SetAsCancel()` methods on Button
4. **File Dialog Filters**:
- Changed `SetFilters([]application.FileFilter{...})` → `AddFilter("Display Name", "*.ext;*.ext2")`
5. **Save Dialog Filename**:
- Changed `SetDefaultFilename()` → `SetFilename()`
6. **Folder Selection**:
- Removed non-existent `app.SelectFolderDialog()`
- Now uses `application.OpenFileDialog().CanChooseDirectories(true).CanChooseFiles(false)`
7. **Show() Return Value**:
- Removed incorrect `result, err := dialog.Show()` pattern
- `Show()` returns nothing - responses are handled via button callbacks
### Files Modified:
- `docs/src/content/docs/features/dialogs/message.mdx` - Complete rewrite of question dialog examples
- `docs/src/content/docs/features/dialogs/overview.mdx` - Updated all code examples
- `docs/src/content/docs/features/dialogs/file.mdx` - Updated file dialog examples
- `v3/UNRELEASED_CHANGELOG.md` - Added changelog entry
* All changes are complete. Here's a summary of what was updated:
## Summary
I've updated the Wails v3 dialogs documentation to match the actual API. The documentation now consistently uses:
### DialogManager Pattern (Recommended)
- `app.Dialog.Info()`, `app.Dialog.Question()`, `app.Dialog.Warning()`, `app.Dialog.Error()`
- `app.Dialog.OpenFile()`, `app.Dialog.SaveFile()`
This is consistent with other runtime features like `app.Window`, `app.Event`, etc.
### Key API Corrections
1. **Dialog Creation**: Both `app.Dialog.*()` (DialogManager) and `application.*Dialog()` (package-level) are documented
2. **Question Dialog Buttons**: Use `AddButton("label")` which returns `*Button`, then `button.OnClick(callback)`
3. **Default/Cancel Buttons**: `SetDefaultButton(button)` and `SetCancelButton(button)` take `*Button` pointers
4. **File Filters**: Use `AddFilter("Display Name", "*.ext")` instead of `SetFilters()`
5. **Save Dialog Filename**: Use `SetFilename()` instead of `SetDefaultFilename()`
6. **Folder Selection**: Use `app.Dialog.OpenFile().CanChooseDirectories(true).CanChooseFiles(false)`
### Files Modified
- `docs/src/content/docs/features/dialogs/overview.mdx`
- `docs/src/content/docs/features/dialogs/message.mdx`
- `docs/src/content/docs/features/dialogs/file.mdx`
- `v3/UNRELEASED_CHANGELOG.md`
* Audit complete! All documentation files now consistently use `app.Dialog.*` for all code examples. Here's the summary:
## Audit Complete
All dialog documentation has been updated to consistently use the `app.Dialog.*` pattern:
### Changes Made:
**message.mdx:**
- All examples now use `app.Dialog.Info()`, `app.Dialog.Question()`, `app.Dialog.Warning()`, `app.Dialog.Error()`
- Function signatures updated to accept `app *application.App` parameter
- Nested dialog calls within callbacks also updated
**file.mdx:**
- All examples now use `app.Dialog.OpenFile()`, `app.Dialog.SaveFile()`
- Function signatures updated to accept `app *application.App` parameter
- All error/info dialogs within file operations also updated
**overview.mdx:**
- Already consistent from earlier edits
### Documentation Structure:
Each file now properly documents both approaches in a dedicated section:
```go
// Via DialogManager (recommended when you have an app instance):
app.Dialog.Info()
app.Dialog.OpenFile()
// Package-level functions (useful in callbacks or when app isn't in scope):
application.InfoDialog()
application.OpenFileDialog()
```
But all code examples use the `app.Dialog.*` pattern for consistency with other runtime features like `app.Window`, `app.Event`, etc.
* docs: Fix reference/dialogs.mdx and reference/application.mdx API documentation
Updated docs to match actual Wails v3 Dialogs API:
- reference/dialogs.mdx: Complete rewrite with correct API
- Use `app.Dialog.OpenFile()` and `app.Dialog.SaveFile()` instead of `app.OpenFileDialog()`
- Use `AddFilter("name", "pattern")` instead of `SetFilters([]FileFilter{...})`
- Use `SetFilename()` instead of `SetDefaultFilename()`
- Use `SetDirectory()` instead of `SetDefaultDirectory()`
- Remove non-existent `SelectFolderDialog()` - use `OpenFile().CanChooseDirectories(true).CanChooseFiles(false)`
- Use `AddButton()` with callbacks instead of `SetButtons()`
- Use `SetDefaultButton(*Button)` instead of `SetDefaultButton(int)`
- Document that `Show()` returns nothing, use callbacks
- reference/application.mdx: Fix Dialog Methods section
- Use `app.Dialog.*` manager pattern
- Show correct Question dialog with button callbacks
- Fix file dialog examples with `AddFilter()`
- Remove `SelectFolderDialog()` reference
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* docs: Remove package-level dialog function references
Remove all references to package-level dialog functions
(application.InfoDialog(), application.OpenFileDialog(), etc.)
from documentation. Only the app.Dialog manager pattern
should be used.
Updated files:
- reference/dialogs.mdx
- features/dialogs/overview.mdx
- features/dialogs/message.mdx
- features/dialogs/file.mdx
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* refactor: Remove package-level dialog functions in favor of app.Dialog manager
BREAKING CHANGE: Remove package-level dialog functions. Use app.Dialog manager instead.
Removed functions:
- application.InfoDialog()
- application.QuestionDialog()
- application.WarningDialog()
- application.ErrorDialog()
- application.OpenFileDialog()
- application.SaveFileDialog()
Use the Dialog manager pattern instead:
- app.Dialog.Info()
- app.Dialog.Question()
- app.Dialog.Warning()
- app.Dialog.Error()
- app.Dialog.OpenFile()
- app.Dialog.SaveFile()
This aligns dialogs with other runtime managers like app.Window and app.Event.
Updated files:
- v3/pkg/application/application.go - Remove exported dialog functions
- v3/pkg/application/dialog_manager.go - Use internal newMessageDialog/newOpenFileDialog
- v3/pkg/application/messageprocessor_dialog.go - Use internal dialog constructors
- v3/examples/* - Update all examples to use app.Dialog pattern
- v3/internal/commands/appimage_testfiles/main.go - Update test file
- v3/UNRELEASED_CHANGELOG.md - Document breaking change
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: Use application.Get() in dialogs-basic example and correct filter docs
- Update dialogs-basic helper functions to use application.Get() instead
of passing app through function parameters
- Fix incorrect documentation claiming space/comma delimiters work for
filter patterns (only semicolons are supported)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
* ## Summary
I've verified and fixed the bug reported in GitHub issue #4389. Here's what was done:
### Root Cause Analysis
The crash occurred on macOS when using `Hide()` and `Show()` to toggle window visibility via a system tray. The sequence was:
1. `Hide()` calls `orderOut:nil` which removes the window from screen
2. With `ApplicationShouldTerminateAfterLastWindowClosed = true` (default), macOS considers the app to have no visible windows
3. macOS triggers `windowShouldClose:` which emits `EventWindowShouldClose`
4. The event mapping translates this to `Common.WindowClosing`
5. The `WindowClosing` handler destroys the window and removes it from the window map
6. When `Show()` is called later, the window doesn't exist anymore → crash
### Fix Implementation
**File: `v3/pkg/application/webview_window_close_darwin.go`**
- Added new exported function `windowIsHidden()` that checks if a window is marked as hidden via `window.options.Hidden`
**File: `v3/pkg/application/webview_window_darwin.m`**
- Added extern declaration for `windowIsHidden`
- Modified `windowShouldClose:` delegate method to return `false` early (without emitting close events) if the window is hidden
The fix ensures that when a window is intentionally hidden (not closed), the close event sequence is not triggered, preserving the window for later re-showing.
### Test Case Created
Created `v3/tests/systray-hide-show-test/` - a test application that:
- Creates a window and system tray
- Clicking the tray toggles window visibility
- Previously crashed after hide→show→hide sequence; now works correctly
### Files Modified
1. `v3/pkg/application/webview_window_close_darwin.go` - Added `windowIsHidden()` function
2. `v3/pkg/application/webview_window_darwin.m` - Check hidden state in `windowShouldClose:`
3. `v3/UNRELEASED_CHANGELOG.md` - Added fix entry
### Files Added
1. `v3/tests/systray-hide-show-test/main.go` - Test case
2. `v3/tests/systray-hide-show-test/icon.png` - Icon for test
All existing tests pass. The fix is minimal and targeted, only affecting the specific scenario where a hidden window receives a close query.
* Done. The redundant test case has been removed. The fix is covered by the existing `v3/examples/hide-window/` example.
Current staged changes:
- Deleted `v3/tests/systray-hide-show-test/` (test case, icon, and binary)
The fix itself (in `webview_window_close_darwin.go` and `webview_window_darwin.m`) and the changelog entry were already committed in the previous commit.
All tests pass. Let me provide a summary of the changes.
## Summary
This issue (#4012) is about **Dynamic Context Menu** support, labeled as a Bug affecting macOS.
### Root Cause Analysis
I identified two related issues:
1. **macOS Memory Leak**: In `webview_window_darwin.go`, the `openContextMenu` function created a **new** `macosMenu` and `NSMenu` every time a context menu was displayed, ignoring any existing `menu.impl`. This caused:
- Memory leaks (NSMenu objects never released)
- Wasted CPU cycles rebuilding the native menu each time
- Inconsistent behavior with other platforms
2. **Windows Memory Leak**: In `webview_window_windows.go`, the `openContextMenu` function created a new `Win32Menu` each time without destroying the previous one, leaking Windows menu handles.
### Fixes Applied
**1. macOS (`v3/pkg/application/webview_window_darwin.go:889-897`):**
```go
func (w *macosWebviewWindow) openContextMenu(menu *Menu, data *ContextMenuData) {
// Reuse existing impl if available, otherwise create new one
if menu.impl == nil {
menu.impl = newMenuImpl(menu)
}
thisMenu := menu.impl.(*macosMenu)
thisMenu.update()
C.windowShowMenu(w.nsWindow, thisMenu.nsMenu, C.int(data.X), C.int(data.Y))
}
```
This now:
- Reuses existing `menu.impl` if available (consistent with Linux)
- Only creates new impl on first display
- The `update()` call still rebuilds native items from current Go state for dynamic updates
**2. Windows (`v3/pkg/application/webview_window_windows.go:1174-1184`):**
```go
func (w *windowsWebviewWindow) openContextMenu(menu *Menu, _ *ContextMenuData) {
// Destroy previous context menu if it exists to prevent memory leak
if w.currentlyOpenContextMenu != nil {
w.currentlyOpenContextMenu.Destroy()
}
// Create the menu from current Go-side menu state
thisMenu := NewPopupMenu(w.hwnd, menu)
thisMenu.Update()
w.currentlyOpenContextMenu = thisMenu
thisMenu.ShowAtCursor()
}
```
This now properly destroys the old `Win32Menu` before creating a new one.
**3. Updated `v3/UNRELEASED_CHANGELOG.md`** with fix entries.
### Files Changed
- `v3/pkg/application/webview_window_darwin.go`
- `v3/pkg/application/webview_window_windows.go`
- `v3/UNRELEASED_CHANGELOG.md`
### Testing
- Build passes ✓
- All existing tests pass ✓
- Manual testing recommended using `v3/examples/contextmenus` app
When an application starts with Hidden: true, clicking the dock icon
now correctly shows the window. This matches standard macOS UX where
clicking the dock icon should bring up the app's windows.
The fix adds a default handler for ApplicationShouldHandleReopen that
automatically shows all hidden windows when there are no visible windows.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <noreply@anthropic.com>
fix(macos): fix print dialog not opening and add Window.Print() to runtime (#4290)
The print dialog was not opening on macOS because the CGO windowPrint function was passing the wrong pointer type to NSPrintOperation's runOperationModalForWindow method. It was passing the raw void* window instead of the properly cast WebviewWindow* nsWindow.
This also adds a Window.Print() method to the JavaScript runtime, allowing frontend code to trigger the print dialog directly without needing a Go binding.
Changes:
- Fix webview_window_darwin.go to use nsWindow instead of window
- Add WindowPrint constant (51) and handler to messageprocessor_window.go
- Add Print() method to window.ts in the runtime
- Rebuild bundled runtime (runtime.js and runtime.debug.js)
- Add print example in v3/examples/print to demonstrate both Go API and JS runtime methods
- Update API documentation for Window.Print() in both Go and JavaScript references
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <noreply@anthropic.com>
Remove the setup.Action that runs the wizard when calling `wails setup`.
The signing and entitlements subcommands are retained.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>