-
Notifications
You must be signed in to change notification settings - Fork 815
Description
Description
The find command's first/last keywords are locator types rather than modifiers, which means they cannot be chained after other locators like role. This leads to confusing validation errors when users intuitively try to combine them.
Reproduction
agent-browser find role spinbutton first fill '20'Error:
✗ Validation error: name: Expected string, received null, subaction: Invalid enum value. Expected 'click' | 'fill' | 'check' | 'hover', received 'first'
Expected Behavior
Either:
- Support
first/lastas modifiers after any locator type:find role spinbutton first fill '20' - Provide a clear error message like:
"first" is a locator type, not a modifier. Use: find first "[role=spinbutton]" fill '20'
Current Workaround
Use CSS attribute selectors with first/last as the locator type:
agent-browser find first "[role=spinbutton]" fill "20"Analysis
In cli/src/commands.rs, parse_find() treats position 2 (rest.get(2)) as the subaction unconditionally:
let subaction = rest.get(2).unwrap_or(&"click");When first occupies that position, it gets passed as the subaction to the daemon's Zod schema which expects one of click | fill | check | hover.
Suggestion
The simplest improvement would be better error messaging. A more ambitious change would allow first/last/nth to work as post-locator modifiers by detecting them in the subaction position and restructuring the command accordingly.
Version: 0.8.3