fix: suppress link rendering during slot sync after graph reconfigure

After graph reconfiguration (e.g., undo/redo), there's a timing gap where
canvas renders links before Vue components have mounted and synced slot
positions to layoutStore.

This adds a pendingSlotSync flag to layoutStore that:
- Is set to true at start of graph.onConfigure()
- Is cleared after flushScheduledSlotLayoutSync() completes
- Causes drawConnections() to skip link rendering when true

This prevents links from rendering with stale/missing positions during the
brief window between configure() completing and Vue components syncing.

Amp-Thread-ID: https://ampcode.com/threads/T-019c084c-49dd-764b-8125-8938c42612c8
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Subagent 5
2026-01-28 23:24:53 -08:00
parent dd3e4d3edc
commit 299386aa03
4 changed files with 38 additions and 2 deletions

View File

@@ -31,13 +31,19 @@ function scheduleSlotLayoutSync(nodeId: string) {
raf.schedule()
}
function flushScheduledSlotLayoutSync() {
if (pendingNodes.size === 0) return
export function flushScheduledSlotLayoutSync() {
if (pendingNodes.size === 0) {
// Even if no pending nodes, clear the flag (e.g., graph with no nodes)
layoutStore.setPendingSlotSync(false)
return
}
const conv = useSharedCanvasPositionConversion()
for (const nodeId of Array.from(pendingNodes)) {
pendingNodes.delete(nodeId)
syncNodeSlotLayoutsFromDOM(nodeId, conv)
}
// Clear the pending sync flag - slots are now synced
layoutStore.setPendingSlotSync(false)
}
export function syncNodeSlotLayoutsFromDOM(