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
+7 -4
View File
@@ -674,7 +674,7 @@ def read_node_source(
def _follow_header(
controller: FlowController, name: str, node_id: str, code: str
controller: FlowController, name: str, node_id: str, code: str, drop: bool
) -> FlowDef | None:
"""Bring a function node's ports and settings in line with its header.
@@ -694,7 +694,7 @@ def _follow_header(
or definition.origin
):
return None
followed = follow_header(node, code)
followed = follow_header(node, code, drop)
if followed == node:
return None
definition.nodes = [followed if n.id == node_id else n for n in definition.nodes]
@@ -716,6 +716,7 @@ async def save_node_source(
source: NodeSource,
controller: FlowControllerDep,
user: CurrentUser,
drop: bool = True,
) -> Any:
"""Save a node's source as an unpublished edit and report whether it loads.
@@ -730,7 +731,9 @@ async def save_node_source(
A node with its own code takes its input ports and settings from the
header of ``process`` (see `follow_header`), and the answer carries the
node when that changed it.
node when that changed it. ``drop=false`` is the editor's autosave, which
adds and renames from the header but keeps what it no longer names until
the editor is left.
"""
definition = _read_flow(controller, name)
ref = _source_ref(definition, node_id)
@@ -746,7 +749,7 @@ async def save_node_source(
controller.store.write_node_source, name, node_id, source.code, True
)
followed = await run_in_threadpool(
_follow_header, controller, name, node_id, source.code
_follow_header, controller, name, node_id, source.code, drop
)
node_def = next((n for n in definition.nodes if n.id == node_id), None)
device = (