Repository navigation
feat(clients): explain an Atlas-tab preview that cannot load - #1203
Conversation
The panel held a blank rectangle in three cases it could name: the frame blocked, sahajatlas.com unreachable, and a region with nothing published. All three now land on the same explanation page the tab and the missing atlas role already use, so the five refusals read alike. Whether the region is empty is answered server-side rather than asked of the widget: which classes are published is this CMS's own fact, and the preview session sends no message carrying it. `atlasPreviewTarget` counts published, unfinished classes across the region's whole subtree, which is the public feed's own test rather than a plain count, so no SahajAtlasWeb change is needed. Blocked and unreachable are one case, because the browser cannot tell them apart from here: no first message from the atlas within a budget restarted by each `load`. `PreviewTarget`'s module state moves to `helpers/panelUrl`, so a URL one field composed is never read as a freshly resolved default by the next. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVMMpVpaBfNTttyXRB
Review of the branch, in four quality passes plus a security sweep. `drawnOnMapWhere` is now the one spelling of what the Atlas map draws, read by the geojson feed that returns those classes and by the preview panel that only asks whether a region has any. The copy had already lost the feed's placed-in-a-region clause, so a Worldwide service counted a class the map would not draw. The sitemap stays out of it: a crawler's reach is settled by the client's own published-only access. The emptiness question now follows the page the panel will open. A region whose slug chain cannot resolve has none, so the panel opens the atlas root — and asking its empty subtree refused a preview with every region to show. `heard` outlives the watch effect, because Payload renders the iframe once and never unmounts it: reopening the panel brings back a frame that already loaded and already spoke, and a restarted clock expired over a working map. A popup preview unmounts the window whole, so neither state is watched. Also: one `panelNoticeUrl`, so two fields cannot resolve the same reason against different origins; an existence read in place of a full count, on a path Payload resolves on every render and every save; and the spec's classes go through `testData.createEvent` rather than a second hand-rolled create. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVMMpVpaBfNTttyXRB
|
🚅 Deployed to the SahajCloud-pr-1203 environment in sahajcloud
1 service not affected by this PR
|
|
🤖 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
The diff is the size of its ticket and no larger. Two of its three new modules are verbatim moves — mapVisibility out of geojson.ts, panelUrl out of PreviewTarget — so the only new logic is atlasPreviewTarget and one effect. Answering the empty-region question from the CMS is the smaller of the two options #1201 offered, and it needs no SahajAtlasWeb release.
The one contract this touches does not move: drawnOnMapWhere is clause-for-clause what geojson.ts applied before, in the same order.
One real hole: the watchdog does not re-arm for a new panel address unless the frame fires load, which defeats what the [url] effect was added to do. The other two are naming and placement.
Findings
- should-fix —
MapPreviewField.tsx:153— effect order leaves a new address unwatched. - consider —
MapPreviewField.tsx:46—heardshadows the mode effect's ownheard. - consider —
mapVisibility.ts:3— a third module for onewherethatlifecycle/finishedcould hold.
What was checked
- Ladder.
setURLhas exactly two callers, both now throughpanelUrl;AdjustedColorsandAudioUploadread the context but never move the panel, so nothing is left outside the new seam. - Consumer side.
LivePreviewUnavailableReasonhas no reader outside the explanation page and the admin fields./api/events/geojsonis SahajAtlasWeb's surface, and itswhereis byte-equivalent. - Correctness.
descendantRegionIdsincludes the region itself, so a class on the city counts.buildRegionWebPathreturnsnullfor Worldwide, soopensOnis the root. - Preview links. All three are on-host and cite fixture ids on this branch:
1022001(atlas role, published classes underFixture Vasanta),1022008(new,Fixture Wellspring, nothing published),1022004(no atlas role).
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
React runs effect bodies in declaration order, so the `[url]` reset landed after the watchdog had already read `heard.current` as true from the old address and armed nothing. A new panel address was then watched only if the frame fired `load` — the one event a blocked frame may never deliver, which is the case the clock exists for. `heardFrom` holds the address the atlas has answered from instead of a bare flag, so a new address is unheard by construction and no effect ordering carries the answer. The separate `[url]` effect goes with it, and the rename settles the review's second point: the ref no longer shadows the mode effect's own `heard`. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVNAgnq9rueQAnvkWh
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVNAgnq9rueQAnvkWh
|
Three critic threads, all answered. Pushed c2fcaf6. Adopted
Rebutted
Lean gate ✓ (277 files, 3791 tests) and 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
@sydevs-bot Revise the error messages to be easier to understand for a non-technical user |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
Second pass, on the ask about the error messages. The words are already plain and the facts are right — what makes these hard for a volunteer is their shape.
Every body explains the machinery before it says what is wrong. All eight open the same way: "This panel shows the atlas as visitors see it…", "Live preview opens this service's own atlas…", "The preview draws this service's own region…". A volunteer needs two things, in order: what is wrong, then what to do. The opening clause is for whoever maintains the panel. Cutting it from each body halves the reading and loses nothing.
Then give every message a step. Five have one. atlas-unreachable ends in reassurance, and atlas-tab-only ends in a fact where it could say "Open the Atlas tab to see it".
Findings
- should-fix —
page.tsx:34—atlas-unreachableleaves the reader nothing to try. - should-fix —
page.tsx:43— "Publish a class in the region" names no place to click. - consider —
page.tsx:31— four nouns for two things.
What was checked
- Each pointer against the admin's own labels. "Service" (
Clients.ts:448), "Access" (:584), "Sahaj Atlas" as a role label (access/config/roles.ts:171) and "Location" (Events.ts:402) all name something on screen. Only "a class in the region" does not. - "Classes" stays. It is already this repo's volunteer-facing word (
InstallGuide/steps.ts:259, 356). Only the instruction needs the sidebar's word beside it. - The three bodies outside the diff —
no-path,no-region,not-reviewable— carry the same opening and the same fix. - Nothing re-litigated from the first review: its three threads are answered at c2fcaf6.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
…s-preview-notices
The unreachable notice ended in reassurance and named no action, so a volunteer reading it had nothing to try. Switching tabs and back re-points the panel at the atlas, which is the one recovery that works from inside the admin, and the ad blocker is the cause that explains most of these. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjX9Yhz36j1FrUDnG9i
"Publish a class in the region" named nothing a volunteer can click. The sidebar calls the collection Events, and that is the word the instruction needs beside the map's own "classes". Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjX9Yhz36j1FrUDnG9i
Every notice opened by explaining the machinery, so a volunteer read a sentence written for whoever maintains the panel before reaching their own problem. Each body now leads with what is wrong, or with the step that fixes it, and the table names one thing one way: the map, and the preview. "This panel" and the bare "atlas" as a name for either are gone, leaving "atlas" only where it names the Sahaj Atlas role. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjX9Yhz36j1FrUDnG9i
|
Error messages revised for a non-technical reader. Pushed c38feb8, on a clean merge of Adopted
The review's wider point, with them. All eight entries explained the machinery before naming the problem. Each now leads with what is wrong, or the step that fixes it. Lean gate ✓ (277 files, 3791 tests), 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
Change outline
Contract — the panel's refusal vocabulary
Two reason codes join the open vocabulary, each with its own copy on the page that already owns these explanations. No consumer outside the admin reads them.
Flow — how a
clientsdocument resolves its panel URLThe decision moves out of the inline
livePreview.urlinto a named helper beside the collection, which answers the page or the refusal that stands in for it.clients admin.livePreview.url({ data, locale, req }) src/collections/Clients/Clients.ts - isAtlasClient(data) ? buildRegionWebPath(…) ?? '' : null - reason: 'no-atlas-role' + atlasPreviewTarget({ data, req }) src/collections/Clients/atlasPreviewTarget.ts + not an atlas service → { path: null, reason: 'no-atlas-role' } + buildRegionWebPath(region) # null when the slug chain cannot resolve + opensOn = path === null ? null : region # a pathless region opens the ROOT, + # so the root's emptiness is the question + hasVisibleClasses(opensOn) + drawnOnMapWhere(now) # the feed's own predicate, below + + region in descendantRegionIds(…) # absent for Worldwide + find limit 1, pagination false, select one column # existence, not COUNT(DISTINCT id) + nothing to draw → { path: null, reason: 'no-classes' } + else → { path } livePreviewUrl({ base, params, ...target })Copy — what each notice says
Every entry opened by explaining the machinery before naming the problem, and three ended without
an action. Each body now leads with what is wrong, or with the step that fixes it, and the table
names one thing one way — the map, and the preview. The three entries outside this PR's own two
(
no-path,no-region,not-reviewable) carried the same opening and are rewritten with them.Flow — one predicate for what the map draws
The feed's three clauses were spelled once in the handler and copied, minus one, into the new count. Naming them is what stops the panel saying "no classes" beside a map with a pin on it.
Components — the Atlas tab's fields, and who may move the panel
MapPreviewFieldgrows a second effect: a clock the atlas's first message clears. Module state that was private toPreviewTargetbecomes the seam both fields compose through.Preview
Fixture Vasantaholds published classes: the live map, no notice. Blocksahajatlas.comin devtools and reload to see the unreachable notice after the clock.Fixture Wellspring(new, empty) has nothing published. Opens on the empty-region notice.no-atlas-roleexplanation, unchanged, for comparing the wording.Test results
clients-preview.int8 passed,events-geojson.int30 passed,atlas-sitemap.int22 passedManual verification
1022001, blocksahajatlas.comwith devtools request blocking and reload. The panel should show "The map did not load" within ~12s, not a blank rectangle.1022008, the Atlas tab should open on "This region has no published classes yet".1022001with nothing blocked, confirm the map draws, the Light/Dark toggle still repaints it, and moving a colour picker still repaints live.Notes for reviewer
Two judgement calls I'd like checked, both flagged by the review and both declined with reasons:
InfoBannerbeside the toggle. A banner would be reversible and need no new machinery; repointing is one-way, since navigating the frame away ends any chance of a late message. I kept the repoint because the ticket asks for the five cases to read alike, and the other four are the explanation page. If you prefer the banner, it is a smaller change than this one.MapPreviewField, not inPreviewTarget. Generalising it would give every preview surface the same notice — but it needs a per-surface answer about frontends that post nothing at all, which is a decision rather than a refactor. Filed as feat(admin): say why a live-preview panel is blank, on every surface rather than the Atlas tab alone #1204, with that decision as its open question, rather than widened here.Dismissed findings:
clientssession sendsdraft=true." — it should not:geojson.tsANDsPUBLISHEDeven for a live-preview request, by its own docblock, so the previewed map draws published classes only.MapPreviewFieldshould readpanelDefaultUrl()rather than the provider'surl." — it needs what the panel is showing, which is what tells it the panel is already explaining itself; the default stays the atlas URL throughout.URLparse per message.Detail
Why the empty-region signal is the CMS's, not the widget's. The ticket allowed for a SahajAtlasWeb ticket if the atlas had to report it. It does not: which classes are published is this repo's own fact, and
atlasPreviewTargetanswers it from the same predicate the map feed runs. No SahajAtlasWeb change is needed, and the preview session (startClientsPreview) is untouched.Four defects the review caught, each now pinned by a test:
PLACED_IN_REGION, so a Worldwide service counted a class the map drops.providers/LivePreview/index.js), so the reopened frame has already loaded and already spoken, and the fresh clock expired over a working map.heardFromnow outlives the effect, holding the address the atlas answered from, and only aloadclears it. A popup preview returnsnullfor the whole window, so that state is not watched either.[url]reset landed after the watchdog had read the old address's answer and armed nothing — leaving a new panel address watched only if the frame firedload, the one event a blocked frame may never deliver.heardFromholds the address rather than a flag, so a new one is unheard by construction and the separate[url]effect is gone.Fixture pre-mortem. The empty-region case needs a service whose region subtree holds nothing published. No existing fixture region qualified — every childless one either has published classes beneath it or is spoken for — so
Fixture Wellspring(regions1002007, a city underFixture Vasanta) andFixture Wellspring Circle(clients1022008) are new. Checked againstsrc/fixture/events.ts: published classes sit on1002003,1002002,1002005and1002013, none of them under the new city. Ids verified free insrc/fixture/ids.ts,regions.tsandclients.ts.Cost of the new resolution.
livePreview.urlis re-resolved on every server render of aclientsdocument and after every save, before Payload knows whether the panel is even open — so the check is one memoisedregionsread (already paid bybuildRegionWebPath) plus oneLIMIT 1events read.pagination: falseis what skips Payload'sCOUNT(DISTINCT id), so Postgres stops at the first matching row rather than aggregating a country.Security review: ran twice (the diff matches this repo's
securityReview.triggerPattern). No findings. It confirmed the geojson predicate is byte-equivalent to what it replaced, the explanation page'sObject.hasOwnguard still refuses prototype-chain keys, andpanelNoticeUrlcannot leave the admin origin becauselivePreviewUnavailableUrlis always path-absolute.Closes #1201
🤖 Generated with Claude Code
https://claude.ai/code/session_01Mg9rjVMMpVpaBfNTttyXRB