From 8c69e329e08ec90d50e4fbc38fc4a1f302c675a3 Mon Sep 17 00:00:00 2001 From: giles Date: Thu, 5 Mar 2026 09:37:07 +0000 Subject: [PATCH] Fix dict kwarg evaluation in renderComponentDOM, no-cache static in dev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dict values (e.g. {:X-CSRFToken csrf}) passed as component kwargs were not being evaluated through sxEval — symbols stayed unresolved in the DOM. Also add Cache-Control: no-cache headers for /static/ in dev mode so browser always fetches fresh JS/CSS without needing hard refresh. Co-Authored-By: Claude Opus 4.6 --- shared/infrastructure/factory.py | 8 ++++++++ shared/static/scripts/sx.js | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/shared/infrastructure/factory.py b/shared/infrastructure/factory.py index 188f581..601012f 100644 --- a/shared/infrastructure/factory.py +++ b/shared/infrastructure/factory.py @@ -341,6 +341,14 @@ def create_base_app( response.headers["HX-Preserve-Search"] = value return response + # Prevent browser caching of static files in dev (forces fresh fetch on reload) + if app.config["NO_PAGE_CACHE"]: + @app.after_request + async def _no_cache_static(response): + if request.path.startswith("/static/"): + response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" + return response + # --- context processor --- if context_fn is not None: @app.context_processor diff --git a/shared/static/scripts/sx.js b/shared/static/scripts/sx.js index 070f0bc..87efa7b 100644 --- a/shared/static/scripts/sx.js +++ b/shared/static/scripts/sx.js @@ -1286,8 +1286,8 @@ kwargs[args[i].name] = sxEval(v, env); } } else { - // Data arrays, dicts, etc — pass through as-is - kwargs[args[i].name] = v; + // Data arrays, dicts, etc — evaluate in caller's env + kwargs[args[i].name] = sxEval(v, env); } i += 2; } else {