diff options
| author | Igor Soarez <igor@soarez.me> | 2026-08-30 16:27:22 +0100 |
|---|---|---|
| committer | Igor Soarez <igor@soarez.org> | 2026-10-14 12:19:26 +0100 |
| commit | c8fd7b7078da841d5537aee9334291887445889f (patch) | |
| tree | 2ee3611d169dc872bde0af8be186e1356af17e7d /src/cdp | |
| parent | 3a0bfc3af446a947f8392aaa3e3b2605ea7ad2da (diff) | |
fix(profile): never prompt for a profile when driving a remote browser
Profile selection works by launching the browser with --profile-directory and
letting ProcessSingleton delegate to the running process, which only reaches a
browser on this machine. discoverEndpoint() already withholds userDataDir for a
remote target, but resolveUserDataDir() fell through to the local candidate
dirs, so the picker offered this disk's Chromium profiles for a browser on
another host - on castle, Brave's profiles for a Chrome on :9223. Pinning one
launched a local browser and polled the remote for a sentinel that could never
appear, failing after the seed deadline; seedProfileWindow()'s mismatch guard
missed it because connectedDir is undefined on the remote path.
Setup now returns early instead of prompting - the question had no actionable
answer, and since cancelling stores nothing it returned every session.
/browser-profile and seedProfileWindow() refuse with the reason, the latter
catching a pin left over from a local session.
Diffstat (limited to 'src/cdp')
| -rw-r--r-- | src/cdp/current-target.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/cdp/current-target.ts b/src/cdp/current-target.ts new file mode 100644 index 0000000..82bebe6 --- /dev/null +++ b/src/cdp/current-target.ts @@ -0,0 +1,27 @@ +/** + * The target the harness is actually pointed at, resolved with I/O. + * + * `resolveCdpTarget` in endpoint.ts is deliberately pure, so every caller that + * needs the *effective* target has to read the stored choice first. This wraps + * that pair so callers outside the CDP layer — profile selection in + * particular — can ask "am I driving a browser on this machine?" without + * duplicating the precedence rules. + */ + +import { type CdpTarget, resolveCdpTarget } from "./endpoint"; +import { readTarget } from "./target-store"; + +/** The effective target: BU_CDP_HTTP, else /browser-target, else the default. */ +export const currentCdpTarget = async (): Promise<CdpTarget> => + resolveCdpTarget(process.env, await readTarget()); + +/** + * True when the harness is driving a browser on another host. + * + * Profile selection is meaningless in that case: it works by launching the + * browser binary with --profile-directory and letting ProcessSingleton hand + * the argv to the running browser (see profile/launch.ts), which only reaches + * a browser on this machine. + */ +export const drivingRemoteBrowser = async (): Promise<boolean> => + (await currentCdpTarget()).kind === "remote"; |
