Header of process and node ports follow each other both ways: a panel edit rewrites only the def line of edited code, a code save reads the header back into input ports and settings (draft and response); Space types in the node editor again
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WgBfkm4rCmtd1T4vHWjEPx
This commit is contained in:
@@ -273,6 +273,7 @@ function FlowEditorInner({
|
||||
flush,
|
||||
conflict,
|
||||
resolveConflict,
|
||||
adopt,
|
||||
mutation: saving,
|
||||
} = useAutosave(flowName)
|
||||
const publish = usePublish(flowName)
|
||||
@@ -855,13 +856,34 @@ function FlowEditorInner({
|
||||
})
|
||||
|
||||
const sourceMutation = useMutation({
|
||||
mutationFn: ({ nodeId, code }: { nodeId: string; code: string }) =>
|
||||
FlowsService.saveNodeSource({
|
||||
mutationFn: async ({ nodeId, code }: { nodeId: string; code: string }) => {
|
||||
// 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()
|
||||
return FlowsService.saveNodeSource({
|
||||
name: flowName,
|
||||
nodeId,
|
||||
requestBody: { code },
|
||||
}),
|
||||
onSuccess: () => {
|
||||
})
|
||||
},
|
||||
onSuccess: (saved) => {
|
||||
const followed = saved.node
|
||||
if (followed && saved.version) {
|
||||
// The header changed the ports in the draft: take them, and the
|
||||
// version they moved it to, so the next save is not a conflict.
|
||||
adopt(saved.version)
|
||||
commit(
|
||||
(latest.current.nodes ?? []).map((node) =>
|
||||
node.id === followed.id
|
||||
? {
|
||||
...node,
|
||||
requires: followed.requires,
|
||||
params: followed.params,
|
||||
}
|
||||
: node,
|
||||
),
|
||||
)
|
||||
}
|
||||
queryClient.invalidateQueries({ queryKey: ["flows", flowName] })
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user