Bind all canvas element identities to their snapshot owners
Foundry Go checks / check (push) Successful in 2m53s
Foundry Go checks / check (pull_request) Successful in 2m55s

This commit is contained in:
2026-11-09 04:11:26 +08:00
parent ad6ab30b5f
commit 9cf6e4cedf
2 changed files with 29 additions and 1 deletions
+8 -1
View File
@@ -20,6 +20,7 @@ func writeCanvasModelStream(ctx context.Context, w http.ResponseWriter, model ca
view := model.view(nil)
// A count covers direct members only; an empty canvas is explicit too.
counts := map[string]int{}
owners := map[string]string{}
for _, canvas := range view.Canvases {
counts[canvas.ID] = 0
}
@@ -29,11 +30,17 @@ func writeCanvasModelStream(ctx context.Context, w http.ResponseWriter, model ca
reject(w, 500, "invalid_model_coverage")
return
}
id := modelString(element["id"])
if id == "" || owners[id] != "" {
reject(w, 500, "invalid_model_identity")
return
}
owners[id] = owner
counts[owner]++
}
header := response{"streamVersion": 1, "kind": "header", "sequence": 0, "snapshotToken": token,
"documentFormatVersion": canvasModelFormat, "projectId": model.Root, "canvases": view.Canvases,
"versions": view.Versions, "tombstones": view.Tombstones, "removedCanvasIds": view.Removed, "elementCount": len(view.Elements), "canvasElementCounts": counts}
"versions": view.Versions, "tombstones": view.Tombstones, "removedCanvasIds": view.Removed, "elementCount": len(view.Elements), "canvasElementCounts": counts, "elementOwners": owners}
const maxLine = 8 * 1024 * 1024
const maxBytes = 64 * 1024 * 1024
sequence, total := 0, 0