Load recipe to show plan in run detail view

When viewing a run, try to load the recipe by hash to display
the plan/steps in the UI.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-11 22:05:41 +00:00
parent 50ea0f1491
commit ccf28bd351

View File

@@ -102,9 +102,48 @@ async def get_run(
# Only render HTML if browser explicitly requests it
if wants_html(request):
# Try to load the recipe to show the plan
plan = None
recipe_id = run.get("recipe")
if recipe_id and len(recipe_id) == 64: # Looks like a hash
try:
from ..services.recipe_service import RecipeService
recipe_service = RecipeService(get_redis_client(), get_cache_manager())
recipe = await recipe_service.get_recipe(recipe_id)
if recipe:
# Build plan from recipe nodes
nodes = recipe.get("nodes", [])
if not nodes:
dag = recipe.get("dag", {})
nodes = dag.get("nodes", [])
steps = []
if isinstance(nodes, list):
for node in nodes:
steps.append({
"name": node.get("id", ""),
"type": node.get("type", "EFFECT"),
"status": "completed", # Run completed
"inputs": node.get("inputs", []),
})
elif isinstance(nodes, dict):
for node_id, node in nodes.items():
steps.append({
"name": node_id,
"type": node.get("type", "EFFECT"),
"status": "completed",
"inputs": node.get("inputs", []),
})
if steps:
plan = {"steps": steps}
except Exception as e:
logger.warning(f"Failed to load recipe for plan: {e}")
templates = get_templates(request)
return render(templates, "runs/detail.html", request,
run=run,
plan=plan,
active_tab="runs",
)