Skip to content

Agent Zero AI framework

fix: defer DOM insertion until module imports resolve in component loader

Alessandro37d94433246e
diff --git a/webui/js/components.js b/webui/js/components.js
index 282a7a9f4..c9ff2a357 100644
--- a/webui/js/components.js
+++ b/webui/js/components.js
@@ -57,6 +57,7 @@ export async function importComponent(path, targetElement) {
];
const loadPromises = [];
+ const deferredNodes = [];
let blobCounter = 0;
for (const node of allNodes) {
@@ -156,14 +157,17 @@ export async function importComponent(path, targetElement) {
targetElement.appendChild(clone);
} else {
- const clone = node.cloneNode(true);
- targetElement.appendChild(clone);
+ deferredNodes.push(node.cloneNode(true));
}
}
// Wait for all tracked external scripts/styles to finish loading
await Promise.all(loadPromises);
+ for (const deferred of deferredNodes) {
+ targetElement.appendChild(deferred);
+ }
+
// Remove loading indicator
const loadingEl = targetElement.querySelector(':scope > .loading');
if (loadingEl) {