From da320e36ebe4dc804bd727fbf60df41138487efa Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 4 Feb 2026 14:42:34 -0600 Subject: [PATCH] Enhance ancestry node handling in PatchTree - Added logic to create a placeholder node when an ancestor object is missing from both instanceMap and patch.added, allowing the ancestry chain to maintain integrity during rapid changes. - Improved logging to provide context when a placeholder node is created, enhancing debugging capabilities. --- plugin/src/PatchTree.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugin/src/PatchTree.lua b/plugin/src/PatchTree.lua index 7ea1c46f..2ede49c9 100644 --- a/plugin/src/PatchTree.lua +++ b/plugin/src/PatchTree.lua @@ -183,7 +183,19 @@ function Tree:buildAncestryNodes(previousId: string?, ancestryIds: { string }, p local value = instanceMap.fromIds[ancestorId] or patch.added[ancestorId] if not value then - Log.warn("Failed to find ancestor object for " .. ancestorId) + -- Ancestor is missing from both instanceMap and patch.added. + -- This can happen during rapid changes (e.g., undo operations) where + -- patches arrive referencing instances that were never fully synced. + -- Create a placeholder node to maintain the ancestry chain, allowing + -- the visualization to still work with incomplete information. + Log.warn("Failed to find ancestor object for {}; creating placeholder node", ancestorId) + self:addNode(previousId, { + id = ancestorId, + className = "Unknown", + name = "[Unknown Ancestor]", + instance = nil, + }) + previousId = ancestorId continue end self:addNode(previousId, {