Files
gsusgg-ComfyUI_CozyGen/js/web/cozygen_choice_input.js
gsusgg 7da9b874be Dev2 (#6)
* Fix page not loading if no choice_type

* Chain lora ipmrovements, workflows work but need to test further.

* More improvement of lora bypass function.Might be stable

* 1 feat: Add video output and enhance responsive UI
    2                                                                                      3 This commit introduces two major sets of changes: a new video                          output node and significant improvements to the UI layout and                          responsiveness.
    4                                                                                      5 Video Output:
    6 - Adds a new  node to save image batches as
      video files (webm, mp4, or gif).
    7 - Implements a  WebSocket message to notify
      the frontend upon completion.
    8 - Adds  and  as dependencies for video
      encoding.
    9                                                                                     10 UI Enhancements:                                                                    11 - Reduces padding and vertical spacing across all main UI
      components for a more compact and unified layout.
   12 - Adds a new  screen breakpoint () to the Tailwind CSS
      configuration.
   13 - Updates the controls form to use the new  breakpoint,
      improving the two-column layout on smaller screens.

* moved pagination controls in gallery to top,added options for per page load amount.

* added video/audio/gif support initial. most load and play, investigating outliers

* feat: Add video output, gallery sorting, and UI layout improvements

* Removed webp support for now, verified i2v and t2v work with basic nodes (should work anywhere, but ya know), fixed video playback not loading in preview (still doesnt show if page is unloaded during generation, but will save to gallery)

* ui update for static generate button, broke out input nodes to reduce complexity(dynamicinputnodes still function), improved model population of dropdowns with new choice input node

* fixed bugs, completed example workflows

* fixed max int stuck at 2048

* fixed >1 batch size image preview

* added qwen image edit example,bypass option now disables dropdown

* Update2 commit

* readme update

* cleanup
2025-09-24 12:16:32 -05:00

56 lines
2.2 KiB
JavaScript

import { app } from "../../scripts/app.js";
// Helper function to get choices from the backend API
async function getChoices(choiceType) {
try {
const response = await fetch(`/cozygen/get_choices?type=${choiceType}`);
if (!response.ok) {
throw new Error(`Failed to fetch choices: ${response.statusText}`);
}
const data = await response.json();
return data.choices || [];
} catch (error) {
console.error(`CozyGenChoiceInput: Error fetching choices for type '${choiceType}':`, error);
return [];
}
}
app.registerExtension({
name: "CozyGen.ChoiceInput",
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData.name === "CozyGenChoiceInput") {
// This function is called when the node is created in the graph
const onNodeCreated = nodeType.prototype.onNodeCreated;
nodeType.prototype.onNodeCreated = async function () {
onNodeCreated?.apply(this, arguments);
const choiceTypeWidget = this.widgets.find((w) => w.name === "choice_type");
const valueWidget = this.widgets.find((w) => w.name === "value"); // The hidden value widget
const bypassWidget = this.widgets.find((w) => w.name === "display_bypass");
if (!choiceTypeWidget || !valueWidget) {
console.error("CozyGenChoiceInput: Required widgets not found!");
return;
}
const choices = await getChoices(choiceTypeWidget.value);
const comboWidget = {
type: "combo",
name: "value", // This must match the hidden input name
value: choices.includes(valueWidget.value) ? valueWidget.value : choices[0],
callback: (v) => { valueWidget.value = v; },
options: { values: choices }
};
this.widgets.splice(this.widgets.indexOf(valueWidget), 1, comboWidget);
if (bypassWidget && bypassWidget.value) {
this.addWidget("toggle", "Bypass", false, (v) => {
console.log(`Bypass toggled to: ${v}`);
});
}
};
}
},
});