'use client'; import { useState, useMemo } from 'react'; import Link from 'next/link'; import { AitmChangeStory } from '@/utils/aitmChangeStory'; import { parseAitmChangeStoryBlock } from '@/utils/aitmChangeStory'; import EmptyState from '@/components/EmptyState'; interface RepoCodeChangesTabProps { owner: string; name: string; activities: any[]; posts: any[]; } /** Extracts AITM checkpoint-linked stories from posts. */ function extractCheckpointPosts(posts: any[]): { post: any; story: AitmChangeStory; cleanContent: string }[] { const results: { post: any; story: AitmChangeStory; cleanContent: string }[] = []; for (const post of posts) { const { story, cleanContent } = parseAitmChangeStoryBlock(post.content || ''); if (story) { results.push({ post, story, cleanContent }); } } return results; } /** File change type badge */ function ChangeTypeBadge({ type }: { type: 'added' | 'removed' | 'modified' }) { const styles = { added: 'bg-green-500/10 text-green-500 border-green-500/20', removed: 'bg-red-500/10 text-red-500 border-red-500/20', modified: 'bg-yellow-500/10 text-yellow-500 border-yellow-500/20', }; const labels = { added: 'Added', removed: 'Removed', modified: 'Modified' }; return ( {labels[type]} ); } /** A single checkpoint-linked change story card */ function CheckpointCard({ story, cleanContent, post, owner, name, }: { story: AitmChangeStory; cleanContent: string; post: any; owner: string; name: string; }) { const [expanded, setExpanded] = useState(false); const aitmUrl = story.aitmProjectId ? `https://timemachine.gitgram.app/project/${story.aitmProjectId}/checkpoint/${story.checkpointId}` : null; return (
{story.diffAdded}
Added
{story.diffRemoved}
Removed
{story.diffModified}
Modified
{cleanContent}
)}{activity.summary || activity.title || activity.description || 'Repository activity captured.'}
{activity.commitSha && ({activity.commitSha.slice(0, 7)}
)}