feat(coding): add conversation archive and first-message titles
This commit is contained in:
11
electron/coding-runtime/conversation-title.ts
Normal file
11
electron/coding-runtime/conversation-title.ts
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user