fix(sf): guard progress widget cleanup

This commit is contained in:
Mikael Hugo 2026-05-08 07:17:29 +02:00
parent 10694440e3
commit 0cfe839f7a
2 changed files with 15 additions and 3 deletions

View file

@ -688,7 +688,7 @@ function handleLostSessionLock(ctx, lockStatus) {
: `Session lock lost (${lockFilePath}). Stopping gracefully.${recoverySuggestion}`;
ctx?.ui.notify(message, "error");
ctx?.ui.setStatus("sf-auto", undefined);
ctx?.ui?.setWidget?.("sf-progress", undefined);
safeSetWidget(ctx, "sf-progress", undefined);
ctx?.ui.setFooter(undefined);
if (ctx) initHealthWidget(ctx);
}
@ -1069,7 +1069,7 @@ export async function stopAuto(ctx, pi, reason) {
resetProactiveHealing();
// UI cleanup
ctx?.ui.setStatus("sf-auto", undefined);
ctx?.ui?.setWidget?.("sf-progress", undefined);
safeSetWidget(ctx, "sf-progress", undefined);
ctx?.ui.setFooter(undefined);
if (ctx) initHealthWidget(ctx);
restoreProjectRootEnv();
@ -1219,7 +1219,7 @@ export async function pauseAuto(ctx, _pi, _errorContext) {
s.pendingVerificationRetry = null;
s.verificationRetryCount.clear();
ctx?.ui.setStatus("sf-auto", "paused");
ctx?.ui?.setWidget?.("sf-progress", undefined);
safeSetWidget(ctx, "sf-progress", undefined);
ctx?.ui.setFooter(undefined);
if (ctx) initHealthWidget(ctx);
const resumeCmd = s.stepMode ? "/next" : "/autonomous";

View file

@ -1,3 +1,5 @@
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, it, vi } from "vitest";
import { safeSetWidget } from "../widget-safe.js";
@ -33,4 +35,14 @@ describe("safeSetWidget", () => {
placement: "belowEditor",
});
});
it("auto_runtime_uses_safeSetWidget_for_progress_widget_cleanup", () => {
const autoSource = readFileSync(
join(process.cwd(), "src/resources/extensions/sf/auto.js"),
"utf8",
);
expect(autoSource).not.toMatch(/\.setWidget\?\.\(/);
expect(autoSource).not.toMatch(/\.setWidget\(/);
});
});