Repository navigation
feat(clients): live-preview a service's colours on the Atlas tab - #1129
Conversation
A service manager picked three atlas colours and a logo with no way to see the result: to find out what visitors got they had to save and go and look at their own site. The Atlas tab now opens a live preview of the standalone atlas on the service's own region, at `?scope=clients`, and moving a picker repaints it before anything is saved. The atlas answers with what it rendered, so each picker can show the colour visitors actually get and why it is not the one that was entered — and, where a seed can express that colour, a button writes it into the field. A role adjusted only by `panel-text` has no such seed, so it shows the note and no button. On Config, Usage and Diagnostics, which only an administrator sees, the panel closes and explains itself. `unavailable` is the one preview target that leaves the default's origin, and it is safe because the declaration is a reason code rather than a URL: no origin, no credential, and it lands on the admin's own origin. This collection's `livePreview.url` reads `data`, so a save re-resolves it — `PreviewTarget` re-applies on that change rather than letting the atlas back into a panel that should be explaining itself. Registrant emails take black or white text by whichever can be read on BOTH stops of the brand gradient, so a pale brand stops shipping white-on-pale. The brand colours themselves never change. A sample registrant email renders beside the logo and support address, through the real template, from values that have not been saved yet. `ATLAS_DEFAULT_COLORS` copies the retuned seeds from sydevs/SahajAtlasWeb#389 — `color2` and `color3` only. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVKFZaNEE4JgBvahah
…missed `relativeLuminance` read six hex digits off a colour `colorField`'s validator accepts in its short form, so `#ff0` gave NaN on every channel and the rule answered white — white on yellow, which is the defect it exists to prevent. The palette report was module state with no document key, so opening one service after another showed the first's rendered colours under the second's pickers, with a button offering to write them in. The subscriber supplies its own id now, since the message carries none. The light/dark control's listener depended only on stable values, so it never attached: `autoOpen` opens the panel after the field has mounted, and the control claimed a mode the atlas had never been told. It keys on the panel's URL now, and asserts the mode as soon as there is a frame. The email preview had no catch and no stale guard, so a network blip was an unhandled rejection and an older render could land after a newer one. It also re-rendered on every keystroke in the support address, which the template does not draw — that is the message's Reply-To, and it is named under the frame instead. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVKFZaNEE4JgBvahah
A role whose `adjustedBy` arrived as anything but an array would throw inside a picker's render and take the field down with it. The shape crosses a window boundary, so it is narrowed rather than cast. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVKFZaNEE4JgBvahah
|
🚅 Deployed to the SahajCloud-pr-1129 environment in sahajcloud
1 service not affected by this PR
|
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
#1082 and this branch each re-measured the unit lane, so all four conflicts are the same drifting fact stated in four places. Neither side's count survives the merge: the tree now holds both sets of specs. Measured here instead — 265 files, 3560 tests — and recorded in PERF.md with its own session row, since perf-figures-pinned.spec holds every consumer to what is on disk. No code conflicted. The two sides overlap on documentation alone. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjW39iuJsgv5ZBz7cwe
|
Merged Neither side's number survives the merge — the tree now holds both sets of specs — so I measured it here and wrote that: 265 files / 3560 tests, recorded in The two sides overlap on documentation alone — no source file conflicted, and none was touched by both. Lean gate green on the merge: lint, format, typecheck, typecheck:tests, 3560 unit tests, 135 s. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
#1112 landed its own re-measurement of the unit lane while this branch carried the one from the last merge, so both sides state a different count for the same fact in three places. Neither survives: the merged tree holds both sets of specs. Measured here — 266 files, 3565 tests — and recorded in PERF.md as its own session row, which is what perf-figures-pinned.spec reads the four consumer docs against. AGENTS.md stated the old file count without conflicting, so it moved too. Both sides' session rows are kept and renumbered. A row is a measurement someone took, not a figure to overwrite. No code conflicted. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYibqRjk5PCRSxEt1h
|
Resolved three documentation conflicts. All three are the same fact — the unit lane's file and test counts — stated in different places, and neither side's figure survives the merge: the tree now holds both sets of specs. Re-measured here instead: 266 files, 3565 tests. Written into Both sides' PERF.md session rows are kept and renumbered, and this run's added. A row is a measurement someone took, not a figure to overwrite. No code conflicted. Lean gate green: 266 files / 3565 tests, 116 s. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
`Lint, Test & Smoke` went red on this head with every test passing: the Workers Custom Domain for pr-1129 was attached, but its edge certificate had not finished provisioning when the 3-minute reachability bound ran out. The address answers 302 now. Three minutes was not headroom, it was the measurement. The run before this one, minutes earlier on another PR's first attach, spent 2m32s in the same wait and passed with eight seconds to spare. Ten minutes puts real distance between the bound and what Cloudflare takes, and costs nothing when the certificate is ready: the loop returns on the first answer. The annotation now carries the title the sydevs dispatcher matches, so a timeout here is re-run rather than handed to a session. Neither cause the message names — a slow certificate, an undeployed Worker — is something a PR's branch can change. Lean gate green: lint, format, typecheck, typecheck:tests, 266 unit files / 3565 tests. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZToNgi12cLHSUiWek
…iew field - The pickers and the adjustment banner sit in an unnamed "Branding Colors" group, with Reset colors beside its title (the Regions Import classes shape); nothing stored moves - Each banner row shows the colour's light and dark swatch, and drops the hex - The light/dark toggle is its own "Map Preview" field below the group - The surface reason reads for both modes; a near-white check has words ready for the atlas Co-Authored-By: Claude Opus 5.5 <[email protected]>
…review in the group - Branding Colors uses Payload's own group title markup, with Reset beside it - Map Preview and the registration email sample move into the Branding Colors group - Each swatch is marked by its own mode, from the atlas's `lightAdjustedBy` / `darkAdjustedBy`; an atlas sending only the union marks both - The dark-map swatch carries a faded black mark; reasons are joined with semicolons - The adjustment banner keeps ordinary field spacing Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lors and Import classes - `helpers/labelWithAction` draws a heading with a text-link action beside it; Branding Colors' Reset colors and Regions' Import classes both use it, each keeping its own heading and its own rule for when the action shows - The Atlas tab reads only the atlas's per-mode `lightAdjustedBy` / `darkAdjustedBy`; the union field is gone from the report Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…port - The banner hid itself for the round trip between a colour change and the atlas's report on it, so it flickered on every pick; the last answer now stays up, with Use adjusted colors disabled until the report arrives - The near-white and near-black reasons go with the atlas checks that sent them Co-Authored-By: Claude Opus 5.5 <[email protected]>
…as now reads it `isBrandColor` reads only the old `#000000` sentinel as unset, matching the atlas's `isBrandSeed`; a near-colourless pick no longer snaps to the default in the picker, the banner or the emails. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… pick - The button stays enabled while a report is pending; a press in that window applies nothing, where toggling `disabled` flickered it - The atlas's near-white and near-black checks have words again Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@sydevs-bot review |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
Third look, over the twenty commits since the second. The contract reads right: lightAdjustedBy/darkAdjustedBy, the six check ids and the retuned seeds match SahajAtlasWeb#399 exactly, and isBrandColor mirrors its isBrandSeed.
What moved since you acknowledged §3 as built is the shape of it. 40f7204 put the per-picker notes back; 3b35380 took them out for one banner, leaving two criteria unmet and no waiver in the body. The colour labels were renamed in the same stretch, which #1110 reserves for another PR. And one tab now carries two bespoke message listeners.
Findings
- should-fix — §3's per-picker note is a banner, and a
panel-text-only role shows nothing (paletteReport.ts:17). - should-fix — the colour labels are renamed, which #1110 defers;
Accentis a third word forcontrast(appearance.ts:38). - should-fix — a second
messagelistener besideusePreviewMessage, guarding the same channel differently (MapPreviewField.tsx:62). - consider — the banner's answer round-trips through
JSON.stringify/parseto be its own dependency (AdjustedColors.tsx:43).
What was checked
- #1110's seven sections and eleven criteria against all 41 files; §3 and two criteria are the gap.
- Producer side on
origin/fix/dark-near-white-brand:RoleReport's fields andPALETTE_CHECKS' ids line up withreadSwatchandSWATCH_REASONS;DEFAULT_SEEDSequalsATLAS_DEFAULT_COLORS. #399 is still open, so the banner stays dark until it merges. - Ladder:
labelWithActionis generic andImportClassesLabeljoined it;MapPreviewFieldreusesToggleGroupandoriginOf. - Previews:
previewUrlsets no seed, and neitherPREVIEW_ACCESS_*half is here, so all three links are unreachable from this run.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
tests/PERF.md: both sides appended rows to the same table. Kept all 72, in order, renumbered.
The answer was serialised and parsed back only so it could be its own effect dependency. A ref holds it with no round trip and no effect, and is read on the same render that drops the current answer. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXdTVjk731s9nycbh5
MapPreviewField listened for the atlas's first message itself, checking the sender but not its origin, so the tab guarded one channel two ways. It now reads `usePreviewMessage`, which checks both, and keeps its own re-arm on reload. A frame that has navigated elsewhere no longer counts as proof the atlas is listening. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXdTVjk731s9nycbh5
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXdTVjk731s9nycbh5
|
Four critic threads, and Adopted
Recorded, not built
Lean gate green: 274 files / 3723 tests. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
- The banner holds the latest palette report instead of re-deriving a kept answer through state and an effect. `readSwatch` now marks a report about a colour the field no longer holds (`current: false`) rather than refusing it, so the last report stays on screen until the next one lands, and the button applies nothing while any row is stale. - The listener lives with its one consumer and keeps only palette reports, so the atlas's other messages cannot clear the banner. - One stylesheet for the folder; the email frame's inline styles move into it. - `readableTextOn` moves beside `brandTextColor`, its only caller, and `themeColors.ts` returns to what main holds. Its cases join the email template spec. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The bot's ref-based banner fix is superseded by the latest-report hook. Its frame-origin guard is kept as `isFromPreviewFrame`, shared by the banner and the mode toggle, so usePreviewMessage stays removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
tests/PERF.md: the one conflict. Both sides appended rows to the same table — this branch 7 (#1129), `main` 13 (#1104). Kept all 86, each side's rows in its own order, `main`'s first where both inserted at the same point, renumbered end to end. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWN12hk1J2r8mSGqZY
|
Resolved Two things the auto-merge got right and a reviewer may want named. Gate green on the merge: 277 files / 3825 tests, 74.4 s. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
color1— the stop Outlook always paints — falling back to the worse stop where one of them is illegible there, and a sample one renders in a collapsible under the colours.infrastructure-failureso the dispatcher re-runs the job rather than dispatching a repair for something no branch can fix. Joined here because it is what was failing this PR's own CI.Change outline
Contract — what the admin panel gains
One endpoint, admin-panel only:
Flow — what crosses the iframe boundary
⚠ Whatever the frame says is accepted from that frame alone, checked by
usePreviewMessageas each message arrives — both fields read it there, so one guard spells the channel:event.sourcemust beiframeRef.current.contentWindowandevent.originthe iframe's own. Nothing about the frame is captured at mount, so a panel that opens after the fields (autoOpen), reloads, or is repointed needs no re-subscribe. A report whoseenteredno longer matches the field is ignored; between a pick and its report the last answer stays up, its button inert, so nothing flickers. The CMS computes no colours — every adjustment and every suggestion is the atlas's.Behaviour — the preview target per tab
The panel had one URL per document. It now has one per tab, and holds it through a save.
PreviewTarget effect, on every change of the provider's `url` if (url !== lastComposedUrl) serverResolvedUrl = url - if (!serverResolvedUrl) return + if (!serverResolvedUrl || isLivePreviewUnavailableUrl(serverResolvedUrl)) return - composed = composeTargetUrl(serverResolvedUrl, target) + composed = target.unavailable + ? new URL(livePreviewUnavailableUrl(target.unavailable), window.location.origin) + : composeTargetUrl(serverResolvedUrl, target) if (!composed || composed === url) return setURL(composed)⚠
unavailableis the one target that leaves the default's origin. It names a reason code, not a URL — no origin, no credential — and lands on the admin's own origin.composeTargetUrlis untouched and still refuses every cross-origin path.⚠ A document's own refusal outranks a tab's. A service with no atlas resolves to the explanation page already, so the tab target is skipped rather than telling it its preview belongs to a tab it does not have.
⚠ This collection's
livePreview.urlreadsdata, because the preview opens the service's own region, so a save re-resolves it and callssetURLwith the real atlas. The effect above runs on that change, which is what keeps a save on Config from putting the atlas back in a panel that should be explaining itself.Behaviour — text on a brand gradient
⚠
primarygoes first because it is the only stop that always paints. Both sites set it asbackgroundColorbeneath the gradient'sbackgroundImage, and Outlook desktop drops the image. Reading the minimum across both stops therefore let a surface those readers never see choose the text:ATLAS_DEFAULT_COLORStook black at 3.44 where white on#1E6C71alone scores 6.11, and across the gradient the two are 3.44 to 3.15 — both legible, 0.29 apart. Below that legibility floor the worse stop still decides, so a dark primary with a pale second stop keeps black. The three project brands are unaffected: white clears no stop of any of them.Files
Preview
Data: not seeded — this repo sets no previewUrl.seed, and a Railway PR environment boots with only its admin, so the Services list is empty until somebody creates one. The two explanation pages need no data and open as they will in production.Contract impact
Consumes the
sahaj-atlas:palette-reportandsahaj-atlas:preview-modemessages from sydevs/SahajAtlasWeb#392 (merged) as reshaped by sydevs/SahajAtlasWeb#399: the report's per-modelightAdjustedBy/darkAdjustedByreplace itsadjustedByunion, which this PR was the only reader of. ⚠ #399 merges first — until it deploys this tab shows no adjustment banner; nothing else breaks.isBrandColormirrors #399'sisBrandSeed: only#000000reads as unset.Test results
test:unit(274 files / 3723 tests, run withTZ=UTC).ics-builder.spec.ts(from feat(events): serve a token-addressed calendar feed for a class #1134 onmain) fails in a non-UTC local zone and passes in UTC, as CI runs — unrelated to this PR.tests/int/clients-preview.int.spec.ts5 passed;atlas-preview-fields.spec.ts15 (sender and origin checks, the kept answer, the mode re-send each watched failing without their fix).Manual verification
Everything below needs a browser and the SahajAtlasWeb build beside it; none of it ran here.
#fffdfa,#fafcff,#fff7f5): the banner lists each with its light and dark swatch and reasons, matching the preview's buttons, pills and pins. Use adjusted colors writes the suggestions; Reset colors repaints the defaults.⚠ One acceptance line is only partly met. The panel explains a service with no atlas and a tab that has no preview. A frame the host blocks, or an atlas that is down, is not something the CMS can observe from here — the iframe simply fails to paint. Worth your call on whether that needs its own work.
Deviations from #1110
Two, both the goal owner's own commits on this branch. Neither is in the ticket's text, so they are recorded here.
panel-text-only role offering no button — hold through the banner, with one gap: a palette whose only adjustment anywhere ispanel-textshows nothing at all. That check moves the panel's text step, not the swatch, so there is no colour to show that differs from the one entered. §3 also predates fix(ui): brand colours that read in both modes, ringed pins, a per-mode palette report SahajAtlasWeb#399, which replaced its three check ids with six and splitadjustedByper mode.color1–color3keep their names, so the ticket's note deferring a field rename to its own PR still stands.Accentis a third word for the role the widget callscontrast;ROLE_OF_COLUMNinpaletteReport.tsis the one place the two meet.Notes for reviewer
Merges last, after sydevs/SahajAtlasWeb#399. #1127 (the write-only mailing-list key) and SahajAtlasWeb#392 have both landed; #399 is the report shape this PR now reads.
⚠ The order is load-bearing here, not tidiness. Payload's live preview posts the whole reduced form state to the preview frame, and on this branch alone that state still contains
mailingList.apiKey. #1127 is what takes it out. Merging this before #1127 would send a service's provider secret to sahajatlas.com.Three judgement calls:
clientspreview cases are their own int spec (tests/int/clients-preview.int.spec.ts) rather than an extension ofclients-access.int.spec.ts. That file is about who may read and write aclientsrow; where the panel points is a different subject.supportEmailis the message'sReply-Torather than anything the template paints, so posting it would have cost a full server-side render on every keystroke in that field for no visible change.readableTextOnlives insrc/lib/branding/themeColors.ts, besidetint/shade, rather than insrc/emails/. It is a question about a brand colour, and that module already owns the hex parsing.Detail
This changes existing emails, including unbranded ones. The We Meditate and Sahaj Atlas gradients both run from a mid-toned primary to a paler second stop, so the header title and filled buttons go from white to black on them. That is the rule working, not a side effect — white was unreadable at the light end of those gradients too.
Dismissed review note.
relativeLuminanceexpands#RGBbefore parsing.colorField's validator accepts the short form, so a service really can store#ff0; read as six digits every channel wasNaN, which answered white — white on yellow, the exact defect the rule exists to prevent.tests/unit/atlas-preview.spec.tspins both forms.The email sample renders only once it is opened. The collapsible starts collapsed and each render is a full server-side render of the real template, so an effect running on mount billed every Atlas-tab visit for a sample nobody asked to see.
useDebouncedEffectfrom@payloadcms/uiis deliberately not used for the 500 ms settle: it discards the effect's return value, so theAbortControllerhas nowhere to hang and an older render can land after a newer one.Security review: ran on the original push, no findings. It traced the endpoint's gate (
requireActiveManagerthenoverrideAccess: falsewith the caller's ownreq, so an unlisted manager gets the 404), confirmed the posted logo id cannot reach an image the caller may not read, confirmed nothing attacker-controlled reaches markup (React escapes the text children, and the sample renders in<iframe sandbox="" srcDoc>), and confirmedcomposeTargetUrlstays strict for every target but the fixed reason code. Nothing pushed since matchessecurityReview.triggerPattern.One thing it raised below its reporting threshold, and the reason the merge order above exists: adding
admin.livePreviewtoclientsmakes Payload post the reduced form state toSAHAJATLAS_URLonce the preview answers itsreadyhandshake — which the atlas child does answer. Onmainafter #1127 that state carries no credential. On this branch alone it still would.Closes #1110
🤖 Generated with Claude Code
https://claude.ai/code/session_01Mg9rjVjKuC7JyLRa1YRmH3