Repository navigation
feat(translations): adopt availableLocales, per-locale publish status and the English merge for WeMeditate App - #747
Conversation
…e and availableLocales for the app Brings `wm-app-config` and `wm-app-translations` onto the model #705 built for the two web projects, so "published in French" is a fact the CMS can answer for every surface rather than two of three. - `wm-app-translations` sets `versions.drafts.localizeStatus: true` (the object form — `drafts: true` sanitises the flag back to `false`) and gains the `clientEnglishFallback` afterRead hook, so an API client reading a partially translated locale gets English for blank keys instead of a blank app. - `wm-app-config` gains `availableLocalesField`, gating each offered language on that language being published in `wm-app-translations`. The field's `unpublishedLocales` string branch now has no caller, since all three translations globals set the flag. It stays as what answers for a global that has not opted in, and its comment says so rather than naming `wm-app-config` as the future case it already is. Migration is drizzle-generated only, the exact analogue of #705's: the `wm_app_config_available_locales` sub-table and enum, and `_status` / `version__status` moving into the two `_locales` tables with their indexes. It is NOT augmented with a backfill — `src/migrations/AGENTS.md` says to surface that trade-off rather than decide it, and the PR does. Refs #709 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01T2vEx8jGwrhtW31ntxczAB
…merge Each new assertion was watched failing before it was kept, per docs/rules/testing-reqs.md. - `publishing one locale does not open the gate for another` is the case that discriminates. Its sibling — that `wm-app-config` gates on its own translations global — passed with `localizeStatus` reverted to `drafts: true`, because a whole-global publish satisfies it either way. Publishing Italian and then asserting Spanish is still refused fails without the flag and passes with it. - The English merge case reaches `daily.common.retry`, a key inside a JSON field inside a group. The atlas cases only exercise a top-level leaf, so a merge handling `groupField: null` alone would pass all of them and still leave the app blank. Verified by removing the hook. - `wm-app-config`'s structure spec read `fields[0]` for the tabs field, which `availableLocales` now precedes. It finds the tabs field instead, and pins the new field as top-level. - The two suites writing `wm-app-config` carry `availableLocales: ['en']` in their required-field fixture. `['en']` needs no `skipAvailableLocalesCheck`: the field returns true once the gated set is empty, above the check that reads stored data — verified against `src/fields/availableLocalesField.ts`. Refs #709 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01T2vEx8jGwrhtW31ntxczAB
…he draft reset - The "three things distinguish the two web globals" section now reads as three things true of all three, since #709 removed the exception. - Records that the `_status` move lands every locale as `draft` and does not carry the previous whole-global status across. That was a seed step for the web globals; for the app it is live content. - Corrects `availableLocalesField`'s signature: the option is `description`, not the `surface` the doc named — there is no `surface` parameter. - Counts that moved from two to three config globals, and the note that `['en']` alone clears the gate without the skip flag. Refs #709 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01T2vEx8jGwrhtW31ntxczAB
Four findings from the reuse/simplification and efficiency/altitude passes. - `WeMeditateWebTranslations` still told the reader that `wm-app-translations` "deliberately keeps `drafts: true`, and so keeps one status for every locale". This branch does the opposite, and it was the one comment the change left un-updated — the worst kind, since it is phrased as intent about a sibling file. - One `publishLocale(slug, locale, data)` replaces the two per-global publish helpers the new cases had copied; `publishAtlasLocale` delegates to it. - Dropped the app's `refuses a set that omits English` case. The English invariant is checked above the `translationsSlug` read, so it cannot differ per mount — which is why the `wm-web` block carries only its gating case. It was a bootstrap-heavy case asserting a third instance of one `if`. - `two`/`both config globals` became three in the three code comments that still said otherwise, matching the docs pass. Skipped, with reasons: a `translationsGlobal()` factory for the three now-near-identical translations globals (real rule-of-three, but a refactor of two files this ticket does not otherwise touch — noted in the PR body), and lifting the `wm-app-config` required-field fixture into `tests/utils/testData.ts` (the duplication predates this change, and doing it properly pulls in two more suites). The efficiency pass found nothing: `schemaLookups` runs once at module load, not per read, and the `availableLocales` validate short-circuits before its query for an English-only set. Refs #709 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01T2vEx8jGwrhtW31ntxczAB
The `_status` move lands every locale as `draft` and does not carry the previous whole-global status across. `src/globals/AGENTS.md` recorded that, but an operator reads DEPLOYMENT.md, so the step that unblocks the app belongs there. Refs #709 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01T2vEx8jGwrhtW31ntxczAB
|
🚅 Deployed to the SahajCloud-pr-747 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
Right size for #709. The code is fine. The deploy is not.
The migration lands every locale draft, English included, so published reads are blank for all 19. clientEnglishFallback cannot cover it — its English read is draft: false too. The app is blank until an operator republishes.
Closes #709 also closes the ticket with its fourth bullet undone, no follow-up filed.
Findings
- blocker — the reset covers English; the app goes fully blank — migration:15
- should-fix — the recovery step contradicts this diff's own warning — DEPLOYMENT.md:170
- should-fix — the REST block claims three globals, exercises two — spec:330
- consider — the string branch has no caller — field:66
What was checked
Read whole: the field, clientEnglishFallback, the status translations section, the sibling config globals, the migration, migrations/AGENTS.md §Augmenting. wm-app- in the sibling repos is generated types only, so the contract lands in WeMeditateApp alone. projects.ts:75: clients read app strings directly.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The post-deploy step offered "Publish all locales" as an alternative, which src/globals/AGENTS.md warns against two files away in this same diff: it publishes the empty locales too, and availableLocales then accepts a language with no strings in it. Name "Publish in <Locale>" as the step and say why the other one is not it. Also sharpens the blast radius the review thread on the migration flagged: English is in the reset, so a client's published read returns nothing for every locale, and clientEnglishFallback cannot mask it — its English read passes draft: false too. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_017q3nH2N1phPEgirKxgaF1q
The REST block's comment claims all three config globals gained a sub-table, but it exercised two. The collision this field replaces is a read-time Drizzle failure the local API never reaches, so the one new table this issue adds — wm_app_config_available_locales — was the one nothing read over REST. Same shape as the wm-web-config case: unconfigured, asserting the read does not break. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_017q3nH2N1phPEgirKxgaF1q
With the third global opted in, the branch has no caller and the comment above it had grown longer than the branch. Keep the branch — it is what a read answers if the root experimental.localizeStatus flag is ever off — and state that in one clause instead of two sentences. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_017q3nH2N1phPEgirKxgaF1q
The nested guide said every locale lands unpublished without saying English is one of them, which is the difference between a partial and a total blank for an API client — clientEnglishFallback reads English with draft: false too, so it has nothing to merge from. Also names the per-locale republish rather than the all-locales button its own warning two lines up rules out. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_017q3nH2N1phPEgirKxgaF1q
|
Addressed the adversarial review. Pushed Adopted, resolved:
Asked, still open — the blocker. Confirmed: English is in the draft reset and Lean gate green. CI is running. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
I could not mark ready here — the dispatch token is not allowed to. Everything else on this item is done, so this is the one step left for you. 🤖 sydevs dispatcher |
One conflict: `src/migrations/index.ts`, where both branches register a new migration. Kept both, in timestamp order — `20260909_161243_wm_app_…` then main's `20260909_161353_atlas_translations_by_view`. Their DDL does not overlap: ours touches `wm_app_*`, main's `sy_atlas_translations_locales`. Everything else auto-merged and was verified rather than assumed: `pnpm generate:types` reproduced the merged `src/payload-types.ts` byte-for-byte, and the two specs both sides edited keep both intents — #706's atlas tab set and fixture keys, plus this branch's wm-app blocks. Gate: lint, typecheck, typecheck:tests, test:unit (1770 passed); available-locales.int + translations-globals.int (38), wm-app-config.int + wemeditateAppStatus.int (25). Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014APmwZ1wiWLJiZXGqpr5jm
|
Merged One thing for you. Neither snapshot now holds both branches' schema — the out-of-order snapshot trap ( So the next Gate green: lint, both typechecks, 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
`main` moved again with #747 — `wm-app-translations` gains per-locale `_status` and `wm-app-config` gains `availableLocales`. Both sides' behaviour is kept. - `src/globals/AGENTS.md`: kept this branch's #707 Web-tabs section and its two key conventions, and took `main`'s framing sentence. All three translations globals now carry per-locale status, so "three things distinguish the two web globals from wm-app" is no longer true. - `tests/COVERAGE.md`: took `main`'s two rewritten rows and kept this branch's two wm-web rows, which `main` has no counterpart for. - `src/migrations/index.ts`, `src/payload-types.ts` and the four `main`-only specs merged cleanly, in timestamp order. **Both snapshots repaired a second time.** #747's migration is `20260909_161243`, older by timestamp than this branch's `161848` and `162104`, so after the merge the newest-by-timestamp snapshot still described the pre-#747 `wm_app` schema — the out-of-order snapshot trap in `src/migrations/AGENTS.md`. Verified before the repair: `db:migrations:create --skip-empty` re-emitted #747's DDL byte for byte, and replaying it aborts the boot migration on deploy (#566). Both snapshots now carry #747's `wm_app` schema, and the same command emits nothing. **Two comments the merge falsified, corrected without changing behaviour.** `seeds/translations/import.ts` and `tests/int/wm-web-translations-seed.int.spec.ts` both said `wm-app-translations` holds one `_status` for every locale. It has per-locale status since #709. The seed still leaves it unpublished — an operator republishes each locale after the deploy — and the assertion, read at `locale: 'en'`, still holds. Gate: lint, both typechecks, 1778 unit tests, and the three integration specs covering the conflicted files (49 tests) all pass. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0146WwB8svzTLxZMfRraYati
Resolves the conflict #747 created in `src/globals/AGENTS.md`. Both sides edit the same sentence for different reasons, and both edits are wanted: - This branch adds the `Seo` / `Emails` paragraph — the two Atlas tabs no widget view reads. - `main` restates "three things distinguish two of the three globals" as "three things are true of all three", because #709 brought per-locale publish status and `availableLocales` to `wm-app-translations` too. Kept both: the new paragraph, then main's corrected sentence. Everything else auto-merged. Verified rather than assumed: - `src/migrations/index.ts` orders the two branches' migrations by timestamp — 20260909_161243 (main) before 20260909_161353 and 20260912_031449 (this branch). Each migration's DDL is disjoint, so the chain applies cleanly in that order. - `src/payload-types.ts` merged as a strict superset of main's: `git diff origin/main -- src/payload-types.ts` removes nothing. Gate after the merge: lint, `tsc` over `src/` and `tests/`, 1804 unit tests. Integration specs covering every merged file — `atlas-seo`, `atlas-sitemap`, `translations-globals`, `available-locales`, `wm-app-config`, `wemeditateAppStatus` — 139 passed. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012QbFiVem6WXW59R6mE5Qn3
Summary
wm-app-translationsgains per-locale publish status, so "published in French" is now a fact the CMS can answer for all three surfaces rather than two.clientEnglishFallbackhook feat(translations): typed JSON groups, per-locale publish status, and an availableLocales field gated on published translations #705 built.wm-app-configgainsavailableLocales, gating each offered language on that language being published.⚠ This migration unpublishes every locale of live app translations, English included. See Migration and Manual verification — there is a required post-deploy step, and one open decision for you.
Changes
src/globals/WeMeditateAppTranslations/…—versions.drafts.localizeStatus: trueplus theafterReadmerge hook.src/globals/WeMeditateAppConfig/…—availableLocalesField, above the tabs.src/fields/availableLocalesField.ts— comments only. The plain-string_statusbranch now has no caller, and its note is one clause rather than two sentences.DEPLOYMENT.md,src/globals/AGENTS.md— the post-deploy step names "Publish in <Locale>" per locale. Not "Publish all locales": that publishes the empty locales too, andavailableLocalesthen accepts a language with no strings in it.tests/int/available-locales.int.spec.ts— the REST block now covers all three config globals, includingwm_app_config_available_locales, the one sub-table this issue adds.Preview
Contract impact
src/payload-types.tschanges:WmAppConfig.availableLocalesis new. Consumers re-sync withpnpm types:cms.The ticket's fourth bullet — "the app reads
availableLocalesfor its language picker" — is not in this PR. That is WeMeditateApp, which is outside this repo and outside my access. This PR ships the CMS half the app will read; the app-side change needs its own ticket.Migration
src/migrations/20260909_161243_wm_app_localize_status_available_locales.tswm_app_config_available_locales(+ enum); moves_status/version__statusintowm_app_translations_localesand_wm_app_translations_v_localeswith their indexes. Drizzle-generated only, no hand edits. It is the exact analogue of feat(translations): typed JSON groups, per-locale publish status, and an availableLocales field gated on published translations #705's migration forwm_app_*.down()restores the parent columns and drops the sub-table.Data: the previous publish status is NOT carried across, and English is in the reset. The new column lands
DEFAULT 'draft', so all 19 locales become unpublished on the deploy that applies this. English being one of them is what makes a client's published read fully blank rather than partial:clientEnglishFallbackreads English withdraft: falsetoo, so it has nothing to merge from.🔵 One open decision — the backfill.
src/migrations/AGENTS.mdand.claude/workflow.json'sgeneratedFilesboth reserve a hand-edit to a generated migration for you, so I have not made it. The exact statement is on the open thread: oneUPDATEbefore theDROP COLUMNcarries the old status onto every locale row. Say the word and I add it. The alternative already in the PR is the documented post-deploy republish.Test results
pnpm lint,pnpm typecheck,pnpm typecheck:tests,pnpm test:unit(1669 passed)available-locales.int(19),wm-app-config.int(5). Also green earlier in the branch:translations-globals.int(18),wemeditateAppStatus.int(20)migration-validator— 4 pass, 0 fail, 2 warns (both the expectedDROP TABLE/DROP COLUMNof the column move)Manual verification
wm-app-translationsin every locale it was published in, one at a time with "Publish in <Locale>". Until then API clients get blanks in every locale, andwm-app-configrefuses any non-English language. This is the one step that is not optional.wm-app-translationsoffers "Publish in <Locale>" / "Publish all locales" / "Unpublish in <Locale>".wm-app-config, confirm selecting an unpublished language is refused and names it, and that saving with English alone works.GET /api/globals/wm-app-translations?locale=frshows English for blank keys; the same read as a manager does not.Notes for reviewer
gates on its own translations globalpasses with or withoutlocalizeStatus, because a whole-global publish satisfies it either way.publishing one locale does not open the gate for anotheris the case that actually discriminates — verified failing without the flag. The nested-group merge case was verified the same way, by removing the hook.translationsGlobal({ slug, group, schema })factory would collapse ~20 duplicated lines × 3. This is the rule-of-three moment, but it is a refactor of two files this ticket does not otherwise touch, and it would obscure the diff against the feat(translations): typed JSON groups, per-locale publish status, and an availableLocales field gated on published translations #705 precedent.wm-app-configrequired-field fixture intotests/utils/testData.ts. The duplication predates this change and doing it properly pulls inregion-canonical-urlandatlas-sitemaptoo.securityReview.triggerPatternis touched. feat(translations): typed JSON groups, per-locale publish status, and an availableLocales field gated on published translations #705 triggered it only because it editedpayload.config.ts; the rootexperimental.localizeStatusflag was already set there, so this PR does not.Detail
The ticket was a stub ("scope it when picked up"), and its
availableLocalesField({ translationsSlug, surface })call does not match the shipped signature — there is nosurfaceoption, onlydescription. I used the real one and corrected the doc that namedsurface.['en']needs noskipAvailableLocalesCheck. The validator returns true once the gated set — every locale but English — is empty, above thereq.contextcheck and above the query. That is why the two spec fixtures just addavailableLocales: ['en']rather than a context flag. Verified againstsrc/fields/availableLocalesField.ts, and independently by the efficiency review pass.The
localizeStatusassertion intranslations-globals.int.spec.tsnow reads "all three true" rather than "two true, one false". It keeps its detection power: Payload sanitises the per-global flag back tofalseunless the rootexperimental.localizeStatusis set, so a test config that forgot the root flag still turns this red.Efficiency was checked and is fine.
wm-app-translationshas ~480 leaf keys against the atlas global's ~96, so the merge hook's cost was worth confirming:schemaLookupsruns once at module load (inside theGlobalConfigobject literal), not per read, andmergeEnglishis in-memory property access behind a single memoised query thatshouldMergegates before issuing.pnpm db:migrations:createdid not hit the rename-vs-create prompt — exit 0, both files written,index.tsauto-registered. It logged a nodemailerETIMEDOUTwhile booting the config, which is the sandbox having no SMTP host and is unrelated to the migration.The adversarial review's four findings are answered on their threads. Three were adopted (1e0c08b, ca4b2aa, 8476c31) and resolved. The blocker's fix is the backfill above, which stays yours to call.
Closes #709
🤖 Written by the sydevs autonomous loop — see what this is
🤖 Generated with Claude Code
https://claude.ai/code/session_017q3nH2N1phPEgirKxgaF1q