fix(gsd): preserve paused auto badge after provider pause (#4062)

This commit is contained in:
mastertyko 2026-04-13 14:05:59 +02:00 committed by GitHub
parent ae1bcc572d
commit 65ba0fc30b
2 changed files with 34 additions and 3 deletions

View file

@ -677,9 +677,13 @@ function cleanupAfterLoopExit(ctx: ExtensionContext): void {
logWarning("session", `lock cleanup failed: ${err instanceof Error ? err.message : String(err)}`, { file: "auto.ts" });
}
ctx.ui.setStatus("gsd-auto", undefined);
ctx.ui.setWidget("gsd-progress", undefined);
ctx.ui.setFooter(undefined);
// A transient provider-error pause intentionally leaves the paused badge
// visible so the user still has a resumable auto-mode signal on screen.
if (!s.paused) {
ctx.ui.setStatus("gsd-auto", undefined);
ctx.ui.setWidget("gsd-progress", undefined);
ctx.ui.setFooter(undefined);
}
// Restore CWD out of worktree back to original project root
if (s.originalBasePath) {

View file

@ -0,0 +1,27 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const autoSource = readFileSync(join(__dirname, "..", "auto.ts"), "utf-8");
test("#3370: cleanupAfterLoopExit preserves paused auto badge after provider pause", () => {
const cleanupIdx = autoSource.indexOf("function cleanupAfterLoopExit");
assert.ok(cleanupIdx > -1, "auto.ts should define cleanupAfterLoopExit");
const dispatchIdx = autoSource.indexOf("export async function dispatchHookUnit", cleanupIdx);
assert.ok(dispatchIdx > cleanupIdx, "cleanupAfterLoopExit body should be bounded by the next export");
const cleanupBody = autoSource.slice(cleanupIdx, dispatchIdx);
const pausedGuardIdx = cleanupBody.indexOf("if (!s.paused) {");
const clearStatusIdx = cleanupBody.indexOf('ctx.ui.setStatus("gsd-auto", undefined);');
assert.ok(pausedGuardIdx > -1, "loop-exit cleanup must guard UI clearing when auto is paused");
assert.ok(clearStatusIdx > pausedGuardIdx, "status clearing must live behind the paused guard");
assert.ok(
autoSource.includes('ctx?.ui.setStatus("gsd-auto", "paused");'),
"pauseAuto must still set the paused badge for transient provider pauses",
);
});