read.markets/app/routers
Giorgio Gilestro 21835afebe analyze: send the live toggle lang from the frontend, log resolution
The /api/analyze flow previously read principal.user.lang from the
DB on every request and ignored anything the client might send. That
races the language toggle's PATCH: a user can flip the toggle and
click Generate/Regenerate before the PATCH /api/settings/language
hits the DB, so the analysis is sent with the OLD persisted lang
while the toggle visually reads as the new one. From the user's POV
the analysis comes back in the wrong language.

Frontend portfolio.js now reads the live #lang-toggle data-lang
attribute (the same source the UI itself uses) and includes it in
the /api/analyze body. The dataset attribute is updated optimistically
by cassandraSetLang() before the PATCH fires, so it always reflects
what the user is looking at.

Backend universe.py prefers payload["lang"] when present and falls
back to user.lang otherwise — older clients (scripts, direct curl)
that don't send anything still get the DB-stored preference. The
resolution path is logged so we can confirm in prod which lang
actually drove a given request.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 15:32:58 +02:00
..
__init__.py initial commit — cassandra v0.1 2026-05-15 21:56:10 +01:00
api.py Revert "i18n: add diagnostic logging to localizer + lang-toggle click path" 2026-05-27 23:55:59 +02:00
auth.py ui: collapsible settings sections + welcome-email + larger auth inputs 2026-05-26 22:32:59 +02:00
chat.py i18n: prepend a strong language directive for portfolio + chat 2026-05-29 15:21:00 +02:00
email.py css: split cassandra.css into per-section files 2026-05-28 12:31:29 +02:00
ops.py routers: extract chat + ops from api.py 2026-05-27 21:43:17 +02:00
pages.py ui: log page tone badge follows the toggle (novice / pro) 2026-05-29 12:17:49 +02:00
polar_webhook.py stripe: per-cadence cooling-off + manage-subscription button 2026-05-26 20:06:19 +02:00
public.py stripe: wire checkout, customer portal, and webhook for read.markets 2026-05-26 18:45:13 +02:00
stripe_billing.py stripe: detect buyer currency at checkout (GBP/USD/EUR) 2026-05-28 12:42:40 +02:00
sync.py sync: detect orphaned blobs (pepper rotation) + fix AESGCM arg order 2026-05-25 12:49:11 +02:00
ticker_validate.py ticker-validate: add /api/ticker/historical with weekend-walkback 2026-05-27 14:45:52 +02:00
universe.py analyze: send the live toggle lang from the frontend, log resolution 2026-05-29 15:32:58 +02:00