Files
Jyotisha/docs/tasks/PROGRESS-rectification-session-title-result-20260922.md
T
jesse-ux a94a1d6748 fix(sessions): keep rectification result titles when a new chat opens
The case insert trigger writes the result time, then the existing open persist sends the minted title back. A before-update guard keeps that result unless the user chose a non-automatic name, and a new session reads the stored title into the sidebar.
2026-09-25 02:04:56 +08:00

6.8 KiB
Raw Blame History

PROGRESS 校正会话标题改为结果时间(2026-09-25)

  • 任务书:docs/tasks/TASK-rectification-session-title-result-20260922.md
  • 分支:codex/rectification-session-title-result-20260922
  • 基线:514951d7(开工时 origin/staging)
  • 状态:实现完成,待验收。未 push。

做了什么

  • 新增 frontend/supabase/migrations/20260925010000_rectification_session_title_result.sql。没有抄到 frontend/db/migrations(校正迁移只在 supabase,runner 会扫该目录)。
  • 标题算式只在 public.rectification_session_title(time, time, jsonb)。已确认优先于已采用;范围原样拼接,中间是 U+2013 EN DASH;否则 生时校正。to_char(..., 'HH24:MI')。immutable / parallel safe / search_path = '',不读表。
  • 自动派生判据只在 public.rectification_session_title_is_automatic(text)。触发器与回填都调它。
  • 触发器 agentic_rectification_cases_title_from_result,函数 public.sync_rectification_session_title_from_case()。只挂 accepted_time、confirmed_time、candidate_range。不写 updated_at。没有改 touch_chat_session_from_rectification_case。
  • 回填 update 用同一对函数。测试从迁移文件的标记之间切出该语句执行,没有手抄。
  • resolveSessionTitle 对校正入口和校正交接问句返回 生时校正。datedSessionTitle 只剩今日节奏调用者,注释写明。
  • DATED_ENTRY_TITLE 扩到三种自动派生形态,并认得今日节奏的日期形态。连字符范围不是自动派生。
  • 删了 frontend/src/lib/rectification-session-title-repair.ts 和 frontend/tests/rectification-session-title-repair.test.ts。它们只服务已被本单取代的「按创建日把标题改回日期」助手,生产代码没有引用。历史脚本 frontend/scripts/repair-rectification-session-titles.mjs 仍被 rectification-session-title-repair-migration.test.ts 用来锁 20260916020000 的逐字合同,--apply 本来就会报错,没有改成新口径,也没有改历史迁移。脚本头注明不得执行 TITLE_APPLY_SQL。
  • open 路径一个字没动(D4 / BUG-699)。

断言三栏

原值 新值 原因
resolveSessionTitle 校正入口 生时校正 · 8月22日 生时校正 BUG-1001:新建不带日期,结果由触发器写;今日节奏仍是 今日节奏 · 8月22日
session-list-filter 夹具标题 生时校正 · 9月14日 生时校正 · 05:07 例子改成结果时间。该断言只锁是否入列,不锁标题格式
shouldGenerateSessionTitle("生时校正", consultation) 为 true(经 generic 前缀,未单测) false DATED_ENTRY_TITLE 现在认得裸「生时校正」和结果时间,模型不得覆盖自动标题。校正会话仍恒 false

删掉的旧修补测试(任务书允许,T5 已取代):dated titles use the product calendar, not UTC、repair rewrites a wall-clock today stamp back to created_at's local date、repair leaves matching dates and user-renamed titles alone、missing created_at falls back to a dateless title instead of guessing。

T4 故意改红

把迁移里 rectification_session_title_is_automatic 正则的范围间隔号 U+2013 改成连字符 -(一个字符)。rectification-session-title-parity.test.ts 转红(not ok,正则不再含 EN DASH)。已撤回,复跑 ok。未提交该改动。

验证

项 结果
npx tsc --noEmit 0 错
npm run lint 0 error,121 warning。本单改动的文件没有新增 warning。121 是当前树上的既有数,超过任务书 119 的上限,按「不修无关 warning」没有动
定向:agent-reply、session-title-agent、rectification-session-title-parity、rectification-session-title-repair-migration、session-list-filter 23/23 通过
database-rectification-session-title-result.test.ts 真实 Postgres 1/1 通过(约 30s)。四分支、provolatile=i、采用/收窄不改 updated_at、手改名不覆盖、touch 与标题触发器互不干扰、回填 5 行、重跑 0 行、六行 updated_at/pinned/messages 不变。套在 npm run test:db 里仍是 ok 41
npm run test:db 跑完,exit 1。48 条里 13 过、35 红。红的是既有 Windows 缺口:双目录扫描 duplicate migration filename: 20260814025000_personal_report_document_v2.sql,以及 backup 测试的 WSL execvpe(/bin/bash)。不是本单 SQL。地址池没有耗尽
全量 npm test 未跑。这台 Windows 有已知 Docker/EPERM 基线失败,定向已绿
npm run build 失败。Turbopack 报 worktree node_modules junction 指向文件系统根之外。npx next build --webpack 编译成功(69s),收集页面时在 /api/daily-starlanguage 与 /api/rectification/agent 因 Skill symlink EPERM 中断,没有打出路由表。/ 是否仍 Static、首屏 gzip 本机测不到。这是既有 Windows 缺口,不是本单源码错误
Python tests/test_daily_and_rectification_entrypoints.py 未跑。G:\Ferti\Jyotisha\.venv\Scripts\python.exe 不存在,没有装依赖。开工已看过该文件,只断言裸字符串「生时校正」,新格式仍满足

Windows 上 frontend/db/migrations 里 4 个 Git symlink 被检出成相对路径文本,标准双目录扫描报 duplicate migration filename: 20260814025000_personal_report_document_v2.sql。定向数据库测试先走标准 runner;只有撞上这个既有错误时,才把真正的 SQL 逐字节抄到临时目录(跳过占位文本,重复真文件必须一致),再用 MIGRATIONS_DIRECTORY 跑同一个 scripts/db-migrate.mjs。Linux 门禁 symlink 不是普通文件,第一条路径就会成功。没有改 runner。

未改 / 未验证

  • 没有 push,没有改 workflow,没有动 page.tsx、咨询 status 路由、SVG height。
  • 新建会话的 open 仍先 persistSession 本地 minted 标题(BUG-699 的结构断言没动)。插入触发器已经写成范围标题。补了 keep_rectification_result_title:登录用户不能把自动标题写回去盖掉结果,手改的非自动标题仍可保存。新建会话随后 fetchSessionDetail,侧栏改读库里的结果标题,不改 updatedAt。已有会话的 open 仍保留本地 title / updatedAt。
  • 连字符范围 生时校正 · 05:00-05:15:SQL 不覆盖。isAutoDerivedSessionTitle 仍可能为 true,因为 isGenericSessionTitle 的「生时校正」前缀比本单三种形态更宽。对断表没有把这一条算进「必须相同」的那一组。DATED_ENTRY_TITLE 不认连字符。
  • 首屏 gzip 基线未测到。npm run build 在 junction 上 Turbopack panic;next build --webpack 编译过了,但页面收集被 Skill symlink EPERM 打断,没有路由表,不能宣称 / 仍是 Static。
  • 浏览器走查未做。