// Story page tabs (PEP-32): OpenSpec artifacts of the change, comments, checks, the PR and // the activity log. Server components; each tab reads only what it shows. import { AgentBadge } from "@/components/AgentBadge"; import { CircleCheck, CircleX, ExternalLink, GitMerge, GitPullRequest, Hourglass, MessageSquare, Send } from "lucide-react"; import type { ChangeArtifacts, CiSummary, CodeReview, DeltaOp, GiteaPull, Question, StoryComment, TasksProgress } from "@peppa/core"; import { reviewLabel } from "@peppa/core"; import { Hidden, QuestionCard } from "@/components/cards"; import { ago, Disclosure, Empty } from "@/components/common"; import { Markdown } from "@/components/Markdown"; import { eventLine } from "@/components/RunnerConsole"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Textarea } from "@/components/ui/input"; import { cn } from "@/lib/utils"; import { acceptStoryAction, commentStoryAction } from "../../actions"; export const STORY_TABS = [ { id: "proposal", label: "Proposal" }, { id: "design", label: "Design" }, { id: "specs", label: "Specs" }, { id: "tasks", label: "Tasks" }, { id: "comments", label: "Comments" }, { id: "tests", label: "Tests" }, { id: "merge", label: "Merge request" }, { id: "activity", label: "Activity" }, ] as const; export type StoryTab = (typeof STORY_TABS)[number]["id"]; const noChange = (change: string | null) => {change ? `Change ${change} не найден в рабочей копии.` : "Change ещё не создан — агент заведёт его на этапе proposal."}; export function ArtifactTab({ change, changeId, file }: { change: ChangeArtifacts | null; changeId: string | null; file: "proposal" | "design" }) { if (!change) return noChange(changeId); const text = change[file]; if (!text) return {file === "design" ? "design.md в этом change нет — значит, решений сверх proposal не понадобилось." : "proposal.md ещё не написан."}; return (
); } const OP: Record = { ADDED: { label: "добавлено", variant: "ok" }, MODIFIED: { label: "изменено", variant: "info" }, REMOVED: { label: "удалено", variant: "danger" }, RENAMED: { label: "переименовано", variant: "outline" }, }; export function SpecsTab({ change, changeId }: { change: ChangeArtifacts | null; changeId: string | null }) { if (!change) return noChange(changeId); if (!change.specs.length) return В change нет дельта-спецификаций (specs/*/spec.md).; return (
{change.specs.map((spec) => (

{spec.capability}

{spec.sections.map((sec, si) => (
{sec.requirements.length === 0 &&

{OP[sec.op].label}: без требований

} {sec.requirements.map((r, ri) => ( {OP[sec.op].label} {r.name} {r.scenarios.length > 0 && сценариев: {r.scenarios.length}} } >
{r.body && } {r.scenarios.map((sc, i) => (

Сценарий: {sc.name}

))}
))}
))}
))}
); } export function TasksTab({ change, changeId, progress }: { change: ChangeArtifacts | null; changeId: string | null; progress: TasksProgress | null }) { if (!change) return noChange(changeId); if (!progress?.total) return tasks.md ещё нет или в нём нет пунктов.; return (
{progress.sections.map((sec, i) => { const done = sec.items.filter((it) => it.done).length; return (

{sec.title || "Пункты"} {done}/{sec.items.length}

    {sec.items.map((it, j) => (
  • {it.text}
  • ))}
); })}
); } export function ProgressBar({ done, total, current, compact = false }: { done: number; total: number; current: string | null; compact?: boolean }) { const pct = total ? Math.round((done / total) * 100) : 0; return (
{done}/{total}
{current && !compact && Сейчас: {current}}
); } type Thread = { at: number; kind: "q"; q: Question } | { at: number; kind: "c"; c: StoryComment }; export function CommentsTab({ taskKey, taskStatus, questions, comments, back, hasLive }: { taskKey: string; taskStatus: string; questions: Question[]; comments: StoryComment[]; back: string; hasLive: boolean }) { const thread: Thread[] = [...questions.map((q) => ({ at: q.createdAt.getTime(), kind: "q" as const, q })), ...comments.map((c) => ({ at: c.createdAt.getTime(), kind: "c" as const, c }))].sort((a, b) => a.at - b.at); return (
{thread.length === 0 && Вопросов и комментариев пока нет.} {thread.map((t) => t.kind === "q" ? ( ) : (
{t.c.role ? : } {t.c.role ? (t.c.role === "product" ? "зачем и что берём" : "что должно получиться") : <>{t.c.login} комментарий PM} · {ago(t.c.createdAt)}

{t.c.text}

), )}