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): only roll back a usage-limited run in a worktree that was clean
Zhuowei Wang8013bd0303a7
diff --git a/tools/linear-autofix/README.md b/tools/linear-autofix/README.mdindex dd33914..6a8b878 100644--- a/tools/linear-autofix/README.md+++ b/tools/linear-autofix/README.md@@ -235,8 +235,11 @@ reports none. During the pause:- Triage and implementation are skipped, and no review fix round starts.- Review checks keep running, since they do not need Claude: merged PRs,finished reviews and waiting PRs are still handled.-- A ticket cut off mid-run loses that run's commits and uncommitted changes.- The first tick after the reset starts it again from where the run started.+- A ticket cut off mid-run loses that run's commits and uncommitted changes,+ provided its worktree was clean when the run started. The first tick after+ the reset starts it again from where the run started. A worktree that already+ had uncommitted changes is left untouched, since they may be someone's; the+ ticket then stops on the dirty worktree and needs a human.`node src/cli.mjs status` shows the pause, and `node src/cli.mjs resume` clearsit early (for example after adding usage). The run's own `AUTOFIX_*_BUDGET_USD`diff --git a/tools/linear-autofix/src/claude.test.mjs b/tools/linear-autofix/src/claude.test.mjsindex cd86252..aeed43c 100644--- a/tools/linear-autofix/src/claude.test.mjs+++ b/tools/linear-autofix/src/claude.test.mjs@@ -208,6 +208,20 @@ process.stdin.on("end", () => {fs.writeFileSync(path.join(repo, "a.txt"), "by hand\n");await assert.rejects(runCodeClaude(repo, run), UsageLimitError);assert.equal(fs.readFileSync(path.join(repo, "a.txt"), "utf8"), "by hand\n");++ // Dirty before the run: the run is cut off, but nothing is discarded.+ clearUsagePause();+ fs.writeFileSync(path.join(repo, "mine.txt"), "untracked by hand\n");+ const original = console.warn;+ console.warn = () => {};+ try {+ await assert.rejects(runCodeClaude(repo, run), UsageLimitError);+ } finally {+ console.warn = original;+ }+ assert.notEqual(git("rev-parse", "HEAD"), start);+ assert.ok(fs.existsSync(path.join(repo, "mine.txt")));+ assert.ok(fs.existsSync(path.join(repo, "new.txt")));clearUsagePause();});diff --git a/tools/linear-autofix/src/implement.mjs b/tools/linear-autofix/src/implement.mjsindex cfa3c02..68ba64e 100644--- a/tools/linear-autofix/src/implement.mjs+++ b/tools/linear-autofix/src/implement.mjs@@ -54,9 +54,12 @@ export const CODE_TOOLS = [* Run Claude with the code tools in a worktree. A run cut off by the usage limit* leaves half-finished work, so it is dropped: the retry after the reset starts* from the same commit as this run, and never mistakes it for a finished fix.+ * Only a worktree that was clean before the run is rolled back; changes already+ * there may be someone's, so a dirty one is left as it is for a human.*/export async function runCodeClaude(dir, options) {const before = await git.headSha(dir);+ const cleanBefore = !(await git.isDirty(dir));try {return await runClaude({...options,@@ -66,7 +69,11 @@ export async function runCodeClaude(dir, options) {});} catch (err) {if (err instanceof UsageLimitError && err.duringRun) {- await git.discardTo(dir, before);+ if (cleanBefore) await git.discardTo(dir, before);+ else+ console.warn(+ `${dir} had uncommitted changes before the run; leaving the cut-off run's work in place`,+ );}throw err;}