Skip to content

feat(clients): explain an Atlas-tab preview that cannot load - #1203

Merged
sydevs-bot merged 8 commits into
mainfrom
claude/feat-1201-atlas-preview-notices
Nov 18, 2026
Merged

sydevs-bot merged 8 commits into
mainfrom
claude/feat-1201-atlas-preview-notices

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The Atlas tab's preview panel now names the three cases it used to answer with a blank rectangle: the frame blocked, the atlas unreachable, and a region with nothing published.
  • All five refusals land on the same explanation page, so they read alike.
  • Every notice on that page now leads with what is wrong and ends in a step, in the reviewer's words rather than the panel maintainer's.

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.

 LivePreviewUnavailableReason                 src/lib/livePreview/unavailable.ts
   'atlas-tab-only'                           # the panel belongs to another tab
+  'atlas-unreachable'                        # nothing ever arrived from the atlas
   'no-atlas-role'
+  'no-classes'                               # the region draws nothing
   'no-key' | 'no-path' | 'no-region' | 'not-reviewable'

Flow — how a clients document resolves its panel URL

The decision moves out of the inline livePreview.url into 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.

+ drawnOnMapWhere(now)                         src/lib/events/mapVisibility.ts
+   notFinishedWhere(now)                      # re-exported from Events' lifecycle
+   PUBLISHED                                  # moved here, verbatim
+   PLACED_IN_REGION                           # moved here, verbatim

 GET /api/events/geojson                       src/collections/Events/endpoints/geojson.ts
-  andWhere(query.where, { and: [notFinishedWhere(now), PUBLISHED, PLACED_IN_REGION] })
+  andWhere(query.where, drawnOnMapWhere(now))

Components — the Atlas tab's fields, and who may move the panel

MapPreviewField grows a second effect: a clock the atlas's first message clears. Module state that was private to PreviewTarget becomes the seam both fields compose through.

 src/components/admin/
 ├── helpers/
+│   └── panelUrl.ts          # the panel's default + what WE pointed it at, for every field that moves it
+│                            #   trackPanelUrl / panelDefaultUrl / composePanelUrl / panelNoticeUrl
 ├── PreviewTarget/
-│   └── PreviewTarget.tsx    # owned that state privately, and composed its own notice URL
+│   └── PreviewTarget.tsx    # reads the seam; unchanged behaviour
 └── AtlasPreview/
     └── MapPreviewField.tsx  # the light/dark toggle …
+                             #   … + a silence clock, armed per load AND per address, cleared by the atlas's first message
 MapPreviewField                               src/components/admin/AtlasPreview/MapPreviewField.tsx
   effect [iframeRef, mode, url]               # unchanged: re-send the mode once the atlas listens
+  effect [iframeRef, isLivePreviewing, previewWindowType, setURL, url]
+    no frame, or the panel already explaining itself      → watch nothing
+    panel closed, or preview moved to a popup             → watch nothing
+    heardFrom === url (a ref, cleared only by `load`)     → do not re-arm
+    ATLAS_SILENCE_MS elapses with nothing heard
+      composePanelUrl(setURL, panelNoticeUrl('atlas-unreachable'))

Preview

  • Fixture Vasanta Community Site — Atlas tab — atlas role, region Fixture Vasanta holds published classes: the live map, no notice. Block sahajatlas.com in devtools and reload to see the unreachable notice after the clock.
  • Fixture Wellspring Circle — Atlas tab — new fixture: atlas role, region Fixture Wellspring (new, empty) has nothing published. Opens on the empty-region notice.
  • Fixture Mobile App — no atlas role: the existing no-atlas-role explanation, unchanged, for comparing the wording.

Test results

  • Lean gate: ✓ lint, format, typecheck, typecheck:tests, unit lane (277 files, 3791 tests)
  • Targeted specs: clients-preview.int 8 passed, events-geojson.int 30 passed, atlas-sitemap.int 22 passed
  • Build: N/A (Railway builds the preview)

Manual verification

  1. On the Atlas tab of client 1022001, block sahajatlas.com with devtools request blocking and reload. The panel should show "The map did not load" within ~12s, not a blank rectangle.
  2. Switch to the Config tab and back. The panel should return to the live map.
  3. On client 1022008, the Atlas tab should open on "This region has no published classes yet".
  4. On client 1022001 with nothing blocked, confirm the map draws, the Light/Dark toggle still repaints it, and moving a colour picker still repaints live.
  5. The sample registrant email below the colours is unchanged and still starts collapsed.

Notes for reviewer

Two judgement calls I'd like checked, both flagged by the review and both declined with reasons:

  • The browser-side refusal repoints the panel rather than rendering an InfoBanner beside 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.
  • The watchdog lives in MapPreviewField, not in PreviewTarget. 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:

  • "The empty-region count should also see drafts, since a clients session sends draft=true." — it should not: geojson.ts ANDs PUBLISHED even for a live-preview request, by its own docblock, so the previewed map draws published classes only.
  • "MapPreviewField should read panelDefaultUrl() rather than the provider's url." — 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.
  • Merging the two effects' listeners, or the state they keep — their lifetimes differ on purpose: the mode effect's own answer resets on every re-run, so a mode change re-posts on the next message, while the watchdog's must survive one or reopening the panel re-arms the clock over a working map. The cost kept is one URL parse 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 atlasPreviewTarget answers 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:

  1. The copied predicate had lost PLACED_IN_REGION, so a Worldwide service counted a class the map drops.
  2. The emptiness question was asked of the region even when the panel would open the atlas root, refusing a preview that had every region to show.
  3. A first attempt at disarming the clock on panel close re-armed it on reopen — but Payload renders the iframe once and never unmounts it ("defer load and never unmount", providers/LivePreview/index.js), so the reopened frame has already loaded and already spoken, and the fresh clock expired over a working map. heardFrom now outlives the effect, holding the address the atlas answered from, and only a load clears it. A popup preview returns null for the whole window, so that state is not watched either.
  4. Caught by the second round: React runs effect bodies in declaration order, so the [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 fired load, the one event a blocked frame may never deliver. heardFrom holds 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 (regions 1002007, a city under Fixture Vasanta) and Fixture Wellspring Circle (clients 1022008) are new. Checked against src/fixture/events.ts: published classes sit on 1002003, 1002002, 1002005 and 1002013, none of them under the new city. Ids verified free in src/fixture/ids.ts, regions.ts and clients.ts.

Cost of the new resolution. livePreview.url is re-resolved on every server render of a clients document and after every save, before Payload knows whether the panel is even open — so the check is one memoised regions read (already paid by buildRegionWebPath) plus one LIMIT 1 events read. pagination: false is what skips Payload's COUNT(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's Object.hasOwn guard still refuses prototype-chain keys, and panelNoticeUrl cannot leave the admin origin because livePreviewUnavailableUrl is always path-absolute.

Closes #1201

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mg9rjVMMpVpaBfNTttyXRB

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
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1203 November 18, 2026 18:58 Destroyed
@railway-app

railway-app Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-1203 environment in sahajcloud

Service Status Web Updated
SahajCloud 😴 Sleeping (View Logs) Web Nov 18, 2026 at 8:44 pm UTC
1 service not affected by this PR
  • mailpit

@sydevs-bot

sydevs-bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 20:04Z address-review · attempt 1 · session · done
  • 20:04Z address-review · attempt 1 · session
  • 19:57Z review-pr · attempt 1 · session · done
  • 19:57Z review-pr · attempt 1 · session
  • 19:23Z address-review · attempt 1 · session · done

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 18, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 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 — heard shadows the mode effect's own heard.
  • consider — mapVisibility.ts:3 — a third module for one where that lifecycle/finished could hold.

What was checked

  • Ladder. setURL has exactly two callers, both now through panelUrl; AdjustedColors and AudioUpload read the context but never move the panel, so nothing is left outside the new seam.
  • Consumer side. LivePreviewUnavailableReason has no reader outside the explanation page and the admin fields. /api/events/geojson is SahajAtlasWeb's surface, and its where is byte-equivalent.
  • Correctness. descendantRegionIds includes the region itself, so a class on the city counts. buildRegionWebPath returns null for Worldwide, so opensOn is the root.
  • Preview links. All three are on-host and cite fixture ids on this branch: 1022001 (atlas role, published classes under Fixture 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

Comment thread src/lib/events/mapVisibility.ts Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 18, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 18, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 18, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 18, 2026
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
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1203 November 18, 2026 19:33 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Three critic threads, all answered. Pushed c2fcaf6.

Adopted

  • Effect order left a new address unwatched — the ref now holds the address the atlas answered from, not a flag, so a new url is unheard by construction and the [url] effect is gone. Pinned by a spec watched failing against the old code first.
  • heard shadowed the mode effect's own — renamed heardFrom by that same change. One binding for both would be wrong: the mode effect's resets per re-run, the watchdog's must survive one.

Rebutted

Lean gate ✓ (277 files, 3791 tests) and clients-preview.int 8 ✓. Security review ran again: no findings. Body refreshed — the outline named an effect that no longer exists.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 18, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 18, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review November 18, 2026 19:54
@sydevs-bot
sydevs-bot requested a review from Ardnived November 18, 2026 19:54
@sydevs-bot
sydevs-bot enabled auto-merge November 18, 2026 19:54
@sydevs-bot sydevs-bot moved this from Pending to Awaiting in SYDevelopers Technical Roadmap Nov 18, 2026
@Ardnived

Copy link
Copy Markdown
Contributor

@sydevs-bot Revise the error messages to be easier to understand for a non-technical user

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 18, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 18, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 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-unreachable leaves 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

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 18, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 18, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 18, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 18, 2026
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
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1203 November 18, 2026 20:12 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Error messages revised for a non-technical reader. Pushed c38feb8, on a clean merge of main.

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), clients-preview.int 8 ✓. No security review: copy on one frontend page, off securityReview.triggerPattern. Body refreshed — step 1 quoted the old title.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 18, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 18, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 18, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Nov 18, 2026
Merged via the queue into main with commit 0570383 Nov 18, 2026
53 of 57 checks passed
@sydevs-bot
sydevs-bot deleted the claude/feat-1201-atlas-preview-notices branch November 18, 2026 21:20
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 18, 2026

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-1203 — c38feb8f Deployed Nov 18, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

feat(clients): explain an Atlas-tab preview that cannot load

3 participants