fix(chat): keep stored rectification titles on open
Independent Staging Quality Gate / validate (push) Successful in 11m43s
Independent Staging Quality Gate / publish (push) Successful in 2m3s

Opening a saved birth-time session no longer restamps the title or updatedAt from the wall clock. Occupies BUG-699, recurrence of BUG-553.
This commit is contained in:
jesse-ux
2026-09-15 14:48:03 +08:00
parent 224244c014
commit 2d7698ead3
13 changed files with 397 additions and 10 deletions
+19 -3
View File
@@ -8553,15 +8553,15 @@
- 状态:resolved
- 首次发现:2026-09-06
- 最近更新:2026-09-06
- 最近更新:2026-09-15
- 影响面:侧栏历史列表、`GET /api/sessions``PATCH /api/sessions/[id]``use-session-management`
- 用户现象:刚聊过的会话不在最上面;改名、收藏、换模型或换资料后刷新,这条会话反而排到最顶。
- 触发条件:登录后打开侧栏历史;对已有会话做元数据 PATCH,或不发新消息就刷新。
- 根因:`visibleSessions` 只按 `pinned` 排,开着页面时 `updatedAt` 变化不改位置。元数据 PATCH 和服务端 `metadataUpdateValues` 一律写 `updated_at = now()`,非对话操作也会把会话顶到列表头。真正该 bump 的是发问 / 回答落库。
- 修复:`sortSessions` 置顶优先、组内 `updatedAt` 倒序且稳定。元数据 PATCH 不再写 `updated_at`;客户端改名 / 收藏 / 归档 / 换模型 / 换资料不再 `timestamp()`。列表改为游标分页,历史按本地日期分组,侧栏标题去掉资料名前缀。
- 验证:`frontend/tests/session-groups.test.ts``session-cursor.test.ts``chat-session-write.test.ts``metadataUpdateValues` 不含 `updated_at`)、`sidebar-state.test.ts`(改名不 bump `updatedAt`)、`sidebar-contract.test.ts``chart-library-session.test.ts`
- 防复发:元数据 PATCH 不得写 `updated_at``updatedAt` 只由对话活动推进。侧栏历史排序必须置顶 + `updatedAt` 倒序,不得只按置顶。
- 相关记录:BUG-024
- 防复发:元数据 PATCH 不得写 `updated_at``updatedAt` 只由对话活动推进。侧栏历史排序必须置顶 + `updatedAt` 倒序,不得只按置顶。打开已有会话不得改 `title` / `updatedAt`,由 BUG-699 与 `frontend/tests/session-open-preserves-identity.test.ts` 执行。
- 相关记录:BUG-024、BUG-699
- 复发自:无
- 修复版本:`a1956deb`
@@ -10853,3 +10853,19 @@
- 相关记录:BUG-696
- 复发自:无
- 修复版本:待发布
## BUG-699 | 打开历史校正会话会改成今天的标题并顶到列表最前
- 状态:resolved
- 首次发现:2026-09-15
- 最近更新:2026-09-15
- 影响面:侧栏历史列表、`openRectificationCase``persistSession` 的 update 标题字段
- 用户现象:点开一条以前的生时校正,标题变成今天的日期,并出现在列表最上面。刷新后位置会回去,标题不会。
- 触发条件:点侧栏里已有的校正会话,或从首页校正卡打开一条已存在的可续校正。
- 根因:复发自 BUG-553。`openRectificationCase` 构造 `merged``pinned` / `archivedAt``existing` 继承,`title``updatedAt` 却无条件用墙钟重算,再 `persistSession` 把标题写回服务端。`persistSession` 的 update 不写 `updated_at`(BUG-553 的修复仍在),所以排序只是客户端暂时错位。BUG-553 的防复发当时只是一句话,测试只锁了元数据 PATCH 和改名/收藏/归档/换模型/换资料,没有覆盖校正 open。
- 修复:已有会话的 `title` / `updatedAt` 继承 `existing`,只有新建才 `resolveSessionTitle` + `timestamp()`。错日期标题按 `created_at` 的 Asia/Shanghai 月日修回;对不上正则的手改标题不动。
- 验证:`frontend/tests/session-open-preserves-identity.test.ts``rectification-session-title-repair.test.ts`。浏览器级验收见 `docs/testing/rectification-open-identity-20260915.md`。staging 标题修回行数见本单 PROGRESS。
- 防复发:构造可能作用于已有会话的 `ChatSession` 时,不得无条件写 `updatedAt: timestamp()``resolveSessionTitle``at` 默认墙钟,只能用于新建。
- 相关记录:BUG-553
- 复发自:BUG-553
- 修复版本:待发布
@@ -0,0 +1,46 @@
# PROGRESS · 打开历史校正不再改名(BUG-6992026-09-15
- 执行分支:`codex/rectification-open-retitles-session-20260915`
- 工作树:`.worktrees/rectification-open-retitles-session-20260915`
- 基线:`origin/staging` @ `224244c0`(任务书写 `ff5023a2`;其后一笔是本任务书)
## 做了什么
任务 1`openRectificationCase``rectificationOpenIdentity(existing, minted)`。已有会话的 `title` / `updatedAt` 全等于 `existing`;新建才 `resolveSessionTitle` + `timestamp()``pinned` / `archivedAt` 仍从 `existing` 继承。
任务 1.3 `messages: []`**无害,保持原样。** `persistSession` 的 update 分支不写 `messages`,服务端对话不受影响。校正面从 turns 渲染。
任务 2.1`session-open-preserves-identity.test.ts` 断言 existing 命中时 identity 全等、未命中才用 minted,并锁 hook 里 `merged` 只用 `openIdentity`
任务 2.2:同一文件扫 `frontend/src/hooks/``frontend/src/lib/` 里带 `id` + `sessionType`/`messages` 的对象字面量,禁止无条件 `updatedAt: timestamp()``randomUUID` 新建除外)。把 1.1 改回 `updatedAt: timestamp()` 后这两条变红,已改回,未提交破坏。
任务 2.3`SessionTitleOptions.at``resolveSessionTitle` 默认 `new Date()` 处加了注释:只能用于新建。
任务 3:修回逻辑在 `rectification-session-title-repair.ts`,运维脚本 `frontend/scripts/repair-rectification-session-titles.mjs`(默认只读 `--check``--apply` 才写)。幂等,只动匹配正则且月日与 `created_at` 的 Asia/Shanghai 不一致的行。本机没有 `SCHEMA_DATABASE_URL`**staging 未跑**,损坏面数字待产品在 staging 执行后回填。
## 测试数字
| | `test(` 声明(`git grep -E '^test\(' -- frontend/tests` |
| --- | ---: |
| 基线 `224244c0` | 3213 |
| 改后 | 3221+4 identity+4 title-repair |
定向:`session-open-preserves-identity` 4 pass`rectification-session-title-repair` 4 pass。破坏性复核:把 `merged.updatedAt` 改回 `timestamp()` 后 identity 源码合同与跨文件时钟合同变红。
`tsc --noEmit` 0 错。`npm run lint` **0 error** / 120 warning(既有,未动)。
本机 Windows 全量 TAP 仍受 CRLF / Skill 软链 / Docker 影响,不能当作 Linux 27 的证据。
## 任务 1.3
`persistSession` update 字段是 title / theme / model_id / chart_profile_*,不含 messages,也不含 `updated_at`。结论:清空本地 `messages` 再 hydrate turns 对服务端无害,不改。
## 生产 `7b620c7a`
该 SHA 没有 `use-rectification-surface.ts`。当时 `page.tsx``merged` 用固定标题「生时校正」,**没有**墙钟日期,也**没有** `persistSession(merged)`。生产不受「标题写成今天并写库」影响。`updatedAt: timestamp()` 当时只动客户端,刷新可恢复。任务 3 **不必在生产跑**
## 偏离
- 任务 3 staging 核对 / 修补因本机没有库连接而未跑。脚本已落地。产品在 staging 跑:`node frontend/scripts/repair-rectification-session-titles.mjs` 看行数,确认后加 `--apply`
- CHANGELOG 写的是修回规则已交付;实际写库要等 staging 脚本跑完。
- 浏览器项见 `docs/testing/rectification-open-identity-20260915.md`,不得写成通过。
+1 -1
View File
@@ -120,7 +120,7 @@
| `TASK-chat-reading-load-20260915.md` | `PROGRESS-chat-reading-load-20260915.md` | 首页主题卡下线 + 回答两层可见性 + 折叠层宽表可横滑 + 输入框 16px。内容一字不删。⚠️ BUG-630 走查路径失效 | 已验收(2 条契约测试未通过,见修复单) | `8144fca2` |
| `TASK-mobile-touch-and-breakpoints-20260915.md` | `PROGRESS-mobile-touch-and-breakpoints-20260915.md` | 消息操作按钮触屏命中区 27×34、相邻仅隔 1px(BUG-695);CSS 平板上限 900px 与 `sidebarViewportForWidth` 的 1024 不一致,9011023 是混合态(BUG-696);报告域 720/760/860 三个断点互不对齐,761–860 目录已塌、正文还是桌面(BUG-697)。含断点白名单契约测试。**串行在 chat-reading-load 之后** | 已验收 | `6c748d86`BUG-695697 |
| `TASK-chat-reading-load-fix-20260915.md` | `PROGRESS-chat-reading-load-fix-20260915.md` | **验收修复单**`chat-bundle-splitting-contract``message-markdown` 包裹数 1→2、`plainParagraphs(spoken)` 字面量已不存在)与 `chat-navigation-a11y-contract``window.location.assign("/login")` 4→3,建议问题入口删除带走一处)两条既有断言被本轮打红且未更新;Linux 全量 27→29。只改测试不改产品代码 | 待验收 | `codex/chat-reading-load-fix-20260915` |
| `TASK-rectification-open-retitles-session-20260915.md` | | **P0 复发单**:点侧栏历史校正会话,`openRectificationCase` 无条件用墙钟重算 `title` 并把 `updatedAt` 盖成此刻(同一处 `pinned`/`archivedAt` 却从 `existing` 继承了),`persistSession` 把改名写回服务端 → 12 号的会话被改成「9月15日 · 生时校正」并顶到列表最前。标题**永久损坏**、排序刷新可恢复。复发自 BUG-553(其防复发只是一句话,无测试执行,且没覆盖校正 open 路径)。含历史标题按 `created_at` 修回(BUG-699 | 待领取 | `codex/rectification-open-retitles-session-20260915` |
| `TASK-rectification-open-retitles-session-20260915.md` | `PROGRESS-rectification-open-retitles-session-20260915.md` | **P0 复发单**:点侧栏历史校正会话,`openRectificationCase` 无条件用墙钟重算 `title` 并把 `updatedAt` 盖成此刻(同一处 `pinned`/`archivedAt` 却从 `existing` 继承了),`persistSession` 把改名写回服务端 → 12 号的会话被改成「9月15日 · 生时校正」并顶到列表最前。标题**永久损坏**、排序刷新可恢复。复发自 BUG-553(其防复发只是一句话,无测试执行,且没覆盖校正 open 路径)。含历史标题按 `created_at` 修回(BUG-699 | 待验收 | `codex/rectification-open-retitles-session-20260915` |
| `TASK-settings-dialog-size-and-nav-20260915.md` | — | **复发单**:设置弹窗四个分区尺寸仍随内容跳变(BUG-698,复发自 BUG-554——旧防复发只查「有没有写 height」,查不到「写了没生效」);首要嫌疑是 `.settings-modal``dvh` 没有 `vh` 回退,不支持时整条 `height` 作废退化成内容高度,需先复现确认。另按产品要求去掉分区菜单左侧强调条,并拆开与悬停共用的选中态 | 待领取 | `codex/settings-dialog-size-and-nav-20260915` |
### 个人报告
@@ -0,0 +1,34 @@
# 真机 / 浏览器清单 · 打开历史校正不得改名(2026-09-15)
代码级合同在 `frontend/tests/session-open-preserves-identity.test.ts`。下面必须用已登录的 staging 看。截图不要带真实姓名、出生资料或会话正文。
地址:`https://staging.jyotisha.chat`
## A. 打开三条不同日期的历史校正
侧栏里找三条**标题日期不同**的生时校正(例如 12 日、13 日、14 日)。没有三条就用现有的,记下打开前的标题、所在分组、上下邻居。
对每一条:
1. 点开。
2. **看:** 标题一个字都没变。
3. **看:** 仍在原来的分组(今天 / 昨天 / 最近 7 天…),没有跳到最上面。
4. **看:** 上下邻居还是打开前那两条。
5. 刷新页面。**看:** 标题、分组、位置仍与打开前一致。
## B. 新建一条
1. 从首页「开始新的生时校正」开一条新的。
2. **看:** 标题是「{今天} · 生时校正」,出现在「今天」分组最上面。
## C. 首页校正卡打开已有可续校正
若首页校正卡会回到一条**已经存在**的校正:
1. 先记下那条在侧栏里的标题和位置。
2. 点首页校正卡。
3. **看:** 标题和位置都不变,与 A 相同。
## 结论
> 待填。测完写日期 + 设备 + 浏览器 + 逐条正常/有问题。