fix(chat): make Home pass react-hooks lint after the split
eslint-plugin-react-hooks now analyzes the smaller Home, so render-time ref writes and sync effect setState were failing the staging gate. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7215,3 +7215,19 @@
|
||||
- 相关记录:BUG-456、BUG-460、BUG-461
|
||||
- 复发自:BUG-460
|
||||
- 修复版本:待发布
|
||||
|
||||
## BUG-470 | Home 拆分后 eslint 开始分析 page.tsx,staging quality gate 因 16 条 react-hooks 失败
|
||||
|
||||
- 状态:resolved
|
||||
- 首次发现:2026-09-02
|
||||
- 最近更新:2026-09-02
|
||||
- 影响面:Gitea `backend-quality-gate` `validate`、`frontend/src/app/page.tsx`、账户 overlay、首页 lint
|
||||
- 用户现象:向 `staging` 推送 `124d3990` 后 quality gate run `2280` 失败。`validate` job `5496` 前端测试 2460/2460 通过,随后 `npm run lint --prefix frontend` 报 `✖ 86 problems (16 errors, 70 warnings)`。`publish` 因 `needs: validate` 跳过。
|
||||
- 触发条件:含第三批 Home 拆分的提交进入完整 runner 的 frontend lint。`eslint-plugin-react-hooks` v7 的 compiler 规则开始分析已缩到约 2000 行的 `Home`。
|
||||
- 根因:拆分前 `Home` 过大,同一套规则不分析该组件,render 里写 ref、effect 同步 setState、模块级 `{ current }` 赋值和 `Date.now()` 都不会报错。拆分后这些写法变成 16 个 error:`react-hooks/refs`、`react-hooks/immutability`、`react-hooks/set-state-in-effect`、`react-hooks/purity`。模块级 holder 是第三批为打通 hook 循环新加的;其余模式在拆分前已存在,只是当时扫不到。
|
||||
- 修复:循环回调改为 `useRef`,在产出它们的自定义 hook 体里写入(与已有 `resumeRectificationSession.current` 相同)。`sessionsRef` 改在 session hook 内同步。`preview` 改为 state,不再在 render 读 `uiPreview.current`。账户 overlay 改为传入 `model` 对象,去掉 render 里累加 epoch / 写 `modelRef`。聊天 actions 改到 `copyAssistantMessage` 之后的 effect。effect 里同步 setState 改 `queueMicrotask`。合盘卡片时间改走 `timestamp()`。
|
||||
- 验证:`npm run lint --prefix frontend` 0 error;`./node_modules/.bin/tsc --noEmit`;`frontend/tests/account-dialog-overlay.test.ts`;相关首页/账户合同测试。
|
||||
- 防复发:`Home` 不得在 render 里写 `ref.current` 或改模块级 `{ current }`;账户 overlay 不得再靠 `openEpoch` + `modelRef` 在 render 里刷 memo;源码合同锁定 overlay 走 `model` prop、chat actions 只在 effect 里写入。
|
||||
- 相关记录:BUG-326、BUG-339、BUG-343、BUG-383
|
||||
- 复发自:BUG-326(render 里写 ref);BUG-339(effect 同步 setState)
|
||||
- 修复版本:待发布
|
||||
|
||||
Reference in New Issue
Block a user