Skip to content

feat(devtools): 机型选择支持全部 171 台设备并改为可搜索对话框 - #200

Merged
lbb00 merged 2 commits into
mainfrom
feat/device-picker-search
Sep 7, 2026
Merged

feat(devtools): 机型选择支持全部 171 台设备并改为可搜索对话框#200
lbb00 merged 2 commits into
mainfrom
feat/device-picker-search

Conversation

@lbb00

@lbb00 lbb00 commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

改了什么

模拟器面板原来只列 @devicekit/devices 里的少数经典机型,一个下拉列表放不下 171 台。现在:

  • 机型列表改为全部 DEVICES(171 台,含 19 台平板)。
  • 下拉换成可搜索面板:按名称 / 系统 / 尺寸搜索,尺寸同时索引 393x852 和界面显示的 393×852;按 iOS / Android / HarmonyOS 与手机 / 平板两组 chip 筛选;分组展示,当前机型有勾选标记,平板带标签。
  • 打开时预高亮当前机型,直接回车保持原机型,不会跳到列表第一行。
  • 面板改为独立的 overlay WebContentsView。原来它由主窗口渲染进程画,而模拟器是挂在主窗口之上的 WebContentsView,居中的对话框左侧会被切掉一块,CSS z-index 跨不过这层边界。现在照 projectCreateDialog 的模板接成 VIEW_ID.devicePicker 覆盖视图,层级 dialog(40)、整窗覆盖。DevicePicker 本身变成常开的纯组件(device / devices / onSelect / onClose),开关由主进程挂载或撤下视图决定,选择结果经 IPC 回给 use-device——设备状态本来就归它,弹层归属跟着状态 owner 走。
  • simulator-panel 回到纯展示:只通过 onOpenDevicePicker 上报点击,自身不再渲染任何机型列表。

已知限制

关闭面板后焦点不会回到工具栏的机型按钮。触发按钮和面板现在分属两个 WebContents,组件还不回去。仓库里其它 overlay(popover、compile-mode、project-create dialog)关闭路径同样没有焦点归还,这是它们共同的既有行为,本 PR 没有单独为机型选择开特例。

验证

  • 单测:device-picker.test.tsx 保留全部 171 台渲染、搜索(含 ×)、chip 筛选、当前机型标记与预高亮、回车保持当前机型、对话框无障碍名称;原先断言"对话框自己消失"的几条改为断言上报 onSelect / onClose,因为关闭已由主进程撤视图完成。新增 device-picker-panel.test.tsxuse-device 的三条弹层用例、view-manager-dialog-zorder 的 picker-above-simulator 用例。
  • ./scripts/gate.sh:lint / typecheck / test / pawl 四项全过(GATE_EXIT=0)。
  • e2e:新增 device-picker-overlay.spec.ts(真实 z-order 与 bounds、搜索选型、复用后状态复位);device-frame-integrationwindow-info-follows-devicenative-host-white-screen-reconciledevtools-panel 四个 spec 由驱动原生 <select> 迁到驱动覆盖视图自己的 WebContents,共 22 条通过。
  • 真启 Electron 实测(主进程读 contentView.children,数组顺序即绘制顺序):面板打开时 device-picker/index.html 排在 simulator 之后、整窗 1280×948 覆盖;对话框自身 x 384–896 / y 280–668,与 simulator 的 x 0–437 真实重叠——正是原缺陷被切掉的那块。用户路径三段有断言:搜索机型名 → 点中行 → 工具栏按钮标签与 simulator 的 device 属性都变为 Pixel 8;再开一次搜索框为空、data-current 落在 Pixel 8 上。
  • 未做:截图/像素比对(证据取自主进程 API 与页面内 DOM 读数);devtools 全量 e2e;多项目窗口同时打开时的 picker 归属。
  • Codex 两轮评审:第一轮 4 条(搜索 × 不匹配、关闭后焦点丢失、缺 DialogTitle、键盘路径没测试)已修;第二轮 4 条——面板被模拟器遮挡、e2e 仍驱动已删除的原生 <select>、注释引用不存在的 DESIGN.md、文档机型表过期——均已修,遮挡一条的修法即上面的 overlay 迁移。

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T13:58:30.575744Z 1761aab PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1761aabd47

ℹ️ 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".

模拟器面板原来只列 @devicekit/devices 的少数经典机型,下拉列表也放不下更多。现在改为全部 DEVICES,并把下拉换成 cmdk 搜索对话框:按名称、系统、尺寸搜索(尺寸同时索引 393x852 和界面显示的 393×852),按 iOS / Android / HarmonyOS 与手机 / 平板筛选,打开时预高亮当前机型,直接回车不会跳到列表第一行。

CommandDialog 新增 title、trigger、commandProps:标题以视觉隐藏的 DialogTitle 提供无障碍名称;触发按钮放进同一个 Dialog root,关闭后焦点回到按钮而不是丢到 body。

simulator-panel 的 onDeviceChange 改为传机型名字符串,use-device 用 findDevice 解析,找不到时回退到 DEFAULT_DEVICE。

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@lbb00
lbb00 changed the base branch from worktree-device-frame-package to main September 7, 2026 04:20
对话框原来由主窗口渲染进程画,而模拟器是挂在它之上的 WebContentsView,居中的面板左侧被切掉一块(实测对话框 x 384-896 与模拟器 x 0-437 重叠),CSS z-index 跨不过这层边界。现在照 projectCreateDialog 的模板做成 device-picker 覆盖视图,层级 dialog(40),整窗覆盖;DevicePicker 本身改成常开的纯组件,开关由主进程挂载/撤下视图决定,选择结果经 IPC 回给 use-device。e2e 里对原生 select 的驱动一并迁到覆盖视图自己的 WebContents。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@lbb00
lbb00 force-pushed the feat/device-picker-search branch from 1761aab to 4d9d240 Compare September 7, 2026 05:00
@lbb00
lbb00 merged commit d623af6 into main Sep 7, 2026
2 checks passed
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