# 18-streaming-ui / app 流式 UI 工作台:每块 setState 与缓冲 + RAF 合并且提交数对比;乱序 seq 的缓冲与重连; 长列表滚动锚定(用户上滑暂停、回底恢复)。流从主进程经 MessagePort 推送。 ## 运行 ```bash pnpm --filter @tutorial/18-streaming-ui-app start pnpm --filter @tutorial/18-streaming-ui-app smoke pnpm --filter @tutorial/18-streaming-ui-app shots ``` ## smoke 输出 ```json {"evt":"smoke","ok":true,"naiveCommits":60,"batchedCommits":23,"sameText":true, "reorderApplied":20,"reorderBuffered":0,"cancelled":true, "scrollPaused":true,"scrollResumed":true} ``` ## 结构 - `main/`:MessageChannelMain 流、乱序发送、取消、smoke/shots - `preload/`:转发端口消息,暴露 start/cancel/onStream - `src/App.tsx`:对比 / 乱序 / 滚动三个页签与 smoke 驱动 ## testid | testid | 用途 | | --- | --- | | `app-title` / `status` | 标题与状态 | | `tab-compare` / `tab-reorder` / `tab-scroll` | 三个页签 | | `start-compare` / `naive-commits` / `batched-commits` / `frames` | 渲染对比 | | `start-reorder` / `reconnect` / `applied` / `buffered` | 乱序 | | `scroll-box` / `scroll-state` / `resume-scroll` | 滚动锚定 | ## 已知限制 - 块间隔与 RAF 计数受机器负载影响;只看相对关系。 - 只在 macOS arm64 与 Chromium 156 实测。