* Get the first user message from a list of chat messages
(messages: ChatMessage[])
| 21 | * Get the first user message from a list of chat messages |
| 22 | */ |
| 23 | function getFirstUserPrompt(messages: ChatMessage[]): string { |
| 24 | for (const msg of messages) { |
| 25 | if (msg?.variant === 'user' && msg.content) { |
| 26 | // Truncate long prompts |
| 27 | const content = msg.content.trim() |
| 28 | if (content.length > 100) { |
| 29 | return content.slice(0, 97) + '...' |
| 30 | } |
| 31 | return content |
| 32 | } |
| 33 | } |
| 34 | return '(empty chat)' |
| 35 | } |
| 36 | |
| 37 | interface ChatDirInfo { |
| 38 | chatId: string |