fix(cad): retry health checks so buttons aren't permanently disabled
All CAD shapes (KiCad, FreeCAD, Blender) now retry health checks up to 3 times with 3s delay before disabling the generate button. Prevents transient failures during container startup from permanently greying out the button. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
358965cb61
commit
25aaadd247
|
|
@ -384,20 +384,25 @@ export class FolkBlender extends FolkShape {
|
|||
this.#renderResult();
|
||||
}
|
||||
|
||||
// Health check
|
||||
fetch("/api/blender-gen/health").then(r => r.json()).then((h: any) => {
|
||||
if (!h.available && this.#generateBtn) {
|
||||
this.#generateBtn.disabled = true;
|
||||
this.#generateBtn.title = (h.issues || []).join(", ") || "Blender service unavailable";
|
||||
} else if (h.warnings?.length && this.#generateBtn) {
|
||||
this.#generateBtn.title = h.warnings.join(", ");
|
||||
}
|
||||
}).catch(() => {
|
||||
if (this.#generateBtn) {
|
||||
this.#generateBtn.disabled = true;
|
||||
this.#generateBtn.title = "Cannot reach Blender health endpoint";
|
||||
}
|
||||
});
|
||||
// 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; }
|
||||
this.#generateBtn.disabled = true;
|
||||
this.#generateBtn.title = (h.issues || []).join(", ") || "Blender service unavailable";
|
||||
} else if (h.warnings?.length && this.#generateBtn) {
|
||||
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();
|
||||
|
||||
return root;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -311,18 +311,23 @@ export class FolkFreeCAD extends FolkShape {
|
|||
this.#renderResult();
|
||||
}
|
||||
|
||||
// Health check
|
||||
fetch("/api/freecad/health").then(r => r.json()).then((h: any) => {
|
||||
if (!h.available && this.#generateBtn) {
|
||||
this.#generateBtn.disabled = true;
|
||||
this.#generateBtn.title = h.error || "FreeCAD MCP server unavailable";
|
||||
}
|
||||
}).catch(() => {
|
||||
if (this.#generateBtn) {
|
||||
this.#generateBtn.disabled = true;
|
||||
this.#generateBtn.title = "Cannot reach FreeCAD health endpoint";
|
||||
}
|
||||
});
|
||||
// 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();
|
||||
|
||||
return root;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -397,18 +397,23 @@ export class FolkKiCAD extends FolkShape {
|
|||
this.#showExports();
|
||||
}
|
||||
|
||||
// Health check
|
||||
fetch("/api/kicad/health").then(r => r.json()).then((h: any) => {
|
||||
if (!h.available && this.#generateBtn) {
|
||||
this.#generateBtn.disabled = true;
|
||||
this.#generateBtn.title = h.error || "KiCAD MCP server unavailable";
|
||||
}
|
||||
}).catch(() => {
|
||||
if (this.#generateBtn) {
|
||||
this.#generateBtn.disabled = true;
|
||||
this.#generateBtn.title = "Cannot reach KiCAD health endpoint";
|
||||
}
|
||||
});
|
||||
// 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();
|
||||
|
||||
return root;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue