From 254de089ee468795bac175d99e09ddaec4ac1469 Mon Sep 17 00:00:00 2001 From: amankumarsingh77 Date: Tue, 28 Jul 2026 19:50:02 +0530 Subject: fix(domains): keep element refs stable across a mutation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit interactiveDiff re-assigned refs by tree position after every fill, click and select, so any element appearing or disappearing shifted the numbering and a ref the agent was still holding silently resolved to a different element — while the tools kept promising that refs survive re-renders. Refs are now carried over by backendNodeId and only genuinely new elements draw a new number. Report: docs/superpowers/reports/2026-07-26-bug-audit.md#f6 Co-Authored-By: Claude Opus 5 (1M context) --- src/cdp/session.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/cdp/session.ts') diff --git a/src/cdp/session.ts b/src/cdp/session.ts index 2e0e71f..80fec16 100644 --- a/src/cdp/session.ts +++ b/src/cdp/session.ts @@ -43,6 +43,7 @@ export type CdpSession = { resolveRef(ref: string): number | undefined; /** The active tab's prior ref signatures — baseline for the post-mutation diff. */ refSignatures(): ReadonlyMap; + refMappings(): ReadonlyMap; call(method: M, params?: ParamsOf, opts?: { timeoutMs?: number }): Promise, CdpError>>; callOnTarget(method: M, params: ParamsOf, sessionId: string, opts?: { timeoutMs?: number }): Promise, CdpError>>; callBrowser(method: M, params?: ParamsOf, opts?: { timeoutMs?: number }): Promise, CdpError>>; @@ -396,6 +397,10 @@ export const createCdpSession = ( const tab = targetId ? tabs.get(targetId) : undefined; return tab?.refSig ?? new Map(); }, + refMappings() { + const tab = targetId ? tabs.get(targetId) : undefined; + return tab?.refMap ?? new Map(); + }, call(method, params, opts) { return req(method, params, sessionId, opts); }, -- cgit v1.2.3