feat: add cursor-interactive element detection in snapshots (#374)

* fix: only warn about ignored flags when explicitly passed via CLI

The warning about launch-time options being ignored (when daemon is
already running) was incorrectly shown when options were set via
environment variables like AGENT_BROWSER_EXECUTABLE_PATH, even when
no CLI flag was passed.

Now the warning only appears when flags are explicitly passed on the
command line, not when values come solely from environment variables.

Fixes #372

* feat: add cursor-interactive element detection in snapshots

Add -C/--cursor flag to snapshot command that detects clickable elements
that don't have proper ARIA roles but are interactive based on:
- cursor: pointer CSS style
- onclick attribute/handler
- tabindex attribute

This helps with modern web apps that use custom divs/spans as buttons.

Fixes #366

* fix: add cursor option to getSnapshot type signature
This commit is contained in:
Chris Tate
2026-02-04 23:44:58 -06:00
committed by GitHub
parent d34ce8c2d0
commit 74be667c80
9 changed files with 291 additions and 0 deletions
+18
View File
@@ -403,6 +403,9 @@ pub fn parse_command(args: &[String], flags: &Flags) -> Result<Value, ParseError
"-c" | "--compact" => {
obj.insert("compact".to_string(), json!(true));
}
"-C" | "--cursor" => {
obj.insert("cursor".to_string(), json!(true));
}
"-d" | "--depth" => {
if let Some(d) = rest.get(i + 1) {
if let Ok(n) = d.parse::<i32>() {
@@ -1948,6 +1951,21 @@ mod tests {
assert_eq!(cmd["interactive"], true);
}
#[test]
fn test_snapshot_cursor() {
let cmd = parse_command(&args("snapshot -C"), &default_flags()).unwrap();
assert_eq!(cmd["action"], "snapshot");
assert_eq!(cmd["cursor"], true);
}
#[test]
fn test_snapshot_interactive_cursor() {
let cmd = parse_command(&args("snapshot -i -C"), &default_flags()).unwrap();
assert_eq!(cmd["action"], "snapshot");
assert_eq!(cmd["interactive"], true);
assert_eq!(cmd["cursor"], true);
}
#[test]
fn test_snapshot_compact() {
let cmd = parse_command(&args("snapshot --compact"), &default_flags()).unwrap();
+2
View File
@@ -905,6 +905,7 @@ Designed for AI agents to understand page structure.
Options:
-i, --interactive Only include interactive elements
-C, --cursor Include cursor-interactive elements (cursor:pointer, onclick, tabindex)
-c, --compact Remove empty structural elements
-d, --depth <n> Limit tree depth
-s, --selector <sel> Scope snapshot to CSS selector
@@ -916,6 +917,7 @@ Global Options:
Examples:
agent-browser snapshot
agent-browser snapshot -i
agent-browser snapshot -i -C # Interactive + cursor-interactive elements
agent-browser snapshot --compact --depth 5
agent-browser snapshot -s "#main-content"
"##