docs: record the UI verification workflow and its limits

- AGENTS §3: UI/GUI verification must be run by the user via
  ui-smoke.cmd; the DSH sandbox blocks named pipes so WebView2 cannot
  start, and Rust->JS calls have no compiler check.
- HANDOFF §4.1: canonical description (why the sandbox fails, the script
  flow, the report/screenshot outputs, when to run it, maintenance notes).
- STATUS §12: current verification matrix; README: command.
This commit is contained in:
2026-11-04 17:33:34 +08:00
parent 1ad4a265c3
commit d78d1aa722
4 changed files with 33 additions and 0 deletions

View File

@@ -53,6 +53,10 @@
- 开发构建:`.\agent\scripts\build.ps1`(cargo test + build --release + 字符串校验;产物留在 `target\release\`)。
- DSH 的 pwsh 执行策略可能阻止未签名脚本;先运行 `Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force`。
- 开发冒烟:`$env:MD_PREVIEW_CONFIG_DIR="$PWD\target\smoke"; .\target\release\md-preview.exe <file>`。
- **UI/GUI 验证只能由用户执行**:DSH 沙箱禁止命名管道,WebView2/Chromium 起不来(窗口白屏、`msedgewebview2.exe` 立即退出;这不是应用 bug)。
- 请用户在自己的桌面 PowerShell 运行 `.\agent\tests\ui-smoke.cmd`(`.ps1` 在 AllSigned 策略下会被拒;`.cmd` 内部用 `-ExecutionPolicy Bypass`),然后读 `target\ui-test\ui-smoke.json` 与 `ui-smoke.png` 判断。
- 发布前必跑;改页面 HTML/CSS/JS 或 Rust→JS 调用后必跑。细节见 `docs/HANDOFF.md` §4.1。
- **Rust → JS 调用没有编译器检查**:改参数列表时同步改页面函数签名,并保留“精确输出 + 页面签名”测试(`set_content_script_matches_the_page_signature`)。
- 不要把 `target\release\md-preview.exe` 复制到任何固定路径,也不要覆盖 Nutstore。
- `git clean -xdf` 会删除被忽略的 `backup/`,禁止使用。

View File

@@ -42,6 +42,9 @@ cargo test
# 冒烟(发布后;含注册表与可选启动)
.\agent\tests\smoke.ps1 -Launch
# 发布前 UI 冒烟(用户桌面;CDP + 截图)
.\agent\tests\ui-smoke.cmd
# 发布(必须由用户在自己的普通 PowerShell 运行)
.\agent\scripts\publish.ps1
~~~

View File

@@ -69,6 +69,25 @@ cd D:\Scripts\md-preview\AgentLowWorking
- 如果发布后仍报 os error 5:`icacls <Nutstore exe> | Select-String 'Mandatory Label'` 应为 Medium;确认不是从 Low 目录直接启动。
- 不要再把仓库改回 Medium,也不要为了改代码申请 danger-full-access。
### 4.1 UI 验证:只能由用户执行(2026-11-04 起)
**DSH 沙箱禁止命名管道**,Chromium/WebView2 的 Mojo IPC 起不来:应用窗口会出现,但 `msedgewebview2.exe` 立即退出、页面白屏;Edge headless 也会报 `FATAL: mojo platform_channel ... 拒绝访问 (0x5)`。这是环境限制,不是应用 bug,也不要用沙箱里的白屏判断页面好坏。
因此 GUI/UI 验证统一走这条链路:
1. 用户在自己桌面 PowerShell 运行 `.\agent\tests\ui-smoke.cmd`(默认跑 `target\release\md-preview.exe`,独立配置目录 `target\ui-test\config`)。
- 机器执行策略是 AllSigned,未签名 `.ps1` 会被拒;`.cmd` 内部用 `-ExecutionPolicy Bypass`,不改系统策略。
- 需要 Node 21+(本机 `C:\Program Files\nodejs` 的 24.x);脚本会自己找,也可 `-Node <path>`。
- 用 `-Exe <path>` 测发布版;`-KeepOpen` 失败时留窗口。
2. 脚本流程:启动应用 → 等 `http://127.0.0.1:9333/json/list` 就绪 → `ui-smoke.mjs` 通过 CDP 断言页面(加载完成、`#preview` 有内容、`window.ipc`、页面 API、标题/折叠按钮/代码高亮/正文长度)→ 截图 → 关闭应用。
3. 产物:`target\ui-test\ui-smoke.json`(checks/snapshot/errors)、`ui-smoke.png`、`app.stdout.log` / `app.stderr.log`。Agent 直接读 JSON 和截图判断。
4. 何时跑:每次发布前;改页面 HTML/CSS/JS 后;改 Rust→JS 调用后。2026-11-04 的“白屏 + 数字 1234”就是发布前没跑它。
维护细节(改脚本前看):
- 就绪判断必须用 `/json/list` 真的返回,不能只看 TCP 端口——WebView2 的端口可能只开一瞬间。
- Node 解析要用 `Get-Command` 结果的 `.Path`(或常见安装目录),不要拿命令对象直接喂 `Test-Path`。
- **Rust → JS 调用没有编译器检查**:改 `__setContent` / `__setPreview` 等参数列表时必须同步页面签名,并用 `set_content_script_matches_the_page_signature` 这类“精确输出 + 页面签名”测试锁住;白屏就是多传了一个 `active.id`,标签 id 被当 HTML 渲染。
## 5. 已删除的联网/更新功能(不要加回来)
- 工具栏 Update 按钮、`#btn-update`、更新相关 CSS/JS

View File

@@ -221,3 +221,10 @@ cargo test
- 下一步(讨论中,未动手):编辑区样式化——加粗、标题加粗加大、行内代码换字体。
- 技术前提:`<textarea>` 不支持字符级样式;改字号会改变软换行与光标位置,透明叠加层只适合“同字号”样式。
- 候选:A 透明 textarea + 样式层(只能同字号);B 自研 contenteditable 行编辑器;C 内嵌 CodeMirror 5(单文件、离线、约 +280 KB)。倾向 C,待用户确认体积与交互取舍。
## 12. 测试与验证(2026-11-04 起)
- 代码级:`cargo test`(当前 60)、`cargo clippy --all-targets`、`cargo fmt -- --check`、`agent\scripts\build.ps1`。
- UI 级:**只能由用户**在桌面 PowerShell 运行 `agent\tests\ui-smoke.cmd`;Agent 读 `target\ui-test\ui-smoke.json` + `ui-smoke.png`。原因与流程见 `HANDOFF.md` §4.1(DSH 沙箱禁止命名管道,WebView2 无法启动)。
- 边界:Rust→JS 调用没有编译器检查;改参数必须同步页面签名,并保留 `set_content_script_matches_the_page_signature` 这类测试。
- 已验证(2026-11-04):ui-smoke 8/8 checks,截图确认页面正常渲染。