Repository navigation
feat(admin): say why a live-preview panel is blank, on every surface rather than the Atlas tab alone - #1209
Conversation
…ab alone #1201 gave the Clients Atlas tab a notice when its preview frame never answers. Every other live-preview surface still showed a blank rectangle. The detector moves off `MapPreviewField`'s own message listener and onto Payload's `appIsReady`, which every subscribing consumer sets through the live-preview handshake. `previewNoticePlugin` mounts the watcher on every entity declaring `admin.livePreview`, so no surface declares anything. The three scoped-global previews are excluded: both consumers mount their subscriber only for an unscoped session, so a watchdog over them would call a working preview blocked. The arming condition reads the panel URL's own `scope`, which this repo writes. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWVXUcw6agBdvJJKM7
Each case fails against its own defect: the scope rule, the closed panel, the popup, a frame that has spoken, a panel already explaining itself, the `load` restart, and an address the latch had to be cleared for. The `load` restart is kept from #1201 rather than dropped with the message listener: it bounds silence from a frame that has settled, so a slow network buys itself more time instead of being called blocked. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWVXUcw6agBdvJJKM7
- One `appendDocumentControl` (`src/lib/admin/documentControls.ts`) holds the slot append and the ⚠ that a global's slot is `components.elements` while a collection's is `components.edit`. `withUploadNotice` and `previewNoticePlugin` are three lines each, and the new mount inherits the guard spec the old one had. - The preview `scope` vocabulary is named once and typed on `livePreviewUrl`, so a scope spelled only at a call site cannot leave its panel unwatched with nothing to say so. - One base for reading a part off a panel URL, since two readers of one address that disagree about its origin disagree about the address. - The latch clear now carries the watcher's own guards, and dispatches nothing when the latch is already clear. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWVXUcw6agBdvJJKM7
The panel URL cannot answer whether a page runs a live-preview subscriber. `lectures` carries no scope and looked watchable, but WeMeditateWeb mounts `LivePreviewDocument` on `pages/[slug]` and `meditations/[id]/embed` only — `lectures/[id]/(full)` renders `LectureTemplate` bare. Watching it would have replaced a working preview with "the preview did not load" 12 seconds after the panel opened. So the exception moves to the entity, which knows: `previewNoticePlugin` skips one declaring `admin.custom.livePreviewSubscribes: false`. It is an opt-out, so a new surface is still covered by declaring nothing. The three scoped globals declare it for the same reason the scope rule excluded them. `PREVIEW_SCOPES` stays as the typed vocabulary its two consumers read back. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWVXUcw6agBdvJJKM7
|
🚅 Deployed to the SahajCloud-pr-1209 environment in sahajcloud
1 service not affected by this PR
|
sydevs-bot
left a comment
There was a problem hiding this comment.
1 question for the reviewer, one per thread.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
Moving the clock onto Payload's own appIsReady is the right shape, and smaller than what it replaces. Finding that lectures subscribes to nothing, and declaring that on the entity rather than guessing it from the panel URL, is the best thing in the diff.
Three of the seven new pieces answer nothing the ticket asked for: src/lib/livePreview/scope.ts, the scope option on livePreviewUrl, and PANEL_URL_BASE. Each replaces a literal that worked on main, and the first two are justified by a reader this PR then abandoned.
Nothing else looked oversized. The ladder came back empty on the rest: the slot, the latch and admin.custom are all Payload's own.
Findings
should-fix—src/lib/livePreview/scope.ts:11: nothing readsPREVIEW_SCOPESback, and two docblocks say a watchdog does.consider—src/lib/livePreview/unavailable.ts:28:PANEL_URL_BASEis exported for one use three lines below.consider—src/lib/admin/documentControls.ts:50: the globals arm mounts on no entity today.
What was checked
Read whole: LivePreviewNotice, previewNotice/plugin.ts, documentControls.ts, MapPreviewField, uploadNotice.ts, panelUrl.ts, both new specs.
Verified upstream rather than trusting the cites: renderDocumentSlots reads edit for a collection and elements for a global; beforeDocumentControls renders inside LivePreviewProvider; setLivePreviewURL clears appIsReady while the raw setter behind urlFromProps does not. Plugin order puts this after formsPlugin, so user-submissions is covered.
Consumer side: WeMeditateWeb mounts LivePreviewDocument on pages/[slug] and meditations/[id]/embed only, so lectures is right; SahajAtlasWeb subscribes for event, region and submission.
Every preview link is on-host, and each id exists in src/fixture/.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
`PREVIEW_SCOPES` and the `scope` option on `livePreviewUrl` were both
justified by a watchdog arming on the panel URL's scope. That mechanism is
gone: `previewNoticePlugin` reads `admin.custom.livePreviewSubscribes`
instead. All four references were emitters, and two docblocks claimed a
reader that does not exist.
The closed set does not earn them either. Both consumers branch on
presence alone — SahajAtlasWeb's `documentPreviewActive` and
WeMeditateWeb's `useDocumentPreviewActive` each return
`active && scope === null` — so no consumer distinguishes one value from
another, and a typed set here enforces nothing across the seam. Where the
value does matter, the call site already says so in prose.
Back to the inline `params: { scope: '…' }` spelling. Every emitted query
string is byte-identical: `scope` sat between `params` and the token, which
is where the spread put it.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjY73RxDdgXLKoRA8zT
`PANEL_URL_BASE` was exported for a single use three lines below it, where `main` had the literal inline. Its docblock argued against two readers that disagree about an address's origin — there is one, and exporting the constant invites the second rather than preventing it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjY73RxDdgXLKoRA8zT
|
Three critic findings addressed. Head Adopted
Rebutted
Still open — whether
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
The reviewer answered B on the lecture question: WeMeditateWeb mounts the subscriber, and this opt-out comes out when that merges. Without the trigger beside the line, a reader cannot tell a permanent exception from a parked one — and the coverage spec pins `['lectures']`, so the removal is a pair. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVpbR6TsqiEZnzy81b
|
The lecture question is answered. Head Answered
The opt-out stays on this branch until that merges, and No other thread waits on us, and 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Ardnived
left a comment
There was a problem hiding this comment.
It feels like we have a few divergent ways to handle live preview notice / live preview unavailable now. Review them all, not just the changes in this PR and consolidate them if feasible.
Three things point a panel at the explanation page — the server, a tab's `previewTargetField` declaration, and the watchdog — and they shared one flat union of reasons. `helpers/panelUrl` tells a URL a component composed from one the server resolved by comparing the URL text alone, so the three are only safe while the server's reasons and the panel's are disjoint. Nothing stated that or enforced it: a reason emitted from both sides would make the two byte-identical, `panelDefaultUrl()` would keep returning the previous document's URL, and a tab's repoint would compose against that document's origin — the hazard `PreviewTarget`'s own docblock names. `ServerResolvedReason` and `PanelComposedReason` name the two halves, each entry point now takes only its own, and the spec fails on an overlap. `composePanelNotice` is the one browser-side way to put an explanation in the panel; `panelNoticeUrl` stops being exported. Both callers behaved identically before, spelled twice. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXb96GRbMpLQnwsd1F
|
Reviewed every way a panel says it is blank, and consolidated what could be. Head Adopted — "review them all … and consolidate them if feasible" Three entry points reach The real divergence was the vocabulary: one flat union, while the system rests on its two halves being disjoint.
The three cannot become one — server render, tab mount, 12 s of silence. Notes for reviewer carries the table and why. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
… since the pilot (#1239) #1217 had to edit a hand-kept tab list to drop one tab; the schema file is the list. #1209's admin-ui section restated LivePreviewNotice's own appIsReady comment and enumerated the opt-outs a grep finds. The ⚠ invariants and the WeMeditateWeb#287 pointer stay. Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
lecturesis left unwatched: its WeMeditateWeb route mounts no subscriber, so watching it would have replaced a working preview with an error page. The reviewer chose to make it subscribe instead — feat(preview): stream unsaved lecture edits into the preview panel WeMeditateWeb#287 — and this line comes out when that merges.withUploadNoticeand the new mount share oneappendDocumentControl, which records that a global's slot is not a collection's.Change outline
The watchdog left the Atlas tab and became a panel-level concern.
Who resolves which reason, after the review pass below.
What arms the clock, and what stands it down.
Preview
Test results
pnpm test:unit(3851 passed)clients-preview,wm-web-live-preview,translations-globalsintegration specs (53 passed);live-preview-notice,preview-notice-coverage,atlas-preview-fields,preview-target-component,upload-notice-coverage,fixture-coverage,lib-boundary,client-bundle-safetyunit specsManual verification
Notes for reviewer
The review of every way a panel says it has nothing to show. Asked for on the second review
round. Three entry points exist, and they already shared one destination page, one reason
vocabulary and one composer:
livePreviewUrl(server)no-atlas-role,no-classes,no-key,no-path,no-region,not-reviewableadmin.livePreview.urlpreviewTargetField({ unavailable })(a tab)atlas-tab-onlycomposePanelNotice, in the browserLivePreviewNotice(the watchdog)preview-unreachablecomposePanelNotice, in the browserWhat was actually divergent, and is now one thing. The vocabulary was a single flat union, so
nothing said which half a reason belonged to — yet the whole system rests on the two halves being
disjoint.
trackPanelUrltells a URL a component composed from one the server resolved bycomparing the URL text alone. A reason emitted from both sides makes those two byte-identical:
the server's explanation is taken for ours,
panelDefaultUrl()keeps returning the previousdocument's URL, and a tab's repoint composes against that document's origin — the hazard
PreviewTarget's own docblock names.ServerResolvedReasonandPanelComposedReasonsplit it,each entry point takes only its own half (a
tscerror otherwise), andlive-preview-unavailable.spec.tsfails on an overlap — watched failing against a'no-path'added to the panel half.
The two browser paths also spelled
composePanelUrl(setURL, panelNoticeUrl(reason))separately.composePanelNoticeis now the one way in, andpanelNoticeUrlis no longer exported.What did not merge, and why. The three entry points cannot become one: they resolve at three
different moments — server render, tab mount, and 12 s of silence — and the first has no browser
to run in while the last has no field to mount on.
PreviewTargetandLivePreviewNoticestayseparate components for the same reason: one is a
uifield inside a tab, which is the onlysignal the client has for which tab is open, and the other is a document control that must mount
where no field is declared. They share everything below that seam.
Which surfaces are watched, and why.
clientsAtlas tabstartClientsPreviewevents,regions,user-submissionsLivePreviewController/SubmissionLivePreviewpages,meditationsLivePreviewDocumentlecturessy-atlas-translations,wm-web-translations,wm-web-configThe ticket's survey was wrong about one row, and it changed the mechanism. It has the watcher
arm on the panel URL's
scope, on the premise that every unscoped preview subscribes.lecturesis unscoped and does not: WeMeditateWeb mounts
LivePreviewDocumentonpages/[slug]andmeditations/[id]/embedonly, andlectures/[id]/(full)rendersLectureTemplatebare. A panelURL cannot express that, so the exception moved to the entity —
admin.custom.livePreviewSubscribes: false, an opt-out, so a new surface is still covered bydeclaring nothing.
That exception is now temporary. The question thread asked whether
lecturesshould stayunwatched or start subscribing, and the reviewer answered B: WeMeditateWeb mounts
LivePreviewDocumentonlectures/[id]/(full), and the opt-out line comes out when that merges.sydevs/WeMeditateWeb#287 holds that work, and the line now names it.
That left a
PREVIEW_SCOPESvocabulary and ascopeoption onlivePreviewUrlwith no reader,and review took both out: every reference was an emitter, and both consumers branch on a scope's
presence alone (
active && scope === null), so neither distinguishes one value from another.The four call sites are back to
main's inlineparams: { scope: '…' }, and every emitted querystring is byte-identical.
One behaviour from #1201 was kept that the ticket dropped. The ticket's clock has no
loadlistener. The listener is kept, because it bounds silence from a frame that has settled rather
than the whole load — without it a slow first byte eats the budget, and under-waiting replaces a
working preview with an error page. It is pinned by a test.
Dismissed review findings. Parsing the panel URL once across both predicates, and splitting the
appIsReadydependency into its own effect to save one listener re-attach: both are a handful ofallocations per document view, and each costs a public signature or a second effect. Patching
@payloadcms/uiso its raw URL setter clearsappIsReadyas its own docblock promises: declinedas disproportionate, and the component's docblock now says the fix stops there on purpose.
Dropping
appendDocumentControl's globals arm because no global is watched today: declined —previewNoticePluginpassesglobals: watched, so removing it would leave a future globaldeclaring only
admin.livePreviewsilently unwatched, which is the opt-out design inverted.Detail
Why the document controls and not a field.
beforeDocumentControlsrenders insideLivePreviewProviderand needs no declaration per surface.PreviewTargetwas the alternative,and it mounts only where a
previewTargetFieldis declared —pages,lectures,eventsandregionsdeclare none.Why
appIsReadyand not #1203's ref. The latch is provider state, so it survives the panelbeing closed and reopened (Payload renders the iframe once and never unmounts it), and the
component needs no
postMessagelistener of its own. Its one gap is that Payload clears it in thecontext's
setURLbut not when the server re-resolves the URL — every save — which the componentcloses itself.
Security review: ran (the diff touches
src/components/admin/andsrc/payload.config.ts).No findings, over three rounds — the third after the vocabulary split, which only narrows what may
reach the notice URL builder from eight reasons to two compile-time literals. It traced the
live-preview token through every
livePreviewUrlcall site (the token key spreads last, so acaller's
paramscannot displace it),composePanelNoticeintosetURL(alwayssame-origin, built from a compile-time literal), the unauthenticated explanation page (lookup and
rendering unchanged), and
appendDocumentControlagainst thewithUploadNoticeit replaces(identical for collections; the globals arm is an identity map when no predicate is passed).
Fixture pre-mortem. No new rows. The six links above name rows that exist on this branch:
clients1022001,regions1002002 andpages1014001 are anchors insrc/fixture/ids.tsandcontent-ids.ts;user-submissions1026040 andlectures1019001 are written insrc/fixture/user-submissions.tsandsrc/fixture/lectures.ts. The new component is registered insrc/fixture/views.ts, whichtests/unit/fixture-coverage.spec.tschecks.Closes #1204
🤖 Generated with Claude Code
https://claude.ai/code/session_01Mg9rjWVXUcw6agBdvJJKM7