The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.
JavaScript agent-skillsai-agentautomationbrowserbrowser-automationclaude-codecodexhermes-agentskillsskills-sh
fix(tools): reopen the review loop when a human comments on a finished PR
Zhuowei Wang5627d289f657
diff --git a/tools/linear-autofix/README.md b/tools/linear-autofix/README.mdindex 6724165..73ccda6 100644--- a/tools/linear-autofix/README.md+++ b/tools/linear-autofix/README.md@@ -234,6 +234,11 @@ blocks `done` and waits for a human, but does not trigger another fix round.If CI or the Codex review has not reported for a head within two hours theticket escalates rather than finishing, since both run on every PR here.+`done` is not final while the PR is open: every tick still looks at finished+PRs, and a new human review thread or conversation comment puts the ticket back+into the review loop, so a comment left after the bot declared the PR clean is+still acted on. Once the PR is merged or closed the ticket is left alone.+Codex skips draft PRs, so a draft (Windows ticket) with green CI and no threadsis reported on Linear as _ready for Windows verification_ and waits for a humanto mark it ready; the loop then resumes.diff --git a/tools/linear-autofix/src/review.mjs b/tools/linear-autofix/src/review.mjsindex f7fbcec..a73b272 100644--- a/tools/linear-autofix/src/review.mjs+++ b/tools/linear-autofix/src/review.mjs@@ -14,6 +14,7 @@ import * as linear from "./linear.mjs";import {note,runDir,+ save,transition,usagePausedUntil,worktreePath,@@ -95,14 +96,58 @@ export function assessHead({};}+/**+ * Describe feedback that arrived on a finished PR, or null when there is none.+ * Pure. `threads` are the fresh unresolved review threads, `prComments` the+ * conversation comments newer than the bot's baseline.+ */+export function pendingFeedback(threads, prComments) {+ const parts = [];+ if (threads.length) parts.push(`${threads.length} review thread(s)`);+ if (prComments.length) parts.push(`${prComments.length} comment(s)`);+ return parts.length ? parts.join(", ") : null;+}++/**+ * A `done` ticket is finished only until a human comments on its PR again.+ * While the PR is open, look for new review threads or conversation comments+ * and put the ticket back into the review loop when there are any. Once the PR+ * is merged or closed, remember that and stop asking GitHub.+ */+export async function watchDone(record) {+ if (!record.pr?.number || record.pr.state) return false;+ const pr = await github.viewPr(record.pr.number);+ if (pr.state !== "OPEN") {+ record.pr.state = pr.state;+ save(record);+ return false;+ }+ const { fresh } = splitThreads(await github.reviewThreads(pr.number));+ const prComments = freshPrComments(+ pr.comments,+ record.review?.commentsSeenAt ?? "",+ );+ const feedback = pendingFeedback(fresh, prComments);+ if (!feedback) return false;+ record.review ??= { rounds: 0 };+ transition(+ record,+ "in_review",+ `new feedback on the finished PR ${pr.url}: ${feedback}`,+ );+ return true;+}+export async function review(issue, record) {const pr = await github.viewPr(record.pr.number);record.pr.draft = pr.isDraft;if (pr.state === "MERGED") {+ record.pr.state = pr.state;await git.removeWorktree(worktreePath(record.identifier));return transition(record, "done", `PR merged ${pr.url}`);}if (pr.state === "CLOSED") {+ record.pr.state = pr.state;return transition(record, "done", `PR closed without merge ${pr.url}`);}await flushE2eComment(record, pr.number);diff --git a/tools/linear-autofix/src/review.test.mjs b/tools/linear-autofix/src/review.test.mjsindex 5816001..0fd7c3e 100644--- a/tools/linear-autofix/src/review.test.mjs+++ b/tools/linear-autofix/src/review.test.mjs@@ -1,6 +1,6 @@import assert from "node:assert/strict";import { test } from "node:test";-import { assessHead } from "./review.mjs";+import { assessHead, pendingFeedback } from "./review.mjs";const clean = {body: "<!-- codex-review -->\n## 🤖 Codex Review · `abcd1234`\n<sub>x</sub>\nNo issues found that require changes.",@@ -155,3 +155,12 @@ test("new human PR conversation comments start a fix round", () => {assert.deepEqual(r.problems, ["comments"]);assert.equal(r.action, "fix");});++test("a finished PR reopens on new threads or comments, and only then", () => {+ assert.equal(pendingFeedback([], []), null);+ assert.equal(pendingFeedback([{ id: "t" }], []), "1 review thread(s)");+ assert.equal(+ pendingFeedback([{ id: "t" }], [{ body: "a" }, { body: "b" }]),+ "1 review thread(s), 2 comment(s)",+ );+});diff --git a/tools/linear-autofix/src/tick.mjs b/tools/linear-autofix/src/tick.mjsindex be3d2dc..53a4d3f 100644--- a/tools/linear-autofix/src/tick.mjs+++ b/tools/linear-autofix/src/tick.mjs@@ -14,7 +14,7 @@ import {} from "./state.mjs";import { triage } from "./triage.mjs";import { implement } from "./implement.mjs";-import { review } from "./review.mjs";+import { review, watchDone } from "./review.mjs";import { clearErrors, recordError } from "./actions.mjs";import { flushTickLog } from "./journal.mjs";@@ -118,6 +118,12 @@ export async function tick() {}));console.log(`stages: ${stageCounts(work.map((w) => w.record))}`);+ // 0. Finished PRs that are still open: a human comment reopens the loop.+ for (const { record } of work.filter((w) => w.record.stage === "done")) {+ if (stopRequested()) return;+ await guarded(record, () => watchDone(record));+ }+// 1. Review loops first: cheap checks that may finish a PR.for (const { issue, record } of work.filter((w) => w.record.stage === "in_review",