Fix embedded media to use /raw endpoint

After content negotiation fix, /cache/{hash} returns HTML for
browsers. Embedded <img> tags need /raw to get actual image data.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-09 12:24:04 +00:00
parent 55878d46ac
commit e53e5a5ee6

View File

@@ -1006,7 +1006,7 @@ async def run_detail(run_id: str, request: Request):
if input_media_type == "video":
input_elem = f'<video src="{input_video_src}" controls muted loop playsinline class="max-w-full max-h-64 rounded-lg"></video>'
elif input_media_type == "image":
input_elem = f'<img src="/cache/{input_hash}" alt="input" class="max-w-full max-h-64 rounded-lg">'
input_elem = f'<img src="/cache/{input_hash}/raw" alt="input" class="max-w-full max-h-64 rounded-lg">'
else:
input_elem = '<p class="text-gray-400">Unknown format</p>'
media_html += f'''
@@ -1023,7 +1023,7 @@ async def run_detail(run_id: str, request: Request):
if output_media_type == "video":
output_elem = f'<video src="{output_video_src}" controls autoplay muted loop playsinline class="max-w-full max-h-64 rounded-lg"></video>'
elif output_media_type == "image":
output_elem = f'<img src="/cache/{output_hash}" alt="output" class="max-w-full max-h-64 rounded-lg">'
output_elem = f'<img src="/cache/{output_hash}/raw" alt="output" class="max-w-full max-h-64 rounded-lg">'
else:
output_elem = '<p class="text-gray-400">Unknown format</p>'
media_html += f'''
@@ -1271,7 +1271,7 @@ async def list_runs(request: Request, page: int = 1, limit: int = 20):
if input_media_type == "video":
html_parts.append(f'<video src="{video_src_for_request(input_hash, request)}" muted loop playsinline class="max-h-24 rounded"></video>')
else:
html_parts.append(f'<img src="/cache/{input_hash}" alt="input" class="max-h-24 rounded">')
html_parts.append(f'<img src="/cache/{input_hash}/raw" alt="input" class="max-h-24 rounded">')
html_parts.append('</div></div>')
if has_output:
@@ -1285,7 +1285,7 @@ async def list_runs(request: Request, page: int = 1, limit: int = 20):
if output_media_type == "video":
html_parts.append(f'<video src="{video_src_for_request(output_hash, request)}" autoplay muted loop playsinline class="max-h-24 rounded"></video>')
else:
html_parts.append(f'<img src="/cache/{output_hash}" alt="output" class="max-h-24 rounded">')
html_parts.append(f'<img src="/cache/{output_hash}/raw" alt="output" class="max-h-24 rounded">')
html_parts.append('</div></div>')
html_parts.append('</div>')
@@ -2743,7 +2743,7 @@ async def list_media(
video_src = video_src_for_request(content_hash, request)
html_parts.append(f'<video src="{video_src}" controls muted loop playsinline class="max-h-32 rounded"></video>')
elif media_type == "image":
html_parts.append(f'<img src="/cache/{content_hash}" alt="{content_hash[:16]}" class="max-h-32 rounded object-contain">')
html_parts.append(f'<img src="/cache/{content_hash}/raw" alt="{content_hash[:16]}" class="max-h-32 rounded object-contain">')
else:
html_parts.append('<p class="text-gray-400 text-sm py-4">Unknown file type</p>')
@@ -4000,7 +4000,7 @@ async def ui_runs(request: Request):
input_video_src = video_src_for_request(input_hash, request)
html_parts.append(f'<video src="{input_video_src}" controls muted loop playsinline class="max-h-32 rounded"></video>')
elif input_media_type == "image":
html_parts.append(f'<img src="/cache/{input_hash}" alt="input" class="max-h-32 rounded">')
html_parts.append(f'<img src="/cache/{input_hash}/raw" alt="input" class="max-h-32 rounded">')
html_parts.append('</div></div>')
# Output box
@@ -4016,7 +4016,7 @@ async def ui_runs(request: Request):
output_video_src = video_src_for_request(output_hash, request)
html_parts.append(f'<video src="{output_video_src}" controls autoplay muted loop playsinline class="max-h-32 rounded"></video>')
elif output_media_type == "image":
html_parts.append(f'<img src="/cache/{output_hash}" alt="output" class="max-h-32 rounded">')
html_parts.append(f'<img src="/cache/{output_hash}/raw" alt="output" class="max-h-32 rounded">')
html_parts.append('</div></div>')
html_parts.append('</div>')
@@ -4252,7 +4252,7 @@ async def ui_run_partial(run_id: str, request: Request):
input_video_src = video_src_for_request(input_hash, request)
html += f'<video src="{input_video_src}" controls muted loop playsinline class="max-h-32 rounded"></video>'
elif input_media_type == "image":
html += f'<img src="/cache/{input_hash}" alt="input" class="max-h-32 rounded">'
html += f'<img src="/cache/{input_hash}/raw" alt="input" class="max-h-32 rounded">'
html += '</div></div>'
if has_output:
@@ -4267,7 +4267,7 @@ async def ui_run_partial(run_id: str, request: Request):
output_video_src = video_src_for_request(output_hash, request)
html += f'<video src="{output_video_src}" controls autoplay muted loop playsinline class="max-h-32 rounded"></video>'
elif output_media_type == "image":
html += f'<img src="/cache/{output_hash}" alt="output" class="max-h-32 rounded">'
html += f'<img src="/cache/{output_hash}/raw" alt="output" class="max-h-32 rounded">'
html += '</div></div>'
html += '</div>'