Skip to content

Commit 6007d59

Browse files
BloggerBustjayanth-kumar-morem
authored andcommitted
fix(ast): inject missing component_id into known component calls
Previously, known component calls lifted via _lift_statements could omit the `component_id` keyword in the AST if routed through `_lift_consumer_stmt`. This led to inconsistent component identity and diffing issues. This change ensures that all known component calls receive a stable `component_id` argument before being lifted, regardless of path taken.
1 parent 8cc47a1 commit 6007d59

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

preswald/engine/transformers/reactive_runtime.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,6 +1539,16 @@ def _lift_statements( # noqa: C901
15391539
logger.debug(f"[AST] Missing atom mapping for {full_func_name=}. Regenerating...")
15401540
component_id, atom_name = self.generate_component_and_atom_name(full_func_name, stmt)
15411541

1542+
# Inject component_id into the call AST node if not already present
1543+
if isinstance(call_node, ast.Call):
1544+
already_has_id = any(kw.arg == "component_id" for kw in call_node.keywords)
1545+
if not already_has_id:
1546+
call_node.keywords.append(ast.keyword(
1547+
arg="component_id",
1548+
value=ast.Constant(value=component_id)
1549+
))
1550+
logger.debug(f"[AST] Injected component_id='{component_id}' into call '{full_func_name}'")
1551+
15421552
if self._uses_known_atoms(stmt):
15431553
self._lift_consumer_stmt(stmt)
15441554
else:

0 commit comments

Comments
 (0)