From d3a54fc8458b465eaf1c1849c6d12d542cde3c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=81=D0=B5=D0=BB=D1=8C?= Date: Fri, 13 Nov 2026 16:25:05 +0500 Subject: [PATCH 1/2] =?UTF-8?q?PEP-38:=20runners=20console=20=E2=80=94=20f?= =?UTF-8?q?ilter=20counters,=20search,=20limit=20resume=20time,=20details?= =?UTF-8?q?=20panel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- apps/web/app/(app)/help/page.tsx | 2 +- apps/web/app/(app)/runners/page.tsx | 110 +++++++++---- apps/web/components/LocalTime.tsx | 24 +++ apps/web/components/RunnerConsole.tsx | 146 ++++++++++++++++++ apps/web/components/Workspace.tsx | 7 +- apps/web/lib/queries.ts | 5 + .../changes/pep-38-factory-console/tasks.md | 8 +- 7 files changed, 265 insertions(+), 37 deletions(-) create mode 100644 apps/web/components/LocalTime.tsx create mode 100644 apps/web/components/RunnerConsole.tsx diff --git a/apps/web/app/(app)/help/page.tsx b/apps/web/app/(app)/help/page.tsx index 6c792523..d1375129 100644 --- a/apps/web/app/(app)/help/page.tsx +++ b/apps/web/app/(app)/help/page.tsx @@ -52,7 +52,7 @@ export default async function Help() {
  • Доска — Бэклог → В работе → Ревью → Готово. Перенос в «В работе» запускает агента.
  • Агент — Claude Code (или Codex) в сессии на машине Пеппы: пишет OpenSpec-proposal, реализует, открывает PR и отдаёт задачу на ревью.
  • Участники — владелец проекта добавляет людей по логину Gitea (блок «Участники» на странице проекта). Агенты проекта работают на подписке Claude владельца.
  • -
  • Раннер — агент, запущенный по задаче в tmux на машине Пеппы. Все раннеры твоих и общих проектов — в разделе Раннеры: статус, задача, команда tmux attach, сообщение, остановка и resume; фильтры «ждут тебя / работают / остановлены (упали) / завершены».
  • +
  • Раннер — агент, запущенный по задаче в tmux на машине Пеппы. Все раннеры твоих и общих проектов — в разделе Раннеры: статус, задача, команда tmux attach, сообщение, остановка и resume; фильтры-счётчики «ждут тебя / работают / упали / готово» и поиск; строки, где нужен ты, подсвечены, у раннера на лимите — «остановлена · продолжит в HH:MM». Выбери раннер — справа его детали, вопросы и действия (живой терминал появится там же).
  • Главная — вопросы агентов (только архитектурные стопперы) и «готово к ревью», активные раннеры и проекты. Отвечать можно в вебе, Telegram или через MCP. Список проектов и «Новый проект» — в разделе Проекты.
  • diff --git a/apps/web/app/(app)/runners/page.tsx b/apps/web/app/(app)/runners/page.tsx index 9644c1b3..dca587f2 100644 --- a/apps/web/app/(app)/runners/page.tsx +++ b/apps/web/app/(app)/runners/page.tsx @@ -1,49 +1,101 @@ import Link from "next/link"; -import { listUserSessions, RUNNER_FILTERS, type RunnerFilter } from "@peppa/core"; +import { Search } from "lucide-react"; +import { listUserSessions, RUNNER_FILTERS, type RunnerFilter, type SessionView } from "@peppa/core"; import { AutoRefresh } from "@/components/AutoRefresh"; -import { SessionCard } from "@/components/cards"; import { Empty, Flash, PageHeader } from "@/components/common"; +import { RunnerDetails, RunnerRow } from "@/components/RunnerConsole"; +import { Input } from "@/components/ui/input"; import { Workspace } from "@/components/Workspace"; import { requireUser } from "@/lib/auth"; import { db } from "@/lib/db"; +import { inbox, sessionEvents } from "@/lib/queries"; import { cn } from "@/lib/utils"; const FILTERS: Array<{ key: RunnerFilter | undefined; label: string }> = [ - { key: undefined, label: "Все" }, - { key: "waiting", label: "Ждут тебя" }, - { key: "working", label: "Работают" }, - { key: "stopped", label: "Остановлены" }, - { key: "finished", label: "Завершены" }, + { key: undefined, label: "все" }, + { key: "waiting", label: "ждут тебя" }, + { key: "working", label: "работают" }, + { key: "stopped", label: "упали" }, + { key: "finished", label: "готово" }, ]; +const inFilter = (s: SessionView, f: RunnerFilter) => (RUNNER_FILTERS[f] as string[]).includes(s.status); +const matches = (s: SessionView, q: string) => + [s.taskKey, s.taskTitle, s.projectKey, s.tmuxName, `#${s.id}`].some((v) => v?.toLowerCase().includes(q)); -export default async function Runners({ searchParams }: { searchParams: Promise<{ error?: string; f?: string }> }) { +type Params = { error?: string; f?: string; q?: string; id?: string }; + +export default async function Runners({ searchParams }: { searchParams: Promise }) { const user = await requireUser(); - const { error, f } = await searchParams; + const { error, f, q: rawQ, id } = await searchParams; const filter = f && f in RUNNER_FILTERS ? (f as RunnerFilter) : undefined; - const all = await listUserSessions(db, user.id); - const count = (k: RunnerFilter | undefined) => (k ? all.filter((s) => (RUNNER_FILTERS[k] as string[]).includes(s.status)).length : all.length); - const shown = filter ? all.filter((s) => (RUNNER_FILTERS[filter] as string[]).includes(s.status)) : all; - const back = filter ? `/runners?f=${filter}` : "/runners"; + const q = rawQ?.trim().toLowerCase() ?? ""; + const [all, open] = await Promise.all([listUserSessions(db, user.id), inbox(user.id)]); + const asking = new Map(); + for (const x of open) if (x.sessionId) asking.set(x.sessionId, [...(asking.get(x.sessionId) ?? []), x]); + const needsPm = (s: SessionView) => s.status === "waiting_input" || asking.has(s.id); + + const found = q ? all.filter((s) => matches(s, q)) : all; + const count = (k: RunnerFilter | undefined) => (k ? found.filter((s) => inFilter(s, k)).length : found.length); + // Who needs the PM first, then live runners, then finished ones; newest first inside each group. + const rank = (s: SessionView) => (needsPm(s) ? 0 : ["done", "failed"].includes(s.status) ? 2 : 1); + const shown = (filter ? found.filter((s) => inFilter(s, filter)) : found).sort((a, b) => rank(a) - rank(b) || b.id - a.id); + + const url = (p: { f?: string; q?: string; id?: number | string }) => { + const sp = new URLSearchParams(); + if (p.f) sp.set("f", p.f); + if (p.q) sp.set("q", p.q); + if (p.id) sp.set("id", String(p.id)); + const s = sp.toString(); + return s ? `/runners?${s}` : "/runners"; + }; + const base = { f: filter, q: rawQ?.trim() || undefined }; + const selected = (id && all.find((s) => s.id === Number(id))) || shown[0]; + const back = url({ ...base, id: selected?.id }); + const aside = selected ? ( + + ) : null; + return ( - + - Агенты в tmux по задачам твоих и общих проектов. Подключиться к раннеру — команда tmux attach на машине Пеппы. - -
    - {shown.length === 0 ? {filter ? "Таких раннеров нет." : "Раннеров пока не было: перенеси задачу в «В работе» на доске проекта."} : shown.map((s) => )} + Агенты в tmux по задачам твоих и общих проектов: кто ждёт тебя, кто работает, что готово. +
    + +
    + {filter && } + + +
    + {shown.length === 0 ? ( + {q || filter ? "Таких раннеров нет." : "Раннеров пока не было: перенеси задачу в «В работе» на доске проекта."} + ) : ( +
      + {shown.map((s) => ( + + ))} +
    + )} ); } diff --git a/apps/web/components/LocalTime.tsx b/apps/web/components/LocalTime.tsx new file mode 100644 index 00000000..9bd49e62 --- /dev/null +++ b/apps/web/components/LocalTime.tsx @@ -0,0 +1,24 @@ +"use client"; + +import { useEffect, useRef } from "react"; + +/** HH:MM (with the date when not today) in the viewer's time zone; the server renders its own zone first. */ +export function LocalTime({ iso }: { iso: string }) { + const d = new Date(iso); + const today = new Date().toDateString() === d.toDateString(); + const time = d.toLocaleTimeString("ru-RU", { hour: "2-digit", minute: "2-digit" }); + return ( + + ); +} + +/** On narrow screens the side panel sits under the list: bring the chosen runner into view. */ +export function ScrollIntoViewOnNarrow({ id }: { id: string | number }) { + const ref = useRef(null); + useEffect(() => { + if (window.matchMedia("(max-width: 1279px)").matches) ref.current?.scrollIntoView({ block: "start" }); + }, [id]); + return ; +} diff --git a/apps/web/components/RunnerConsole.tsx b/apps/web/components/RunnerConsole.tsx new file mode 100644 index 00000000..7fd70724 --- /dev/null +++ b/apps/web/components/RunnerConsole.tsx @@ -0,0 +1,146 @@ +// 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. + ))} +
    +
    + )} +
    + ); +} diff --git a/apps/web/components/Workspace.tsx b/apps/web/components/Workspace.tsx index 2ea900f4..30bb2a48 100644 --- a/apps/web/components/Workspace.tsx +++ b/apps/web/components/Workspace.tsx @@ -1,13 +1,14 @@ import type { ReactNode } from "react"; import { ActivityAside } from "@/components/ActivityAside"; import { Footer } from "@/components/Footer"; +import { cn } from "@/lib/utils"; /** * Centre + right panel of the console (PEP-38). The page decides what the right panel shows; * without `aside` it gets the default activity panel, `aside={null}` hides it. - * Below xl the panel goes under the page content, the footer is always last. + * Below xl the panel goes under the page content (`asideWideOnly`: shown on xl only), the footer is always last. */ -export function Workspace({ children, aside }: { children: ReactNode; aside?: ReactNode }) { +export function Workspace({ children, aside, asideWideOnly = false }: { children: ReactNode; aside?: ReactNode; asideWideOnly?: boolean }) { const panel = aside === undefined ? : aside; return (
    @@ -15,7 +16,7 @@ export function Workspace({ children, aside }: { children: ReactNode; aside?: Re
    {children}
    {panel && ( -