Skip to content

fix(bridge): support fileChooserAccept in Bridge mode and WSL environments#2693

Open
FE-runner wants to merge 1 commit into
web-infra-dev:mainfrom
FE-runner:fix/bridge-file-chooser-wsl
Open

fix(bridge): support fileChooserAccept in Bridge mode and WSL environments#2693
FE-runner wants to merge 1 commit into
web-infra-dev:mainfrom
FE-runner:fix/bridge-file-chooser-wsl

Conversation

@FE-runner

Copy link
Copy Markdown

问题

关联 issue:#2691

Bridge 模式下使用 fileChooserAccept 报错 -32000 Not allowed;WSL 环境下路径无法被 Windows Chrome 读取。

根本原因

问题一registerFileChooserListener 在调用 Page.setInterceptFileChooserDialog 前没有执行 ensureDebuggerAttached(),导致 debugger 未 attach 时命令被拒绝。

问题二:WSL 环境中,Midscene CLI 使用 Linux 路径(如 /home/user/file.zip),通过 DOM.setFileInputFiles 传给 Windows Chrome 后,Chrome 无法识别该路径格式,导致文件上传失败。

修复内容

packages/web-integration/src/chrome-extension/page.ts

registerFileChooserListener 中,发送 CDP 命令前先调用 ensureDebuggerAttached()

await this.ensureDebuggerAttached();
await this.sendCommandToDebugger('Page.enable', {});

packages/core/src/agent/agent.ts

normalizeFilePaths 中,检测 WSL 环境(WSL_DISTRO_NAME)并自动转换路径:

  • /mnt/c/pathC:\path(WSL 挂载的 Windows 盘符)
  • /home/user/path\\wsl$\Ubuntu\home\user\path(WSL 本地路径)

测试

在 WSL2 + Windows Chrome Bridge 模式下,使用 fileChooserAccept 上传文件测试通过。

…ments

- chrome-extension/page.ts: call ensureDebuggerAttached() before
  Page.setInterceptFileChooserDialog in registerFileChooserListener,
  fixing -32000 Not allowed error in Bridge mode

- agent.ts: convert WSL paths in normalizeFilePaths so Windows Chrome
  can read files via DOM.setFileInputFiles:
  /mnt/c/... → C:\...
  /home/... → \\wsl$\<distro>\...
@FE-runner FE-runner marked this pull request as draft June 18, 2026 07:32
@FE-runner FE-runner marked this pull request as ready for review June 18, 2026 07:32
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