diff --git a/packages/core/src/tasks.ts b/packages/core/src/tasks.ts index 0eded9cf..3c5be9b7 100644 --- a/packages/core/src/tasks.ts +++ b/packages/core/src/tasks.ts @@ -361,13 +361,13 @@ export async function askPm(db: Db, ref: TaskRef, { topic, head, details, ...q } // PEP-154: no service text (tags, command output, paths) in what the person reads. const original = q.text; q = { ...q, text: messageText(q.kind, q.text) }; + // The status goes BEFORE the question: an answer that comes at once (it moves the story on) + // must not be overwritten by a late «awaiting approval» (cjm «rejected proposal» raced here). + if (q.kind === "approval") await updateTask(db, ref, { status: "awaiting_approval" }, q.sessionId); // PEP-151: the same state of the story again refreshes the earlier message instead of adding one. const row = await raiseOnce(db, { projectId: ref.project.id, taskId: ref.task.id, sessionId: q.sessionId ?? null, kind: q.kind, text: q.text, options: q.options, topic, head }, async () => { return insertQuestion(db, { projectId: ref.project.id, taskId: ref.task.id, ...q, msgType: q.msgType ?? defaultMessageType(q) }, details); }); - // The status goes right after the question: an answer that comes at once (it moves the story - // on) must not be overwritten by a late «awaiting approval». - if (q.kind === "approval") await updateTask(db, ref, { status: "awaiting_approval" }, q.sessionId); // PEP-152: the details follow the message (a refreshed one gets the fresh details). if (details !== undefined) await setMessageDetails(db, row.id, details); await keepQuestionDetails(db, row.id, original, q.text).catch(() => {});