Просмотр исходного кода

fix: make autosave watch both node and edge arrays

useAutosave's own doc comment says its edit token should be "the node
and edge arrays", but the call site only passed nodes. An edge-only
edit (reconnect, delete) never touches nodes, so after the first edge
edit in a burst, neither nodes nor hasChanges change again and the
idle timer keeps its original deadline instead of restarting - the
opposite of "one burst becomes one version," which is the entire
point of the hook. No data was lost (the save always reads the live
graph), but the debounce guarantee was broken for edge-only work.

Pass both arrays, memoized so the token's identity only changes when
nodes or edges themselves change, not on every unrelated re-render.
fszontagh 1 месяц назад
Родитель
Сommit
a8344e3210
1 измененных файлов с 7 добавлено и 1 удалено
  1. 7 1
      webui/src/pages/WorkflowEditorPage.tsx

+ 7 - 1
webui/src/pages/WorkflowEditorPage.tsx

@@ -909,7 +909,13 @@ function WorkflowEditorInner() {
 
   // Autosave, so nobody has to remember to press anything. Edits are grouped -
   // see the hook for why one version per keystroke would be no history at all.
-  useAutosave(nodes, hasChanges, !isViewingExecution && !!id && !saveMutation.isPending, () => {
+  // The edit token is both arrays: an edge-only edit (reconnect, delete) never
+  // touches `nodes`, so passing `nodes` alone would leave the idle timer
+  // unrestarted for every edge edit after the first in a burst. Memoized so the
+  // token's identity only changes when `nodes` or `edges` themselves do, not on
+  // every unrelated re-render of this page.
+  const autosaveToken = useMemo(() => [nodes, edges], [nodes, edges])
+  useAutosave(autosaveToken, hasChanges, !isViewingExecution && !!id && !saveMutation.isPending, () => {
     handleSaveRef.current()
   })