Skip to content

feat(tools): store selector candidates for browser clicks - #26

Open
Matt-patto wants to merge 1 commit into
understudy-ai:mainfrom
Matt-patto:feat/click-selector-candidates
Open

Matt-patto wants to merge 1 commit into
understudy-ai:mainfrom
Matt-patto:feat/click-selector-candidates

Conversation

@Matt-patto

Copy link
Copy Markdown

Summary

  • Snapshot refs (browser tool, action: "snapshot") now also record an xpath and a testId selector per element, alongside the existing selector CSS path.
  • resolveLocator surfaces the candidate set, and action: "click" returns it in the tool result details (action, targetId, target, selectors) so session traces store every way to re-find the clicked element — CSS path, XPath, and test-id attribute — instead of just the one selector that was used.
  • Applies to clicks through both the managed Playwright browser and the Chrome/Edge extension relay, since both resolve via the same snapshot refs.

Motivation: replay and self-healing previously had a single CSS path per element; when the DOM shifted there was nothing to fall back on.

Test plan

  • pnpm build — all packages compile
  • pnpm typecheck (packages/tools) — clean
  • pnpm lint (changed files) — clean
  • vitest packages/tools/src/__tests__/browser-tool.test.ts — 11/11 pass, incl. new test asserting details.selectors for ref-based and explicit-selector clicks
  • Manual: browser tool snapshot → click on a real page, inspect details.selectors

Generated with Devin

Snapshot refs and click results previously kept a single CSS path per
element, leaving replay nothing to fall back on when the DOM shifts.
Each snapshot ref now also records an xpath and test-id selector, and
the click action returns the resolved candidate set in its details so
downstream traces have alternatives to retry with.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant