aboutsummaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/index.ts b/src/index.ts
index e4d23f8..f80c028 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -11,7 +11,7 @@ import { restoreDownloadBehavior } from "./domains/files";
import { createDaemonTransport } from "./daemon/transport";
import { setDebugClicks } from "./util/debug";
import { asBoolean, asString } from "./util/guards";
-import { describeCdpTarget, isValidTargetValue, localAliases, resolveCdpTarget } from "./cdp/endpoint";
+import { describeCdpTarget, isValidTargetValue, localAliases, redactWsUrl, resolveCdpTarget } from "./cdp/endpoint";
import { clearTarget, readTarget, writeTarget } from "./cdp/target-store";
import { ensureDaemon, stopDaemon } from "./daemon/spawn";
import { queryLiveWsUrl } from "./cdp/discovery";
@@ -50,8 +50,12 @@ export default function browserHarnessExtension(pi: ExtensionAPI): void {
// when it is really just "not needed yet", so say which it is, and show
// what we would connect to.
const target = resolveCdpTarget(process.env, await readTarget());
+ // FORK: a BU_CDP_WS pin is not probed: /json/version answering says nothing
+ // about whether the browser id pinned in that URL is still current.
const reachable =
- target.kind === "remote" ? (await queryLiveWsUrl(target.port, 2_000, target.host)) !== null : null;
+ target.kind === "remote" && target.source !== "ws"
+ ? (await queryLiveWsUrl(target.port, 2_000, target.host)) !== null
+ : null;
const browserLine = s.alive
? "🟢 Connected"
@@ -61,7 +65,7 @@ export default function browserHarnessExtension(pi: ExtensionAPI): void {
const targetLine =
target.kind === "remote"
- ? `${describeCdpTarget(target)}${reachable ? " — reachable ✓" : " — unreachable ✗"}` +
+ ? `${describeCdpTarget(target)}${reachable === null ? "" : reachable ? " — reachable ✓" : " — unreachable ✗"}` +
(reachable === false && target.source === "default"
? "\n will fall back to this machine's browser"
: "")
@@ -134,10 +138,14 @@ export default function browserHarnessExtension(pi: ExtensionAPI): void {
// Warn rather than silently disobey: the environment deliberately wins,
// so a stored choice made now would not take effect this session.
- const envOverride = (process.env["BU_CDP_HTTP"] ?? "").trim();
+ // FORK: BU_CDP_WS outranks both (upstream reads it first); show only its host:port.
+ const wsOverride = (process.env["BU_CDP_WS"] ?? "").trim();
+ const httpOverride = (process.env["BU_CDP_HTTP"] ?? "").trim();
+ const envOverride =
+ wsOverride !== "" ? `BU_CDP_WS (${redactWsUrl(wsOverride)})` : httpOverride !== "" ? `BU_CDP_HTTP=${httpOverride}` : "";
if (envOverride !== "") {
ctx.ui.notify(
- `Saved, but BU_CDP_HTTP=${envOverride} is set in this environment and takes precedence.\n` +
+ `Saved, but ${envOverride} is set in this environment and takes precedence.\n` +
`Still using: ${describeCdpTarget(resolved)}`,
"warning",
);