Documentation
¶
Overview ¶
Package desktop contains the Wails desktop application wrapper for Pando. It renders the Pando web UI inside a native WebView window instead of opening an external browser. The desktop binary is compiled separately and embedded into the main pando binary via go:embed in embed_binary.go.
Index ¶
- Constants
- Variables
- func DefaultWorkingDir() (string, error)
- func EmbeddedDesktopBinary() []byte
- func ImportLoginShellPath()
- func Launch(embedBin []byte, pandoURL string, simpleMode bool) error
- func LaunchWindow(embedBin []byte, url string) error
- func LaunchedFromApp() bool
- func SpawnInstance(dir string) error
- type App
- func (a *App) GetPandoURL() string
- func (a *App) IsSimpleMode() bool
- func (a *App) MinimiseToTray()
- func (a *App) OnDomReady(ctx context.Context)
- func (a *App) OpenInBrowser(url string)
- func (a *App) OpenSettings()
- func (a *App) QuitApp()
- func (a *App) RegisterRuntimeBridge(ipcJS, runtimeJS string)
- func (a *App) SaveDownload(url, defaultFilename string) (string, error)
- func (a *App) SaveFileDialog(title, defaultFilename string) (string, error)
- func (a *App) SetTrayAvailable(ok bool)
- func (a *App) SetWindowFocused(focused bool)
- func (a *App) ShowWindow()
- func (a *App) Shutdown(ctx context.Context)
- func (a *App) Startup(ctx context.Context)
- func (a *App) ToggleWindow()
- func (a *App) TrayAvailable() bool
- type MissingLibrariesError
Constants ¶
const LaunchedFromAppEnv = "PANDO_LAUNCHED_FROM_APP"
LaunchedFromAppEnv is set by the macOS Pando.app bundle wrapper so the CLI knows it was opened from Finder/Dock/Launchpad rather than a terminal.
Variables ¶
var DesktopBundle embed.FS
Functions ¶
func DefaultWorkingDir ¶ added in v1.2.4
DefaultWorkingDir returns the directory `pando desktop` works in when no --cwd flag is given. A GUI launch starts with the filesystem root as its working directory, which is read-only on macOS and never a sensible workspace, so it falls back to the user's home directory (Pando's general, project-less workspace).
func EmbeddedDesktopBinary ¶ added in v1.0.2
func EmbeddedDesktopBinary() []byte
func ImportLoginShellPath ¶ added in v1.2.4
func ImportLoginShellPath()
ImportLoginShellPath prepends the PATH of the user's login shell to the process PATH. Apps opened from Finder inherit launchd's minimal PATH (/usr/bin:/bin:/usr/sbin:/sbin), which hides Homebrew, language toolchains, LSP servers and agent CLIs that the tools and delegated agents rely on. It is a no-op off macOS or when the process was started from a terminal.
func Launch ¶ added in v0.267.0
Launch starts the desktop wrapper and blocks until the desktop window exits.
Resolution order:
- A pando-desktop wrapper shipped on disk next to the running executable (packaged .app/.pkg installs) — launched in place, preserving its signature & notarization.
- On macOS, an embedded Pando.app bundle extracted to a temp dir.
- The raw embedBin bytes (the compiled pando-desktop produced by `make desktop-embed`) extracted to a temp dir.
embedBin may be nil/empty when the wrapper is shipped on disk instead of embedded.
func LaunchWindow ¶ added in v0.700.0
LaunchWindow starts a desktop wrapper for url and returns immediately.
When LaunchWindow has to extract an embedded wrapper or app bundle, the temp directory is intentionally left behind so the child process keeps its files for its whole lifetime; the OS temp cleanup can reclaim it later.
func LaunchedFromApp ¶ added in v1.2.4
func LaunchedFromApp() bool
LaunchedFromApp reports whether this process was started by a GUI launcher (the Pando.app wrapper) instead of a terminal. Older bundles do not set LaunchedFromAppEnv, so on macOS a process re-parented to launchd (PPID 1) is treated the same way: that is how LaunchServices starts app executables.
func SpawnInstance ¶ added in v1.2.4
SpawnInstance starts an independent `pando desktop` process working in dir. The child runs its own API server and window, in its own process group, so closing the window that spawned it does not take it down.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App holds the Wails desktop application state.
func (*App) GetPandoURL ¶ added in v0.267.0
GetPandoURL returns the configured Pando URL. Exposed as Wails binding.
func (*App) IsSimpleMode ¶ added in v0.267.0
IsSimpleMode returns whether simple mode is active. Exposed as Wails binding.
func (*App) MinimiseToTray ¶ added in v1.1.0
func (a *App) MinimiseToTray()
MinimiseToTray hides the window into the system tray when a tray icon is live, and falls back to a regular taskbar minimise otherwise: hiding a window with no tray icon would leave no way to bring it back. Exposed as Wails binding.
func (*App) OnDomReady ¶
OnDomReady is called by Wails every time a document finishes loading.
The first load is the embedded loading page, served by the Wails asset server with the runtime injected: it captures that runtime, hands it to Go and then navigates to the Pando URL. Every later load is a Pando page, where Wails injects nothing, so the captured runtime is replayed into it. That is what gives the WebUI window.runtime (window controls, drag regions) and the window.go bindings.
func (*App) OpenInBrowser ¶
OpenInBrowser opens a URL in the user's real browser instead of the webview. Design previews and exports are the reason it exists: a preview belongs in a browser with devtools, and a PDF the webview cannot display should not become a blank panel. Exposed as Wails binding.
func (*App) OpenSettings ¶ added in v1.1.0
func (a *App) OpenSettings()
OpenSettings shows the window on the Settings view. The WebUI handles the event with its router (no reload); a page without that listener, such as the loading page, gets a plain navigation. Exposed as Wails binding.
func (*App) QuitApp ¶ added in v1.1.0
func (a *App) QuitApp()
QuitApp closes the application. Exposed as Wails binding.
func (*App) RegisterRuntimeBridge ¶ added in v1.1.0
RegisterRuntimeBridge stores the Wails IPC and runtime scripts captured by the loading page. Only the first registration is kept: it comes from the Wails-served page, before any remote content has loaded. Exposed as Wails binding.
func (*App) SaveDownload ¶ added in v0.700.0
SaveDownload fetches a URL and writes it to a path the user picks.
It exists because a webview is not a browser: an <a download> or a window.open on a Pando export URL has nowhere to put the file. Doing the fetch on the Go side also keeps the API token out of a second HTTP client. Returns the written path, or "" when the user cancels the dialog. Exposed as Wails binding.
func (*App) SaveFileDialog ¶
SaveFileDialog asks the user where to write a file and returns the chosen path, or "" when they cancel. Exposed as Wails binding.
func (*App) SetTrayAvailable ¶ added in v1.1.0
SetTrayAvailable is called by the tray integration once its icon is up (or known to be impossible on this desktop).
func (*App) SetWindowFocused ¶ added in v0.267.0
SetWindowFocused is called from JavaScript when the window gains or loses focus. This controls whether OS notifications are shown. Exposed as Wails binding.
func (*App) ShowWindow ¶ added in v1.1.0
func (a *App) ShowWindow()
ShowWindow brings the window back from the tray or the taskbar. Exposed as Wails binding.
func (*App) ToggleWindow ¶ added in v0.267.0
func (a *App) ToggleWindow()
ToggleWindow shows the window, restoring it from the tray or the taskbar. Exposed as Wails binding.
func (*App) TrayAvailable ¶ added in v1.1.0
TrayAvailable reports whether a system tray icon is live. Exposed as Wails binding.
type MissingLibrariesError ¶ added in v1.0.0
type MissingLibrariesError struct {
Libraries []string // missing shared objects, e.g. libwebkit2gtk-4.1.so.0
Glibc string // required glibc symbol version, e.g. GLIBC_2.34
Help string
Err error
}
MissingLibrariesError reports that the desktop wrapper could not start because the system lacks the GTK/WebKitGTK runtime (or has a too old glibc). Its message carries distro-specific install instructions.
func (*MissingLibrariesError) Error ¶ added in v1.0.0
func (e *MissingLibrariesError) Error() string
func (*MissingLibrariesError) Unwrap ¶ added in v1.0.0
func (e *MissingLibrariesError) Unwrap() error