- 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>
75 lines
3.4 KiB
TypeScript
75 lines
3.4 KiB
TypeScript
import { notFound } from "next/navigation";
|
||
import { loadEnv } from "@peppa/shared";
|
||
import { AutoRefresh } from "@/components/AutoRefresh";
|
||
import { Flash, SessionCard } from "@/components/ui";
|
||
import { Board, type Card } from "@/components/Board";
|
||
import { columnOf } from "@peppa/runner";
|
||
import { requireUser } from "@/lib/auth";
|
||
import { board, projectForUserByKey, projectSessions } from "@/lib/queries";
|
||
import { addGoal, addTask } from "../../actions";
|
||
|
||
export default async function ProjectPage({ params, searchParams }: { params: Promise<{ key: string }>; searchParams: Promise<{ error?: string }> }) {
|
||
const user = await requireUser();
|
||
const { key } = await params;
|
||
const { error } = await searchParams;
|
||
const p = await projectForUserByKey(user.id, key).catch(() => null);
|
||
if (!p) notFound();
|
||
const [{ goals, tasks }, sessions] = await Promise.all([board(p.id), projectSessions(p.id)]);
|
||
const back = `/p/${p.key}`;
|
||
const groups = [...goals.map((g) => ({ goal: g })), { goal: null }];
|
||
const goalTitle = new Map(goals.map((g) => [g.id, g.title]));
|
||
const cards: Card[] = tasks.map((t) => ({
|
||
key: `${p.key}-${t.number}`,
|
||
title: t.title,
|
||
status: t.status,
|
||
column: columnOf(t.status),
|
||
goal: t.goalId ? (goalTitle.get(t.goalId) ?? null) : null,
|
||
}));
|
||
return (
|
||
<>
|
||
<AutoRefresh />
|
||
<Flash error={error} />
|
||
<h1>
|
||
<span className="mono">{p.key}</span> {p.name}
|
||
</h1>
|
||
<p className="muted">
|
||
<a href={`${loadEnv().GITEA_URL}/${p.giteaOwner}/${p.giteaRepo}`}>{p.giteaOwner}/{p.giteaRepo}</a> · <span className="mono">{p.workspacePath}</span>
|
||
</p>
|
||
|
||
<Board cards={cards} back={back} />
|
||
|
||
{groups.map(({ goal }) => (
|
||
<details key={goal?.id ?? "none"} className="add">
|
||
<summary>+ Задача{goal ? ` · 🎯 ${goal.title}` : " без цели"}</summary>
|
||
<form action={addTask} className="stack">
|
||
<input type="hidden" name="projectId" value={p.id} />
|
||
<input type="hidden" name="back" value={back} />
|
||
{goal && <input type="hidden" name="goalId" value={goal.id} />}
|
||
<input type="text" name="title" required placeholder="Что сделать" aria-label="Название задачи" />
|
||
<textarea name="description" rows={3} placeholder="Описание: контекст, критерии готовности" aria-label="Описание задачи" />
|
||
<button className="primary">Создать задачу</button>
|
||
</form>
|
||
</details>
|
||
))}
|
||
|
||
<section>
|
||
<details>
|
||
<summary>+ Цель</summary>
|
||
<form action={addGoal} className="stack">
|
||
<input type="hidden" name="projectId" value={p.id} />
|
||
<input type="hidden" name="back" value={back} />
|
||
<input type="text" name="title" required placeholder="Верхнеуровневая цель" aria-label="Название цели" />
|
||
<textarea name="description" rows={3} placeholder="Зачем и какой результат" aria-label="Описание цели" />
|
||
<button className="primary">Создать цель</button>
|
||
</form>
|
||
</details>
|
||
</section>
|
||
|
||
<section>
|
||
<h2>Сессии</h2>
|
||
{sessions.length === 0 ? <p className="empty">Сессий ещё не было.</p> : sessions.map((s) => <SessionCard key={s.id} s={s} back={back} />)}
|
||
</section>
|
||
</>
|
||
);
|
||
}
|