mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-17 04:45:33 -08:00
Refuse a quick-task finish that offers the review again once a review ran in that launch
AI Assisted
This commit is contained in:
1 parent
d599d87669
commit
2f790027a9
2 files changed
+47
No files matched your search
@@ -56,6 +56,8 @@ import {
|
|||||||
ask,
|
ask,
|
||||||
until,
|
until,
|
||||||
clientFor,
|
clientFor,
|
||||||
|
consoleSession,
|
||||||
|
postPatch,
|
||||||
} from "./web-console-test-helpers.mjs";
|
} from "./web-console-test-helpers.mjs";
|
||||||
|
|
||||||
let sid;
|
let sid;
|
||||||
@@ -1559,6 +1561,27 @@ test("finish.changelog is accepted on quick-task and finalize, and refused on im
|
|||||||
assert.deepEqual(problems("implement", true, "Paused at Phase 2"), []);
|
assert.deepEqual(problems("implement", true, "Paused at Phase 2"), []);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// A quick task once re-posted its finish with Review it now after every
|
||||||
|
// review, so each press started the same review again.
|
||||||
|
test("a quick-task finish offering the review again after one ran in that launch is refused", () => {
|
||||||
|
const s = consoleSession(["--workflow", "quick-task"]);
|
||||||
|
try {
|
||||||
|
const finish = (review) => ({ finish: { headline: "Built", command: "git add -A", ...(review ? { review: true } : {}), dashboard: true } });
|
||||||
|
assert.equal(postPatch(s, finish(true)).status, 0, "before any review, the finish offers it");
|
||||||
|
assert.equal(postPatch(s, { finish: null, run: { event: "review", id: "review" } }).status, 0);
|
||||||
|
const again = postPatch(s, finish(true), { expectFail: true });
|
||||||
|
assert.equal(again.status, 3);
|
||||||
|
assert.match(again.stderr, /finish\.review: a review already ran in this quick task/);
|
||||||
|
assert.equal(postPatch(s, finish(false)).status, 0, "the finish without review goes through");
|
||||||
|
// A new launch starts clean.
|
||||||
|
cli(["open", "--resume", s.sid, "--no-open", "--workflow", "dashboard"]);
|
||||||
|
cli(["open", "--resume", s.sid, "--no-open", "--workflow", "quick-task"]);
|
||||||
|
assert.equal(postPatch(s, finish(true)).status, 0, "a new quick task may offer its own review");
|
||||||
|
} finally {
|
||||||
|
cli(["stop", "--session", s.sid, "--force"]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Update CHANGELOG first is a hop like Commit it now, into Changelog.
|
// Update CHANGELOG first is a hop like Commit it now, into Changelog.
|
||||||
test("a changelog request from a finished screen carries the resume into the changelog workflow and its skill file", async () => {
|
test("a changelog request from a finished screen carries the resume into the changelog workflow and its skill file", async () => {
|
||||||
await post("/submit", {
|
await post("/submit", {
|
||||||
|
|||||||
@@ -220,6 +220,7 @@ function postOnce() {
|
|||||||
delete patch.folderIssue;
|
delete patch.folderIssue;
|
||||||
const reread = liftReread(patch, before.workflow);
|
const reread = liftReread(patch, before.workflow);
|
||||||
const ledgerLines = ledgerFromPost(dir, run, folderIssue, before.workflow);
|
const ledgerLines = ledgerFromPost(dir, run, folderIssue, before.workflow);
|
||||||
|
refuseReviewAgain(dir, patch.finish, ledgerLines, before.workflow);
|
||||||
// Taken before the lock: git processes must not run while it is held.
|
// Taken before the lock: git processes must not run while it is held.
|
||||||
const snap = reread === undefined ? null : snapshot(before.worktree || repoRoots().worktree, { prHosts: readPrHosts() });
|
const snap = reread === undefined ? null : snapshot(before.worktree || repoRoots().worktree, { prHosts: readPrHosts() });
|
||||||
|
|
||||||
@@ -323,6 +324,29 @@ export function gitBlock(snap, reread, previous) {
|
|||||||
return { ...snap, refreshFailed };
|
return { ...snap, refreshFailed };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A quick task whose review already ran in this launch ends on a finish
|
||||||
|
* without `review` (building-review.md, "The way back out"). Offering
|
||||||
|
* Review it now again sends the person round the same review for as long as
|
||||||
|
* they press it, which happened once: exit 3 instead.
|
||||||
|
*/
|
||||||
|
export function refuseReviewAgain(dir, finish, ledgerLines, workflow) {
|
||||||
|
if (workflow !== "quick-task" || !finish || typeof finish !== "object" || !finish.review) return;
|
||||||
|
const ledger = readLedger(dir);
|
||||||
|
const launch = lastLaunchId(ledger);
|
||||||
|
const reviewed = [...ledger, ...ledgerLines].some((e) => e.kind === "run" && e.event === "review" && String(e.id).startsWith(`${launch}:`));
|
||||||
|
if (!reviewed) return;
|
||||||
|
die(
|
||||||
|
rule(
|
||||||
|
"",
|
||||||
|
"finish.review",
|
||||||
|
'a review already ran in this quick task, so offering it again only loops. Post "Check the fixes" if anything was fixed, then the finish without "review" (building-review.md, "The way back out")',
|
||||||
|
{ finish: { headline: "The review is done", doc: "review", commit: true, changelog: true, dashboard: true } },
|
||||||
|
),
|
||||||
|
3,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ledger lines a post's `run` and `folderIssue` stand for, or exit 3 on
|
* The ledger lines a post's `run` and `folderIssue` stand for, or exit 3 on
|
||||||
* the first bad one. Ids are scoped by the skill run in progress, so the same
|
* the first bad one. Ids are scoped by the skill run in progress, so the same
|
||||||
|
|||||||
Reference in new issue
Block a user