Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions js/faviconStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@ import { app } from "/scripts/app.js";
// Simple script that adds the current queue size to the window title
// Adds a favicon that changes color while active

const id = "pysssss.FaviconStatus";

app.registerExtension({
name: "pysssss.FaviconStatus",
name: id,
setup() {
let progressEnabled = false;

api.addEventListener("status", ({ detail }) => {
let title = "ComfyUI";
let favicon = "favicon";
let title = "ComfyUI";
if (detail && detail.exec_info.queue_remaining) {
favicon += "-active";
title = `(${detail.exec_info.queue_remaining}) ${title}`;
}
document.title = title;

if (!progressEnabled) {
document.title = title;
}

let link = document.querySelector("link[rel~='icon']");
if (!link) {
Expand All @@ -25,5 +32,24 @@ app.registerExtension({

link.href = new URL(`assets/${favicon}.ico`, import.meta.url);
});
api.addEventListener("progress", ({ detail }) => {
let title = "ComfyUI";
if (detail && detail.value && detail.max) {
title = `(${Math.floor(detail.value/detail.max*100)}%) ${title}`;
}
if (progressEnabled) {
document.title = title;
}
});

app.ui.settings.addSetting({
id,
name: "🐍 Show progress in title",
defaultValue: false,
type: "boolean",
onChange(value) {
progressEnabled = value;
},
});
},
});