-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: browser_choose_file #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new synchronous file chooser tool to enable uploading files via the browser, addressing issue #31.
- Implements the browser_choose_file tool in common.ts using a zod schema for validation.
- Updates index.ts to include the new tool in both snapshot and screenshot tool lists.
- Extends the Context class in context.ts to listen for file chooser events and provide a method to submit files, and updates README.md with corresponding documentation.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/tools/common.ts | Added the chooseFile tool using a zod schema for file paths. |
| src/index.ts | Registered the chooseFile tool in both tool lists. |
| src/context.ts | Added event handling for file chooser events and submission. |
| README.md | Updated documentation to include information for browser_choose_file. |
Comments suppressed due to low confidence (1)
src/context.ts:81
- [nitpick] Consider providing a more descriptive error message in submitFileChooser to help with debugging when no file chooser is detected.
if (!this._fileChooser)
src/tools/utils.ts
Outdated
| const page = context.existingPage(); | ||
| await waitForCompletion(page, () => callback(page)); | ||
| return snapshot ? captureAriaSnapshot(page, status) : { | ||
| return snapshot ? captureAriaSnapshot(context, page, status) : { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd clear the file chooser after the action.
Resolves #31.
Prompt used for testing:
This won't work for asynchronously opened filechoosers, but let's start with the synchronous variant. I also tested with including the file chooser open state in the snapshot, but that didn't give better results.
I also tested with OneDrive and WeTransfer, but somehow our ARIA snapshots for those pages are missing some elements that are crucial to locate the upload buttons.