Fix activity detail to show provenance/inputs
- Include provenance in activity object_data when creating activities - Add fallback: look up asset from registry if activity lacks provenance - Existing activities now show inputs by looking up the asset 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
41
server.py
41
server.py
@@ -638,10 +638,23 @@ async def ui_activity_detail(activity_index: int, request: Request):
|
||||
media_type = obj.get("mediaType", "")
|
||||
description = obj.get("summary", "") or obj.get("content", "")
|
||||
|
||||
# Provenance from object
|
||||
# Provenance from object - or fallback to registry asset
|
||||
provenance = obj.get("provenance", {})
|
||||
origin = obj.get("origin", {})
|
||||
|
||||
# Fallback: if activity doesn't have provenance, look up the asset from registry
|
||||
if not provenance or not origin:
|
||||
registry = load_registry()
|
||||
assets = registry.get("assets", {})
|
||||
# Find asset by content_hash or name
|
||||
for asset_name, asset_data in assets.items():
|
||||
if asset_data.get("content_hash") == content_hash or asset_data.get("name") == obj_name:
|
||||
if not provenance:
|
||||
provenance = asset_data.get("provenance", {})
|
||||
if not origin:
|
||||
origin = asset_data.get("origin", {})
|
||||
break
|
||||
|
||||
# Type colors
|
||||
type_color = "bg-green-600" if activity_type == "Create" else "bg-yellow-600" if activity_type == "Update" else "bg-gray-600"
|
||||
obj_type_color = "bg-blue-600" if "Image" in obj_type else "bg-purple-600" if "Video" in obj_type else "bg-gray-600"
|
||||
@@ -1577,20 +1590,26 @@ def _register_asset_impl(req: RegisterRequest, owner: str):
|
||||
save_registry(registry)
|
||||
|
||||
# Create ownership activity
|
||||
object_data = {
|
||||
"type": req.asset_type.capitalize(),
|
||||
"name": req.name,
|
||||
"id": f"https://{DOMAIN}/objects/{req.content_hash}",
|
||||
"contentHash": {
|
||||
"algorithm": "sha3-256",
|
||||
"value": req.content_hash
|
||||
},
|
||||
"attributedTo": f"https://{DOMAIN}/users/{owner}"
|
||||
}
|
||||
|
||||
# Include provenance in activity object_data if present
|
||||
if req.provenance:
|
||||
object_data["provenance"] = req.provenance
|
||||
|
||||
activity = {
|
||||
"activity_id": str(uuid.uuid4()),
|
||||
"activity_type": "Create",
|
||||
"actor_id": f"https://{DOMAIN}/users/{owner}",
|
||||
"object_data": {
|
||||
"type": req.asset_type.capitalize(),
|
||||
"name": req.name,
|
||||
"id": f"https://{DOMAIN}/objects/{req.content_hash}",
|
||||
"contentHash": {
|
||||
"algorithm": "sha3-256",
|
||||
"value": req.content_hash
|
||||
},
|
||||
"attributedTo": f"https://{DOMAIN}/users/{owner}"
|
||||
},
|
||||
"object_data": object_data,
|
||||
"published": now
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user