Frontend drops 15 files no page reaches (issue #139, BUG-1480)

Unreachable from every app entry and frontend/scripts (dynamic imports
counted): chart-basics-tab, error-toast, seven unused shadcn ui files
(skeleton among them), three birth-time helpers only tests used, the motion
provider shell (it imported motion/react statically), and the two empty
people/account stores. Tests that only exercised them are removed or trimmed,
each with old/new/reason notes. Unreachable files 18 -> 3 (all kept on
purpose); npm test names drop exactly the 4 removed and 1 renamed test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jesse_Chen
2026-10-28 12:43:07 +08:00
co-authored by Claude Opus 5.5
parent b9a5415e71
commit 2fbce95536
23 changed files with 31 additions and 780 deletions
+15
View File
@@ -20203,3 +20203,18 @@
- 关联:BUG-734(健康探测走缓存)、BUG-727 / BUG-301(前台快照)。
- 复发自:无
- 修复版本:分支 `codex/vedastro-negative-day-20261028`。
## BUG-1480 | 前端留着 15 个没有任何页面用到的文件
- 状态:resolved(代码 + 回归测试;待部署)
- 首次发现 / 最近更新:2026-10-28 / 2026-10-28(issue #118 代码体检第 24 条 → #139)
- 影响面:`frontend/src/`;不影响任何页面(这些文件从任何入口都不可达)。
- 现象:从所有页面、布局、接口、错误页入口和 `frontend/scripts/` 出发(计入动态 import),有 18 个文件不可达。其中 `lib/motion/provider.tsx` 静态引用 `motion/react`,将来谁一引用 Motion 就回到首屏;`ui/skeleton` 与 DESIGN「揭幕后不得出现骨架」冲突,留着容易被误用。
- 根因:改版和组件库生成后留下的残余,只被测试引用或没人引用。
- 修复:删除 15 个:`components/chart-page/chart-basics-tab.tsx`、`components/error-toast.tsx`、`components/ui/{avatar,empty,field,kbd,separator,skeleton,switch}.tsx`、`lib/birth-time-choice-question-model.ts`、`lib/birth-time-guided-terminal.ts`、`lib/birth-time-guided-turn-identity.ts`、`lib/motion/provider.tsx`、`stores/account-store.ts`、`stores/people-store.ts`。保留 `app/forbidden.tsx`(Next 的特殊入口文件)以及进度记录里写过理由的 `reader-appendix-language.ts`、`personal-report-longform-download.ts`。删前对每个文件用 `git grep -- tests/ frontend/` 核对,Python 源码契约测试里没有引用。
- 测试变化(只少被删模块的用例):删除 `birth-time-guide-flow.test.ts`(1 条,只测 `guidedTurnIdentity`);`birth-time-choice-question.test.ts` 删 2 条(click intent submits primary and unknown options immediately、unmatched requests clarification without creating scoring evidence);`birth-time-guided-review-fixes.test.ts` 删 1 条(dynamic medium terminal preserves its candidate range without direct adoption),另 1 条去掉 `guidedTerminalPath` 断言;`birth-time-rectification-contract.test.ts` 1 条去掉 `guidedTerminalPath` 断言;`ui-kit-stores.test.ts` 去掉两个空骨架 store 的断言(Home 不引用它们的断言保留);`motion-presets.test.ts`「LazyMotion loads domAnimation asynchronously and honors reduced motion」改名为「the home and the layout never import motion or a motion shell statically」,只留首页与 layout 的静态引用约束。改动处都写了原值 / 新值 / 原因。
- 验证:不可达文件 18 → 3(上面保留的 3 个)。全量前端测试与 staging 逐条比对:少的名字正好是上面 4 条删除和 1 条改名,没有新增失败。tsc 0、lint 0 error。删的都是不可达文件,打包内容不变。
- 防复发:删除前跑可达性检查并 `git grep -- tests/ frontend/`;只被测试引用的模块连同测试一起删。
- 关联:前端死代码清理(frontend-dead-code 进度记录)。
- 复发自:无
- 修复版本:分支 `codex/frontend-dead-files-20261028`。