diff options
Diffstat (limited to 'src/profile/bind.ts')
| -rw-r--r-- | src/profile/bind.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/profile/bind.ts b/src/profile/bind.ts index 95cffaa..5382547 100644 --- a/src/profile/bind.ts +++ b/src/profile/bind.ts @@ -1,6 +1,8 @@ import type { BrowserClient } from "../client"; import type { ResultOf } from "../cdp/commands"; import { type CdpError, cdpError } from "../cdp/errors"; +import { currentCdpTarget } from "../cdp/current-target"; +import { describeCdpTarget } from "../cdp/endpoint"; import { type Result, err, ok } from "../util/result"; import { detectRunningBrowser, resolveBrowserExecutable } from "./browser-process"; import { openProfileWindow } from "./launch"; @@ -25,6 +27,20 @@ export const seedProfileWindow = async ( client: BrowserClient, pin: ProfilePin, ): Promise<Result<string, CdpError>> => { + // A pin left over from a local session is not actionable against a browser on + // another host: the launch below would start a browser HERE and then poll the + // REMOTE one for a sentinel that cannot appear, failing only after the seed + // deadline. Refuse up front and say why. + const target = await currentCdpTarget(); + if (target.kind === "remote") { + return err(cdpError( + "discovery_failed", + `the selected profile "${pin.label}" belongs to a browser on this machine, but the harness is driving ` + + `${describeCdpTarget(target)}. Run /browser-profile and clear the selection, or /browser-target local to ` + + "drive this machine's browser.", + )); + } + const connectedDir = client.userDataDir(); if (connectedDir && connectedDir !== pin.userDataDir) { return err(cdpError( |
