Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
fix(editor): opening a workflow no longer marks it Modified and saves it
trohitg7f57e1188a5a
diff --git a/client/src/hooks/__tests__/useWorkflowCanvas.test.tsx b/client/src/hooks/__tests__/useWorkflowCanvas.test.tsxindex a3098a79..7fa4302f 100644--- a/client/src/hooks/__tests__/useWorkflowCanvas.test.tsx+++ b/client/src/hooks/__tests__/useWorkflowCanvas.test.tsx@@ -39,6 +39,17 @@ describe('employee canvas ownership', () => {expect(useAppStore.getState().hasUnsavedChanges).toBe(false);});+ it('does not count React Flow measuring the nodes as an edit', () => {+ // On mount React Flow gives each node its measured size; none of that is+ // saved, so opening a workflow must not mark it changed and save it.+ const original = useAppStore.getState().currentWorkflow;+ const { result } = mount();+ act(() => result.current.setNodes(nodes => nodes.map(node => ({ ...node, width: 120, height: 80, positionAbsolute: node.position }))));+ act(() => vi.advanceTimersByTime(1_000));+ expect(useAppStore.getState().currentWorkflow).toBe(original);+ expect(useAppStore.getState().hasUnsavedChanges).toBe(false);+ });+it('flushes edits made just before leaving Dev and preserves them on returning', () => {const first = mount();act(() => first.result.current.setNodes(nodes => nodes.map(node => ({ ...node, position: { x: 900, y: 100 } }))));diff --git a/client/src/utils/workflow.ts b/client/src/utils/workflow.tsindex 5462d050..867c6582 100644--- a/client/src/utils/workflow.ts+++ b/client/src/utils/workflow.ts@@ -32,8 +32,11 @@ export const nextNodeInstanceId = (return `${prefix}${Math.max(largest, sameTypeCount) + 1}`;};+// What React Flow adds while it shows a node (selection, dragging, the+// measured size and absolute position) is never saved, so it is no edit:+// counted, opening a workflow measured every node and saved it as changed.export const sanitizeNodesForComparison = (nodes: Node[]): Node[] =>- nodes.map(n => ({ ...n, selected: undefined, dragging: undefined }));+ nodes.map(n => ({ ...n, selected: undefined, dragging: undefined, width: undefined, height: undefined, positionAbsolute: undefined }));export const sanitizeEdgesForComparison = (edges: Edge[]): Edge[] =>edges.map(e => ({ ...e, selected: undefined }));