Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: improve browser discovery, doctor diagnostics, and setup docs

Boschf157bd420323
diff --git a/README.md b/README.md
index 83c569dc..59008b5d 100644
--- a/README.md
+++ b/README.md
@@ -190,6 +190,8 @@ PinchTab's primary tested operator workflow is local macOS and Linux.
Windows binaries are published, but Windows support is currently limited and best-effort because the project does not have the same level of automated and manual coverage there. On Windows, prefer running `pinchtab server` or `pinchtab bridge` directly instead of relying on the daemon workflow.
+On **macOS**, prefer a dedicated automation browser (Google Chrome for Testing or Chromium) over your daily Google Chrome. Driving your primary Chrome headless can prevent it from opening a normal window while PinchTab is running. PinchTab now prefers a dedicated browser automatically, and `pinchtab doctor browsers` warns if automation would fall back to your primary Chrome — install Chrome for Testing or set `browser.binary` to a separate build. See [docs/reference/config.md](docs/reference/config.md).
+
### Shell Completion
Generate and install shell completions after `pinchtab` is on your `PATH`:
diff --git a/cmd/pinchtab/cmd_cli_runtime.go b/cmd/pinchtab/cmd_cli_runtime.go
index 103da17e..4e89cb24 100644
--- a/cmd/pinchtab/cmd_cli_runtime.go
+++ b/cmd/pinchtab/cmd_cli_runtime.go
@@ -8,6 +8,8 @@ import (
"time"
"github.com/pinchtab/pinchtab/internal/activity"
+ "github.com/pinchtab/pinchtab/internal/browsers"
+ "github.com/pinchtab/pinchtab/internal/browsers/runtimekit"
"github.com/pinchtab/pinchtab/internal/cli/output"
"github.com/pinchtab/pinchtab/internal/config"
"github.com/spf13/cobra"
@@ -33,6 +35,14 @@ func runCLIEnsuringServer(command string, fn func(cliRuntime)) {
func runCLIWithServerCheck(cfg *config.RuntimeConfig, command string, fn func(cliRuntime)) {
rt := newCLIRuntime(cfg)
+ // Only preflight when this command would auto-start the local server. For a
+ // remote --server the browser lives on that host, so local discovery is moot.
+ if canAutoStartServerForCLI(cfg, rt.base) {
+ if err := preflightBrowserBinary(cfg); err != nil {
+ fmt.Fprintf(os.Stderr, "pinchtab: %v\n", err)
+ os.Exit(1)
+ }
+ }
if err := ensureServerForCLI(cfg, rt.base, rt.token, command); err != nil {
fmt.Fprintf(os.Stderr, "pinchtab: %v\n", err)
os.Exit(1)
@@ -40,6 +50,36 @@ func runCLIWithServerCheck(cfg *config.RuntimeConfig, command string, fn func(cl
fn(rt)
}
+// preflightBrowserBinary fails fast with an actionable message when the active
+// provider has no usable browser, instead of letting the launch silently retry
+// and surface only the bridge's generic "instance not ready after 10s" timeout.
+// It mirrors the launch-time resolution in bridge/runtime.InitBrowser (explicit
+// browser.binary wins over discovery) so it can't diverge from what actually runs.
+func preflightBrowserBinary(cfg *config.RuntimeConfig) error {
+ if cfg == nil || strings.TrimSpace(cfg.CDPAttachURL) != "" {
+ return nil // attaching to an external CDP endpoint; no local binary needed
+ }
+ browserID := config.NormalizeBrowser(cfg.DefaultBrowser)
+ if _, ok := browsers.Get(browserID); !ok {
+ return nil // unknown provider — let the normal path report it
+ }
+ if override := strings.TrimSpace(cfg.BrowserBinary); override != "" {
+ if info, err := os.Stat(override); err != nil || info.IsDir() {
+ return fmt.Errorf("configured browser.binary does not point at a usable executable: %s\n"+
+ " Point it at an existing browser binary, or unset it to use auto-discovery. "+
+ "Run `pinchtab doctor` for details", override)
+ }
+ return nil
+ }
+ if runtimekit.FindBrowserBinary(browserID) == "" {
+ return fmt.Errorf("no %s browser found on this machine.\n"+
+ " Install one (e.g. Google Chrome for Testing, or `apt-get install -y chromium` "+
+ "on Debian/Ubuntu) or set browser.binary in your config.\n"+
+ " Run `pinchtab doctor` for the full diagnosis", browserID)
+ }
+ return nil
+}
+
func newCLIRuntime(cfg *config.RuntimeConfig) cliRuntime {
return cliRuntime{
client: newCLIHTTPClient(resolveCLIAgentID()),
diff --git a/cmd/pinchtab/cmd_cli_runtime_test.go b/cmd/pinchtab/cmd_cli_runtime_test.go
index 848fb005..29cb63d4 100644
--- a/cmd/pinchtab/cmd_cli_runtime_test.go
+++ b/cmd/pinchtab/cmd_cli_runtime_test.go
@@ -3,6 +3,9 @@ package main
import (
"io"
"net/http"
+ "os"
+ "path/filepath"
+ "strings"
"testing"
"github.com/pinchtab/pinchtab/internal/config"
@@ -187,6 +190,47 @@ func TestRunCLIWithInjectsAgentIDHeaders(t *testing.T) {
}
}
+// TestPreflightBrowserBinary covers the fail-fast no-browser diagnosis that
+// replaces the bridge's opaque "instance not ready after 10s" 503 on the
+// documented `pinchtab nav` cold start.
+func TestPreflightBrowserBinary(t *testing.T) {
+ existing := filepath.Join(t.TempDir(), "chrome")
+ if err := os.WriteFile(existing, []byte("#!/bin/sh\n"), 0o755); err != nil {
+ t.Fatal(err)
+ }
+
+ t.Run("missing override fails fast with guidance", func(t *testing.T) {
+ err := preflightBrowserBinary(&config.RuntimeConfig{
+ DefaultBrowser: "chrome",
+ BrowserBinary: filepath.Join(t.TempDir(), "does-not-exist"),
+ })
+ if err == nil {
+ t.Fatal("expected error for a missing browser.binary override")
+ }
+ if !strings.Contains(err.Error(), "browser.binary") || !strings.Contains(err.Error(), "doctor") {
+ t.Errorf("error should name browser.binary and point at doctor; got: %v", err)
+ }
+ })
+
+ t.Run("existing override passes", func(t *testing.T) {
+ if err := preflightBrowserBinary(&config.RuntimeConfig{
+ DefaultBrowser: "chrome",
+ BrowserBinary: existing,
+ }); err != nil {
+ t.Errorf("expected nil for an existing override binary; got %v", err)
+ }
+ })
+
+ t.Run("external CDP attach skips local binary check", func(t *testing.T) {
+ if err := preflightBrowserBinary(&config.RuntimeConfig{
+ DefaultBrowser: "chrome",
+ CDPAttachURL: "http://127.0.0.1:9222",
+ }); err != nil {
+ t.Errorf("expected nil when attaching to external CDP; got %v", err)
+ }
+ })
+}
+
type roundTripFunc func(*http.Request) (*http.Response, error)
func (fn roundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) {
diff --git a/cmd/pinchtab/cmd_daemon.go b/cmd/pinchtab/cmd_daemon.go
index 66bda6b3..1c13640c 100644
--- a/cmd/pinchtab/cmd_daemon.go
+++ b/cmd/pinchtab/cmd_daemon.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ "github.com/pinchtab/pinchtab/internal/browsers/chrome"
"github.com/pinchtab/pinchtab/internal/cli"
"github.com/pinchtab/pinchtab/internal/config"
"github.com/pinchtab/pinchtab/internal/daemon"
@@ -83,9 +84,27 @@ func handleDaemonInstall(manager daemon.Manager) {
printDaemonActionError(manager, fmt.Sprintf("daemon install failed: %v", err))
}
fmt.Println(cli.StyleStdout(cli.SuccessStyle, " [ok] ") + message)
+ warnPrimaryChromeMacOS(fileCfg)
printDaemonFollowUp()
}
+// warnPrimaryChromeMacOS surfaces the issue #583 collision at install time:
+// on macOS, auto-launching the user's daily Google Chrome for headless
+// automation can stop their normal Chrome from opening a window.
+func warnPrimaryChromeMacOS(fileCfg *config.FileConfig) {
+ if fileCfg == nil || !chrome.ResolvesToPrimaryChromeMacOS(fileCfg.BrowserBinary()) {
+ return
+ }
+ fmt.Fprintln(os.Stderr, cli.StyleStderr(cli.WarningStyle,
+ " [warn] Automation will use your primary Google Chrome on macOS."))
+ fmt.Fprintln(os.Stderr, cli.StyleStderr(cli.MutedStyle,
+ " Launching it headless can stop your normal Chrome from opening (issue #583)."))
+ fmt.Fprintln(os.Stderr, cli.StyleStderr(cli.MutedStyle,
+ " Install Google Chrome for Testing or Chromium, or set browser.binary in config"))
+ fmt.Fprintln(os.Stderr, cli.StyleStderr(cli.MutedStyle,
+ " to a dedicated automation browser."))
+}
+
func handleDaemonUninstall(manager daemon.Manager) {
message, err := manager.Uninstall()
if err != nil {
diff --git a/cmd/pinchtab/root.go b/cmd/pinchtab/root.go
index f3972ccf..53518fb6 100644
--- a/cmd/pinchtab/root.go
+++ b/cmd/pinchtab/root.go
@@ -26,6 +26,17 @@ browsers, manage tabs, and perform interactive tasks.`,
},
}
+// versionCmd mirrors --version as a subcommand, since `pinchtab version` is a
+// common first instinct and cobra only wires up the --version flag by default.
+var versionCmd = &cobra.Command{
+ Use: "version",
+ Short: "Print the PinchTab version",
+ Args: cobra.NoArgs,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Printf("pinchtab %s\n", version)
+ },
+}
+
// maybeRunWizard checks if the security wizard should run and triggers it.
func maybeRunWizard() {
fileCfg, configPath, err := config.LoadFileConfig()
@@ -104,5 +115,7 @@ func init() {
rootCmd.AddGroup(primaryGroup, browserGroup, mgmtGroup, configGroup)
+ rootCmd.AddCommand(versionCmd)
+
cli.SetupUsage(rootCmd)
}
diff --git a/docs/reference/config.md b/docs/reference/config.md
index bbb3a3b2..fd3a851d 100644
--- a/docs/reference/config.md
+++ b/docs/reference/config.md
@@ -387,6 +387,17 @@ When the selected browser is `cloak`, `browser.binary` (or the target's
`binary`) must point at the local CloakBrowser Chromium executable. PinchTab
does not download, bundle, or redistribute the CloakBrowser binary.
+On **macOS**, prefer a dedicated automation browser over your daily Google
+Chrome. Launching `/Applications/Google Chrome.app` headless makes macOS treat
+Chrome as already running, so opening your normal Chrome from the Dock just
+activates the windowless automation process and no window appears (issue #583).
+PinchTab's discovery now prefers Google Chrome for Testing, Chromium, then Chrome
+Canary, and only falls back to your primary Chrome as a last resort. If only your
+daily Chrome is installed, install [Google Chrome for
+Testing](https://developer.chrome.com/blog/chrome-for-testing) or set
+`browser.binary` to a separate Chrome/Chromium build. `pinchtab doctor browsers`
+warns when automation would use your primary Chrome.
+
`browser.cloak` maps supported CloakBrowser fingerprint settings to native launch
flags:
diff --git a/internal/browsers/chrome/chrome.go b/internal/browsers/chrome/chrome.go
index 142457d1..b84f0204 100644
--- a/internal/browsers/chrome/chrome.go
+++ b/internal/browsers/chrome/chrome.go
@@ -14,6 +14,12 @@ import (
"github.com/pinchtab/pinchtab/internal/browsers"
)
+// primaryChromeAppMacOS is the user's daily Google Chrome executable. On macOS,
+// launching it for headless automation collides with LaunchServices and can stop
+// the user's normal Chrome from opening (issue #583), so PinchTab prefers a
+// dedicated automation browser and only falls back to this as a last resort.
+const primaryChromeAppMacOS = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
+
var binaryNames = []string{
"google-chrome",
"google-chrome-stable",
@@ -42,10 +48,19 @@ func CommonPaths(goos string) []string {
"/opt/google/chrome/chrome",
}
case "darwin":
+ // Prefer a dedicated automation browser over the user's daily Google
+ // Chrome. On macOS, launching /Applications/Google Chrome.app directly
+ // with --headless=new makes LaunchServices treat Chrome as already
+ // running, so the user's next Dock/Spotlight launch just activates the
+ // windowless automation process instead of opening a real window
+ // (see issue #583). Chrome for Testing / Chromium / Canary have a
+ // distinct app identity and avoid the collision; the daily Chrome is a
+ // last resort.
return []string{
- "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
+ "/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",
"/Applications/Chromium.app/Contents/MacOS/Chromium",
"/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",
+ primaryChromeAppMacOS,
}
case "windows":
return []string{
@@ -101,6 +116,18 @@ func (Browser) Capabilities() browsers.CapabilitySet {
)
}
+// ResolvesToPrimaryChromeMacOS reports whether, absent an explicit binary
+// override, Chrome discovery would launch the user's daily Google Chrome on
+// macOS — the configuration that triggers the issue #583 LaunchServices
+// collision (automation blocks the user's normal Chrome from opening).
+func ResolvesToPrimaryChromeMacOS(binaryOverride string) bool {
+ if runtime.GOOS != "darwin" || strings.TrimSpace(binaryOverride) != "" {
+ return false
+ }
+ d := browserprobe.DiscoverBinary(BinaryNames(), CommonPaths(runtime.GOOS))
+ return d.Found == primaryChromeAppMacOS
+}
+
func (Browser) DiscoverBinary() browsers.BinaryDiscovery {
d := browserprobe.DiscoverBinary(BinaryNames(), CommonPaths(runtime.GOOS))
return browsers.BinaryDiscovery{Found: d.Found, Probed: d.Probed}
diff --git a/internal/browsers/chrome/chrome_test.go b/internal/browsers/chrome/chrome_test.go
index adaceb2c..2fefc8f1 100644
--- a/internal/browsers/chrome/chrome_test.go
+++ b/internal/browsers/chrome/chrome_test.go
@@ -2,6 +2,9 @@ package chrome_test
import (
"context"
+ "os"
+ "path/filepath"
+ "runtime"
"slices"
"strings"
"testing"
@@ -147,6 +150,31 @@ func TestCommonPathsPerOS(t *testing.T) {
}
}
+func TestCommonPathsDarwinPrefersDedicatedBrowser(t *testing.T) {
+ paths := chrome.CommonPaths("darwin")
+ if len(paths) == 0 {
+ t.Fatal("darwin CommonPaths empty")
+ }
+
+ primary := "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
+ cft := "/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing"
+
+ // The user's daily Chrome must be the LAST resort (issue #583): launching it
+ // for automation collides with macOS LaunchServices.
+ if got := paths[len(paths)-1]; got != primary {
+ t.Errorf("expected primary Chrome to be last; got last = %q in %v", got, paths)
+ }
+
+ primaryIdx := indexOf(paths, primary)
+ cftIdx := indexOf(paths, cft)
+ if cftIdx < 0 {
+ t.Fatalf("expected Chrome for Testing in darwin CommonPaths; got %v", paths)
+ }
+ if cftIdx >= primaryIdx {
+ t.Errorf("Chrome for Testing (%d) must be preferred over primary Chrome (%d)", cftIdx, primaryIdx)
+ }
+}
+
func TestDiscoverBinaryReturnsValidResult(t *testing.T) {
b, ok := browsers.Get("chrome")
if !ok {
@@ -545,6 +573,41 @@ func TestChrome_ValidateTarget(t *testing.T) {
}
}
+// TestChromePresentHonorsBrowserBinaryOverride guards the issue #583 follow-up:
+// a configured browser.binary that sits off the static discovery path must PASS
+// chrome_present (it's what the runtime launches), not report a false "no
+// chrome/chromium found" FAIL while the binary_* checks pass right below it.
+func TestChromePresentHonorsBrowserBinaryOverride(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("chrome_present is skipped on windows")
+ }
+ dir := t.TempDir()
+ fake := filepath.Join(dir, "fakechrome")
+ if err := os.WriteFile(fake, []byte("#!/bin/sh\necho 'Chromium 149.0.0.0'\n"), 0o755); err != nil {
+ t.Fatal(err)
+ }
+
+ check := findCheckByID(t, (&chrome.Browser{}).DoctorChecks(browsers.TargetConfig{}), "chrome_present")
+ res := check.Fn(context.Background(), &browsers.DoctorEnv{Binary: fake})
+ if res.Status != browsers.DoctorPass {
+ t.Fatalf("chrome_present with override status = %v, want DoctorPass; detail: %s", res.Status, res.Detail)
+ }
+ if !strings.Contains(res.Detail, fake) {
+ t.Errorf("expected detail to reference the override path %q; got %q", fake, res.Detail)
+ }
+}
+
+func findCheckByID(t *testing.T, checks []browsers.DoctorCheck, id string) browsers.DoctorCheck {
+ t.Helper()
+ for _, c := range checks {
+ if c.ID == id {
+ return c
+ }
+ }
+ t.Fatalf("check %q not found", id)
+ return browsers.DoctorCheck{}
+}
+
func TestChromeHandleDecisionsCheck(t *testing.T) {
b := &chrome.Browser{}
checks := b.DoctorChecks(browsers.TargetConfig{})
diff --git a/internal/browsers/chrome/doctor.go b/internal/browsers/chrome/doctor.go
index 257f41c3..4cb53c27 100644
--- a/internal/browsers/chrome/doctor.go
+++ b/internal/browsers/chrome/doctor.go
@@ -52,25 +52,41 @@ func (b Browser) DoctorChecks(_ browsers.TargetConfig) []browsers.DoctorCheck {
}
}
-func chromePresenceCheck(ctx context.Context, _ interface{}) browsers.DoctorCheckResult {
+func chromePresenceCheck(ctx context.Context, cfg interface{}) browsers.DoctorCheckResult {
+ // A configured browser.binary override governs the runtime, so resolve against
+ // it first. Honoring it here keeps chrome_present consistent with the binary_*
+ // checks (which already validate the override) — otherwise a working configured
+ // browser sitting off the static discovery path produces a false FAIL.
+ override := ""
+ if env, ok := cfg.(*browsers.DoctorEnv); ok && env != nil {
+ override = strings.TrimSpace(env.Binary)
+ }
+ overridden := override != ""
+
if runtime.GOOS == "windows" {
return browsers.DoctorCheckResult{
Status: browsers.DoctorSkip,
Detail: "chrome discovery not implemented on windows",
}
}
- d := browserprobe.DiscoverBinary(BinaryNames(), CommonPaths(runtime.GOOS))
- if d.Found == "" {
- return browsers.DoctorCheckResult{
- Status: browsers.DoctorFail,
- Detail: "no chrome/chromium found; probed: " + strings.Join(d.Probed, ", "),
+ found := override
+ if found == "" {
+ d := browserprobe.DiscoverBinary(BinaryNames(), CommonPaths(runtime.GOOS))
+ found = d.Found
+ if found == "" {
+ return browsers.DoctorCheckResult{
+ Status: browsers.DoctorFail,
+ Detail: "no chrome/chromium found. Install Chrome/Chromium (e.g. Google Chrome " +
+ "for Testing, or `apt-get install -y chromium` on Debian/Ubuntu) or set " +
+ "browser.binary to an existing build. Probed: " + strings.Join(d.Probed, ", "),
+ }
}
}
- line, err := browserprobe.RunVersion(ctx, d.Found)
+ line, err := browserprobe.RunVersion(ctx, found)
if err != nil {
return browsers.DoctorCheckResult{
Status: browsers.DoctorWarn,
- Detail: fmt.Sprintf("%s: --version failed: %v", d.Found, err),
+ Detail: fmt.Sprintf("%s: --version failed: %v", found, err),
Err: err,
}
}
@@ -78,17 +94,28 @@ func chromePresenceCheck(ctx context.Context, _ interface{}) browsers.DoctorChec
if token == "" {
return browsers.DoctorCheckResult{
Status: browsers.DoctorWarn,
- Detail: fmt.Sprintf("%s: could not parse version from %q", d.Found, line),
+ Detail: fmt.Sprintf("%s: could not parse version from %q", found, line),
}
}
if browserprobe.CompareSemver(token, chromeMinVersion) < 0 {
return browsers.DoctorCheckResult{
Status: browsers.DoctorWarn,
- Detail: fmt.Sprintf("%s -> %s (< required %s)", d.Found, token, chromeMinVersion),
+ Detail: fmt.Sprintf("%s -> %s (< required %s)", found, token, chromeMinVersion),
+ }
+ }
+ if !overridden && runtime.GOOS == "darwin" && found == primaryChromeAppMacOS {
+ // Works, but flag the macOS collision (issue #583) without downgrading
+ // status — the browser launches fine, it's just sub-optimal here.
+ return browsers.DoctorCheckResult{
+ Status: browsers.DoctorPass,
+ Detail: fmt.Sprintf("%s -> %s (>= %s); note: this is your primary Google Chrome — "+
+ "automating it on macOS can stop your normal Chrome from opening (issue #583). "+
+ "Install Google Chrome for Testing or Chromium, or set browser.binary.",
+ found, token, chromeMinVersion),
}
}
return browsers.DoctorCheckResult{
Status: browsers.DoctorPass,
- Detail: fmt.Sprintf("%s -> %s (>= %s)", d.Found, token, chromeMinVersion),
+ Detail: fmt.Sprintf("%s -> %s (>= %s)", found, token, chromeMinVersion),
}
}
diff --git a/internal/browsers/cloak/cloak_test.go b/internal/browsers/cloak/cloak_test.go
index 4f252545..ddba9405 100644
--- a/internal/browsers/cloak/cloak_test.go
+++ b/internal/browsers/cloak/cloak_test.go
@@ -2,6 +2,9 @@ package cloak_test
import (
"context"
+ "os"
+ "path/filepath"
+ "runtime"
"slices"
"strings"
"testing"
@@ -761,6 +764,43 @@ func TestCloak_CanHandle_StateChanging(t *testing.T) {
}
}
+// TestCloakPresentHonorsBrowserBinaryOverride is the original report: the
+// CloakBrowser installer drops its Chromium in a versioned dir that isn't on the
+// static probe list, so a configured browser.binary must PASS cloakbrowser_present
+// rather than report a false "cloakbrowser not found" FAIL.
+func TestCloakPresentHonorsBrowserBinaryOverride(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("cloakbrowser_present is skipped on windows")
+ }
+ dir := t.TempDir()
+ fake := filepath.Join(dir, "chromium-145.0.0.0", "chrome")
+ if err := os.MkdirAll(filepath.Dir(fake), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(fake, []byte("#!/bin/sh\necho 'Chromium 145.0.0.0'\n"), 0o755); err != nil {
+ t.Fatal(err)
+ }
+
+ checks := (&cloak.Browser{}).DoctorChecks(browsers.TargetConfig{})
+ var present *browsers.DoctorCheck
+ for i := range checks {
+ if checks[i].ID == "cloakbrowser_present" {
+ present = &checks[i]
+ break
+ }
+ }
+ if present == nil {
+ t.Fatal("cloakbrowser_present check not found")
+ }
+ res := present.Fn(context.Background(), &browsers.DoctorEnv{Binary: fake})
+ if res.Status != browsers.DoctorPass {
+ t.Fatalf("cloakbrowser_present with override status = %v, want DoctorPass; detail: %s", res.Status, res.Detail)
+ }
+ if !strings.Contains(res.Detail, fake) {
+ t.Errorf("expected detail to reference the override path %q; got %q", fake, res.Detail)
+ }
+}
+
func TestCloakHandleDecisionsCheck(t *testing.T) {
b := &cloak.Browser{}
checks := b.DoctorChecks(browsers.TargetConfig{})
diff --git a/internal/browsers/cloak/doctor.go b/internal/browsers/cloak/doctor.go
index 6d61eac1..85e41208 100644
--- a/internal/browsers/cloak/doctor.go
+++ b/internal/browsers/cloak/doctor.go
@@ -70,25 +70,38 @@ func (Browser) DoctorChecks(_ browsers.TargetConfig) []browsers.DoctorCheck {
}
}
-func cloakPresenceCheck(ctx context.Context, _ interface{}) browsers.DoctorCheckResult {
+func cloakPresenceCheck(ctx context.Context, cfg interface{}) browsers.DoctorCheckResult {
if runtime.GOOS == "windows" {
return browsers.DoctorCheckResult{
Status: browsers.DoctorSkip,
Detail: "cloakbrowser discovery not implemented on windows",
}
}
- d := browserprobe.DiscoverBinary(BinaryNames(), CommonPaths(runtime.GOOS))
- if d.Found == "" {
- return browsers.DoctorCheckResult{
- Status: browsers.DoctorFail,
- Detail: "cloakbrowser not found; set browser.binary or install CloakBrowser. probed: " + strings.Join(d.Probed, ", "),
+ // An explicit browser.binary override is what the runtime launches, so resolve
+ // against it before falling back to discovery. The CloakBrowser installer drops
+ // its Chromium in a versioned dir that isn't on the static probe list, so without
+ // this a perfectly working configured binary reports a false FAIL while the
+ // binary_* checks below it pass.
+ override := ""
+ if env, ok := cfg.(*browsers.DoctorEnv); ok && env != nil {
+ override = strings.TrimSpace(env.Binary)
+ }
+ found := override
+ if found == "" {
+ d := browserprobe.DiscoverBinary(BinaryNames(), CommonPaths(runtime.GOOS))
+ found = d.Found
+ if found == "" {
+ return browsers.DoctorCheckResult{
+ Status: browsers.DoctorFail,
+ Detail: "cloakbrowser not found; set browser.binary or install CloakBrowser. probed: " + strings.Join(d.Probed, ", "),
+ }
}
}
- line, err := browserprobe.RunVersion(ctx, d.Found)
+ line, err := browserprobe.RunVersion(ctx, found)
if err != nil {
return browsers.DoctorCheckResult{
Status: browsers.DoctorWarn,
- Detail: fmt.Sprintf("%s: --version failed: %v", d.Found, err),
+ Detail: fmt.Sprintf("%s: --version failed: %v", found, err),
Err: err,
}
}
@@ -96,18 +109,18 @@ func cloakPresenceCheck(ctx context.Context, _ interface{}) browsers.DoctorCheck
if token == "" {
return browsers.DoctorCheckResult{
Status: browsers.DoctorWarn,
- Detail: fmt.Sprintf("%s: could not parse version from %q", d.Found, line),
+ Detail: fmt.Sprintf("%s: could not parse version from %q", found, line),
}
}
if browserprobe.CompareSemver(token, cloakMinVersion) < 0 {
return browsers.DoctorCheckResult{
Status: browsers.DoctorWarn,
- Detail: fmt.Sprintf("%s -> %s (< required %s)", d.Found, token, cloakMinVersion),
+ Detail: fmt.Sprintf("%s -> %s (< required %s)", found, token, cloakMinVersion),
}
}
return browsers.DoctorCheckResult{
Status: browsers.DoctorPass,
- Detail: fmt.Sprintf("%s -> %s (>= %s)", d.Found, token, cloakMinVersion),
+ Detail: fmt.Sprintf("%s -> %s (>= %s)", found, token, cloakMinVersion),
}
}