- web board (Backlog / In progress / Review / Done) with drag-and-drop and buttons; moveTask starts an agent on In progress, stops on Backlog/Done - routine proposals go straight to apply; request_approval/ask_pm only for architectural stoppers (RULES.md, MCP hints, template pushed to Gitea) - Stop hook keeps the agent going (decision: block, max 2 in a row, sessions.auto_nudges reset by a human answer) instead of pinging the PM - review: ready-for-review message with Accept (acceptTask → done, session stopped) in Telegram and web; a text reply goes back to the agent - mock-claude honours Stop-hook block; 6 new e2e tests (48 total, green) - OpenSpec: pep-7 archived (task-autonomy, web-workspace board) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
3.2 KiB
TypeScript
85 lines
3.2 KiB
TypeScript
"use client";
|
||
|
||
import Link from "next/link";
|
||
import { useState, useTransition } from "react";
|
||
import { moveTaskCard } from "@/app/(app)/actions";
|
||
|
||
export type Column = "backlog" | "in_progress" | "review" | "done";
|
||
export interface Card {
|
||
key: string;
|
||
title: string;
|
||
status: string;
|
||
column: Column;
|
||
goal: string | null;
|
||
}
|
||
|
||
const COLUMNS: Array<{ id: Column; title: string; hint: string }> = [
|
||
{ id: "backlog", title: "Бэклог", hint: "" },
|
||
{ id: "in_progress", title: "В работе", hint: "сюда — запустить агента" },
|
||
{ id: "review", title: "Ревью", hint: "" },
|
||
{ id: "done", title: "Готово", hint: "" },
|
||
];
|
||
const STATUS: Record<string, string> = { proposing: "proposal", awaiting_approval: "ждёт PM", blocked: "блок", in_progress: "агент" };
|
||
const NEXT: Partial<Record<Column, { to: Column; label: string }>> = {
|
||
backlog: { to: "in_progress", label: "В работу →" },
|
||
review: { to: "done", label: "Принять ✓" },
|
||
};
|
||
|
||
/** Task 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={`board${pending ? " busy" : ""}`}>
|
||
{COLUMNS.map((c) => (
|
||
<section
|
||
key={c.id}
|
||
className={`col${over === c.id ? " over" : ""}`}
|
||
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>
|
||
{c.title} <span className="muted">{cards.filter((x) => x.column === c.id).length}</span>
|
||
</h3>
|
||
{c.hint && <p className="hint muted">{c.hint}</p>}
|
||
{cards
|
||
.filter((x) => x.column === c.id)
|
||
.map((card) => (
|
||
<article key={card.key} className="tcard" draggable onDragStart={(e) => e.dataTransfer.setData("text/plain", card.key)}>
|
||
<Link href={`/t/${card.key}`}>
|
||
<span className="mono">{card.key}</span> {card.title}
|
||
</Link>
|
||
<div className="row wrap">
|
||
{card.goal && <span className="goal muted">🎯 {card.goal}</span>}
|
||
{STATUS[card.status] && <span className={`badge s-${card.status}`}>{STATUS[card.status]}</span>}
|
||
{NEXT[c.id] && (
|
||
<button className="small" disabled={pending} onClick={() => move(card.key, NEXT[c.id]!.to)}>
|
||
{NEXT[c.id]!.label}
|
||
</button>
|
||
)}
|
||
</div>
|
||
</article>
|
||
))}
|
||
</section>
|
||
))}
|
||
</div>
|
||
);
|
||
}
|