peppa/apps/web/components/ActivityAside.tsx
Асель 28fbde4add PEP-38: console foundation — Tailwind v4, shadcn/ui components, dark theme, three-panel layout
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 16:21:43 +05:00

65 lines
3.3 KiB
TypeScript
Raw Permalink 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 { ago } from "@/components/ui";
import { requireUser } from "@/lib/auth";
import { activeSessions, inbox } from "@/lib/queries";
import { SESSION_STATUS, TONE_BG } from "@/lib/status";
import { cn } from "@/lib/utils";
/** Default right panel: what waits for the PM and what is running now. */
export async function ActivityAside({ questions = true }: { questions?: boolean }) {
const user = await requireUser();
const [items, sessions] = await Promise.all([questions ? inbox(user.id) : [], activeSessions(user.id)]);
return (
<div className="flex flex-col gap-6">
{questions && (
<PanelSection title="Ждут тебя" count={items.length} href="/" more="на Главную">
{items.length === 0 ? (
<p className="text-sm text-muted-foreground">Агентам ничего не нужно.</p>
) : (
items.slice(0, 6).map((q) => (
<Link key={q.id} href={q.taskKey ? `/t/${q.taskKey}` : "/"} className="block rounded-md border border-primary/25 bg-primary/5 px-3 py-2 text-sm text-foreground hover:border-primary/50 hover:no-underline">
<span className="font-mono text-xs text-primary">{q.taskKey ?? `#${q.id}`}</span>{" "}
<span className="line-clamp-2 text-muted-foreground">{q.text}</span>
</Link>
))
)}
</PanelSection>
)}
<PanelSection title="Активные раннеры" count={sessions.length} href="/runners" more="все">
{sessions.length === 0 ? (
<p className="text-sm text-muted-foreground">Сейчас ничего не запущено.</p>
) : (
sessions.slice(0, 12).map((s) => {
const st = SESSION_STATUS[s.status] ?? { label: s.status, tone: "muted" as const };
return (
<Link key={s.id} href={`/runners?id=${s.id}`} className="flex items-center gap-2 rounded-md px-2 py-1.5 text-sm text-foreground hover:bg-accent hover:no-underline">
<span className={cn("size-2 shrink-0 rounded-full", TONE_BG[st.tone], s.status === "running" && "animate-pulse")} title={st.label} />
<span className="shrink-0 font-mono text-xs">{s.taskKey ?? s.projectKey}</span>
<span className="min-w-0 flex-1 truncate text-muted-foreground">{s.taskTitle}</span>
<span className="shrink-0 font-mono text-[11px] text-muted-foreground">{ago(s.lastActivityAt)}</span>
</Link>
);
})
)}
</PanelSection>
</div>
);
}
export function PanelSection({ title, count, href, more, children }: { title: string; count?: number; href?: string; more?: string; children: React.ReactNode }) {
return (
<section className="flex flex-col gap-2">
<h2 className="m-0 flex items-center gap-2 font-mono text-[11px] font-semibold tracking-wider text-muted-foreground uppercase">
{title}
{count != null && count > 0 && <span className="rounded bg-muted px-1.5 text-foreground tabular-nums">{count}</span>}
{href && more && (
<Link href={href} className="ml-auto font-sans text-xs font-normal tracking-normal normal-case text-muted-foreground hover:text-foreground">
{more} →
</Link>
)}
</h2>
{children}
</section>
);
}