From c88082515dcd9c0df1328b85420e97d7286ad428 Mon Sep 17 00:00:00 2001 From: amankumarsingh77 Date: Tue, 28 Jul 2026 22:01:47 +0530 Subject: refactor: attach and windowId become session methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cdp/attach.ts and cdp/window.ts were a module each for a single `map(await session.callBrowser(...))` one-liner that took the session as its first argument — two files, two imports and two names for what the session can expose itself. They are now session.attach(targetId) and session.windowId(targetId). session.ts also repeated `targetId ? tabs.get(targetId) : undefined` eight times; that is now currentTab(). Co-Authored-By: Claude Opus 5 (1M context) --- src/profile/bind.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/profile/bind.ts') diff --git a/src/profile/bind.ts b/src/profile/bind.ts index ca745ca..95cffaa 100644 --- a/src/profile/bind.ts +++ b/src/profile/bind.ts @@ -1,8 +1,6 @@ import type { BrowserClient } from "../client"; -import { attachTo } from "../cdp/attach"; import type { ResultOf } from "../cdp/commands"; import { type CdpError, cdpError } from "../cdp/errors"; -import { getWindowId } from "../cdp/window"; import { type Result, err, ok } from "../util/result"; import { detectRunningBrowser, resolveBrowserExecutable } from "./browser-process"; import { openProfileWindow } from "./launch"; @@ -79,10 +77,10 @@ export const seedProfileWindow = async ( const ownership = client.ownership(); ownership.setHarnessWindow(seed.targetId); ownership.add(seed.targetId); - const win = await getWindowId(client.session(), seed.targetId); + const win = await client.session().windowId(seed.targetId); if (win.success) ownership.setHarnessWindowId(win.data); - const attached = await attachTo(client.session(), seed.targetId); + const attached = await client.session().attach(seed.targetId); if (attached.success) { await client.session().callOnTarget("Page.navigate", { url: "about:blank" }, attached.data); } -- cgit v1.2.3