From 6c59ac0cbcf6c610c212c8199894085f5bf528b4 Mon Sep 17 00:00:00 2001 From: gilesb Date: Wed, 7 Jan 2026 21:59:38 +0000 Subject: [PATCH] Fix activity detail to show provenance/inputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- server.py | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/server.py b/server.py index edb6179..186949a 100644 --- a/server.py +++ b/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 }