From 9e9bf2a3badb59d0ce5bdb47c4e9d09ffb259e69 Mon Sep 17 00:00:00 2001 From: amankumarsingh77 Date: Mon, 27 Jul 2026 01:17:32 +0530 Subject: refactor(cdp): extract attachTo, getWindowId, evaluateJson helpers Target.attachToTarget was decoded at 5 sites, Browser.getWindowForTarget at 5, and Runtime.evaluate unwrapped at another. Each is now one typed helper. Deletes the dead cdp/window-binding.ts. Co-Authored-By: Claude Opus 5 (1M context) --- src/cdp/window-binding.ts | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 src/cdp/window-binding.ts (limited to 'src/cdp/window-binding.ts') diff --git a/src/cdp/window-binding.ts b/src/cdp/window-binding.ts deleted file mode 100644 index 4ae1ac3..0000000 --- a/src/cdp/window-binding.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { BrowserClient } from "../client"; - -/** - * Capture the real Chrome windowId of a freshly-created harness window and bind - * it as the session's durable window identity. Best-effort: a failed CDP call - * leaves the previous binding untouched. Call this on every code path that - * spawns a NEW dedicated window (newWindow:true), so the windowId never points - * at a window that has since been replaced. - */ -export const bindHarnessWindowId = async (client: BrowserClient, targetId: string): Promise => { - const r = await client.session().callBrowser("Browser.getWindowForTarget", { targetId }); - if (!r.success) return; - const wid = (r.data as { windowId?: number }).windowId; - if (typeof wid === "number") client.ownership().setHarnessWindowId(wid); -}; -- cgit v1.2.3