feat: add TF reference refresh button to Terraform Agent menu

- Add dropdown menu (⋮) in Terraform toolbar with "Atualizar Referência TF" button
- Remove standalone reference-status API endpoint, keep only refresh-reference
- Button triggers `terraform providers schema -json` regeneration with progress feedback
- Shows line count and update timestamp after successful refresh
- Update README with new line counts
This commit is contained in:
nogueiraguh
2026-03-08 01:05:18 -03:00
parent 19e481275d
commit 805286c05f
3 changed files with 51 additions and 16 deletions

View File

@@ -3765,22 +3765,16 @@ async def tf_delete_workspace(wid: str, u=Depends(current_user)):
@app.post("/api/terraform/refresh-reference")
async def tf_refresh_reference(u=Depends(current_user)):
"""Regenerate the OCI Terraform resource reference from provider schema."""
"""Regenerate the OCI Terraform resource reference from provider schema (internal, triggered by UI button)."""
loop = asyncio.get_event_loop()
result = await loop.run_in_executor(_chat_executor, _regenerate_tf_reference)
return result
@app.get("/api/terraform/reference-status")
async def tf_reference_status(u=Depends(current_user)):
"""Check if OCI Terraform resource reference is available."""
# Add status info
p = Path(_TF_RESOURCE_REF_PATH)
if p.exists():
content = _load_tf_resource_reference()
lines = content.count('\n') if content else 0
mtime = datetime.fromtimestamp(p.stat().st_mtime).isoformat()
return {"available": True, "lines": lines, "updated_at": mtime}
return {"available": False}
result["lines"] = content.count('\n') if content else 0
result["updated_at"] = datetime.fromtimestamp(p.stat().st_mtime).strftime('%d/%m/%Y %H:%M')
return result
def _write_tf_files(wdir: Path, tf_code: str):