Add ghost serve --window for a dedicated app window#31
Draft
murrayju wants to merge 1 commit into
Draft
Conversation
Adds a --window/-w flag to ghost serve that launches the web UI in a standalone application window without an address bar, using a Chromium-based browser's --app=<url> flag (Chrome, Chromium, Edge, or Brave). Falls back to a normal browser tab when no such browser is available. Mutually exclusive with --no-open.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
ghost serve --window(alias-w) to launch the web UI in a dedicated system window without an address bar / tab strip, instead of a normal browser tab.It opens the URL via a Chromium-based browser's
--app=<url>flag (Chrome, Chromium, Edge, or Brave), and gracefully falls back to a normal browser tab (with a warning) when no such browser is found. The flag is mutually exclusive with--no-open.Why this approach (and the trade-offs)
The original request was for a "native OS" way to open a chromeless window. After digging in, the honest reality is that there is no clean native, cross-platform CLI way to do this — "app window without an address bar" is fundamentally a browser/PWA feature, not an OS primitive:
--app=<url>works out of the box (effectively native, no extra install).WKWebViewhosted in our own window.The genuinely-native route is an embedded OS webview (WKWebView / WebView2 / WebKitGTK, e.g.
webview/webview_go), but that requires CGo + a C toolchain for every target, which directly conflicts with ourCGO_ENABLED=0cross-compile pipeline (GoReleaser builds linux/windows/darwin × 386/amd64/arm64 from a single runner). Adopting it would mean per-platform native build runners and a much heavier release setup — a large architectural change for a convenience flag.So this PR uses the Chromium
--app=approach, which:CGO_ENABLED=0build pipeline.This is up for discussion — hence the draft. If we'd rather go fully native via an embedded webview (accepting the CGo cost and reworked release pipeline) or drop the chromeless behavior entirely, I'm happy to adjust.
Changes
internal/common/browser.go— NewOpenAppWindow(url)(avar, likeOpenBrowser, for test stubbing). Searches for a Chromium-based browser per platform and launches it with--app=<url>:/Applications+~/Applicationsbundles viaopen -na <app> --args --app=<url>.google-chrome/chromium/microsoft-edge/brave-browseronPATH, started detached.ProgramFiles/ProgramFiles(x86)/LocalAppDatafor Chrome, Chromium, Edge, Brave.ErrNoAppModeBrowsersentinel when none is found.internal/cmd/serve.go— New--window/-wflag (mutually exclusive with--no-open), an example, and logic to open the app window with a graceful fallback toOpenBrowser.internal/cmd/main_test.go—withOpenAppWindowtest option; stubscommon.OpenAppWindowby default (mirrors the existingOpenBrowserstub).internal/cmd/serve_test.go— Cases for: successful app-window open (browser not called), fallback to browser when no app-mode browser is found, and the--window/--no-openmutual-exclusion error.docs/cli/ghost_serve.md— Regenerated.Testing
./checkpasses (fmt, vet, staticcheck, tests).