Files
kajan988 bc8cb2007c Add kill-all keybind command with toast, silent kill route, bump to v0.0.6
Register a native ComfyUI command (assignable in Settings > Keybindings, no default combo) that kills all comfy-env isolation workers, shows a green success toast, and logs the count. Rewrite /workerkeeper/kill_all to use the silent _shutdown_worker path so no comfy-env shutdown noise appears. Add WEB_DIRECTORY and js/killall.js frontend extension with a WorkerKeeper settings group.
2026-07-20 09:56:45 +03:00

56 lines
1.9 KiB
JavaScript

import { app } from "../../scripts/app.js";
import { api } from "../../scripts/api.js";
const SETTING_TOAST = "workerkeeper.showToast";
app.registerExtension({
name: "workerkeeper.killall",
settings: [
{
id: SETTING_TOAST,
name: "Show toast notification",
category: ["WorkerKeeper", "General"],
type: "boolean",
defaultValue: true,
},
],
commands: [
{
id: "workerkeeper.killAll",
label: "WorkerKeeper: Kill all isolation workers",
icon: "pi pi-times-circle",
function: async () => {
let killed = 0;
try {
const res = await api.fetchApi("/workerkeeper/kill_all", { method: "POST" });
const data = await res.json();
killed = data.killed ?? 0;
} catch (e) {
console.error("[WorkerKeeper] kill_all failed", e);
app.extensionManager.toast.add({
severity: "error",
summary: "WorkerKeeper",
detail: "Failed to kill workers (see console).",
life: 4000,
});
return;
}
console.info(`[WorkerKeeper] killed ${killed} isolation worker(s)`);
const showToast = app.extensionManager.setting.get(SETTING_TOAST);
if (showToast !== false) {
app.extensionManager.toast.add({
severity: "success",
summary: "WorkerKeeper",
detail: killed
? `Killed ${killed} isolation worker(s).`
: "No live isolation workers.",
life: 3000,
});
}
},
},
],
});