Add L2 links to run detail page and publish success message

- Run detail page now shows "Published to L2" with link when already published
- Publish success message now includes "View on L2" link

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-09 09:48:25 +00:00
parent a0a4c08b9a
commit ad63774acd

View File

@@ -895,26 +895,46 @@ async def run_detail(run_id: str, request: Request):
</div>
'''
# Publish section
# Publish section - check if already published to L2
publish_html = ""
if run.status == "completed" and run.output_hash:
publish_html = f'''
<div class="border-t border-dark-500 pt-6 mt-6">
<h2 class="text-lg font-semibold text-white mb-3">Publish to L2</h2>
<p class="text-sm text-gray-400 mb-4">Register this transformation output on the L2 ActivityPub server.</p>
<div id="publish-result"></div>
<form hx-post="/ui/publish-run/{run.run_id}" hx-target="#publish-result" hx-swap="innerHTML"
class="flex flex-wrap gap-3 items-center">
<input type="text" name="output_name" value="{run.output_name}"
placeholder="Asset name" required
class="px-4 py-2 bg-dark-600 border border-dark-500 rounded-lg text-white placeholder-gray-500 focus:border-blue-500 focus:outline-none min-w-[200px]">
<button type="submit"
class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg transition-colors">
Publish to L2
</button>
</form>
</div>
'''
l2_shares = await database.get_l2_shares(run.output_hash, ctx.actor_id)
if l2_shares:
# Already published - show link to L2
share = l2_shares[0]
l2_server = share.get("l2_server", "")
l2_https = l2_server.replace("http://", "https://")
asset_name = share.get("asset_name", "")
publish_html = f'''
<div class="border-t border-dark-500 pt-6 mt-6">
<h2 class="text-lg font-semibold text-white mb-3">Published to L2</h2>
<div class="bg-green-900/30 border border-green-700 rounded-lg p-4">
<p class="text-green-300">
Published as <strong>{asset_name}</strong>
<a href="{l2_https}/ui/asset/{asset_name}" target="_blank" class="underline ml-2">View on L2</a>
</p>
</div>
</div>
'''
else:
# Not published - show publish form
publish_html = f'''
<div class="border-t border-dark-500 pt-6 mt-6">
<h2 class="text-lg font-semibold text-white mb-3">Publish to L2</h2>
<p class="text-sm text-gray-400 mb-4">Register this transformation output on the L2 ActivityPub server.</p>
<div id="publish-result"></div>
<form hx-post="/ui/publish-run/{run.run_id}" hx-target="#publish-result" hx-swap="innerHTML"
class="flex flex-wrap gap-3 items-center">
<input type="text" name="output_name" value="{run.output_name}"
placeholder="Asset name" required
class="px-4 py-2 bg-dark-600 border border-dark-500 rounded-lg text-white placeholder-gray-500 focus:border-blue-500 focus:outline-none min-w-[200px]">
<button type="submit"
class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg transition-colors">
Publish to L2
</button>
</form>
</div>
'''
# Delete section
delete_html = f'''
@@ -3659,9 +3679,12 @@ async def ui_publish_run(run_id: str, request: Request, output_name: str = Form(
cache_manager.pin(fixed.content_hash, reason="fixed_input_in_published_recipe")
break
# Use HTTPS for L2 links
l2_https = l2_server.replace("http://", "https://")
return HTMLResponse(f'''
<div class="bg-green-900/50 border border-green-700 text-green-300 px-4 py-3 rounded-lg mb-4">
Published to L2 as <strong>{result["asset"]["name"]}</strong>
Published to L2 as <strong>{result["asset"]["name"]}</strong>!
<a href="{l2_https}/ui/asset/{result["asset"]["name"]}" target="_blank" class="underline">View on L2</a>
</div>
''')
except http_requests.exceptions.HTTPError as e: