From b15025befd793b69632e2f58bc97109bf2a1f47c Mon Sep 17 00:00:00 2001 From: giles Date: Thu, 5 Mar 2026 01:45:04 +0000 Subject: [PATCH] Fix highlight undefined symbol by expanding component strings server-side Page helpers returning SX component call strings (e.g. "(~docs-intro-content)") were sent to the client unexpanded. Components containing Python-only helpers like `highlight` then failed with "Undefined symbol" on the client. Now async_eval_slot_to_sx re-parses and expands these strings server-side. Co-Authored-By: Claude Opus 4.6 --- shared/sx/async_eval.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/shared/sx/async_eval.py b/shared/sx/async_eval.py index b810129..bb617cf 100644 --- a/shared/sx/async_eval.py +++ b/shared/sx/async_eval.py @@ -1064,7 +1064,16 @@ async def async_eval_slot_to_sx( if result is None or result is NIL: return SxExpr("") if isinstance(result, str): - # Plain strings from page helpers are already sx source — don't quote. + # Page helpers return sx source strings. If the string is a + # component call (starts with "(~"), re-parse and expand it + # server-side so that Python-only helpers like ``highlight`` + # inside the component body get evaluated here, not on the client. + stripped = result.strip() + if stripped.startswith("(~"): + from .parser import parse_all + parsed = parse_all(stripped) + if parsed: + return await async_eval_slot_to_sx(parsed[0], env, ctx) return SxExpr(result) return SxExpr(serialize(result))