import { useChatStore } from "@/lib/store"; export function useConversation(id: string) { const { conversations, addMessage, updateMessage, deleteConversation } = useChatStore(); const conversation = conversations.find((c) => c.id === id) ?? null; return { conversation, messages: conversation?.messages ?? [], addMessage: (msg: Parameters[1]) => addMessage(id, msg), updateMessage: (msgId: string, updates: Parameters[2]) => updateMessage(id, msgId, updates), deleteConversation: () => deleteConversation(id), }; }