import Link from "next/link"; import { Search, X } from "lucide-react"; import type { ThreadList, ThreadRow } from "@peppa/core"; import { AgentBadge } from "@/components/AgentBadge"; import { ago, StatusBadge } from "@/components/common"; import { Hidden } from "@/components/cards"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { getT } from "@/lib/i18n"; import { words } from "@/lib/auth"; import { cn } from "@/lib/utils"; const COUNT = "rounded-full px-1.5 font-mono text-[11px] leading-4 font-semibold tabular-nums"; /** * PEP-155: the conversations of a project chat — the chat with the analyst and the agents' events * on top, then story threads in groups «Ждут вас», «В работе», «Готово» (folded), with a search. */ export async function ChatThreadList({ base, list, active, discussion, feed, raw, }: { /** `/chats/` */ base: string; list: ThreadList; /** The open thread's key, if a thread is open. */ active: string | null; discussion: boolean; feed: boolean; /** The `thread` parameter as it is in the URL: the search keeps the open conversation. */ raw: string | null; }) { const t = await getT(); const w = await words(); const q = list.q; const href = (thread: string | null) => { const p = new URLSearchParams(); if (thread) p.set("thread", thread); if (q) p.set("q", q); return p.size ? `${base}?${p}` : base; }; const total = list.waiting.length + list.working.length + list.done.length; const rows = (items: ThreadRow[]) => items.map((r) => ); return ( ); } function GroupTitle({ children, count, tone = "bg-muted text-muted-foreground" }: { children: React.ReactNode; count: number; tone?: string }) { return (

{children} {count > 0 && {count}}

); } function Plain({ href, active, title, meta }: { href: string; active: boolean; title: string; meta: string }) { return ( {title} {meta} ); } async function Row({ r, href, active }: { r: ThreadRow; href: string; active: boolean }) { const t = await getT(); const title = r.taskKey ? r.title : t.text(r.title); return ( {r.taskKey && {r.taskKey}} 0) && "font-medium")} title={title}> {title} {r.open > 0 && ( ? )} {r.unread > 0 && ( {r.unread > 99 ? "99+" : r.unread} )} {(r.status || r.agentName || r.lastAt) && ( {r.status && } {r.agentName && } {r.lastAt && {ago(r.lastAt, t)}} )} {r.last && ( {r.last.mine && t("вы") + ": "} {r.last.system ? t.text(r.last.text) : r.last.text} )} ); }