import type { ChatMessage } from '../store/useAppStore'; /** Id of the most recent assistant message, or null when there is none. */ export function findLastAssistantId(messages: ChatMessage[]): string | null { for (let i = messages.length - 1; i >= 0; i--) { if (messages[i].role === 'assistant') return messages[i].id; } return null; } /** True while the model has been asked to answer but has not produced any text yet. */ export function shouldShowTypingIndicator(messages: ChatMessage[], isStreaming: boolean): boolean { if (!isStreaming) return false; const last = messages[messages.length - 1]; return last?.role === 'assistant' && last.content === ''; }