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): resume only PRs into the base branch; read the newest thread comments
Zhuowei Wang061a6ba83cc1
diff --git a/tools/linear-autofix/src/github.mjs b/tools/linear-autofix/src/github.mjsindex ea24bbb..a9bbfeb 100644--- a/tools/linear-autofix/src/github.mjs+++ b/tools/linear-autofix/src/github.mjs@@ -38,11 +38,28 @@ export async function findPr(branch) {"--json","number,url,state,isDraft,baseRefName,createdAt",]);- if (!prs.length) return null;- return (- prs.find((p) => p.state === "OPEN") ??- prs.sort((a, b) => b.createdAt.localeCompare(a.createdAt))[0]- );+ return pickPr(prs, config.baseBranch);+}++/**+ * The PR the bot may resume for a branch: an open PR targeting the base+ * branch, else the most recent closed one, else null. An open PR that+ * targets another branch is not the bot's to touch, and pushing the branch+ * would modify it, so that case throws. Pure.+ */+export function pickPr(prs, baseBranch) {+ if (!prs?.length) return null;+ const open = prs.filter((p) => p.state === "OPEN");+ const mine = open.find((p) => p.baseRefName === baseBranch);+ if (mine) return mine;+ if (open.length) {+ throw new Error(+ `${open[0].url} is open against ${open[0].baseRefName}, not ${baseBranch}; the bot only works on PRs into ${baseBranch}`,+ );+ }+ return [...prs].sort((a, b) =>+ String(b.createdAt).localeCompare(String(a.createdAt)),+ )[0];}function dry(what) {@@ -122,7 +139,7 @@ export async function reviewThreads(number) {pageInfo{ hasNextPage endCursor }nodes{id isResolved isOutdated path line- comments(first:50){ nodes{ id body createdAt author{ login } } }+ comments(last:50){ nodes{ id body createdAt author{ login } } }}}} }diff --git a/tools/linear-autofix/src/triage.test.mjs b/tools/linear-autofix/src/triage.test.mjsindex 988389a..160f73c 100644--- a/tools/linear-autofix/src/triage.test.mjs+++ b/tools/linear-autofix/src/triage.test.mjs@@ -11,7 +11,7 @@ import fs from "node:fs";import os from "node:os";import path from "node:path";import { parseJsonBlock, renderPrompt } from "./claude.mjs";-import { ciStatus } from "./github.mjs";+import { ciStatus, pickPr } from "./github.mjs";test("validateTriage normalizes a good result and rejects bad ones", () => {const t = validateTriage({@@ -158,3 +158,41 @@ test("sharesScope compares the first two path segments and refuses empty brancheassert.equal(sharesScope(["docs/x.md"], []), true);assert.equal(sharesScope([], ["package/ego-browser/src/b.ts"]), false);});++test("pickPr resumes only an open PR into the base branch and refuses one into another branch", () => {+ const dev = {+ number: 1,+ url: "u1",+ state: "OPEN",+ baseRefName: "dev",+ createdAt: "2026-11-01T00:00:00Z",+ };+ const main = {+ number: 2,+ url: "u2",+ state: "OPEN",+ baseRefName: "main",+ createdAt: "2026-11-02T00:00:00Z",+ };+ const closed = {+ number: 3,+ url: "u3",+ state: "CLOSED",+ baseRefName: "dev",+ createdAt: "2026-10-01T00:00:00Z",+ };+ const older = {+ number: 4,+ url: "u4",+ state: "MERGED",+ baseRefName: "dev",+ createdAt: "2026-09-01T00:00:00Z",+ };+ assert.equal(pickPr([closed, dev, main], "dev"), dev);+ assert.throws(+ () => pickPr([main, closed], "dev"),+ /open against main, not dev/,+ );+ assert.equal(pickPr([older, closed], "dev"), closed);+ assert.equal(pickPr([], "dev"), null);+});