✨ feat: add browser snapshot refs and ref-based element actions#12
✨ feat: add browser snapshot refs and ref-based element actions#12
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
tap | 5db285a | Commit Preview URL Branch Preview URL |
Apr 12 2026, 01:28 PM |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c96227627
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if backendNodeID > 0 { | ||
| if err := ClickTargetByBackendNodeID(ctx, rt.DebugURL, rt.TargetID, backendNodeID); err != nil { | ||
| return fmt.Errorf("fill submit: %w", err) | ||
| } | ||
| submitSelector = "" |
There was a problem hiding this comment.
Defer submit click until after selector-based fills
When submitArg is a snapshot ref, this branch clicks the submit element immediately, but selector-based fields are still only queued and executed later in FillTarget. In mixed inputs (any CSS selector fields plus --submit @eN), the form can be submitted before those selector fields are populated, resulting in partial/incorrect submissions. Trigger the submit click only after all fill operations complete.
Useful? React with 👍 / 👎.
browser/manager.go
Outdated
| s, err := m.loadSnapshot(sessionName, tabName) | ||
| if err != nil { | ||
| return "", 0, fmt.Errorf("resolve %s: snapshot not found, run 'tap browser snapshot' first: %w", arg, err) | ||
| } | ||
| for _, ref := range s.Refs { |
There was a problem hiding this comment.
Reject stale snapshots when resolving @e refs
Ref resolution only checks that a snapshot file exists and then trusts its Refs, with no validation that the current tab document still matches that snapshot. After navigation/reload or reopening a tab with the same name, stale @eN mappings can be reused, leading to invalid-node errors or actions against the wrong element. Validate snapshot freshness (e.g., compare current metadata/document key) before resolving refs.
Useful? React with 👍 / 👎.
Motivation
@e1) instead of brittle CSS selectors so agents can reliably click/type/fill/select.state.jsonwhile enabling later ref resolution.Description
browser/snapshot.goandManager.saveSnapshot/loadSnapshotusing path.../snapshots/{session}/{tab}.json.browser/cdp_snapshot.gousingaccessibility.GetFullAXTree, producingSnapshotResultwithNodesandRefsmapping@eN→backendDomNodeId/AX node info.backendNodeId:ClickTargetByBackendNodeID,FillTargetByBackendNodeID,TypeTargetByBackendNodeID,SelectTargetByBackendNodeID.Snapshot,ClickElement,TypeElement,FillElements,SelectElement, andresolveElementArgto resolve@eNto a backend node or fallback selector.tap browser snapshotcommand with flags (--interactive,--selector,--depth,-f/--format) and makeclick,type,fill, andselectacceptselector|@eNtargets; updatecmd/tap/browser.go,cmd/tap/browser_action.go, README anddocs/browser.mdexamples.Testing
mise run fmt, which completed successfully.mise run lint, which reported no issues.mise run test;browserpackage tests passed but the overall test run failed due to environment constraints (connect: network is unreachableandexec: "google-chrome": executable file not found in $PATH), causingfetchand top-level package tests to fail in this CI-like environment.Codex Task