diff --git a/server.py b/server.py index 9169be1..e27c27e 100644 --- a/server.py +++ b/server.py @@ -406,9 +406,16 @@ UI_HTML = """ .status.running { background: #4d4d1a; color: #facc15; } .status.failed { background: #4d1a1a; color: #f87171; } .status.pending { background: #333; color: #888; } - .media-container { margin-top: 12px; } + .media-row { display: flex; gap: 16px; margin-top: 12px; flex-wrap: wrap; } + .media-box { flex: 1; min-width: 200px; } + .media-box label { font-size: 11px; color: #666; display: block; margin-bottom: 4px; } + .media-container { } .media-container img, .media-container video { - max-width: 100%; max-height: 400px; border-radius: 4px; + max-width: 100%; max-height: 300px; border-radius: 4px; + } + @media (max-width: 600px) { + .media-row { flex-direction: column; } + .media-box { min-width: 100%; } } .hash { font-family: monospace; font-size: 11px; color: #666; } .info { font-size: 13px; color: #aaa; } @@ -466,32 +473,44 @@ async def ui_runs(): ''') - # Show input - if run.inputs: - input_hash = run.inputs[0] - html_parts.append(f'
Input: {input_hash[:32]}...
') - input_cache_path = CACHE_DIR / input_hash - if input_cache_path.exists(): - input_media_type = detect_media_type(input_cache_path) - html_parts.append('
') - if input_media_type == "video": - html_parts.append(f'') - elif input_media_type == "image": - html_parts.append(f'input') - html_parts.append('
') + # Show input and output side by side + has_input = run.inputs and (CACHE_DIR / run.inputs[0]).exists() + has_output = run.status == "completed" and run.output_hash and (CACHE_DIR / run.output_hash).exists() - # Show output if completed - if run.status == "completed" and run.output_hash: - cache_path = CACHE_DIR / run.output_hash - if cache_path.exists(): - media_type = detect_media_type(cache_path) - html_parts.append(f'
Output: {run.output_hash[:32]}...
') - html_parts.append('
') - if media_type == "video": - html_parts.append(f'') - elif media_type == "image": - html_parts.append(f'{run.output_name}') - html_parts.append('
') + if has_input or has_output: + html_parts.append('
') + + # Input box + if has_input: + input_hash = run.inputs[0] + input_media_type = detect_media_type(CACHE_DIR / input_hash) + html_parts.append(f''' +
+ +
+ ''') + if input_media_type == "video": + html_parts.append(f'') + elif input_media_type == "image": + html_parts.append(f'input') + html_parts.append('
') + + # Output box + if has_output: + output_hash = run.output_hash + output_media_type = detect_media_type(CACHE_DIR / output_hash) + html_parts.append(f''' +
+ +
+ ''') + if output_media_type == "video": + html_parts.append(f'') + elif output_media_type == "image": + html_parts.append(f'output') + html_parts.append('
') + + html_parts.append('
') # Show error if failed if run.status == "failed" and run.error: @@ -544,30 +563,34 @@ async def ui_run_detail(run_id: str): ''' - if run.inputs: - input_hash = run.inputs[0] - html += f'
Input: {input_hash[:32]}...
' - input_cache_path = CACHE_DIR / input_hash - if input_cache_path.exists(): - input_media_type = detect_media_type(input_cache_path) - html += '
' - if input_media_type == "video": - html += f'' - elif input_media_type == "image": - html += f'input' - html += '
' + # Show input and output side by side + has_input = run.inputs and (CACHE_DIR / run.inputs[0]).exists() + has_output = run.status == "completed" and run.output_hash and (CACHE_DIR / run.output_hash).exists() - if run.status == "completed" and run.output_hash: - cache_path = CACHE_DIR / run.output_hash - if cache_path.exists(): - media_type = detect_media_type(cache_path) - html += f'
Output: {run.output_hash[:32]}...
' - html += '
' - if media_type == "video": - html += f'' - elif media_type == "image": - html += f'{run.output_name}' - html += '
' + if has_input or has_output: + html += '
' + + if has_input: + input_hash = run.inputs[0] + input_media_type = detect_media_type(CACHE_DIR / input_hash) + html += f'
' + if input_media_type == "video": + html += f'' + elif input_media_type == "image": + html += f'input' + html += '
' + + if has_output: + output_hash = run.output_hash + output_media_type = detect_media_type(CACHE_DIR / output_hash) + html += f'
' + if output_media_type == "video": + html += f'' + elif output_media_type == "image": + html += f'output' + html += '
' + + html += '
' if run.status == "failed" and run.error: html += f'
Error: {run.error}
'