fix(web): persist generated session titles against the post-RPC title (BUG-557)

The first-round title guard compared the pre-RPC snapshot, so append_consultation_question had already rewritten the title and the model name never landed.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jesse_Chen
2026-09-06 19:22:43 +08:00
co-authored by Cursor
parent e2d6f20361
commit 0102a973a3
9 changed files with 243 additions and 11 deletions
+16
View File
@@ -8613,4 +8613,20 @@
- 复发自:无
- 修复版本:`bf8ad0d1`
## BUG-557 | 会话标题守卫比较 RPC 前快照,模型标题写库恒 0 行
- 状态:resolved
- 首次发现:2026-09-06
- 最近更新:2026-09-06
- 影响面:`POST /api/consult` 首轮会话标题
- 用户现象:新会话首轮模型起的标题,刷新、关标签或换设备后变回问题截断标题。
- 触发条件:普通咨询新会话发第一问,在客户端 PATCH 标题之前刷新或离开。
- 根因:`append_consultation_question` 会把空标题 / 「新对话」改成问题前 14 字。守卫却用 RPC 前快照做 `.eq("title")`,更新恒 0 行且不报错。
- 修复:`shouldGenerateSessionTitle` 仍看 RPC 前标题。RPC 成功后再读一次当前标题做守卫。更新带 `.select("id")`0 行 `console.warn("session title guard missed")`
- 验证:`frontend/tests/session-title-persist-contract.test.ts``application-billing-contract.test.ts`
- 防复发:标题守卫必须比较 RPC 后的 `chat_sessions.title`,并断言影响行数。不得用 TS 重算 SQL 的截断规则。
- 相关记录:BUG-553
- 复发自:BUG-553`a1956deb` 的测试没断言守卫会命中)
- 修复版本:待发布