type Tweet = { id: string content: string summary_title: string summary_link: string summary_source: string } type Highlight = { title: string link: string source?: string summary: string } export default function TweetCards({ tweets, onEdit, currentEditingTweetId, tweetConversations, pendingTweetUpdate, highlights: _highlights, onSendMessage, onAcceptUpdate, onRejectUpdate, onCloseEditor }: { tweets: Tweet[], onEdit: (tweet: Tweet) => void, currentEditingTweetId: string | null, tweetConversations: Record>, pendingTweetUpdate: string | null, highlights: Highlight[], onSendMessage: (message: string) => Promise, onAcceptUpdate: () => void, onRejectUpdate: () => void, onCloseEditor: () => void }) { const XLogo = () => ( ) return (
{tweets.map((tweet) => (
{/* Header */}
AI Newsletter
@AI_Newsletter
ยท
now
{/* Tweet Content */}
{tweet.content}
{/* Source Link */}
{tweet.summary_source}
{tweet.summary_title}
{/* Actions */}
{currentEditingTweetId !== tweet.id && ( )}
{/* Inline Chatbot - Show only for the currently editing tweet */} {currentEditingTweetId === tweet.id && (

Edit Tweet with AI

{/* Current Tweet Preview */}
Current Tweet:
{tweet.content}
About: {tweet.summary_title}
{/* Conversation History */}
{(tweetConversations[tweet.id] || []).map((msg, i) => { const isLastMessage = i === (tweetConversations[tweet.id] || []).length - 1 const isAIMessage = msg.role === 'assistant' const hasUpdateInMessage = pendingTweetUpdate && isLastMessage && isAIMessage return (
{msg.content}
{/* Show accept/reject buttons after the last AI message with an update */} {hasUpdateInMessage && (
Suggested Tweet:
280 ? 'text-red-600' : pendingTweetUpdate.length > 260 ? 'text-yellow-600' : 'text-green-600' }`}> {pendingTweetUpdate.length}/280
{pendingTweetUpdate}
{pendingTweetUpdate.length > 280 && (
Tweet is too long! Ask the AI to shorten it.
)}
)}
) })}
{/* Message Input */}
{ e.preventDefault() const formData = new FormData(e.target as HTMLFormElement) const message = formData.get('message') as string if (!message.trim()) return // Clear input const form = e.target as HTMLFormElement form.reset() // Send message and get AI response await onSendMessage(message) }}>
)}
))}
) }