Skip to content

Commit 4bde363

Browse files
committed
Better UI Rendering
1 parent 82a875f commit 4bde363

4 files changed

Lines changed: 31 additions & 3 deletions

File tree

Roadmap.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ ProjectStructure.md has notes to assist AI in developing this project
4343

4444
### **ComfyUI Ultimate Sampler Grid – Development Roadmap**
4545

46-
## Batch Encoding
46+
## Jobs don't generate prompts in the order they're written in the array, it's mildly inconvenient. Lets fix that and make it run in order from top to bottom of the array.
47+
48+
## Custom Job Resume / Skipping - Start At Job # Option
49+
50+
## Batch Encoding could use with implementing the smart, look ahead, caching system we built for lora swapping.
4751

4852
## Add HF-RemoteVae list to BuilderUI Remote Vae (when Remote URL is selected, add a Presets: selection to choose which one from the list)
4953

web/conf_builder/conf-builder-config-management.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ export function renderConfigSection(node, container, availableConfigs) {
122122
saveBtn.style.width = "100%";
123123
saveBtn.onclick = async () => {
124124
await node.saveConfigToBackend();
125-
const { getAvailableConfigs } = await import('./conf-builder-utilities.js');
125+
const { getAvailableConfigs, clearConfigsCache } = await import('./conf-builder-utilities.js');
126+
clearConfigsCache(); // Invalidate so getAvailableConfigs fetches fresh list
126127
await getAvailableConfigs();
127128
node.renderUI();
128129
};

web/conf_builder/conf-builder-main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ app.registerExtension({
167167
headers: { "Content-Type": "application/json" },
168168
body: JSON.stringify({ name: name, data: this.state })
169169
});
170-
if (utilities) await utilities.getAvailableConfigs();
170+
if (utilities) { utilities.clearConfigsCache(); await utilities.getAvailableConfigs(); }
171171
} catch (e) {
172172
console.error("Save Failed", e);
173173
}

web/conf_builder/conf-builder-utilities.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ let availableSchedulers = [];
2323
let availableSessions = ["None"];
2424
let availableConfigs = ["None"];
2525

26+
// Cache-loaded flags for fetchers that can't use null-check
27+
// (their initial values are already non-null arrays)
28+
let _modelListsLoaded = false;
29+
let _sessionsLoaded = false;
30+
let _configsLoaded = false;
31+
2632
// Track all active ConfigBuilder nodes for refresh
2733
let activeConfigBuilderNodes = new Set();
2834

@@ -46,8 +52,15 @@ export function clearAllCaches() {
4652
dualClipTypes = [];
4753
availableSamplers = [];
4854
availableSchedulers = [];
55+
_modelListsLoaded = false;
56+
_sessionsLoaded = false;
57+
_configsLoaded = false;
4958
}
5059

60+
// Targeted cache invalidation for when specific data changes
61+
export function clearConfigsCache() { _configsLoaded = false; }
62+
export function clearSessionsCache() { _sessionsLoaded = false; }
63+
5164
export async function refreshAllConfigBuilders() {
5265
console.log("[ConfigBuilder] 🔄 Refreshing all Config Builder nodes...");
5366
clearAllCaches();
@@ -156,6 +169,8 @@ export async function getModelFolders() {
156169
// --- UNIFIED MODEL LISTS (for GGUF, Diffusion Models, Text Encoders) ---
157170

158171
export async function getModelLists() {
172+
// Return cached data if already loaded (cleared by clearAllCaches on explicit refresh)
173+
if (_modelListsLoaded) return;
159174
// Fetch all model lists from the unified endpoint
160175
try {
161176
const resp = await fetch("/configbuilder/model_lists", {
@@ -201,6 +216,7 @@ export async function getModelLists() {
201216
if (availableGGUFModels.length === 0) {
202217
console.log(`[ConfigBuilder] ℹ️ No GGUF models found. Install ComfyUI-GGUF and place .gguf files in the unet_gguf folder.`);
203218
}
219+
_modelListsLoaded = true;
204220
return data;
205221
} catch (e) {
206222
console.error("[ConfigBuilder] Error fetching model lists:", e);
@@ -222,28 +238,35 @@ export function getAvailableSamplers() { return availableSamplers || []; }
222238
export function getAvailableSchedulers() { return availableSchedulers || []; }
223239

224240
export async function getAvailableSessions() {
241+
// Return cached sessions if already loaded (cleared by clearAllCaches on explicit refresh)
242+
if (_sessionsLoaded) return availableSessions;
225243
try {
226244
const resp = await fetch("/object_info", { headers: { "X-Config-Builder-Internal": "true" } });
227245
const objectInfo = await resp.json();
228246
for (const nodeType in objectInfo) {
229247
const nodeDef = objectInfo[nodeType];
230248
if (nodeType === "UltimateConfigBuilder" && nodeDef.input?.required?.load_session) {
231249
availableSessions = nodeDef.input.required.load_session[0];
250+
_sessionsLoaded = true;
232251
return availableSessions;
233252
}
234253
}
235254
} catch (e) { console.error("[ConfigBuilder] Error fetching sessions:", e); }
255+
_sessionsLoaded = true;
236256
return availableSessions;
237257
}
238258

239259
export async function getAvailableConfigs() {
260+
// Return cached configs if already loaded (use clearConfigsCache() to force refresh)
261+
if (_configsLoaded) return availableConfigs;
240262
try {
241263
const resp = await fetch("/configbuilder/list_configs");
242264
if (resp.ok) {
243265
const files = await resp.json();
244266
availableConfigs = files.length > 0 ? files : ["None"];
245267
}
246268
} catch (e) { console.error("[ConfigBuilder] Error fetching configs:", e); }
269+
_configsLoaded = true;
247270
return availableConfigs;
248271
}
249272

0 commit comments

Comments
 (0)