import Link from 'next/link' import { redirect } from 'next/navigation' import { getCurrentUser } from '@/lib/session' import { execAgent } from '@/lib/agent-client' import { parseGitStatus } from '@/lib/parse-git' import DiffViewer from './_components/diff-viewer' export const dynamic = 'force-dynamic' type Props = { params: Promise<{ repo: string }> } function findRepoPath(repoName: string): string | null { const paths = (process.env.REPO_PATHS ?? '') .split(',') .map((p) => p.trim()) .filter(Boolean) return paths.find((p) => p.split('/').filter(Boolean).pop() === repoName) ?? null } export default async function GitRepoPage({ params }: Props) { const user = await getCurrentUser() if (!user) redirect('/login') const { repo } = await params const repoName = decodeURIComponent(repo) const repoPath = findRepoPath(repoName) if (!repoPath) { return (