Fix run detail: add username, total_steps, recipe_name
- Extract username from actor_id format (@user@server) - Set total_steps and executed from recipe nodes - Use recipe name for display instead of hash Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -102,6 +102,14 @@ async def get_run(
|
||||
|
||||
# Only render HTML if browser explicitly requests it
|
||||
if wants_html(request):
|
||||
# Extract username from actor_id (format: @user@server)
|
||||
actor_id = run.get("actor_id", "")
|
||||
if actor_id and actor_id.startswith("@"):
|
||||
parts = actor_id[1:].split("@")
|
||||
run["username"] = parts[0] if parts else "Unknown"
|
||||
else:
|
||||
run["username"] = actor_id or "Unknown"
|
||||
|
||||
# Try to load the recipe to show the plan
|
||||
plan = None
|
||||
recipe_id = run.get("recipe")
|
||||
@@ -111,11 +119,9 @@ async def get_run(
|
||||
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", [])
|
||||
# Use the new build_dag method if available
|
||||
dag = recipe.get("dag", {})
|
||||
nodes = dag.get("nodes", [])
|
||||
|
||||
steps = []
|
||||
if isinstance(nodes, list):
|
||||
@@ -137,6 +143,12 @@ async def get_run(
|
||||
|
||||
if steps:
|
||||
plan = {"steps": steps}
|
||||
run["total_steps"] = len(steps)
|
||||
run["executed"] = len(steps) if run.get("status") == "completed" else 0
|
||||
|
||||
# Use recipe name instead of hash for display
|
||||
if recipe.get("name"):
|
||||
run["recipe_name"] = recipe["name"]
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to load recipe for plan: {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user