aboutsummaryrefslogtreecommitdiff
path: root/src/domains/ref-resolve.ts
diff options
context:
space:
mode:
authoramankumarsingh77 <amankumarsingh7702@gmail.com>2026-07-28 20:30:49 +0530
committerAman Kumar <145339995+amankumarsingh77@users.noreply.github.com>2026-08-02 19:12:46 +0530
commitb67faca60b21b0cf74d5c967f0f8d215ad601e93 (patch)
tree12e8580e1b88c3ce6a2d9157cfa678cb7a55a73c /src/domains/ref-resolve.ts
parenta6ec1d0915106b127affbd6b5fcc9efec48ef712 (diff)
refactor(domains): strip comment noise
Removes module banners, step markers, and comments restating the code. Keeps one-line notes for safeJs's trust boundary, the select-match null sentinels, the TUI width clamp, the single-window tab rule, the input synthesis quirks (char events, keyCode, mousemove, focus, compositor), the stale AX value, ignored-wrapper recursion, and isolated-tab routing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'src/domains/ref-resolve.ts')
-rw-r--r--src/domains/ref-resolve.ts30
1 files changed, 0 insertions, 30 deletions
diff --git a/src/domains/ref-resolve.ts b/src/domains/ref-resolve.ts
index 822f8e8..ece308e 100644
--- a/src/domains/ref-resolve.ts
+++ b/src/domains/ref-resolve.ts
@@ -10,12 +10,6 @@ const staleErr = (ref: string): ToolErr => ({
details: { ref },
});
-/**
- * Resolve a ref to its CDP objectId (a handle to the live JS node). Use when a
- * tool needs to run JS against the element (fill, focus, select, dispatch_key).
- * Re-resolves through the backendNodeId at call time, so it reflects the current
- * DOM even after re-renders — and fails loudly if the node was detached.
- */
export const resolveRefToObjectId = async (
client: BrowserClient,
ref: string,
@@ -24,8 +18,6 @@ export const resolveRefToObjectId = async (
if (backendId === undefined) return err(staleErr(ref));
const resolved = await client.session().call("DOM.resolveNode", { backendNodeId: backendId });
if (!resolved.success) {
- // A detached node (removed by a re-render) fails to resolve — surface it as
- // a stale ref rather than a raw CDP error so the agent knows to re-snapshot.
return err(staleErr(ref));
}
const objectId = resolved.data.object.objectId;
@@ -33,18 +25,12 @@ export const resolveRefToObjectId = async (
return ok(objectId);
};
-/** Resolve a ref to its current backendNodeId (for CDP calls that take one, e.g. DOM.setFileInputFiles). */
export const resolveRefToBackendId = (client: BrowserClient, ref: string): Result<number, ToolErr> => {
const backendId = client.session().resolveRef(ref);
if (backendId === undefined) return err(staleErr(ref));
return ok(backendId);
};
-/**
- * Resolve a ref to the current center of its bounding box, in viewport CSS
- * pixels. Use for browser_click. Fetched fresh via DOM.getBoxModel, so a
- * re-rendered/moved element is clicked at its new position.
- */
export const resolveRefToBox = async (
client: BrowserClient,
ref: string,
@@ -59,19 +45,6 @@ export const resolveRefToBox = async (
const sigOf = (n: SlimNode): string => `${n.role}|${n.name ?? ""}|${n.value ?? ""}|${n.state ?? ""}`;
const keyOf = (n: SlimNode): string => `${n.role}|${n.name ?? ""}`;
-/**
- * Recompute the interactive elements after a mutation and return a compact,
- * human/LLM-readable diff vs. the prior snapshot's baseline — changed values,
- * newly-appeared elements (marked `*`), and removed ones. Re-publishes the fresh
- * ref map so subsequent ref-based calls target the post-mutation DOM.
- *
- * Deliberately cheap: it re-reads the AX tree (no per-node box fetch — the
- * expensive part of a full snapshot) and emits a few lines, not a full tree, so
- * a long action sequence doesn't blow up the context.
- *
- * Returns "" on any failure or when nothing changed — callers append it only if
- * non-empty, so a diff is best-effort and never blocks the primary action.
- */
export const interactiveDiff = async (client: BrowserClient): Promise<string> => {
const session = client.session();
const prev = session.refSignatures();
@@ -82,7 +55,6 @@ export const interactiveDiff = async (client: BrowserClient): Promise<string> =>
const slim = buildTree(rawNodes, { interestingOnly: true, maxNodes: 1000 });
const targets = collectInteractiveTargets(slim);
- // Re-publish fresh refs so later ref calls resolve against the new DOM.
const priorRefs = session.refMappings();
const refByBackendId = new Map<number, string>();
for (const [ref, backendId] of priorRefs) refByBackendId.set(backendId, ref);
@@ -104,8 +76,6 @@ export const interactiveDiff = async (client: BrowserClient): Promise<string> =>
}
session.setRefMap(refMap, refSig);
- // Compare by stable identity (role|name) rather than ref position, since refs
- // renumber when the element set changes. Build prev/current identity → value.
const prevByKey = new Map<string, string>();
for (const sig of prev.values()) {
const parts = sig.split("|");