// Domain cards shared by pages: agent questions, runners, project list. import Link from "next/link"; import { BellRing, CircleCheck, CircleHelp, FileCheck, Hourglass, Play, RotateCcw, Send, ShieldQuestion, Square } from "lucide-react"; import type { Project, Question, SessionView } from "@peppa/core"; import { answerQuestion, messageSession, resumeTaskSession, stopTaskSession } from "@/app/(app)/actions"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { ago, Empty, Key, StatusBadge } from "@/components/common"; import { cn } from "@/lib/utils"; const KIND = { approval: { label: "Одобрение proposal", icon: FileCheck, border: "border-l-primary" }, question: { label: "Вопрос", icon: CircleHelp, border: "border-l-info" }, permission: { label: "Разрешение", icon: ShieldQuestion, border: "border-l-warn" }, attention: { label: "Сессия ждёт тебя", icon: BellRing, border: "border-l-ok" }, } as const; /** Hidden inputs of a server-action form. */ export function Hidden({ fields }: { fields: Record }) { return ( <> {Object.entries(fields).map(([k, v]) => (v == null ? null : ))} ); } export function QuestionCard({ q, taskKey, taskStatus, back, compact = false }: { q: Question; taskKey?: string | null; taskStatus?: string | null; back: string; compact?: boolean }) { const review = q.kind === "attention" && taskStatus === "review"; const answered = !!q.answeredAt; const k = KIND[q.kind]; const Icon = review ? CircleCheck : k.icon; return (
{review ? "Готово к ревью" : k.label} {taskKey && {taskKey}} #{q.id} · {ago(q.createdAt)}

{q.text}

{answered ? (

{q.answeredVia === "system" ? : } {q.answeredVia === "system" ? q.answer : `Ответ (${q.answeredVia}): ${q.answer}`}

) : (
{q.kind === "approval" && } {q.kind === "permission" && ( <> )} {review && } {q.kind === "attention" && !review && } {(q.options ?? []).map((o) => ( ))}
{q.kind !== "permission" && (
)} )}
); } /** Message / stop / resume controls of one runner. */ export function SessionActions({ s, back }: { s: SessionView; back: string }) { const alive = !["done", "failed"].includes(s.status); return (
{alive && (
)} {alive && (
)} {(!alive || ["rate_limited", "stalled"].includes(s.status)) && (
)}
); } export function AttachCommand({ name }: { name: string }) { return tmux attach -t {name}; } export function SessionCard({ s, back, showTitle = false }: { s: SessionView; back: string; showTitle?: boolean }) { return (
{s.taskKey ? {s.taskKey} : {s.projectKey}} {showTitle && s.taskTitle && {s.taskTitle}} #{s.id} · {s.provider} · пок. {s.generation} · {ago(s.lastActivityAt)}
); } export function ProjectList({ projects, userId }: { projects: Project[]; userId: number }) { if (!projects.length) return ( Проектов пока нет. Создать первый ); return ( ); }