- PEP-37: change hub (runner/live.ts) woken by notify() (new 'web' subscriber) and PRAGMA data_version; per-scope fingerprints; GET /api/live SSE (no-transform, ping 15 s); LiveRefresh replaces AutoRefresh with a connection indicator and polling fallback - PEP-33: async PostToolUse/PostToolUseFailure hook -> 'step' events (last 200 per session), AgentSteps live feed on the story page and runner panel, tasks.md progress on board cards and the story header - PEP-32: story page header + tabs Proposal/Design/Specs/Tasks/Comments/Tests/Merge request/Activity, safe Markdown renderer, PM comments visible in get_task, edit title/description/epic, accept-and-merge (acceptStory) - OpenSpec changes archived; specs live-updates, agent-steps, story-page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
135 lines
5.8 KiB
TypeScript
135 lines
5.8 KiB
TypeScript
"use client";
|
||
|
||
import Link from "next/link";
|
||
import { useState, useTransition } from "react";
|
||
import { moveTaskCard } from "@/app/(app)/actions";
|
||
import { Button } from "@/components/ui/button";
|
||
import { Badge } from "@/components/ui/badge";
|
||
import { cn } from "@/lib/utils";
|
||
|
||
export type Column = "backlog" | "in_progress" | "review" | "done";
|
||
export interface Card {
|
||
key: string;
|
||
title: string;
|
||
status: string;
|
||
column: Column;
|
||
/** Epic label (PEP-66), if the story has an open epic. */
|
||
epic?: string | null;
|
||
/** tasks.md progress of a story in work (PEP-33). */
|
||
progress?: CardProgress | null;
|
||
}
|
||
export interface CardProgress {
|
||
done: number;
|
||
total: number;
|
||
current: string | null;
|
||
}
|
||
|
||
/** «7/12» bar and the item the agent is on (PEP-33). */
|
||
export function ProgressLine({ p, className }: { p: CardProgress; className?: string }) {
|
||
const pct = p.total ? Math.round((p.done / p.total) * 100) : 0;
|
||
return (
|
||
<div className={cn("flex min-w-0 flex-col gap-1", className)} title={p.current ? `Сейчас: ${p.current}` : "Все пункты tasks.md выполнены"}>
|
||
<div className="flex items-center gap-2">
|
||
<div className="h-1 flex-1 overflow-hidden rounded-full bg-muted">
|
||
<div className="h-full rounded-full bg-info" style={{ width: `${pct}%` }} />
|
||
</div>
|
||
<span className="font-mono text-[11px] text-muted-foreground tabular-nums">
|
||
{p.done}/{p.total}
|
||
</span>
|
||
</div>
|
||
{p.current && <span className="truncate text-[11px] text-muted-foreground">{p.current}</span>}
|
||
</div>
|
||
);
|
||
}
|
||
|
||
const COLUMNS: Array<{ id: Column; title: string; hint: string; dot: string }> = [
|
||
{ id: "backlog", title: "Бэклог", hint: "", dot: "bg-muted-foreground" },
|
||
{ id: "in_progress", title: "В работе", hint: "сюда — запустить агента", dot: "bg-info" },
|
||
{ id: "review", title: "Ревью", hint: "", dot: "bg-ok" },
|
||
{ id: "done", title: "Готово", hint: "", dot: "bg-ok" },
|
||
];
|
||
const STATUS: Record<string, { label: string; tone: "primary" | "danger" | "info" }> = {
|
||
proposing: { label: "proposal", tone: "primary" },
|
||
awaiting_approval: { label: "ждёт PM", tone: "primary" },
|
||
blocked: { label: "блок", tone: "danger" },
|
||
in_progress: { label: "агент", tone: "info" },
|
||
};
|
||
const NEXT: Partial<Record<Column, { to: Column; label: string }>> = {
|
||
backlog: { to: "in_progress", label: "В работу →" },
|
||
review: { to: "done", label: "Принять ✓" },
|
||
};
|
||
|
||
/** Story board: drag a card (or use its button) to move it; the server starts/stops agents. */
|
||
export function Board({ cards, back }: { cards: Card[]; back: string }) {
|
||
const [pending, start] = useTransition();
|
||
const [over, setOver] = useState<Column | null>(null);
|
||
const move = (key: string, to: Column) => {
|
||
const f = new FormData();
|
||
f.set("taskKey", key);
|
||
f.set("to", to);
|
||
f.set("back", back);
|
||
start(() => moveTaskCard(f));
|
||
};
|
||
return (
|
||
<div className={cn("grid gap-3 sm:grid-cols-2 lg:grid-cols-4", pending && "pointer-events-none opacity-60")}>
|
||
{COLUMNS.map((c) => {
|
||
const list = cards.filter((x) => x.column === c.id);
|
||
return (
|
||
<section
|
||
key={c.id}
|
||
aria-label={c.title}
|
||
className={cn("flex min-h-32 flex-col gap-2 rounded-lg border bg-muted/40 p-2", over === c.id && "border-dashed border-primary bg-primary/5")}
|
||
onDragOver={(e) => {
|
||
e.preventDefault();
|
||
setOver(c.id);
|
||
}}
|
||
onDragLeave={() => setOver(null)}
|
||
onDrop={(e) => {
|
||
e.preventDefault();
|
||
setOver(null);
|
||
const key = e.dataTransfer.getData("text/plain");
|
||
const card = cards.find((x) => x.key === key);
|
||
if (card && card.column !== c.id) move(key, c.id);
|
||
}}
|
||
>
|
||
<h3 className="m-0 flex items-center gap-2 px-1.5 pt-1 font-mono text-[11px] font-semibold tracking-wider text-muted-foreground uppercase">
|
||
<span className={cn("size-1.5 rounded-full", c.dot)} />
|
||
{c.title}
|
||
<span className="ml-auto tabular-nums">{list.length}</span>
|
||
</h3>
|
||
{c.hint && <p className="m-0 px-1.5 text-[11px] text-muted-foreground">{c.hint}</p>}
|
||
{list.map((card) => (
|
||
<article
|
||
key={card.key}
|
||
draggable
|
||
onDragStart={(e) => e.dataTransfer.setData("text/plain", card.key)}
|
||
className="flex cursor-grab flex-col gap-2 rounded-md border bg-card p-2.5 text-sm shadow-xs transition-colors hover:border-primary/40 active:cursor-grabbing"
|
||
>
|
||
<Link href={`/t/${card.key}`} className="text-foreground hover:no-underline">
|
||
<span className="font-mono text-xs text-primary">{card.key}</span> {card.title}
|
||
</Link>
|
||
{card.progress && <ProgressLine p={card.progress} />}
|
||
{(STATUS[card.status] || NEXT[c.id] || card.epic) && (
|
||
<div className="flex flex-wrap items-center gap-1.5">
|
||
{card.epic && (
|
||
<Badge variant="outline" className="max-w-full min-w-0" title={`Эпик: ${card.epic}`}>
|
||
<span className="truncate">{card.epic}</span>
|
||
</Badge>
|
||
)}
|
||
{STATUS[card.status] && <Badge variant={STATUS[card.status]!.tone}>{STATUS[card.status]!.label}</Badge>}
|
||
{NEXT[c.id] && (
|
||
<Button size="xs" className="ml-auto" disabled={pending} onClick={() => move(card.key, NEXT[c.id]!.to)}>
|
||
{NEXT[c.id]!.label}
|
||
</Button>
|
||
)}
|
||
</div>
|
||
)}
|
||
</article>
|
||
))}
|
||
</section>
|
||
);
|
||
})}
|
||
</div>
|
||
);
|
||
}
|