Skip to content

Add option for progress percent in doc Title #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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;
},
});
},
});