fix: generate distinct task collaboration titles

Use verified task names until Agent generates a specific conversation title.
Repair legacy names without changing manual titles or history ordering.
Bound page repairs to 30 entries and a shared two-second deadline, and
re-read titles after task access validation to avoid stale reuse receipts.

Validation: bun run check; 40 focused tests across six files.
This commit is contained in:
2026-10-29 16:55:10 +08:00
parent c3050b602b
commit fbe273e90a
8 changed files with 285 additions and 12 deletions
+4 -1
View File
@@ -182,11 +182,14 @@ export class SessionMetadataStore {
async touch(
record: SessionRecord,
updates: Partial<Pick<SessionRecord, "title" | "status" | "topicId">> = {},
options: { preserveUpdatedAt?: boolean; expectedTitle?: string } = {},
) {
return this.serialize(record.sessionId, async () => {
const current = await this.get({ ...record, userId: record.ownerUserId }, record.sessionId);
if (!current) throw new SessionContextMismatchError();
const next: SessionRecord = { ...current, ...normalizeSessionUpdates(updates), updatedAt: new Date().toISOString() };
if (options.expectedTitle !== undefined && (current.title ?? "") !== options.expectedTitle) return current;
const next: SessionRecord = { ...current, ...normalizeSessionUpdates(updates),
updatedAt: options.preserveUpdatedAt ? current.updatedAt : new Date().toISOString() };
await atomicWriteJson(this.filePath(record.sessionId), next, 0o600);
this.updateIndex(next);
return next;