aboutsummaryrefslogtreecommitdiff
path: root/src/setup.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/setup.ts')
-rw-r--r--src/setup.ts12
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." };