peppa/apps/web/app/(app)/runners/page.tsx
Асель 412f5f05ce PEP-61: top menu — Home instead of Inbox, Runners and Projects pages
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 14:02:37 +05:00

41 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Link from "next/link";
import { listUserSessions, RUNNER_FILTERS, type RunnerFilter } from "@peppa/core";
import { AutoRefresh } from "@/components/AutoRefresh";
import { Flash, SessionCard } from "@/components/ui";
import { requireUser } from "@/lib/auth";
import { db } from "@/lib/db";
const FILTERS: Array<{ key: RunnerFilter | undefined; label: string }> = [
{ key: undefined, label: "Все" },
{ key: "waiting", label: "Ждут тебя" },
{ key: "working", label: "Работают" },
{ key: "stopped", label: "Остановлены" },
{ key: "finished", label: "Завершены" },
];
export default async function Runners({ searchParams }: { searchParams: Promise<{ error?: string; f?: string }> }) {
const user = await requireUser();
const { error, f } = 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";
return (
<>
<AutoRefresh />
<Flash error={error} />
<h1>Раннеры</h1>
<p className="muted">Агенты в tmux по задачам твоих и общих проектов. Подключиться к раннеру — команда tmux attach на машине Пеппы.</p>
<nav className="filters" aria-label="Фильтр раннеров">
{FILTERS.map((x) => (
<Link key={x.label} href={x.key ? `/runners?f=${x.key}` : "/runners"} className={x.key === filter ? "active" : undefined} aria-current={x.key === filter ? "page" : undefined}>
{x.label} <span className="muted">{count(x.key)}</span>
</Link>
))}
</nav>
{shown.length === 0 ? <p className="empty">{filter ? "Таких раннеров нет." : "Раннеров пока не было: перенеси задачу в «В работе» на доске проекта."}</p> : shown.map((s) => <SessionCard key={s.id} s={s} back={back} showTitle />)}
</>
);
}