fix: keep interactive nodes in snapshot -c; better stale-ref guidance (issue #2/#3)
- snapshot -c (compact) now always keeps lines with an interactive ARIA role (button/link/textbox/combobox/option/…), not only `ref=`/`": "` lines — so a clickable control can't vanish from compact output and leave the agent clicking an empty ref (issue #2 P1). Additive: only ever keeps more. compact tests green. - stale-ref error now leads with "take a fresh snapshot" and points to the `eval` fallback for ref-churning SPAs, and demotes AGENT_BROWSER_VERIFY_REF=0 to a flagged last resort instead of presenting it as the fix (issue #3 P1).
This commit is contained in:
@@ -556,8 +556,12 @@ async fn verify_ref_identity(
|
||||
Err(format!(
|
||||
"Ref {} no longer matches its snapshot. Was [{} \"{}\"], now [{} \"{}\"].\n\
|
||||
The DOM mutated between snapshot and interaction (typical with React/Vue \
|
||||
reusing nodes during re-render). Take a fresh snapshot, then re-target.\n\
|
||||
To bypass this guard set AGENT_BROWSER_VERIFY_REF=0.",
|
||||
reusing nodes during re-render). Fix: take a fresh `snapshot` and re-target \
|
||||
with the new ref. For SPAs where refs churn every interaction, drive the \
|
||||
element directly with `eval` (e.g. `eval \"document.querySelector(...).click()\"`), \
|
||||
which doesn't depend on refs.\n\
|
||||
(Last resort: AGENT_BROWSER_VERIFY_REF=0 disables this safety check — only \
|
||||
if you accept clicks may land on a re-rendered/wrong node.)",
|
||||
ref_id, expected_role, expected_name, actual_role, actual_name,
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user