fix(browser): add browser session selection

This commit is contained in:
Peter Steinberger
2026-03-14 03:46:34 +00:00
parent b857a8d8bc
commit 5c40c1c78a
19 changed files with 575 additions and 36 deletions

View File

@@ -79,6 +79,36 @@ describe("runBrowserProxyCommand", () => {
);
});
it("includes chrome-mcp transport in timeout diagnostics when no CDP URL exists", async () => {
dispatcherMocks.dispatch
.mockImplementationOnce(async () => {
await new Promise(() => {});
})
.mockResolvedValueOnce({
status: 200,
body: {
running: true,
transport: "chrome-mcp",
cdpHttp: true,
cdpReady: false,
cdpUrl: null,
},
});
await expect(
runBrowserProxyCommand(
JSON.stringify({
method: "GET",
path: "/snapshot",
profile: "chrome-live",
timeoutMs: 5,
}),
),
).rejects.toThrow(
/browser proxy timed out for GET \/snapshot after 5ms; ws-backed browser action; profile=chrome-live; status\(running=true, cdpHttp=true, cdpReady=false, transport=chrome-mcp\)/,
);
});
it("keeps non-timeout browser errors intact", async () => {
dispatcherMocks.dispatch.mockResolvedValue({
status: 500,

View File

@@ -164,6 +164,7 @@ async function readBrowserProxyStatus(params: {
const body = response.body as Record<string, unknown>;
return {
running: body.running,
transport: body.transport,
cdpHttp: body.cdpHttp,
cdpReady: body.cdpReady,
cdpUrl: body.cdpUrl,
@@ -194,6 +195,9 @@ function formatBrowserProxyTimeoutMessage(params: {
`cdpHttp=${String(params.status.cdpHttp)}`,
`cdpReady=${String(params.status.cdpReady)}`,
];
if (typeof params.status.transport === "string" && params.status.transport.trim()) {
statusParts.push(`transport=${params.status.transport}`);
}
if (typeof params.status.cdpUrl === "string" && params.status.cdpUrl.trim()) {
statusParts.push(`cdpUrl=${params.status.cdpUrl}`);
}