From 349711bcf0a0fad5d94197d6a4ada4ac3d46ac03 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 1 May 2026 02:55:29 +0300 Subject: [PATCH] Add 'drover gui' subcommand: native Win32 MessageBox smoke test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Shows a small message box with version metadata + build info. Used as a fastest possible end-user smoke check after install: double-click drover.exe in a portable bundle (or run 'drover gui' from cmd) and see "OK — the binary launched and the Windows API is reachable" with the right version on screen. No network calls, no admin needed. Implementation: cgo-free, uses only golang.org/x/sys/windows (already pulled in by the updater package). gui_other.go is a stub so the package still compiles on Linux for the CI smoke build. Locally verified: built with -X main.Version=test-local, ran 'drover.exe gui' on Windows 11, message box appeared with correct version/commit/Go runtime info. Co-Authored-By: Claude Opus 4.7 (1M context) --- cmd/drover/gui_other.go | 9 +++++++ cmd/drover/gui_windows.go | 50 +++++++++++++++++++++++++++++++++++++++ cmd/drover/main.go | 12 ++++++++++ 3 files changed, 71 insertions(+) create mode 100644 cmd/drover/gui_other.go create mode 100644 cmd/drover/gui_windows.go diff --git a/cmd/drover/gui_other.go b/cmd/drover/gui_other.go new file mode 100644 index 0000000..c3146dd --- /dev/null +++ b/cmd/drover/gui_other.go @@ -0,0 +1,9 @@ +//go:build !windows + +package main + +import "fmt" + +func showTestWindow() { + fmt.Printf("Drover-Go v%s — test window unavailable on non-Windows builds\n", Version) +} diff --git a/cmd/drover/gui_windows.go b/cmd/drover/gui_windows.go new file mode 100644 index 0000000..c8b12d3 --- /dev/null +++ b/cmd/drover/gui_windows.go @@ -0,0 +1,50 @@ +//go:build windows + +package main + +import ( + "fmt" + "runtime" + "unsafe" + + "golang.org/x/sys/windows" +) + +// showTestWindow displays a native Win32 MessageBox with build info. +// The intent is to give end-users a visual smoke-test on first run: +// double-click drover.exe (or run `drover gui`) and see that: +// 1. the binary actually launches on Windows, +// 2. the embedded version metadata is correct, +// 3. the process can talk to user32.dll (i.e. the runtime is healthy). +// +// This is *not* the production GUI — that comes later via Wails. Here we +// purposely use only stdlib + golang.org/x/sys/windows so this works +// before any Wails/CGO machinery is wired up. +func showTestWindow() { + user32 := windows.NewLazySystemDLL("user32.dll") + messageBox := user32.NewProc("MessageBoxW") + + body := fmt.Sprintf( + "Drover-Go v%s\n\n"+ + "Commit: %s\n"+ + "Build: %s\n"+ + "Go: %s\n"+ + "Arch: %s/%s\n\n"+ + "OK — the binary launched and the Windows API is reachable.", + Version, Commit, BuildDate, runtime.Version(), runtime.GOOS, runtime.GOARCH, + ) + title := fmt.Sprintf("Drover-Go v%s — test window", Version) + + bodyW, _ := windows.UTF16PtrFromString(body) + titleW, _ := windows.UTF16PtrFromString(title) + + // MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND + const flags = 0x00000000 | 0x00000040 | 0x00010000 + + messageBox.Call( + 0, + uintptr(unsafe.Pointer(bodyW)), + uintptr(unsafe.Pointer(titleW)), + flags, + ) +} diff --git a/cmd/drover/main.go b/cmd/drover/main.go index cdb8f27..4987245 100644 --- a/cmd/drover/main.go +++ b/cmd/drover/main.go @@ -49,10 +49,22 @@ func newRootCmd() *cobra.Command { root.AddCommand(newCheckCmd()) root.AddCommand(newUpdateCmd()) root.AddCommand(newServiceCmd()) + root.AddCommand(newGUICmd()) return root } +func newGUICmd() *cobra.Command { + return &cobra.Command{ + Use: "gui", + Short: "Show a test window (smoke check that the binary launches on this machine)", + RunE: func(cmd *cobra.Command, args []string) error { + showTestWindow() + return nil + }, + } +} + func newCheckCmd() *cobra.Command { return &cobra.Command{ Use: "check",