diff options
| author | Igor Soarez <igor@soarez.org> | 2026-08-29 22:59:29 +0100 |
|---|---|---|
| committer | Igor Soarez <igor@soarez.org> | 2026-10-14 12:19:26 +0100 |
| commit | cfa0b6f854e7f15717db385df0e43f974a4b1e67 (patch) | |
| tree | 661c6aa9f5168c74f28a8c694a73381a2d9d0d25 /src | |
| parent | 681ea9d0b3b89bec1ad8c57ef79ae2d4d82ef49b (diff) | |
fix(setup): skip local-browser precondition for every remote target
The pre-flight check only skipped isBrowserRunning() when BU_CDP_HTTP was
set, so a machine with no local browser failed /browser-setup with 'No
browser instance running' before discovery ever dialed the built-in
castle default. Resolve the target the same way discovery does and skip
the local-process check whenever it resolves remote — env var,
/browser-target choice, or default. A resolved local target still
requires a local browser, and an unreachable remote still fails loudly
in step 4.
Diffstat (limited to 'src')
| -rw-r--r-- | src/setup.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/setup.ts b/src/setup.ts index 44dfc2c..f6f58e3 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -2,6 +2,8 @@ import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-age import type { BrowserClient } from "./client"; import { ensureDaemon } from "./daemon/spawn"; import { DAEMON_SOCKET_PATH } from "./daemon/protocol"; +import { resolveCdpTarget } from "./cdp/endpoint"; +import { readTarget } from "./cdp/target-store"; import { isBrowserRunning } from "./profile/browser-process"; import { promptForProfileIfUnset } from "./profile/command"; @@ -24,9 +26,13 @@ export type SetupResult = { success: true; data: string } | { success: false; er export async function performSetup(client: BrowserClient, ctx?: ExtensionContext): Promise<SetupResult> { // Step 1: Check Chrome is running // LOCAL PATCH: isBrowserRunning() enumerates *local* processes, so it can - // never see a browser reached via BU_CDP_HTTP. Skip the precondition in that - // case — step 4 still fails loudly if the remote browser is unreachable. - if (!process.env["BU_CDP_HTTP"]?.trim()) { + // never see a browser reached over the network. Skip the precondition + // whenever the resolved target is remote — via BU_CDP_HTTP, a /browser-target + // choice, or the built-in default (see src/cdp/endpoint.ts for precedence). + // Only a resolved local target still needs a local browser process. Step 4 + // fails loudly either way if the chosen browser is unreachable. + const target = resolveCdpTarget(process.env, await readTarget()); + if (target.kind === "local") { const chromeRunning = await isBrowserRunning(); if (!chromeRunning) { return { success: false, error: "No browser instance running. Please open your browser and then run /browser-setup." }; |
