Store and use activity_id for L2 links

- Add activity_id column to l2_shares table
- Store activity_id when publishing to L2
- Link to /activities/{activity_id} instead of /assets/{name}
- Falls back to asset link if no activity_id

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-10 18:56:23 +00:00
parent 3d45efa90b
commit 9a3d6949fc
2 changed files with 31 additions and 12 deletions

View File

@@ -1126,13 +1126,16 @@ async def run_detail(run_id: str, request: Request):
l2_server = share.get("l2_server", "")
l2_https = l2_server.replace("http://", "https://")
asset_name = share.get("asset_name", "")
activity_id = share.get("activity_id")
# Link to activity if available, otherwise fall back to asset
l2_link = f"{l2_https}/activities/{activity_id}" if activity_id else f"{l2_https}/assets/{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}/asset/{asset_name}" target="_blank" class="underline ml-2">View on L2</a>
Published as <strong>{asset_name[:16]}...</strong>
<a href="{l2_link}" target="_blank" class="underline ml-2">View on L2</a>
</p>
</div>
</div>
@@ -4035,12 +4038,16 @@ async def ui_publish_run(run_id: str, request: Request):
cache_path = get_cache_path(run.output_hash)
media_type = detect_media_type(cache_path) if cache_path else "image"
content_type = "video" if media_type == "video" else "image"
# Get activity_id for linking to the published run
activity = result.get("activity")
activity_id = activity.get("activity_id") if activity else None
await database.save_l2_share(
content_hash=run.output_hash,
actor_id=ctx.actor_id,
l2_server=l2_server,
asset_name=result["asset"]["name"],
content_type=content_type
content_type=content_type,
activity_id=activity_id
)
# Pin the inputs (for provenance)