PEP-149: «product released» and «backlog is empty» notices ask nothing — no answer form; test
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
165b486547
commit
4dec8247a2
@ -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
|
||||
<p className="m-0 mt-1">{t("Повторов: {n} · первое сообщение {ago}", { n: state.repeats, ago: ago(q.createdAt, t) })}</p>
|
||||
</details>
|
||||
)}
|
||||
{/* PEP-149: a notice about the product as a whole (released, backlog is empty) asks nothing — no answer form. */}
|
||||
{answered ? (
|
||||
<p className="m-0 flex items-center gap-1.5 text-sm text-muted-foreground">
|
||||
{q.answeredVia === "system" ? <Hourglass className="size-3.5" /> : <CircleCheck className="size-3.5 text-ok" />}
|
||||
{q.answeredVia === "system" ? t.text(q.answer) : t("Ответ ({via}): {answer}", { via: q.answeredVia, answer: q.answer })}
|
||||
</p>
|
||||
) : (
|
||||
) : notice ? null : (
|
||||
<form action={answerQuestion} className="flex flex-col gap-2">
|
||||
<Hidden fields={{ questionId: q.id, back }} />
|
||||
<div className="flex flex-wrap gap-2">
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user