mirror of
https://github.com/browser-use/browser-use.git
synced 2026-09-14 19:59:47 +08:00
4573b5222f
Pyright / code-style CI on PR #4681 flagged two issues, both real and from this patch: 1. Page.handleFileChooser isn't exposed by cdp_use's PageClient, so the attribute access fails type checking. It isn't needed either: per CDP spec, Page.setInterceptFileChooserDialog(true) alone causes Chromium to suppress the native dialog ("native file chooser dialog is not shown"). The page simply sees no file selected, which is the desired behavior when no upload is in flight. 2. The Page.fileChooserOpened callback signature is sync (FileChooserOpenedEvent, Optional[str]) -> None, not async. Simplify the patch to the minimum required: just enable interception. The protection is unchanged — Chromium still blocks the modal dialog that would wedge the renderer. Drop the custom handler entirely since the interception flag itself delivers the fix and no downstream logic needs a synthesized cancel.
Codebase Structure
The code structure inspired by https://github.com/Netflix/dispatch.
Very good structure on how to make a scalable codebase is also in this repo.
Just a brief document about how we should structure our backend codebase.
Code Structure
src/
/<service name>/
models.py
services.py
prompts.py
views.py
utils.py
routers.py
/_<subservice name>/
Service.py
Always a single file, except if it becomes too long - more than ~500 lines, split it into _subservices
Views.py
Always split the views into two parts
# All
...
# Requests
...
# Responses
...
If too long → split into multiple files
Prompts.py
Single file; if too long → split into multiple files (one prompt per file or so)
Routers.py
Never split into more than one file