Skip to content

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.

fix(tools): baseline PR comments at creation/adoption, refuse reset while the branch is checked out

Zhuowei Wang0b1b80fce541
diff --git a/tools/linear-autofix/src/cli.mjs b/tools/linear-autofix/src/cli.mjs
index 573b6f9..62baa80 100755
--- a/tools/linear-autofix/src/cli.mjs
+++ b/tools/linear-autofix/src/cli.mjs
@@ -99,6 +99,9 @@ async function reset(requested, deleteRemote) {
`${pr.url} is still open; close it before resetting ${identifier}`,
);
}
+ // Refuse before anything is removed: with the branch checked out in the main
+ // checkout, deleting it would fail after the worktree was already gone.
+ await git.assertMainCheckoutNotOn(branch);
const dir = worktreePath(identifier);
await git.removeWorktree(dir);
console.log(`worktree removed: ${dir}`);
diff --git a/tools/linear-autofix/src/implement.mjs b/tools/linear-autofix/src/implement.mjs
index dadad97..e93a85a 100644
--- a/tools/linear-autofix/src/implement.mjs
+++ b/tools/linear-autofix/src/implement.mjs
@@ -226,6 +226,7 @@ export async function publish(record) {
}),
draft,
});
+ prInfo.createdNow = true;
note(record, "pr created", prInfo.url);
}
record.pr = {
@@ -233,7 +234,12 @@ export async function publish(record) {
url: prInfo.url,
draft: prInfo.isDraft ?? draft,
};
- record.review = { rounds: 0 };
+ // Comments cannot predate the PR, so "now" misses nothing for a PR the bot
+ // just created; a PR that already existed keeps its earlier comments visible.
+ record.review = {
+ rounds: 0,
+ commentsSeenAt: prInfo.createdNow ? new Date().toISOString() : "",
+ };
record.consecutiveErrors = 0;
if (["Backlog", "Todo"].includes(record.linearState)) {
diff --git a/tools/linear-autofix/src/review.mjs b/tools/linear-autofix/src/review.mjs
index bd394c3..9323c61 100644
--- a/tools/linear-autofix/src/review.mjs
+++ b/tools/linear-autofix/src/review.mjs
@@ -122,8 +122,9 @@ export async function review(issue, record) {
);
}
// Conversation comments are answered once: everything up to the newest one
- // handled so far has been seen. Adopted/created PRs start from now.
- record.review.commentsSeenAt ??= new Date().toISOString();
+ // handled so far has been seen. The baseline is set when the PR is created
+ // (publish) or adopted (tick); a record without one sees every comment.
+ record.review.commentsSeenAt ??= "";
const prComments = freshPrComments(pr.comments, record.review.commentsSeenAt);
const verdict = assessHead({
pr,
diff --git a/tools/linear-autofix/src/threads.test.mjs b/tools/linear-autofix/src/threads.test.mjs
index a404391..8b69854 100644
--- a/tools/linear-autofix/src/threads.test.mjs
+++ b/tools/linear-autofix/src/threads.test.mjs
@@ -134,4 +134,9 @@ test("freshPrComments keeps only human conversation comments newer than the base
);
assert.equal(freshPrComments(comments, "2026-11-02T05:00:00Z").length, 0);
assert.equal(freshPrComments(comments, null).length, 3);
+ assert.equal(
+ freshPrComments(comments, "").length,
+ 3,
+ "an empty baseline sees every human comment",
+ );
});
diff --git a/tools/linear-autofix/src/tick.mjs b/tools/linear-autofix/src/tick.mjs
index 85c8a10..9eecabf 100644
--- a/tools/linear-autofix/src/tick.mjs
+++ b/tools/linear-autofix/src/tick.mjs
@@ -114,7 +114,8 @@ export async function tick() {
url: existing.url,
draft: existing.isDraft,
};
- record.review = { rounds: 0 };
+ // Adopted PRs may already carry human comments: see them all.
+ record.review = { rounds: 0, commentsSeenAt: "" };
transition(
record,
"in_review",