aboutsummaryrefslogtreecommitdiff
path: root/src/cdp
diff options
context:
space:
mode:
authoramankumarsingh77 <amankumarsingh7702@gmail.com>2026-07-28 19:50:02 +0530
committerAman Kumar <145339995+amankumarsingh77@users.noreply.github.com>2026-08-02 19:12:46 +0530
commit254de089ee468795bac175d99e09ddaec4ac1469 (patch)
tree10ef23546ec6c5b20f6339b6d1b88769f323447e /src/cdp
parentce1240fa9b3b74983cc22171469c24d0708b10ea (diff)
fix(domains): keep element refs stable across a mutation
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) <noreply@anthropic.com>
Diffstat (limited to 'src/cdp')
-rw-r--r--src/cdp/session.ts5
1 files changed, 5 insertions, 0 deletions
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<string, string>;
+ refMappings(): ReadonlyMap<string, number>;
call<M extends CdpMethod>(method: M, params?: ParamsOf<M>, opts?: { timeoutMs?: number }): Promise<Result<ResultOf<M>, CdpError>>;
callOnTarget<M extends CdpMethod>(method: M, params: ParamsOf<M>, sessionId: string, opts?: { timeoutMs?: number }): Promise<Result<ResultOf<M>, CdpError>>;
callBrowser<M extends CdpMethod>(method: M, params?: ParamsOf<M>, opts?: { timeoutMs?: number }): Promise<Result<ResultOf<M>, 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);
},