diff --git a/apps/web/components/cards.tsx b/apps/web/components/cards.tsx index 47eb7afe..148c1594 100644 --- a/apps/web/components/cards.tsx +++ b/apps/web/components/cards.tsx @@ -1,7 +1,7 @@ // Domain cards shared by pages: agent questions, runners, project list. import Link from "next/link"; import { BellRing, CircleCheck, CircleHelp, FileCheck, Hourglass, Play, RotateCcw, Send, ShieldQuestion, Square, SquareTerminal } from "lucide-react"; -import { questionState, type Project, type Question, type SessionView, type StepView } from "@peppa/core"; +import { questionState, questionType, type Project, type Question, type SessionView, type StepView } from "@peppa/core"; import { db } from "@/lib/db"; import { SubscriptionName } from "@/components/SubscriptionName"; import { answerQuestion, messageSession, resumeTaskSession, stopTaskSession } from "@/app/(app)/actions"; @@ -37,6 +37,7 @@ export async function QuestionCard({ q, taskKey, taskStatus, back, compact = fal const t = await getT(); const review = q.kind === "attention" && taskStatus === "review"; const answered = !!q.answeredAt; + const notice = questionType(q, taskStatus) === null && q.taskId == null && q.sessionId == null; // PEP-149: a factory message with answers to choose from is a question for the person. const k = KIND[q.kind === "attention" && !review && q.options?.length ? "question" : q.kind]; const Icon = review ? CircleCheck : k.icon; @@ -71,12 +72,13 @@ export async function QuestionCard({ q, taskKey, taskStatus, back, compact = fal

{t("Повторов: {n} · первое сообщение {ago}", { n: state.repeats, ago: ago(q.createdAt, t) })}

)} + {/* PEP-149: a notice about the product as a whole (released, backlog is empty) asks nothing — no answer form. */} {answered ? (

{q.answeredVia === "system" ? : } {q.answeredVia === "system" ? t.text(q.answer) : t("Ответ ({via}): {answer}", { via: q.answeredVia, answer: q.answer })}

- ) : ( + ) : notice ? null : (
diff --git a/packages/testkit/test/agent-messages.test.ts b/packages/testkit/test/agent-messages.test.ts index 473f241d..48b51672 100644 --- a/packages/testkit/test/agent-messages.test.ts +++ b/packages/testkit/test/agent-messages.test.ts @@ -130,6 +130,21 @@ describe("Тип сообщения определяет маршрут", () => assert.equal(core.questionEvent(failure, { taskStatus: "review" }), "review"); }); + test("Сообщения «продукт обновлён» и «бэклог пуст» — не вопросы", async () => { + const tp = await project({ turns: [] }); + const p = await core.getProject(db, tp.key); + for (const text of ["🚀 Shop: ваш продукт обновлён и открыт для всех", "📭 Shop: все задачи сделаны, бэклог пуст — агентам нечего делать."]) { + const q = await core.askPmProject(db, p, { kind: "attention", text }); + assert.equal(q.msgType, null); + assert.equal(core.needsPerson(q), false, "not in «Ждут вашего ответа», not counted, no push"); + // Telegram: a plain notice — no buttons to press. + assert.deepEqual(renderQuestion(q, { taskKey: null, taskTitle: null, session: null, webUrl: "http://peppa.test" }).buttons, []); + } + // The offer to release has an answer to choose: it is a question. + const offer = await core.askPmProject(db, p, { kind: "question", text: "Показать всем?", options: ["🚀 Показать всем"] }); + assert.equal(core.needsPerson(offer), true); + }); + test("Счётчик открытых вопросов чата считает только вопросы", async () => { const tp = await project({ turns: [] }); const p = await core.getProject(db, tp.key);