Repository navigation
Description
Summary
A translator cannot preview an unsaved translation. SahajCloud's Live Preview repoints the panel at a real view per tab — /search, /filters, /calendar (sydevs/SahajCloud#773, open) — but the widget unlocks drafts only when the boot URL is exactly /preview, so every repointed panel renders published copy.
Approach
- The secret is the signal.
readPreviewParams(src/config/preview.ts:44) returnsnullfor any pathname butPREVIEW_PATH. Replace that pathname gate with asecretgate: a session exists when the query carries a non-emptysecret, on any route. Nopreview=1flag — nothing else unlocks a draft, so the secret's presence is the request./previewstays the document boot route that also carriescollectionandid, and stays inRESERVED_SLUGS(src/lib/shape/path.ts:238) so it never reads as a region. - State this behaviour change out loud.
/previewwith nosecretstops being a session. Today it returns{ active: true, …nulls }and the controller paintsPreviewFallbackover the screen — the defect feat(fields): declarative live-preview targets, repointed by the open tab SahajCloud#773's critic round found ("the Atlas base URL landed on an overlay"). After this it renders the base view, viaresolveStack's reserved-slug skip (src/lib/shape/path.test.ts:188).src/config/preview.test.ts:32pins the old behaviour and must be rewritten. - Keep the scrub, narrow it.
capturePreview(src/config/preview.ts:64)history.replaceStates toPREVIEW_PATH, dropping the whole query and any hash. It must delete onlysecretand re-writepathname + search + hash. Losing the hash was invisible while the target was always/preview; on a real view it is an observable side-effect. The secret still lives in memory only.src/main.tsx:28's comment needs rewording — thekey/mapread order above it still holds. - A document-less session must not take the screen.
PreviewController(src/components/preview/PreviewController.tsx:253,257) falls through toPreviewFallback— "Save this document to preview it." over a click-swallowingfixed inset-0. Distinguish "the URL named no document" from "named one we cannot boot":readPreviewParamsmust record that distinction itself (adocumentflag —collectionis nulled for an unrecognised value, so it cannot carry it). Rendernullfor the first, keepPreviewFallbackfor the second. - Scope the two session-wide hooks to a document session.
usePreviewLinkGuardandusePinnedPreviewQueriesrun ahead of the dispatch (PreviewController.tsx:248-249). The link guard inerts every<a>so a preview cannot leave the previewed doc; a translations session has no doc to leave, and an inert widget stops a translator reaching the screen a string lives on. The pinned['event']/['region']defaults protect live-overlaid docs a translations session never has. - Standalone only.
capturePreviewis called fromsrc/main.tsx:28and nowhere else. Keep it there:src/Widget.tsxmust never readsecretoff a host page's URL. This ticket widens the route, never the entry. - Nothing else is needed to reach drafts.
applyRequestContext(src/config/api/client.ts:45) already attachesx-sahajcloud-preview-secretanddraft=trueoncepreview.active && preview.secret. On the CMS sidehasValidPreviewSecret(SahajCloudsrc/lib/utilities/previewSecret.ts) compares againstSAHAJCLOUD_PREVIEW_SECRET, so a wrong secret is simply not a preview — drafts stay locked and the clientselect/populategate still applies. A bad value in a shared URL adds no failure mode.
Acceptance criteria
-
readPreviewParams('/search', '?secret=…')returns an active session with a nullcollectionandid. -
readPreviewParams('/preview', '')returnsnull— no secret, no session. This replaces today's active-with-nulls. -
/preview?collection=events&id=…&secret=…behaves exactly as it does today. - After boot the address bar carries no
secret, and the pathname, the remaining query parameters and the hash are unchanged. - With a session active on
/search, every SahajCloud request carries the secret header anddraft=true. - A saved-but-unpublished
sy-atlas-translationsdraft renders in the widget on a view path. - A document-less session renders no
PreviewFallback, no link guard and no pinned query defaults. -
src/Widget.tsxnever activates preview from the host page's query string.
Verification checklist
-
pnpm test:run— newreadPreviewParamsandcapturePreviewcases plus the rewrittenpreview.test.ts:32, each watched failing against the old behaviour first (docs/testing.md: a regression spec is not finished until it has failed). -
pnpm lint && pnpm typecheck && pnpm build && pnpm size. - Open
<cloudflare-preview>/search?secret=<SAHAJCLOUD_PREVIEW_SECRET>by hand and confirm a saved draft string renders. ⚠ The CMS cannot produce this URL yet — see Downstream impact. - Read the address bar after that boot: no
secret, still/search. - Open
<cloudflare-preview>/previewwith no query: the base country list renders, with no "Save this document to preview it." overlay.
Open questions
- Should a translations session leave in-widget links live, as the Approach assumes, or keep them inert so the panel stays on the tab's target?
- Does the scrub keep
collection/idin the address bar on/preview? This assumes yes — they are not credentials.
Downstream impact
sydevs/SahajCloud#773 must follow with the secret restored to both translations livePreview.url builders. Its critic round removed it because "the one route that does read one is also the only one that scrubs it" — this ticket makes every route scrub it, which is what re-earns it. translations-globals.int.spec.ts currently asserts the opposite, that locale is the only parameter either URL sends, so that follow-up flips the assertion. It lands after this.
Notes
- The previous revision's "unsaved edit" criterion was wrong, and this ticket no longer claims it.
sy-atlas-translationsdeclaresversions.draftswith no autosave (SahajCloudsrc/globals/SahajAtlasTranslations/SahajAtlasTranslations.ts:13), sodraft=truereturns the last saved draft, never the admin's in-form state. In-form edits arrive only aspayload-live-previewmessages, andusePreviewMessagesis mounted solely by the event and region controllers, throughpopulatePreviewDoc, typed'events' | 'regions'and unable to take a global. Rendering a genuinely unsaved translation needs a handler that shapes form state back throughi18n.addResourceBundle(src/config/locale.ts:111) — a different mechanism, and its own ticket. /previewcannot be retired alongside this change, asked on the thread. The route carries two jobs and this removes only the draft gate. Naming the document stays:webPathis virtual and publish-gated (SahajCloudsrc/fields/publicUrlFields.ts:104,163, andEvents.ts:331takes therequirePublished: truedefault), so the very draft Live Preview exists to show readswebPath: null— the CMS has no view path to point the panel at.PreviewController.tsx:121resolves it after fetching byid, and'preview'stays inRESERVED_SLUGSwhile it does. Retiring the route needs a draft-visible path in SahajCloud plus a route-keyed controller here, as its own ticket after this one.- Filed from feat(fields): declarative live-preview targets, repointed by the open tab SahajCloud#773 at the reviewer's request.
🤖 Written by the sydevs autonomous loop — see what this is
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Hold Until
Projects
- StatusShow more project fieldsDone
Activity
Ardnived commentedon Sep 14, 2026
@sydevs-bot Revise this. Instead of looking for a
preview=1query string, consider the present of the secret header as a request for a preview.sydevs-bot commentedon Sep 14, 2026
🤖 no session running
recent dispatches
Written by the sydevs dispatcher. Sessions never edit this comment.
sydevs-bot commentedon Sep 14, 2026
Revised: the secret is the signal, no
preview=1.readPreviewParamsgates on asecretparam, on any pathname./previewkeepscollectionandid./previewwith no secret stops being a session. Today it paints "Save this document to preview it." over the screen — the defect feat(fields): declarative live-preview targets, repointed by the open tab SahajCloud#773's critic round found.secret.draft=truereturns the last saved draft. In-form edits need a live-preview handler for a global — a second ticket. Comment@sydevs-bot splitto carve it out.## Downstream impact: feat(fields): declarative live-preview targets, repointed by the open tab SahajCloud#773 restores the secret to bothlivePreview.urlbuilders after this lands.Effort stays Moderate. Type unchanged.
@sydevs-bot implementstarts work.🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Ardnived commentedon Sep 14, 2026
@sydevs-bot Answer: can we further simplify the codebase by removing the
/previewendpoints alongside this change?sydevs-bot commentedon Sep 14, 2026
No — not in this ticket.
/previewdoes two jobs. This retires only one.Gone after this: the pathname as the draft gate. The secret unlocks drafts, on any route.
Still needed: naming which document to preview. The CMS cannot name the doc's own view path:
webPathis virtual and publish-gated (SahajCloudsrc/fields/publicUrlFields.ts:104,163) and Events takes that default, so the very draft Live Preview exists to show readswebPath: null. The widget resolves the path after fetching byid(PreviewController.tsx:121). That is whyEvents.ts:127andRegions.ts:113still build/preview?collection=…&id=…, and whypreviewstays inRESERVED_SLUGS.Dropping the route is a separate cross-repo change: expose a draft-visible path, key
PreviewControlleroff the route, retirecollection/id. It also churns the panel —livePreview.urlre-runs on form state, so a path from editable fields reloads on edits anidignores.Recorded under Notes. Comment to have the follow-up filed.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Ardnived commentedon Sep 16, 2026
Delivered by #208 (merged 2026-09-16), alongside
sydevs/SahajCloud#787/#788andsydevs/WeMeditateWeb#99.⚠ The mechanism is not the one this ticket describes. The body says "the secret is the signal" and gates on a non-empty
secretparameter. That approach was rejected during implementation, because widening the route gate without verifying turns any atlas URL into a denial of service: an active session inerts every<a>, snaps navigation back, pins all queries tostaleTime: Infinity, and addsdraft=trueplus the credential to every request — includingPOST /events/:id/register.public/_redirectsserves the SPA shell for every path, sosahajatlas.com/anything?live-preview=xwould have qualified. Share that link and the recipient gets a page where nothing is clickable, with no error.What shipped instead: SahajCloud signs a short-lived Ed25519 token, the widget verifies it with a committed public key, and verification is the gate. A forged or expired token opens no session at all.
?secret=<shared secret>?live-preview=<Ed25519 JWS>, 45–90 minhasValidPreviewSecretcompares againstSAHAJCLOUD_PREVIEW_SECRETAcceptance criteria
collectionandid./preview?collection=event-submissions&id=…still behaves as before (kept for that one collection; see Event submission preview — render a user-submission proposal from postMessage #163).draft=truewhile a session is active.sy-atlas-translationsdraft renders on a view path — though incidentally; see below.Widget.tsxnever activates preview from the host page's URL. Now asserted rather than assumed:Widget.standalone.test.tswalks the real import graph, static and dynamic, and refuses the widget any path toboot.ts/token.ts.PreviewFallback— deleted. Payload never offers live preview for an unsaved document (handleLivePreviewguardsoperation !== 'create'), so it was unreachable.useLivePreviewLinkGuard()andusePinnedLivePreviewQueries()still run above the document check, so a translations session gets a widget where nothing is clickable — the exact failure this ticket named.scopeis never read. Split out rather than left here, because everything else landed and the body no longer describes the system.Answering the open questions
collection/id? Yes. Only the token is removed.Beyond the ticket
?collection=&id=pair — a second unauthenticated claim about the URL that no longer has to be trusted.['event', id]while the drawers read['event', id, locale], so no live edit had ever rendered in the atlas.draft=trueleaves the browser before the token is proven.@payloadcms/live-preview-react, so the merge and relationship population are Payload's again.sydevs/SahajCloud#776is unblocked by this and closes alongside it.