Skip to content

test(web): fix flaky ProjectFaviconPickerDialog preview test races - #29

Merged
Hylouis233 merged 1 commit into
mainfrom
fix/favicon-picker-flaky
Oct 20, 2026
Merged

Hylouis233 merged 1 commit into
mainfrom
fix/favicon-picker-flaky

Conversation

@Hylouis233

Copy link
Copy Markdown
Owner

关联 #28 #27

问题

apps/web/src/components/settings/ProjectFaviconPickerDialog.browser.test.tsx 的 loads previews asynchronously and only acquires offscreen images after scrolling 在 CI Test Web 中偶发失败,两次的报错不同:

两次都只有这一个用例失败(Tests 1 failed | 8473 passed)。

根因

  1. 发布的 URL 被丢弃(test: guard fork-only orchestrationProtocolVersion tags in bundled model manifest #28):缩略图(ProjectFaviconThumbnail.tsx:13-31)在 IntersectionObserver 回调里 setInView(true),重新渲染时调用 createUrl;但 useAtomValue(底层是 useSyncExternalStore)要到之后的 passive effect 才订阅 atom。测试(:195-202)一看到 createUrl 被调用就 publishUrl。effect 的 AtomRegistry 会在调度任务里移除没有订阅者的非 keepAlive 节点(AtomRegistry.js createNode / scheduleAtomRemoval),在这个窗口内写入的成功值会随节点一起丢掉,行订阅后读到的是初始值,永远不会出现 <img>。CI 负载高时 passive effect 延后,这个窗口就更容易被命中。
  2. 断言竞态(chore: sync upstream pingdotgg/t3code main (8866e8f) — 取代 #26 #27):expectPreview(:169-172)先轮询 naturalWidth === 8,然后同步断言回退 svg 已移除。但图片解码(naturalWidth 可用)早于 load 事件派发;组件在 onLoad 里 setLoadedUrl 并重新渲染后才移除回退图标(ProjectFaviconThumbnail.tsx:34-48)。同文件的 keeps the file icon until the image load is acknowledged 用例本身就说明,"naturalWidth 为 8 而 svg 仍在"是合法的中间状态。

组件行为是正确的,问题都在测试本身。

改动(仅测试,1 个文件)

  • addFiles 中的 mock asset atom 改为 Atom.make(...).pipe(Atom.keepAlive)(与 ProjectSettingsPanel.browser.test.tsx 等现有测试的写法一致),这样无论订阅何时完成,发布的 URL 都不会丢。
  • expectPreview 改为轮询完整的最终状态 { width: 8, fallback: false },不再"轮询前置条件 + 同步断言"。
  • 没有调大任何超时,没有跳过测试,断言的含义也没有放宽(仍然要求图片加载完成且回退图标消失)。

验证(本地,Node 24 + 仓库内 vp,单文件运行)

  • 复现(临时测试文件,未提交):在原版 helper 上加两个注入用例:(a) 在行订阅前发布 URL;(b) 将 load 事件延迟 200ms 再派发。两个都失败,报错与 CI 一致:expected undefined to be 8 和 expected SVGSVGElement{ …(2) } to be null。换成修复后的 helper,同样两个用例都通过(9/9)。
  • 修复后整个测试文件连续运行 10 次:10/10 通过(每次 7/7)。
  • 8 个满载 CPU 进程压测下再运行 5 次:5/5 通过。
  • 修复前,同样压测下原版运行 6 次也全部通过,说明本地单靠 CPU 压力很难复现,所以用了上面的确定性注入。
  • vp fmt --check 和 vp lint 通过。

未验证

  • 未跑 apps/web 全量测试,只跑了改动的这一个测试文件。
  • CI 上的稳定性要看后续多次运行。

…rojectFaviconPickerDialog preview test

The preview test failed intermittently in CI in two ways.

A row only subscribes to its asset atom in a passive effect after the
IntersectionObserver render that calls createUrl. The test publishes the URL as
soon as createUrl is called, and the registry discards a value set on an atom
with no subscriber, so the row could stay on its fallback forever. Keep the
mocked asset atoms alive like other browser tests do.

expectPreview also polled naturalWidth and then asserted the fallback was gone
synchronously, but the image decodes before its load event commits. Poll the
complete loaded state instead.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 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-10-20T11:52:36.598492Z 089f3ad 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.

@github-actions github-actions Bot added size:S 10-29 effective changed lines. vouch:trusted Author has write access or is explicitly trusted by OpenT3Code. labels Oct 20, 2026
Copilot AI balanced review requested due to automatic review settings October 20, 2026 11:51

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB +7 B (+0.1%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB +7 B (+0.6%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅
Codex Live turn messages 2 2 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB −24 B (−0.5%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB −24 B (−2.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB −41 B (−0.2%) 29.3 KiB ✅
Claude Live turn messages 2 1 −1 (−50.0%) 8 ✅

Baseline: ca256ef · PR result: 089f3ad · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@Hylouis233
Hylouis233 merged commit a4de20b into main Oct 20, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 effective changed lines. vouch:trusted Author has write access or is explicitly trusted by OpenT3Code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants