docs(tasks): home crash for accounts with saved people brief (agent loop, issue #115)
Co-Authored-By: Claude (agent loop) <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LutgzyJqNhPpZy1nFsJtN3
This commit is contained in:
@@ -541,3 +541,4 @@
|
||||
| `TASK-lagna-precheck-fix-20261027.md` | — | **#112 第 1 次打回**:已有进行中的校正时点链接报冲突(应走首页续上);别人的星盘页不该给校正链接 | 待执行 | `codex/lagna-precheck-20261027` |
|
||||
| `TASK-voice-reading-20261027.md` | `PROGRESS-voice-reading-20261027.md` | **#113 选 R1 C1**:报告前面加一段模型写的「解读」(八节,素材只用引擎事实,失败不影响报告);对话依据写进正文、宫位带生活领域、时间最多三件(BUG-1460、BUG-1461) | Claude 直接执行,待验收 | `codex/voice-reading-20261027` |
|
||||
| — | `PROGRESS-chart-ui-114-20261027.md` | **#114 星盘页一页铺开**:南北印度可点盘、检视、深读四页、对话右栏完整盘面(直接执行) | 待推 staging | `codex/chart-ui-114-20261027` |
|
||||
| `TASK-home-crash-saved-people-20261027.md` | — | **#115 首页崩溃**:存过别人的账户一进首页就「页面出错了」——人物列表的资料缺两个字段,启程引导一读就报错;入口补齐默认值(BUG-1464) | 待领取 | `codex/home-crash-saved-people-20261027` |
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
# 任务书:存过别人的账户一进首页就「页面出错了」(issue #115,2026-10-27)
|
||||
|
||||
- 基线:`origin/staging` `941effe80`
|
||||
- 分支:`codex/home-crash-saved-people-20261027`(从 `origin/staging` 新建)
|
||||
- 执行方:**Grok(Windows + Docker)**,只推这个分支。
|
||||
- BUG 编号:开工时 staging 最大号 1463,本单用 **BUG-1464**(开工前再核对一次最大号,撞号顺延)。
|
||||
|
||||
## 事故实证
|
||||
|
||||
产品负责人在 staging 首页看到「页面出错了」,控制台:`TypeError: Cannot read properties of undefined (reading 'length')`,`app root error`。
|
||||
|
||||
按符号定位(本机用 `8e05e4114` 的同名构建产物对上了报错位置):
|
||||
|
||||
1. `frontend/src/lib/birth-time-intake-model.ts` 的 `isBirthTimeDraftReady`:日期能解析时读 `draft.birthTimeClue.length`。
|
||||
2. 它被 `frontend/src/lib/home-profile.ts` 的 `missingOtherProfileStep` 调用。
|
||||
3. 调用方是 `frontend/src/hooks/use-profile-onboarding.ts` 里的 `pendingOther = chartLibrary.find(...)`:首页**每次渲染**都会对人物列表里每个有名字的别人跑一次 `missingOtherProfileStep(row.profile)`。
|
||||
4. 人物列表(`page.tsx` 的 `subjectCatalog` → `current-subject.ts` 的 `loadSubjectCatalog` → `home-cloud-sync.ts` 的 `fetchCloudChartLibrary` → `normalizeChartLibraryApiRecord`)把接口返回的 `profile` 原样摊开,没有补默认值。
|
||||
5. 接口 `GET /api/chart-profiles` 用 `chart-subject-write.ts` 的 `libraryProfileFromSubjectRow` 生成 profile,**不含 `birthTimeClue` 和 `rectificationCaseId`**(数据库里没有这两列)。
|
||||
|
||||
本机复现(虚构资料):把 `libraryProfileFromSubjectRow({ name, birth_date: "1990-01-01", … })` 经 `normalizeChartLibraryApiRecord` 后交给 `missingOtherProfileStep`,精确时间和大概时段两种人都抛同一个错。
|
||||
|
||||
所以:**只要账户里存了一个有名字、有出生日期的别人,首页就会崩**(除非本机还留着「先看某某的盘」的引导记录,那时 `find` 按 id 短路,不调用这个函数)。
|
||||
|
||||
## 根因
|
||||
|
||||
人物列表里的 profile 是「接口给什么就是什么」,类型上却声明成完整的 `Profile`。`use-profile-onboarding.ts` 的 `pendingOther`(2026-10-24 `4d63475caf` 启程那轮加入)第一次在首页渲染时对**已存的别人**调用 `missingOtherProfileStep`,碰到了缺字段。
|
||||
|
||||
生产不受影响:`origin/main` 不含 `4d63475caf`。
|
||||
|
||||
## 决策记录
|
||||
|
||||
- 不需要产品决定:只是把缺的字段补成空值,用户可见行为就是「首页恢复正常」。
|
||||
- 修在数据入口(`normalizeChartLibraryApiRecord`),**不**在 `isBirthTimeDraftReady` 里加 `?.` 兜底:那样类型仍在说谎,别的调用点还会再踩。
|
||||
|
||||
## 硬红线
|
||||
|
||||
- 不改数据库结构、不动迁移、不改接口返回格式(服务端 `libraryProfileFromSubjectRow` 不动)。
|
||||
- 不改 `.gitea/workflows/**`;不推 main;只推本分支。
|
||||
- `page.tsx` 的 `Home()` 状态数不增长。
|
||||
- 测试只用虚构资料。
|
||||
|
||||
## 任务分解
|
||||
|
||||
### T1 · 人物列表入口补齐默认值
|
||||
|
||||
`frontend/src/lib/home-cloud-sync.ts` 的 `normalizeChartLibraryApiRecord`:`profile` 改为先铺 `emptyProfile`(`home-types.ts`)再铺接口给的字段,最后写 `chartRelationship`。接口给了的字段一律以接口为准。
|
||||
|
||||
验收:
|
||||
- 新测试 `frontend/tests/chart-library-normalize-20261027.test.ts`:
|
||||
1. 用 `libraryProfileFromSubjectRow` 生成虚构的「精确时间」「大概时段」「只有名字」三种行,经 `normalizeChartLibraryApiRecord` 后,`emptyProfile` 的每个键都在且类型对;`missingOtherProfileStep` 不抛错,分别得到 `place`/`null`(视地点是否齐全)、`birth` 等预期值。
|
||||
2. 接口给的字段(名字、日期、时段、关系)原样保留,不被空值盖掉。
|
||||
- 再加一条贴近事故的:给 `useProfileOnboarding` 用到的那段判断(或直接对 `chartLibrary.find` 的同一个谓词)喂一条接口形状的别人,不抛错。能直接渲染 hook 就渲染;不能就测 `missingOtherProfileStep` 那一层,并在进度记录里写明。
|
||||
|
||||
### T2 · 记录
|
||||
|
||||
- `docs/BUG_HISTORY.md` 新增 BUG-1464:现象「存过别人的账户进首页即『页面出错了』」、触发条件、根因(上面第 4、5 条)、修复、验证、防复发(新测试锁住「人物列表 profile 键齐全」)、关联 `4d63475caf`、修复版本。不写任何真实资料。
|
||||
- `docs/tasks/PROGRESS-home-crash-saved-people-20261027.md`。
|
||||
- `docs/tasks/README.md` 状态板本行改状态。
|
||||
|
||||
## 验收命令
|
||||
|
||||
Grok 自跑:
|
||||
- `cd frontend && ./node_modules/.bin/tsc --noEmit`
|
||||
- `npm run lint`(0 error)
|
||||
- `npx tsx --test tests/chart-library-normalize-20261027.test.ts` 以及 `git grep -l "normalizeChartLibraryApiRecord\|missingOtherProfileStep" frontend/tests` 命中的全部测试
|
||||
- `npm test` 全量,失败名单与 `tools/agent-loop/windows-known-failures.txt` 逐条比对
|
||||
|
||||
Claude 验收时跑:Linux 全量 `npm test` 对基线、`next build`(`/` 仍 Static、首屏 gzip ±2%)、Python 快速门不涉及(无 Python 改动)。
|
||||
|
||||
## 让步顺序
|
||||
|
||||
T1 第一位;时间不够时 T1 的 hook 级测试可降为谓词级,但必须写明。
|
||||
|
||||
## 开工前置命令
|
||||
|
||||
```
|
||||
git fetch origin --prune
|
||||
git worktree add -b codex/home-crash-saved-people-20261027 .worktrees/home-crash-saved-people-20261027 origin/staging
|
||||
grep -oE "BUG-1[0-9]{3}" docs/BUG_HISTORY.md | sort -u | tail -1
|
||||
```
|
||||
|
||||
## 真机
|
||||
|
||||
部署后产品负责人用存过别人的账户打开首页:不再出「页面出错了」,首页、人物切换、星盘页照常。清单并入 `docs/testing/ui-kit-migration-20261023.md` 已有的首页条目,不另开文件。
|
||||
Reference in New Issue
Block a user