From c8fd7b7078da841d5537aee9334291887445889f Mon Sep 17 00:00:00 2001 From: Igor Soarez Date: Sun, 30 Aug 2026 16:27:22 +0100 Subject: 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. --- src/profile/command.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/profile/command.ts') diff --git a/src/profile/command.ts b/src/profile/command.ts index 270b42f..ea0ddcc 100644 --- a/src/profile/command.ts +++ b/src/profile/command.ts @@ -1,6 +1,8 @@ import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent"; import type { BrowserClient } from "../client"; import { discoverEndpoint } from "../cdp/discovery"; +import { currentCdpTarget } from "../cdp/current-target"; +import { describeCdpTarget } from "../cdp/endpoint"; import { type Result, err, ok } from "../util/result"; import { type BrowserProfile, listProfiles } from "./list"; import { browserNameForUserDataDir, userDataDirCandidates } from "./paths"; @@ -60,6 +62,21 @@ const resolveUserDataDir = async (client: BrowserClient): Promise 0) withProfiles.push(dir); @@ -164,6 +181,13 @@ export const promptForProfileIfUnset = async ( client.setProfilePin(stored); return undefined; } + // Never prompt for a remote browser. Profile selection cannot act on one (see + // resolveUserDataDir), so asking would be a blocking question with no useful + // answer — and every cancelled prompt stores nothing, so it would come back + // every session. Silence is correct here: the browser keeps its own default + // profile, and /browser-status already reports which browser is being driven. + if ((await currentCdpTarget()).kind === "remote") return undefined; + if (!ctx?.hasUI) { return "No browser profile selected — using whichever window is focused. Run /browser-profile to pin one."; } -- cgit v1.2.3