feat(coding): add conversation archive and first-message titles

This commit is contained in:
2026-09-20 12:43:51 +08:00
parent d61226532a
commit fd0293fe3d
22 changed files with 698 additions and 69 deletions

View File

@@ -0,0 +1,11 @@
import type { ConversationNode } from './contracts';
/** Only real user messages name a conversation; no model call or tool output. */
export function firstMessageTitle(node: ConversationNode): string | null {
if (node.kind !== 'message' || node.role !== 'user' || node.status !== 'complete') return null;
const text = node.blocks.flatMap((block) => block.kind === 'text' ? [block.text] : []).join('\n').trim();
if (text.startsWith('/')) return null;
const firstLine = text.split(/\r?\n/)[0].replace(/\s+/g, ' ').trim();
return [...firstLine].slice(0, 32).join('')
|| (node.blocks.some((block) => block.kind === 'image') ? '附件对话' : null);
}