Header removals wait for the code editor to be left: autosave saves with drop=false, so follow_header adds and renames from the header but keeps a port or setting whose parameter is gone, and leaving the editor (blur or closing the panel) saves once more with removals; source saves of a flow run one at a time

This commit is contained in:
2026-10-15 21:31:04 +02:00
parent 5ca90ffece
commit ce2ce4e3e7
10 changed files with 105 additions and 24 deletions
+16 -3
View File
@@ -865,7 +865,15 @@ function FlowEditorInner({
})
const sourceMutation = useMutation({
mutationFn: async ({ nodeId, code }: { nodeId: string; code: string }) => {
mutationFn: async ({
nodeId,
code,
drop,
}: {
nodeId: string
code: string
drop?: boolean
}) => {
// The server reads the ports off the header and compares them with its
// draft, so the ports on the canvas have to be there first.
await flush()
@@ -873,8 +881,12 @@ function FlowEditorInner({
name: flowName,
nodeId,
requestBody: { code },
drop,
})
},
// One at a time: the save that drops a port must not land before the
// autosave that kept it.
scope: { id: `source:${flowName}` },
onSuccess: (saved) => {
const followed = saved.node
if (followed && saved.version) {
@@ -1454,8 +1466,9 @@ function FlowEditorInner({
onToggleExpand={() => setEditorExpanded((wide) => !wide)}
onChange={updateNode}
onRenameMessage={proposeRename}
onSaveSource={(code) => {
if (selected) sourceMutation.mutate({ nodeId: selected.id, code })
onSaveSource={(code, drop) => {
if (selected)
sourceMutation.mutate({ nodeId: selected.id, code, drop })
}}
// Sharing rewrites the stored document, so the canvas takes the
// server's copy rather than keeping its own.