From 328900e254138c27500f5f9c1d5ce4f671c4b000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=81=D0=B5=D0=BB=D1=8C?= Date: Sat, 14 Nov 2026 03:21:20 +0500 Subject: [PATCH] =?UTF-8?q?PEP-66:=20epics=20(goals=20as=20story=20labels)?= =?UTF-8?q?,=20tabs=20=D0=9A=D0=BE=D0=B4/=D0=A1=D0=BF=D0=B5=D0=BA=D0=B8/PR?= =?UTF-8?q?,=20bug=20settings=20in=20=E2=8B=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- apps/web/app/(app)/actions.ts | 31 ++++- apps/web/app/(app)/p/[key]/page.tsx | 108 +++++++++++---- apps/web/app/(app)/p/[key]/tabs.tsx | 199 ++++++++++++++++++++++++++++ apps/web/components/Board.tsx | 11 +- apps/web/components/Incidents.tsx | 152 +++++++++++---------- packages/core/src/gitea.ts | 35 ++++- packages/core/src/incidents.ts | 4 +- packages/core/src/index.ts | 1 + packages/core/src/projects.ts | 9 ++ packages/core/src/specs.ts | 27 ++++ packages/mcp/src/format.ts | 10 +- packages/mcp/src/index.ts | 57 ++++---- packages/mcp/src/manager.ts | 142 ++++++++++---------- packages/runner/src/code.ts | 101 ++++++++++++++ packages/runner/src/index.ts | 1 + packages/testkit/src/mock-gitea.ts | 26 ++++ 16 files changed, 710 insertions(+), 204 deletions(-) create mode 100644 apps/web/app/(app)/p/[key]/tabs.tsx create mode 100644 packages/core/src/specs.ts create mode 100644 packages/runner/src/code.ts diff --git a/apps/web/app/(app)/actions.ts b/apps/web/app/(app)/actions.ts index e1a0e926..f8a016a6 100644 --- a/apps/web/app/(app)/actions.ts +++ b/apps/web/app/(app)/actions.ts @@ -2,7 +2,9 @@ import { linkEgovIin, + createEpic, createTask, + updateEpic, getQuestion, getSession, PeppaError, @@ -78,12 +80,37 @@ export async function addTask(f: FormData) { const user = await requireUser(); await attempt(f, async () => { const p = await projectForUser(db, user.id, Number(str(f, "projectId"))); - if (!str(f, "title")) throw new PeppaError("Нужно название задачи"); - const ref = await createTask(db, { projectId: p.id, title: str(f, "title"), description: str(f, "description") || undefined }); + if (!str(f, "title")) throw new PeppaError("Нужно название стори"); + const epic = Number(str(f, "epicId")) || undefined; + const ref = await createTask(db, { projectId: p.id, title: str(f, "title"), description: str(f, "description") || undefined, goalId: epic }); return `/t/${ref.key}`; }); } +/** Epics (PEP-66): labels that group stories; stored in the goals table. */ +export async function addEpic(f: FormData) { + const user = await requireUser(); + await attempt(f, async () => { + const p = await projectForUser(db, user.id, Number(str(f, "projectId"))); + if (str(f, "title").length < 2) throw new PeppaError("Нужно название эпика"); + await createEpic(db, p.id, str(f, "title"), str(f, "description") || undefined); + }); +} + +export async function editEpic(f: FormData) { + const user = await requireUser(); + await attempt(f, async () => { + const p = await projectForUser(db, user.id, Number(str(f, "projectId"))); + const id = Number(str(f, "epicId")); + if (str(f, "archive")) { + await updateEpic(db, p.id, id, { status: "archived" }); + return; + } + if (str(f, "title").length < 2) throw new PeppaError("Нужно название эпика"); + await updateEpic(db, p.id, id, { title: str(f, "title"), description: str(f, "description") || null }); + }); +} + export async function startTaskSession(f: FormData) { const user = await requireUser(); await attempt(f, async () => { diff --git a/apps/web/app/(app)/p/[key]/page.tsx b/apps/web/app/(app)/p/[key]/page.tsx index 67c7e3bc..d2c55983 100644 --- a/apps/web/app/(app)/p/[key]/page.tsx +++ b/apps/web/app/(app)/p/[key]/page.tsx @@ -1,16 +1,16 @@ import { notFound } from "next/navigation"; import { ExternalLink, Plus, Rocket } from "lucide-react"; -import { columnOf, currentReleases, describeRepo, isPlatform, listReleases, bugsinkWebhookBase, platformReleaseCandidate, platformReleaseOffers, type Release } from "@peppa/runner"; -import { getIncidentSettings, listErrorSources, listIncidents, listMembers, repoAudience, repoVisibilityLabel } from "@peppa/core"; +import { columnOf, currentReleases, describeRepo, isPlatform, listReleases, bugsinkWebhookBase, openPulls, platformReleaseCandidate, platformReleaseOffers, repoOverview, type Release } from "@peppa/runner"; +import { getIncidentSettings, listEpics, listErrorSources, listIncidents, listMembers, listSpecs, repoAudience, repoVisibilityLabel } from "@peppa/core"; import { AutoRefresh } from "@/components/AutoRefresh"; import { PanelSection } from "@/components/ActivityAside"; import { Board, type Card } from "@/components/Board"; import { Hidden, SessionCard } from "@/components/cards"; import { Empty, Flash, Key, Notice, PageHeader, Section } from "@/components/common"; -import { IncidentsSection } from "@/components/Incidents"; +import { IncidentSettingsPanel, IncidentsSection } from "@/components/Incidents"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; -import { Input, Textarea } from "@/components/ui/input"; +import { Input, NativeSelect, Textarea } from "@/components/ui/input"; import { SettingsDialog } from "@/components/SettingsDialog"; import { Workspace } from "@/components/Workspace"; import { requireUser } from "@/lib/auth"; @@ -18,6 +18,7 @@ import { cn } from "@/lib/utils"; import { db } from "@/lib/db"; import { board, projectForUserByKey, projectSessions } from "@/lib/queries"; import { addProjectMember, addTask, deployProdAction, grantRepoAccessToMembers, removeProjectMember } from "../../actions"; +import { CodeTab, EpicsPanel, PullsTab, SpecsTab } from "./tabs"; const RELEASE_STATUS: Record = { deploying: { label: "выкатывается", tone: "info" }, @@ -29,6 +30,9 @@ const RELEASE_STATUS: Record; searchParams: Promise<{ error?: string; created?: string; tab?: string }> }) { +export default async function ProjectPage({ params, searchParams }: { params: Promise<{ key: string }>; searchParams: Promise<{ error?: string; created?: string; tab?: string; epic?: string }> }) { const user = await requireUser(); const { key } = await params; - const { error, created, tab: tabParam } = await searchParams; + const { error, created, tab: tabParam, epic: epicParam } = await searchParams; const tab = TABS.find((t) => t.id === tabParam)?.id ?? "board"; const p = await projectForUserByKey(user.id, key).catch(() => null); if (!p) notFound(); - const [{ tasks }, sessions, team, repo, incidentSettings, sources, incidents, releases, current] = await Promise.all([ + const [{ tasks }, epics, sessions, team, repo, incidentSettings, sources, incidents, releases, current] = await Promise.all([ board(p.id), + listEpics(db, p.id), projectSessions(p.id), listMembers(db, p), describeRepo(db, p), @@ -80,13 +85,23 @@ export default async function ProjectPage({ params, searchParams }: { params: Pr repo.collaborators !== null && login.toLowerCase() !== p.giteaOwner.toLowerCase() && !collaborators.has(login.toLowerCase()); const missingAccess = team.members.some((m) => noRepoAccess(m.login)); const isOwner = p.ownerId === user.id; - const back = tab === "board" ? `/p/${p.key}` : `/p/${p.key}?tab=${tab}`; - const cards: Card[] = tasks.map((t) => ({ - key: `${p.key}-${t.number}`, - title: t.title, - status: t.status, - column: columnOf(t.status), - })); + // Epic filter (PEP-66): only an open epic of this project filters; anything else shows all. + const epicFilter = epics.find((e) => String(e.id) === epicParam) ?? null; + const boardHref = (epicId?: number) => (epicId ? `/p/${p.key}?epic=${epicId}` : `/p/${p.key}`); + const back = tab === "board" ? boardHref(epicFilter?.id) : `/p/${p.key}?tab=${tab}`; + const epicTitle = new Map(epics.map((e) => [e.id, e.title])); + const cards: Card[] = tasks + .filter((t) => !epicFilter || t.goalId === epicFilter.id) + .map((t) => ({ + key: `${p.key}-${t.number}`, + title: t.title, + status: t.status, + column: columnOf(t.status), + epic: t.goalId ? (epicTitle.get(t.goalId) ?? null) : null, + })); + // Gitea and the working copy are read only for the open tab. + const [code, pulls] = await Promise.all([tab === "code" ? repoOverview(db, p) : null, tab === "pulls" ? openPulls(db, p) : null]); + const specs = tab === "specs" ? listSpecs(p) : []; const aside = (
@@ -115,6 +130,21 @@ export default async function ProjectPage({ params, searchParams }: { params: Pr + + + + + + + +
  • @@ -173,6 +203,14 @@ export default async function ProjectPage({ params, searchParams }: { params: Pr