From dea4f52454b030e132cbe76f3f86f28de5847e65 Mon Sep 17 00:00:00 2001 From: giles Date: Thu, 5 Mar 2026 10:20:24 +0000 Subject: [PATCH] Expand known components server-side in _aser to fix nested highlight calls _aser previously serialized all ~component calls for client rendering. Components whose bodies call Python-only functions (e.g. highlight) would fail on the client with "Undefined symbol". Now _aser expands components that are defined in the env via _aser_component, producing SX wire format with tag-level bodies inlined. Unknown components still serialize as-is. Co-Authored-By: Claude Opus 4.6 --- shared/sx/async_eval.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared/sx/async_eval.py b/shared/sx/async_eval.py index 395b10d..7b5d78d 100644 --- a/shared/sx/async_eval.py +++ b/shared/sx/async_eval.py @@ -1159,12 +1159,14 @@ async def _aser(expr: Any, env: dict[str, Any], ctx: RequestContext) -> Any: if name.startswith("html:"): return await _aser_call(name[5:], expr[1:], env, ctx) - # Component call — expand macros, serialize regular components + # Component call — expand macros, expand known components, serialize unknown if name.startswith("~"): val = env.get(name) if isinstance(val, Macro): expanded = _expand_macro(val, expr[1:], env) return await _aser(expanded, env, ctx) + if isinstance(val, Component): + return await _aser_component(val, expr[1:], env, ctx) return await _aser_call(name, expr[1:], env, ctx) # Serialize-mode special/HO forms (checked BEFORE HTML_TAGS