title_locked:用户手动重命名的标题不许被 handoff 自动标题冲掉
三个标题触发点里,maybeGenerateTitle 见非空即跳过,天然尊重手动改名; 唯独 handoff 的 title 是无条件覆写——用户改名后再一次交接,名字静默蒸发。 - db.js:sessions 加 title_locked 列(迁移,默认 0); - engine.renameSession:手动改名即置 1(唯一上锁入口); - toolHandoff:SELECT 带出 title_locked,task.md 落盘成功后见锁跳过写标题 (其余动作照常,静默处理,不打扰交接回执); - clearSessionMessages:title 置 null 的同时复位锁——旧名字已文不对题, 新一轮自动标题不该被上一世代的改名挡住。 engine 批尾的 title 广播逻辑不动:见锁未写时广播的是原样标题,前端刷新无害。
This commit is contained in:
@@ -1092,7 +1092,9 @@ function renameSession(sessionId, title) {
|
||||
const t = String(title || '').trim();
|
||||
if (!t) throw Object.assign(new Error('名称不能为空'), { status_code: 400 });
|
||||
if (t.length > 100) throw Object.assign(new Error('名称不能超过 100 字'), { status_code: 400 });
|
||||
touch(sessionId, { title: t });
|
||||
// 手动改名即上锁:后续 handoff 的自动标题见 title_locked 即跳过,不许冲掉用户起的名字
|
||||
//(maybeGenerateTitle 本就见非空即跳,无需看锁)。
|
||||
touch(sessionId, { title: t, title_locked: 1 });
|
||||
log.info('task', sessionId + ' 重命名为「' + t + '」');
|
||||
return { ok: true, title: t };
|
||||
}
|
||||
@@ -1235,7 +1237,7 @@ function clearSessionMessages(sessionId) {
|
||||
autoCompressProposed.delete(sessionId); // 历史清零,恢复自动压缩提议额度
|
||||
// 标题随历史一并清零:旧标题描述的是已删除的对话,留着会让新对话文不对题;
|
||||
// 新一轮交互结束后 maybeGenerateTitle 见 title 为空会自动重新生成。
|
||||
touch(sessionId, { status: 'completed', completed_at: now(), cancelled_at: null, held_at: null, title: null, phase: 'advising' });
|
||||
touch(sessionId, { status: 'completed', completed_at: now(), cancelled_at: null, held_at: null, title: null, title_locked: 0, phase: 'advising' });
|
||||
profile.freezeSnapshot(db, sessionId); // 回 advising 重新规划:画像快照随新一轮重新冻结
|
||||
bus.emit(sessionId, 'done', { status: 'completed' });
|
||||
bus.emit(sessionId, 'title', { title: null }); // 供其他打开同一会话的窗口同步清掉旧标题
|
||||
|
||||
Reference in New Issue
Block a user