Repository navigation
Description
Summary
A translator previewing sy-atlas-translations gets a widget where nothing is clickable, so they cannot reach the screen the string they are editing appears on.
SahajCloud points that panel at the atlas root with a scope parameter (src/globals/SahajAtlasTranslations/SahajAtlasTranslations.ts):
{ATLAS}/?locale=<code>&live-preview=<token>&scope=sy-atlas-translations
The widget verifies the token, opens a session — and then applies the document guards to it, because it never reads scope.
What actually happens
LivePreviewController runs both session-wide hooks before it resolves what is being previewed (src/components/live-preview/LivePreviewController.tsx):
export function LivePreviewController() {
useLivePreviewLinkGuard() // every <a> goes inert
usePinnedLivePreviewQueries() // ['event'] / ['region'] pinned to staleTime: Infinity
…
if (!target) return null // ← the document check happens here, too late
}Both are right for a document session: the link guard keeps the panel from navigating away from the document being edited, and the pinned defaults protect a live-overlaid doc from being refetched out from under the edit.
Neither is right for a translations session. There is no document to navigate away from, and no ['event']/['region'] overlay to protect. The guards only take away the navigation the translator needs.
The underlying gap: scope is unread
src/config/live-preview/protocol.ts's LivePreviewSession is { active, token, collection, id }. There is no scope field, and readLivePreviewParams does not look for one — so the parameter the CMS sends rides in the URL unused.
⚠ WeMeditateWeb already models this, and the two consumers should agree. Its LivePreviewState is { active, scope }, readLivePreviewScope parses a closed set, and useDocumentPreviewActive() is active && scope === null — which is exactly the distinction missing here. See lib/live-preview/protocol.ts and session.ts in that repo.
Second-order: a scoped session still drafts everything
applyRequestContext (src/config/api/client.ts) adds draft=true to every request whenever the session is active. So a translations preview also puts events and regions into draft mode.
It is why the translations criterion in #206 passes at all today — drafts arrive incidentally. But it means a translator checking their strings sees them on top of whatever unsaved event and region drafts happen to exist, rather than on published content. WeMeditateWeb scopes this deliberately: "a page preview must not hand drafts to the translations read, and a translations preview must leave the page itself published."
Approach
- Add
scopetoLivePreviewSessionand parse it inreadLivePreviewParams, as a closed set ('sy-atlas-translations'), unrecognised values falling back tonull. Mirror WeMeditateWeb's names. - Move
useLivePreviewLinkGuardandusePinnedLivePreviewQueriesbehind the document check, or gate them onscope === null. - Decide whether
draft=trueshould be scoped too, or stay session-wide. Scoping it is more correct and a wider change — it may deserve splitting out. - Landing each tab on its own view is a separate door from the guards, and reaches four of the five unreachable tabs on its own. See "A resolved target" below.
Why a target per tab does not replace this
SahajCloud already repoints the panel per tab (previewTargetField), and search, filters and calendar declare a path. Those three tabs need no clicking, and targeting is the right mechanism for them.
It cannot cover the rest. A PreviewTarget is JSON, never a function (src/fields/previewTargetField.ts), and the global's livePreview.url reads locale and never data, so a target can only ever name a fixed path. The remaining views are keyed by a document or by layout (resolveStack, src/lib/shape/path.ts):
eventis/<region>/<id>,registrationis<event>/register,shareis<event>/share. Each needs a live event id, which expires.onlineis<region>/online, so it needs a region that has online events.compactrenders only when the embed box is too small, measured at mount (src/lib/slot-decision.ts). No parameter asks for it.
Those tabs are reachable only by clicking, which is exactly what the link guard inerts.
A resolved target reaches four of those five
A fixed path cannot name them. A path the widget resolves can, and it needs no CMS code: composeTargetUrl merges a target's params over the default URL, so a tab declares "preview": { "params": { "view": "event" } } in translationsSchema.json and nothing else changes on that side.
The widget then resolves view at boot, inside a verified session only, into a real path — eventsQuery (src/config/api/index.ts:55) picks the soonest published event for event, registration and share, and a region carrying online events for online. Because the document is chosen at render, it cannot expire the way a hard-coded id would.
Two alternatives were weighed and rejected:
- Pick the id server-side in
livePreview.url. It costs a database read on every resolve, and the id still goes stale mid-session. - A target per key rather than per tab. Not available:
previewTargetFieldis tab-level only, because a collapsed collapsible still mounts its fields.
compact stays unreachable by any link. It is measured at mount, and this repo deliberately offers no override parameter — an open decision, not a design yet.
Acceptance criteria
- A session opened with
scope=sy-atlas-translationsleaves every in-widget link live, and pins no query defaults. - A document session (an event or region path) keeps both guards exactly as they are today.
- An unrecognised
scopevalue behaves as an unscoped document session, never as an error. - A saved-but-unpublished translations draft still renders, on any view path.
Verification
-
pnpm lint && pnpm typecheck && pnpm test:run && pnpm build && pnpm size— each new assertion watched failing against today's behaviour first (docs/testing.md). -
/admin→ Sahaj Atlas → Translations → any tab: navigate inside the panel and confirm the widget still responds. - The same panel on an event path: confirm links are still inert.
Context
Split out of #206 while closing it. #206 listed "a document-less session renders no PreviewFallback, no link guard and no pinned query defaults" as an acceptance criterion; PR #208 delivered the first (PreviewFallback is gone) and not the other two. Everything else in #206 shipped, so this is the remainder rather than a reopening.
Metadata
Metadata
Assignees
Labels
Type
Fields
Hold Until
Projects
- StatusShow more project fieldsDone
Activity
Ardnived commentedon Sep 17, 2026
@sydevs-bot Answer: Why do translation previews need to be able to navigate? In theory
SahajCloudalready has a mechanism to land each tab on the correct page, which if configured correctly will be more reliable than the user navigating around.sydevs-bot commentedon Sep 17, 2026
🤖 no session running
recent dispatches
Written by the sydevs dispatcher. Sessions never edit this comment.
sydevs-bot commentedon Sep 17, 2026
Three tabs already use targets. Five name a view no static path can reach.
A
PreviewTargetis JSON, never a function (src/fields/previewTargetField.ts:7), and the global'surlreadslocale, neverdata. So it can only name a fixed path.search,filtersandcalendardeclare one, and those tabs need no clicking.The rest are keyed by a document or by layout (
src/lib/shape/path.ts:274):eventis/<region>/<id>,registrationis<event>/register,shareis<event>/share. Each needs a live event id, which expires.onlineis<region>/online, so it needs a region that has online events.compactrenders only when the box is too small, measured at mount (src/lib/slot-decision.ts).Those five are reachable only by clicking, and the guard inerts every
<a>but a#hash.Recorded under Approach in the body.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Ardnived commentedon Sep 17, 2026
@sydevs-bot Research possible alternative solutions instead of removing the restriction on clicks, how can we create an actual usable preview link that goes directly to showing the place where the translations are used?
sydevs-bot commentedon Sep 17, 2026
The best link-based option is a
viewparam the widget resolves, not a static path.composeTargetUrlalready merges a target'sparamsover the default URL, so"preview": { "params": { "view": "event" } }intranslationsSchema.jsonneeds no CMS code. At boot, inside a verified session, the widget swapsview=eventfor a real path built fromeventsQuery(src/config/api/index.ts:55) — the soonest published event. Same forregistration,shareandonline. The target stays JSON, and the id is picked at render, so it cannot expire.Rejected: picking the id server-side in
livePreview.url(a database read on every resolve, and it goes stale mid-session), and a per-key target (previewTargetFieldis tab-level only).compactstill has no link. It is measured at mount (src/lib/slot-decision.ts), and this repo refuses an override parameter by design. That one needs your call.Recorded under Approach. The link guard question is now independent of it.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Ardnived commentedon Sep 18, 2026
@sydevs-bot implement