Bring the Wails desktop shell to feature parity with the CLI for provider and alias management while keeping the browser fallback working. Wire tray, notifications, autostart, and GUI warnings so desktop flows behave predictably.
4.2 KiB
Windows Desktop Integrations
Summary
ocswitch desktop already has shared Go application services, a React control panel, a browser fallback shell, and a Wails window wrapper. What is still missing is the set of desktop-native integrations that make the Windows build behave like a real resident utility instead of only a packaged webview.
This task completes that gap with a minimal extension to the current architecture:
- fix the Wails frontend bridge so the GUI actually talks to Go bindings
- add native tray integration for the Wails desktop build
- add native notification delivery for desktop events
- add launch-at-login support for Windows
- preserve the existing browser fallback shell and shared service layer
Product Goal
Provide a Windows-friendly desktop shell for ocswitch that can stay resident, expose quick tray controls, surface important events through native notifications, and reopen automatically at login without rewriting existing business logic.
Current State
Already done
internal/appowns shared workflows for overview, proxy control, doctor, desktop preferences, and OpenCode sync.internal/desktop/http.goalready provides a browser fallback shell with the same workflows.frontend/src/App.tsxalready renders the main control panel for overview, desktop prefs, sync, doctor, providers, and aliases.internal/desktop/wails.goalready boots a Wails window and hides on close.
Missing
- frontend Wails bridge still points at
window.go.main.Appeven though generated bindings live atwindow.go.desktop.App - tray support is only a placeholder and does not expose resident controls
- notifications are only a placeholder and do not use Wails runtime APIs
- launch-at-login only supports Linux XDG autostart today
Requirements
Desktop integration
- Wails desktop build must expose a real system tray on Windows.
- Tray menu must at least support opening the window, hiding the window, starting the proxy, stopping the proxy, and quitting the app.
- Close-to-background behavior must continue to respect
minimizeToTraypreference. - Native notifications must be available when
notificationspreference is enabled. - Native launch-at-login must be available on Windows through a practical low-complexity mechanism.
Reuse and layering
- Keep
internal/appas the owner of shared workflows and state transitions. - Keep
internal/desktopfocused on shell integration only. - Do not duplicate proxy, config, or sync business rules inside tray or frontend code.
- Browser fallback shell must remain operational.
Design Decisions
Tray implementation
Wails v2 does not provide a stable public tray API, so tray support should use github.com/getlantern/systray inside the desktop_wails build.
Why this path:
- lowest implementation cost in current Go codebase
- already present in module graph
- works alongside Wails window lifecycle
- avoids replacing the desktop shell framework
Notification implementation
Use Wails runtime notification APIs for the desktop build. This keeps notifications native and avoids introducing another platform adapter.
Expected event coverage:
- proxy started
- proxy stopped
- OpenCode sync applied
- notifications preference enabled
Windows launch-at-login
Implement Windows startup integration by writing a .cmd launcher into the user Startup folder.
Why this path:
- much simpler than generating
.lnk - good enough for a local utility
- easy to inspect and delete
Non-Goals
- No migration from Wails to Fyne unless current approach proves unworkable.
- No tray support requirement for browser fallback mode.
- No redesign of the React control panel information architecture.
- No expansion into advanced desktop telemetry or background sync daemons.
Acceptance Criteria
- Wails frontend can successfully call Go bindings through generated
desktopnamespace. - Windows desktop build can be hidden and restored through tray controls.
- Tray can start and stop proxy without reopening main window.
- Enabling notifications allows native desktop alerts for key lifecycle events.
- Enabling launch at login creates Windows startup entry; disabling removes it.
- Existing browser fallback flow and current tests remain green.