feature: V3 alpha feature/snapassist support - #4463
Conversation
WalkthroughA Snap Assist feature was introduced for Windows platforms. New methods and interface extensions were added to trigger Snap Assist via simulated key events. The application menu now conditionally displays a "Snap Assist" item on Windows, which invokes the new logic. Platform-specific no-op implementations were added for Linux and macOS. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant AppMenu
participant WebviewWindow
participant WindowsAPI
User->>AppMenu: Select "Snap Assist" (Windows only)
AppMenu->>WebviewWindow: Call SnapAssist()
WebviewWindow->>WindowsAPI: Simulate Win+Z key events
WindowsAPI-->>WebviewWindow: Snap Assist UI triggered
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes detected related to the objectives from the linked issues. Possibly related PRs
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
|
Deploying wails with
|
| Latest commit: |
d43570e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5d46b636.wails.pages.dev |
| Branch Preview URL: | https://v3-alpha-feature-snapassist.wails.pages.dev |
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
v3/pkg/application/webview_window_linux.go (1)
428-432: Add!cgobuild constraint to webview_window_linux.go to avoid duplicatesnapAssistmethodsWhen CGO is enabled, both of the following files are built, resulting in two definitions of
func (w *linuxWebviewWindow) snapAssist() {}and a compilation error:
- v3/pkg/application/linux_cgo.go //go:build linux && cgo
- v3/pkg/application/webview_window_linux.go //go:build linux
To restore the intended symmetry, update webview_window_linux.go so it only builds when CGO is not enabled.
• In v3/pkg/application/webview_window_linux.go, change the file’s build tag from:
- //go:build linux + //go:build linux && !cgo(Optionally add the matching
// +build linux,!cgoline for pre-1.17 tooling.)
♻️ Duplicate comments (1)
v3/pkg/application/linux_cgo.go (1)
1884-1888: Same duplicate stub introduced hereSee comment on
webview_window_linux.go. Having this second definition underlinux && cgois fine if the pure-Go file is constrained tolinux && !cgo; otherwise one of the two must be removed.
🧹 Nitpick comments (1)
v3/pkg/application/webview_window_darwin.go (1)
1440-1442: Consider a short doc-comment to clarify the intentional NO-OPEvery other platform-specific stub explains why the operation is a no-op. A one-liner such as
// snapAssist is not applicable on macOS – Windows-only feature.will prevent future “todo?” questions during maintenance.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
v3/examples/window/main.go(1 hunks)v3/pkg/application/linux_cgo.go(1 hunks)v3/pkg/application/webview_window.go(2 hunks)v3/pkg/application/webview_window_darwin.go(1 hunks)v3/pkg/application/webview_window_linux.go(1 hunks)v3/pkg/w32/constants.go(1 hunks)v3/pkg/w32/user32.go(2 hunks)
🧰 Additional context used
🧠 Learnings (5)
v3/pkg/application/webview_window_linux.go (1)
Learnt from: nixpare
PR: #3763
File: v3/examples/keybindings/main.go:16-17
Timestamp: 2024-09-20T23:34:29.841Z
Learning: In the codebase, application.Options.KeyBindings uses the application.Window type, whereas application.WebviewWindowOptions.KeyBindings uses *application.WebviewWindow. This is intentional and acceptable.
v3/pkg/application/webview_window_darwin.go (1)
Learnt from: nixpare
PR: #3763
File: v3/examples/keybindings/main.go:16-17
Timestamp: 2024-09-20T23:34:29.841Z
Learning: In the codebase, application.Options.KeyBindings uses the application.Window type, whereas application.WebviewWindowOptions.KeyBindings uses *application.WebviewWindow. This is intentional and acceptable.
v3/pkg/application/linux_cgo.go (1)
Learnt from: nixpare
PR: #3763
File: v3/examples/keybindings/main.go:16-17
Timestamp: 2024-09-20T23:34:29.841Z
Learning: In the codebase, application.Options.KeyBindings uses the application.Window type, whereas application.WebviewWindowOptions.KeyBindings uses *application.WebviewWindow. This is intentional and acceptable.
v3/examples/window/main.go (6)
Learnt from: leaanthony
PR: #4031
File: v3/pkg/application/menu.go:199-202
Timestamp: 2025-01-24T22:41:18.566Z
Learning: In the Wails menu system (v3/pkg/application/menu.go), shared state between menus is intentionally designed and desirable. Methods like Append() and Prepend() should maintain shared references to menu items rather than creating deep copies.
Learnt from: leaanthony
PR: #3763
File: v3/examples/window/main.go:472-475
Timestamp: 2024-09-30T06:13:46.595Z
Learning: In v3/examples/window/main.go, time.Sleep is used within a goroutine and does not block the UI thread.
Learnt from: leaanthony
PR: #3763
File: v3/examples/window/main.go:472-475
Timestamp: 2024-10-08T22:11:37.054Z
Learning: In v3/examples/window/main.go, time.Sleep is used within a goroutine and does not block the UI thread.
Learnt from: nixpare
PR: #3763
File: v3/examples/keybindings/main.go:16-17
Timestamp: 2024-09-20T23:34:29.841Z
Learning: In the codebase, application.Options.KeyBindings uses the application.Window type, whereas application.WebviewWindowOptions.KeyBindings uses *application.WebviewWindow. This is intentional and acceptable.
Learnt from: leaanthony
PR: #3763
File: v3/internal/commands/appimage_testfiles/main.go:295-299
Timestamp: 2024-10-08T22:11:37.054Z
Learning: In v3/internal/commands/appimage_testfiles/main.go, time.Sleep is used within a goroutine and does not block the UI thread.
Learnt from: leaanthony
PR: #3763
File: v3/internal/commands/appimage_testfiles/main.go:295-299
Timestamp: 2024-09-30T06:14:32.602Z
Learning: In v3/internal/commands/appimage_testfiles/main.go, time.Sleep is used within a goroutine and does not block the UI thread.
v3/pkg/application/webview_window.go (2)
Learnt from: nixpare
PR: #3763
File: v3/examples/keybindings/main.go:16-17
Timestamp: 2024-09-20T23:34:29.841Z
Learning: In the codebase, application.Options.KeyBindings uses the application.Window type, whereas application.WebviewWindowOptions.KeyBindings uses *application.WebviewWindow. This is intentional and acceptable.
Learnt from: leaanthony
PR: #4031
File: v3/pkg/application/menu.go:199-202
Timestamp: 2025-01-24T22:41:18.566Z
Learning: In the Wails menu system (v3/pkg/application/menu.go), shared state between menus is intentionally designed and desirable. Methods like Append() and Prepend() should maintain shared references to menu items rather than creating deep copies.
🧬 Code Graph Analysis (2)
v3/examples/window/main.go (1)
v3/internal/runtime/runtime_debug_desktop_windows.js (1)
function(336-346)
v3/pkg/w32/user32.go (1)
v2/internal/frontend/desktop/windows/winc/w32/user32.go (1)
SetWindowsHookEx(1195-1203)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: Run Go Tests v3 (ubuntu-latest, 1.24)
- GitHub Check: Run Go Tests v3 (macos-latest, 1.24)
- GitHub Check: Run Go Tests v3 (windows-latest, 1.24)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (6)
v3/pkg/w32/constants.go (1)
2903-2908: Adds missing KEYEVENTF flags – looks correctValues align with Win32
winuser.h(0x0001,0x0002,0x0004,0x0008) and fill the gap required forkeybd_eventusage. No issues spotted.v3/examples/window/main.go (1)
716-723: LGTM! Clean implementation of the SnapAssist feature demonstration.The code correctly follows established patterns in the file by using platform-specific checks and the
currentWindowhelper function. The menu item is appropriately placed under the "State" submenu and is conditionally included only for Windows platforms, which aligns with the feature's availability.v3/pkg/w32/user32.go (2)
152-152: LGTM! Correctly adds the keybd_event procedure binding.The addition follows the established pattern used for other Windows API procedure bindings in this file.
1497-1509: LGTM! Well-implemented Windows API wrapper function.The
KeybdEventfunction correctly wraps the Windowskeybd_eventAPI call with:
- Comprehensive documentation explaining all parameters
- Proper type conversion to
uintptrfor syscall parameters- Consistent style with other wrapper functions in the file
- Appropriate void return type matching the underlying API behavior
This provides the necessary building block for keyboard event synthesis in the SnapAssist feature.
v3/pkg/application/webview_window.go (2)
113-113: LGTM! Correctly extends the interface for platform-specific implementations.The addition of
snapAssist()to thewebviewWindowImplinterface ensures all platform-specific implementations must provide this method, maintaining architectural consistency.
1433-1440: LGTM! Well-implemented public API method.The
SnapAssist()method correctly follows established patterns in the codebase:
- Includes comprehensive documentation explaining cross-platform behavior
- Uses proper safety checks for implementation existence and window state
- Employs
InvokeSyncfor thread-safe execution, consistent with other window methods- Method naming and signature align with codebase conventions
This provides a clean public API for the SnapAssist feature while delegating platform-specific implementation details appropriately.
|
|
* initial implementation * Push missed files * linux fix * Update changelog, runtime and docs.


Implements programmatic SnapAssist feature for v3.
Adds a new method for the runtime: ShowSnapAssist which will be stubbed for Mac/Linux to be a NOOP. Updated examples/window to show this in action.
Closes: #2237
Summary by CodeRabbit
New Features
Documentation