Add inline media previews for runs list and detail page
- Run card shows thumbnail previews for inputs and output - Run detail shows output media inline (image/video/audio) - Add audio detection (MP3, FLAC, OGG, WAV) to detect_media_type - Add debug logging for recipe count on home page - Add console.log debugging for DAG elements Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -182,6 +182,7 @@ async def get_run(
|
||||
|
||||
# Build artifacts list from output and inputs
|
||||
artifacts = []
|
||||
output_media_type = None
|
||||
if run.get("output_hash"):
|
||||
# Detect media type using magic bytes
|
||||
output_hash = run["output_hash"]
|
||||
@@ -192,6 +193,7 @@ async def get_run(
|
||||
if cache_path and cache_path.exists():
|
||||
simple_type = detect_media_type(cache_path)
|
||||
media_type = type_to_mime(simple_type)
|
||||
output_media_type = media_type
|
||||
except Exception:
|
||||
pass
|
||||
artifacts.append({
|
||||
@@ -263,6 +265,7 @@ async def get_run(
|
||||
artifacts=artifacts,
|
||||
run_inputs=run_inputs,
|
||||
dag_elements=dag_elements,
|
||||
output_media_type=output_media_type,
|
||||
active_tab="runs",
|
||||
)
|
||||
|
||||
@@ -308,6 +311,46 @@ async def list_runs(
|
||||
if wants_json(request):
|
||||
return {"runs": runs, "offset": offset, "limit": limit, "has_more": has_more}
|
||||
|
||||
# Add media info for inline previews (only for HTML)
|
||||
cache_manager = get_cache_manager()
|
||||
from ..services.run_service import detect_media_type
|
||||
|
||||
def type_to_mime(simple_type: str) -> str:
|
||||
if simple_type == "video":
|
||||
return "video/mp4"
|
||||
elif simple_type == "image":
|
||||
return "image/jpeg"
|
||||
elif simple_type == "audio":
|
||||
return "audio/mpeg"
|
||||
return None
|
||||
|
||||
for run in runs:
|
||||
# Add output media info
|
||||
if run.get("output_hash"):
|
||||
try:
|
||||
cache_path = cache_manager.get_by_content_hash(run["output_hash"])
|
||||
if cache_path and cache_path.exists():
|
||||
simple_type = detect_media_type(cache_path)
|
||||
run["output_media_type"] = type_to_mime(simple_type)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Add input media info (first 3 inputs)
|
||||
input_previews = []
|
||||
inputs = run.get("inputs", [])
|
||||
if isinstance(inputs, list):
|
||||
for input_hash in inputs[:3]:
|
||||
preview = {"hash": input_hash, "media_type": None}
|
||||
try:
|
||||
cache_path = cache_manager.get_by_content_hash(input_hash)
|
||||
if cache_path and cache_path.exists():
|
||||
simple_type = detect_media_type(cache_path)
|
||||
preview["media_type"] = type_to_mime(simple_type)
|
||||
except Exception:
|
||||
pass
|
||||
input_previews.append(preview)
|
||||
run["input_previews"] = input_previews
|
||||
|
||||
templates = get_templates(request)
|
||||
return render(templates, "runs/list.html", request,
|
||||
runs=runs,
|
||||
|
||||
Reference in New Issue
Block a user