[fix]: make file upload elements more explicit in page snapshot#1975
Open
seanmcguire12 wants to merge 4 commits intomainfrom
Open
[fix]: make file upload elements more explicit in page snapshot#1975seanmcguire12 wants to merge 4 commits intomainfrom
seanmcguire12 wants to merge 4 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 2fad86f The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
No issues found across 6 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Client as Eval / User Script
participant Core as Stagehand Core
participant CDP as Browser (CDP)
participant DOM as domTree.ts
participant A11y as a11yTree.ts
participant LLM as AI Model
Note over Client, LLM: Request Flow for .observe()
Client->>Core: observe("find file upload")
Core->>CDP: DOM.getFlattenedDocument
CDP-->>Core: Raw DOM Nodes (attributes array)
Core->>CDP: Accessibility.getFullAXTree
CDP-->>Core: Raw AX Nodes (roles, names)
rect rgb(240, 240, 240)
Note over Core, DOM: DOM Processing
Core->>DOM: domMapsForSession(nodes)
loop For each Node
DOM->>DOM: NEW: enrichedTagName(node)
opt tag is "input"
DOM->>DOM: NEW: Extract "type" from attributes array
Note right of DOM: e.g., result is "input, file"
end
DOM->>DOM: Map backendNodeId to enriched tag
end
DOM-->>Core: tagNameMap
end
rect rgb(240, 240, 240)
Note over Core, A11y: Accessibility Tree Decoration
Core->>A11y: decorateRoles(axNodes, tagNameMap)
loop For each AX Node
A11y->>A11y: Look up tag in tagNameMap
alt CHANGED: Tag is "input, file"
A11y->>A11y: CHANGED: Override AX role to "input, file"
Note right of A11y: Prevents Chrome's default "button" role
else Standard behavior
A11y->>A11y: Use standard AX role
end
end
A11y-->>Core: Enriched A11y Snapshot
end
Core->>LLM: Send Snapshot (includes "input, file")
Note over LLM: Model identifies element correctly<br/>instead of seeing a generic button
LLM-->>Core: Observations (selector for file input)
Core-->>Client: Return observations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
why
.observe()to find "file upload elements", since the model sees them as a 'button'what changed
[0-12] button: Choose File, we now use[0-12] input, file: Choose Filetest plan
observe()eval which checks that hidden file upload elements are correctly found by the LLMSummary by cubic
Make file upload inputs explicit in the page snapshot so
.observe()can reliably find them. Addresses Linear STG-934 by preventing file inputs from being misclassified as buttons.input, file) and use them in DOM maps.input, filein the a11y outline instead of AXbutton.observe_file_uploadseval inevals.config.json.@browserbasehq/stagehand.Written for commit 2fad86f. Summary will update on new commits. Review in cubic