ReviewOS

also looking at this

stacks/analyticshq

fix(dashboard): unshadow the bridged range so site switching works

#54
Merged glennmichael123 wants to merge fix/switch-site-range into main
2 files +45 -3
9 days ago

Switching sites in the dashboard throws ReferenceError: range is not defined from switchSite (screenshot in the session; reproduced on main).

Cause — mine, from the Fathom upload work. switchSite reads range, a server const that reaches the <script client> block through stx's data bridge via defineClientPayload(...). The bridge inlines a bridged name only if the block does not itself declare it — and that check is textual, not scoped. The Fathom import code added const range = first.data.range inside a nested branch of the same block, so the bridge withheld range from the whole block.

The emitted page shows it plainly. The client block (<script data-stx-scoped>) received six of the seven payload names — range missing — while the sibling <script type="module"> block, which declares nothing, got all seven including var range = "1y". switchSite and the nested const range both live in the starved block.

Fix. Rename the local to importRange (three sites) with a two-line comment saying why the name is reserved. Recompiled: the client block's bridge section goes 6 → 7 names, var range = "1y" is back beside switchSite, no bare range.from remains.

Regression test. tests/unit/client-payload-hygiene.test.ts fails on any view whose client block re-declares a defineClientPayload name. On the previous commit it names dashboard.stx: ["range"]; here it passes. fathom-import 74/74; pickier clean.

Not clicked through: the dashboard needs a signed-in Postgres-backed session that doesn't exist locally, so this was proven by the compiled output before/after rather than by operating the select.

2 changed files on the files tab, with 0 review threads.

Sign in to comment on this pull request.