import Link from "next/link"; import { notFound } from "next/navigation"; import { AutoRefresh } from "@/components/AutoRefresh"; import { ago, Badge, Flash, QuestionCard, SessionCard } from "@/components/ui"; import { requireUser } from "@/lib/auth"; import { openspecArtifacts, taskActivity, taskForUser } from "@/lib/queries"; import { db } from "@/lib/db"; import { goals } from "@peppa/db"; import { eq } from "drizzle-orm"; import { startTaskSession } from "../../actions"; export default async function TaskPage({ params, searchParams }: { params: Promise<{ key: string }>; searchParams: Promise<{ error?: string }> }) { const user = await requireUser(); const { key } = await params; const { error } = await searchParams; const ref = await taskForUser(user.id, decodeURIComponent(key)).catch(() => null); if (!ref) notFound(); const { task, project } = ref; const [goal] = task.goalId ? await db.select().from(goals).where(eq(goals.id, task.goalId)) : []; const { questions, sessions, events } = await taskActivity(task.id); const artifacts = openspecArtifacts(project, task.openspecChange); const back = `/t/${ref.key}`; return ( <>

{project.name} {goal && <> · 🎯 {goal.title}}

{ref.key} {task.title}

{task.prUrl &&

PR

}

{task.description || Без описания}

Сессии

{sessions.map((s) => )}

Вопросы

{questions.length === 0 ?

Вопросов не было.

: questions.map((q) => )}

OpenSpec {task.openspecChange && {task.openspecChange}}

{artifacts?.length ? ( artifacts.map((a) => (
{a.name}
{a.text}
)) ) : (

Change ещё не создан.

)}

События

    {events.map((e) => (
  • {ago(e.createdAt)} {e.type}{" "} {e.type === "progress" ? (e.payload as { text: string }).text : e.type === "task_updated" ? JSON.stringify((e.payload as { to: unknown }).to) : ""}
  • ))}
); }