// Runners console (PEP-38): list rows with status and limit info, and the details panel of the chosen runner. import Link from "next/link"; import { SquareTerminal, X } from "lucide-react"; import type { SessionView } from "@peppa/core"; import { MAX_LIMIT_RESUMES_PER_DAY } from "@peppa/runner"; import { PanelSection } from "@/components/ActivityAside"; import { AttachCommand, QuestionCard, SessionActions } from "@/components/cards"; import { ago, Key, StatusBadge } from "@/components/common"; import { LocalTime, ScrollIntoViewOnNarrow } from "@/components/LocalTime"; import type { InboxItem } from "@/lib/queries"; import { SESSION_STATUS, TONE_BG, TONE_TEXT } from "@/lib/status"; import { cn } from "@/lib/utils"; /** «остановлена · продолжит в 03:10» for a runner that hit the usage limit (PEP-56). */ export function LimitNote({ s }: { s: SessionView }) { if (s.status !== "rate_limited") return null; if (!s.resumeAt) return <>остановлена · лимит; if (s.resumeAt.getTime() <= Date.now()) return <>остановлена · продолжит сейчас; return ( <> остановлена · продолжит в ); } /** `selected`: "wide" — picked by default, highlighted only where the side panel is visible. */ export function RunnerRow({ s, href, selected, needsPm }: { s: SessionView; href: string; selected: boolean | "wide"; needsPm: boolean }) { const limited = s.status === "rate_limited"; const st = SESSION_STATUS[s.status] ?? { label: s.status, tone: "muted" as const }; return (
  • {s.taskKey ?? s.projectKey} {s.taskTitle ?? "без задачи"} {limited ? ( <> {st.label} ) : ( st.label )} {s.projectKey} · {s.provider} · #{s.id} · {s.tmuxName} {ago(s.lastActivityAt)} {limited && ( )}
  • ); } export function RunnerDetails({ s, questions, events, back, closeHref, chosen }: { s: SessionView; questions: InboxItem[]; events: Array<{ id: number; type: string; payload: unknown; createdAt: Date }>; back: string; closeHref: string; chosen: boolean }) { return (
    {/* Picked from the list: on narrow screens the panel is under it, scroll there. */} {chosen && }
    #{s.id}

    {s.taskKey && {s.taskKey}} {s.taskTitle ?? "без задачи"}

    {s.status === "rate_limited" && (

    авто-продолжений сегодня: {s.limitResumes} из {MAX_LIMIT_RESUMES_PER_DAY}

    )}
    Проект
    {s.projectKey}
    Агент
    {s.provider === "codex" ? "Codex" : "Claude Code"} · поколение {s.generation}
    Запущен
    {ago(s.startedAt)}
    Активность
    {ago(s.lastActivityAt)}
    {questions.length > 0 && ( {questions.map((q) => ( ))} )}
    Живой терминал раннера появится здесь (PEP-9). Пока — команда tmux attach выше, на машине Пеппы.
    {events.length > 0 && (
      {events.map((e) => (
    1. {ago(e.createdAt)} {e.type}{" "} {e.type === "progress" ? (e.payload as { text: string }).text : ""}
    2. ))}
    )}
    ); }