fix: don't disable generate button for on-demand sidecars

FreeCAD, KiCad, and Blender shapes were permanently disabling the
generate button when their sidecar containers were stopped. Since these
are on-demand sidecars that start via ensureSidecar() when generate is
clicked, the health check should not disable the button.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2026-04-10 17:33:59 -04:00
parent 857a25e625
commit 9147198ce5
3 changed files with 20 additions and 50 deletions

View File

@ -418,25 +418,17 @@ export class FolkBlender extends FolkShape {
this.#renderResult();
}
// Health check with retry (container may still be starting)
const checkHealth = (attempt = 0) => {
fetch("/api/blender-gen/health").then(r => r.json()).then((h: any) => {
if (!h.available && this.#generateBtn) {
if (attempt < 2) { setTimeout(() => checkHealth(attempt + 1), 3000); return; }
// Health check — only disable if real error (sidecar starts on demand)
fetch("/api/blender-gen/health").then(r => r.json()).then((h: any) => {
if (this.#generateBtn) {
if (!h.available && h.issues?.length) {
this.#generateBtn.disabled = true;
this.#generateBtn.title = (h.issues || []).join(", ") || "Blender service unavailable";
} else if (h.warnings?.length && this.#generateBtn) {
this.#generateBtn.title = h.issues.join(", ");
} else if (h.warnings?.length) {
this.#generateBtn.title = h.warnings.join(", ");
}
}).catch(() => {
if (attempt < 2) { setTimeout(() => checkHealth(attempt + 1), 3000); return; }
if (this.#generateBtn) {
this.#generateBtn.disabled = true;
this.#generateBtn.title = "Cannot reach Blender health endpoint";
}
});
};
checkHealth();
}
}).catch(() => {});
return root;
}

View File

@ -311,23 +311,12 @@ export class FolkFreeCAD extends FolkShape {
this.#renderResult();
}
// Health check with retry (container may still be starting)
const checkHealth = (attempt = 0) => {
fetch("/api/freecad/health").then(r => r.json()).then((h: any) => {
if (!h.available && this.#generateBtn) {
if (attempt < 2) { setTimeout(() => checkHealth(attempt + 1), 3000); return; }
this.#generateBtn.disabled = true;
this.#generateBtn.title = h.error || "FreeCAD MCP server unavailable";
}
}).catch(() => {
if (attempt < 2) { setTimeout(() => checkHealth(attempt + 1), 3000); return; }
if (this.#generateBtn) {
this.#generateBtn.disabled = true;
this.#generateBtn.title = "Cannot reach FreeCAD health endpoint";
}
});
};
checkHealth();
// Health check — only disable if endpoint unreachable (sidecar starts on demand)
fetch("/api/freecad/health").then(r => r.json()).then((h: any) => {
if (this.#generateBtn && h.available === false && h.status && !h.status.includes("on demand")) {
this.#generateBtn.title = h.error || h.status || "FreeCAD MCP server unavailable";
}
}).catch(() => {});
return root;
}

View File

@ -397,23 +397,12 @@ export class FolkKiCAD extends FolkShape {
this.#showExports();
}
// Health check with retry (container may still be starting)
const checkHealth = (attempt = 0) => {
fetch("/api/kicad/health").then(r => r.json()).then((h: any) => {
if (!h.available && this.#generateBtn) {
if (attempt < 2) { setTimeout(() => checkHealth(attempt + 1), 3000); return; }
this.#generateBtn.disabled = true;
this.#generateBtn.title = h.error || "KiCAD MCP server unavailable";
}
}).catch(() => {
if (attempt < 2) { setTimeout(() => checkHealth(attempt + 1), 3000); return; }
if (this.#generateBtn) {
this.#generateBtn.disabled = true;
this.#generateBtn.title = "Cannot reach KiCAD health endpoint";
}
});
};
checkHealth();
// Health check — only disable if endpoint unreachable (sidecar starts on demand)
fetch("/api/kicad/health").then(r => r.json()).then((h: any) => {
if (this.#generateBtn && h.available === false && h.status && !h.status.includes("on demand")) {
this.#generateBtn.title = h.error || h.status || "KiCAD MCP server unavailable";
}
}).catch(() => {});
return root;
}