From 50b63cbafa471a1901f8613d651cd6f09422c077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=81=D0=B5=D0=BB=D1=8C?= Date: Sun, 15 Nov 2026 18:00:53 +0500 Subject: [PATCH] =?UTF-8?q?PEP-120:=20story=20page=20in=20=C2=AB=D0=9F?= =?UTF-8?q?=D1=80=D0=BE=D0=B4=D0=B0=D0=BA=D1=82=C2=BB=20mode=20=E2=80=94?= =?UTF-8?q?=20plain=20card,=20=C2=AB=D0=9F=D0=BE=D0=B4=D1=80=D0=BE=D0=B1?= =?UTF-8?q?=D0=BD=D0=B5=D0=B5=C2=BB,=20=C2=AB=D0=9F=D0=BE=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5.2 --- apps/web/app/(app)/actions.ts | 12 +- apps/web/app/(app)/t/[key]/page.tsx | 144 ++++++++++++------ apps/web/components/StoryProduct.tsx | 103 +++++++++++++ .../pep-120-story-product-view/design.md | 8 +- .../pep-120-story-product-view/tasks.md | 8 +- packages/core/src/index.ts | 1 + packages/core/src/story-product.ts | 94 ++++++++++++ packages/runner/src/flow.ts | 25 ++- packages/testkit/test/story-product.test.ts | 107 +++++++++++++ 9 files changed, 445 insertions(+), 57 deletions(-) create mode 100644 apps/web/components/StoryProduct.tsx create mode 100644 packages/core/src/story-product.ts create mode 100644 packages/testkit/test/story-product.test.ts diff --git a/apps/web/app/(app)/actions.ts b/apps/web/app/(app)/actions.ts index c92a609b..53ab3b60 100644 --- a/apps/web/app/(app)/actions.ts +++ b/apps/web/app/(app)/actions.ts @@ -63,7 +63,7 @@ import { } from "@peppa/core"; import { bugsinkFromEnv } from "@peppa/bugsink"; import { loadEnv } from "@peppa/shared"; -import { acceptStory, budgetChanged, resolveTaskById, deployProd, bugsinkWebhookBase, connectErrorTracking, decideIncident, resolveIncident, acceptTask, answerAndDeliver, grantRepoAccess, moveTask, provisionProject, projectNamespace, setProjectVisibility, shareProject, unshareProject, type BoardColumn, resumeSession, sendToSession, startSession, stopSession, type Provider, startFreeRunner, renameRunner, promoteRunner, queueTaskOnRunner, managesProject, saveAgentsMd, cancelOwnLogin, finishOwnClaudeLogin, connectOwnSubscription, removeOwnSubscription, type OwnSubscriptionKind, chooseSharedSubscription } from "@peppa/runner"; +import { acceptStory, fixStory, budgetChanged, resolveTaskById, deployProd, bugsinkWebhookBase, connectErrorTracking, decideIncident, resolveIncident, acceptTask, answerAndDeliver, grantRepoAccess, moveTask, provisionProject, projectNamespace, setProjectVisibility, shareProject, unshareProject, type BoardColumn, resumeSession, sendToSession, startSession, stopSession, type Provider, startFreeRunner, renameRunner, promoteRunner, queueTaskOnRunner, managesProject, saveAgentsMd, cancelOwnLogin, finishOwnClaudeLogin, connectOwnSubscription, removeOwnSubscription, type OwnSubscriptionKind, chooseSharedSubscription } from "@peppa/runner"; import { revalidatePath } from "next/cache"; import { redirect } from "next/navigation"; import { asWebActor, requireUser, words } from "@/lib/auth"; @@ -189,6 +189,16 @@ export async function acceptStoryAction(f: FormData) { }); } +/** «Поправить» on the story page in «Продакт» mode (PEP-120): the remark goes to the agent, the story — back to work. */ +export async function fixStoryAction(f: FormData) { + const user = asWebActor(await requireUser()); + await attempt(f, async () => { + const ref = await resolveTask(db, str(f, "taskKey")); + await projectForUser(db, user.id, ref.project.id); + await fixStory(db, ref, user, String(f.get("text") ?? "")); + }); +} + /** PEP-67: a superadmin may pick a pool or tick subscriptions; otherwise the project's pool. */ async function launchChoice(f: FormData, user: Awaited>) { const choice = (await isSuperadmin(db, user)) ? str(f, "choice") : ""; diff --git a/apps/web/app/(app)/t/[key]/page.tsx b/apps/web/app/(app)/t/[key]/page.tsx index a4703c23..34be378d 100644 --- a/apps/web/app/(app)/t/[key]/page.tsx +++ b/apps/web/app/(app)/t/[key]/page.tsx @@ -3,7 +3,7 @@ import { Markdown } from "@/components/Markdown"; import Link from "next/link"; import { notFound } from "next/navigation"; -import { Archive, ArchiveRestore, CircleCheck, CircleX, GitPullRequest, Hourglass, Lock, Pencil, Play, X } from "lucide-react"; +import { Archive, ArchiveRestore, ChevronDown, ChevronRight, CircleCheck, CircleX, GitPullRequest, Hourglass, Lock, Pencil, Play, X } from "lucide-react"; import { blockersOf, dependentsOf, @@ -30,6 +30,7 @@ import { readChange, reviewLabel, reviewPreview, + storyProductView, sessionSteps, refinePending, storyComments, @@ -51,7 +52,8 @@ import { Button } from "@/components/ui/button"; import { Input, NativeSelect, Textarea } from "@/components/ui/input"; import { Workspace } from "@/components/Workspace"; import { ReviewPreview } from "@/components/ReviewPreview"; -import { requireUser } from "@/lib/auth"; +import { requireUser, uiMode } from "@/lib/auth"; +import { StoryProduct } from "@/components/StoryProduct"; import { db } from "@/lib/db"; import { taskActivity, taskForUser } from "@/lib/queries"; import { cn } from "@/lib/utils"; @@ -68,7 +70,7 @@ async function gateWithTimeout(ref: Parameters[0]): Promise null), new Promise((r) => setTimeout(() => r(null), 5000))]); } -export default async function StoryPage({ params, searchParams }: { params: Promise<{ key: string }>; searchParams: Promise<{ error?: string; tab?: string; edit?: string }> }) { +export default async function StoryPage({ params, searchParams }: { params: Promise<{ key: string }>; searchParams: Promise<{ error?: string; tab?: string; edit?: string; more?: string }> }) { const user = await requireUser(); const { key } = await params; const sp = await searchParams; @@ -90,7 +92,10 @@ export default async function StoryPage({ params, searchParams }: { params: Prom const epic = task.goalId ? (epics.find((e) => e.id === task.goalId) ?? (await getEpic(db, project.id, task.goalId).catch(() => null))) : null; const tab: StoryTab = STORY_TABS.find((t) => t.id === sp.tab)?.id ?? (change ? "proposal" : "comments"); const tabHref = (id: StoryTab) => `/t/${ref.key}?tab=${id}`; - const back = tabHref(tab); + // PEP-120: «Продакт» sees one plain card; the rest of the page opens by «Подробнее» (?more=1, a tab or the edit form). + const engineer = (await uiMode()) === "engineer"; + const detailsOpen = engineer || !!(sp.more || sp.tab || sp.edit); + const back = engineer || sp.tab ? tabHref(tab) : detailsOpen ? `/t/${ref.key}?more=1` : `/t/${ref.key}`; const preview = await reviewPreview(db, ref); const [blockers, dependents] = await Promise.all([blockersOf(db, ref), dependentsOf(db, ref)]); // PEP-67: superadmins choose the subscriptions a runner may take; others run on the project's pool. @@ -199,31 +204,7 @@ export default async function StoryPage({ params, searchParams }: { params: Prom ); - return ( - - - - - {project.name} - {epic && ( - <> - / - - эпик «{epic.title}» - - - )} - - } - title={ - <> - {ref.key} {task.title} - {task.archivedAt && в архиве} - - } - actions={ + const headerActions = ( <> - } - > - - {task.openspecChange ? ( - - {task.openspecChange} - {change?.archived && в архиве} - - ) : ( - change ещё нет - )} - {progress?.total ? ( - - - - ) : null} - - + ); + // What a product manager reads first: open questions (the «готово к ревью» message is the card's own buttons). + const productQuestions = questions.filter((q) => !q.answeredAt && !(q.kind === "attention" && task.status === "review")).reverse(); + const productView = storyProductView({ + status: task.status, + archived: !!task.archivedAt, + progress, + agentWorking: !!live, + agentName: live?.agentName, + openQuestions: productQuestions.length, + refining, + waitsFor: blockers.filter((b) => b.open).map((b) => b.title), + }); + + const body = ( + <> {refining && (

{refining === "waiting" ? "Аналитик ждёт ваших ответов" : "Продакт и аналитик уточняют задачу"} @@ -403,6 +382,77 @@ export default async function StoryPage({ params, searchParams }: { params: Prom {tab === "merge" && } {tab === "activity" && } + + ); + + return ( + + + + + {project.name} + {epic && ( + <> + / + + эпик «{epic.title}» + + + )} + + } + title={ + <> + {ref.key} {task.title} + {task.archivedAt && в архиве} + + } + actions={engineer ? headerActions : undefined} + > + {engineer && ( + + {task.openspecChange ? ( + + {task.openspecChange} + {change?.archived && в архиве} + + ) : ( + change ещё нет + )} + {progress?.total ? ( + + + + ) : null} + + )} + + + {engineer ? ( + body + ) : ( + <> + + + {detailsOpen ? : } + Подробнее + + {detailsOpen && ( +

+
{headerActions}
+ {body} +
{aside}
+
+ )} + + )}
); } diff --git a/apps/web/components/StoryProduct.tsx b/apps/web/components/StoryProduct.tsx new file mode 100644 index 00000000..08d6fba0 --- /dev/null +++ b/apps/web/components/StoryProduct.tsx @@ -0,0 +1,103 @@ +// PEP-120: the story page for a product manager — one card: what is happening now and +// «шаг N из M», the link to look at the result, what is needed from them, what comes next, +// «Принять» and «Поправить». Everything of a developer stays under «Подробнее» on the page. +import { Check, Eye, Pencil, Send } from "lucide-react"; +import type { Question, ReviewPreview, StoryProductView } from "@peppa/core"; +import { Hidden, QuestionCard } from "@/components/cards"; +import { Button } from "@/components/ui/button"; +import { Textarea } from "@/components/ui/input"; +import { cn } from "@/lib/utils"; +import { acceptStoryAction, fixStoryAction } from "@/app/(app)/actions"; + +export function StoryProduct({ view, taskKey, taskStatus, preview, questions, back }: { view: StoryProductView; taskKey: string; taskStatus: string; preview: ReviewPreview; questions: Question[]; back: string }) { + const pct = view.step ? Math.round(((view.step.n - 1) / view.step.m) * 100) : 0; + return ( +
+
+

{view.now}

+ {view.step && ( +
+
+ + Шаг {view.step.n} из {view.step.m} + +
+
+
+
+ {view.stepText &&

Сейчас: {view.stepText}

} +
+ )} +
+ + {preview.previewUrl && ( +
+ +

Откроется версия для проверки — её видите только вы.

+ {preview.releaseId != null && preview.screenshots.length > 0 && ( +
+ {preview.screenshots.slice(0, 3).map((s) => { + const src = `/api/releases/${preview.releaseId}/shots/${s.n}`; + return ( + + {/* eslint-disable-next-line @next/next/no-img-element */} + Снимок экрана + + ); + })} +
+ )} +
+ )} + +
+
Что нужно от вас
+
{view.need ?? "От вас сейчас ничего не нужно."}
+
Что дальше
+
{view.next}
+
+ + {questions.map((q) => ( + + ))} + + {(view.canAccept || view.canFix) && ( +
+ {view.canAccept && ( +
+ + + + )} + {view.canFix && ( +
+ + + Поправить + +
+ + +