fix: preserve loopback ws cdp tab ops (#31085) (thanks @shrey150)

This commit is contained in:
Peter Steinberger
2026-03-08 18:47:48 +00:00
parent 4d904e7b7d
commit 9914b48c57
7 changed files with 158 additions and 31 deletions

View File

@@ -1,4 +1,4 @@
import { fetchOk } from "./cdp.helpers.js";
import { fetchOk, normalizeCdpHttpBaseForJsonEndpoints } from "./cdp.helpers.js";
import { appendCdpPath } from "./cdp.js";
import type { ResolvedBrowserProfile } from "./config.js";
import type { PwAiModule } from "./pw-ai-module.js";
@@ -27,6 +27,8 @@ export function createProfileSelectionOps({
listTabs,
openTab,
}: SelectionDeps): SelectionOps {
const cdpHttpBase = normalizeCdpHttpBaseForJsonEndpoints(profile.cdpUrl);
const ensureTabAvailable = async (targetId?: string): Promise<BrowserTab> => {
await ensureBrowserAvailable();
const profileState = getProfileState();
@@ -122,7 +124,7 @@ export function createProfileSelectionOps({
}
}
await fetchOk(appendCdpPath(profile.cdpUrl, `/json/activate/${resolvedTargetId}`));
await fetchOk(appendCdpPath(cdpHttpBase, `/json/activate/${resolvedTargetId}`));
const profileState = getProfileState();
profileState.lastTargetId = resolvedTargetId;
};
@@ -144,7 +146,7 @@ export function createProfileSelectionOps({
}
}
await fetchOk(appendCdpPath(profile.cdpUrl, `/json/close/${resolvedTargetId}`));
await fetchOk(appendCdpPath(cdpHttpBase, `/json/close/${resolvedTargetId}`));
};
return {