fix(site-features): wire site features to the backend AppSettings API - #106
Merged
Conversation
site-features-server.ts read/wrote a local config/site-features.json file, which isn't safely shared or persisted across replicas/deploys. Point readSiteFeatures/writeSiteFeatures at the backend's /api/v1/site-features/ endpoint instead (GET public, PUT superuser-only), following the same pattern already used for model-labels -> SiteLabel. writeSiteFeatures now takes the caller's token and throws on a failed write; the PUT route handler catches that and returns a 502 instead of crashing. config/site-features.json is left in place, unused, until all environments have migrated (same caution as config/model-labels.json). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
3 tasks
Contributor
Author
|
Merged by error, I revert sorry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cross-repo dependency: requires backend PR archetype-pal/backend#149 (adds
GET/PUT /api/v1/site-features/, superuser-gated write, backed by the newAppSettingsmodel) to actually work end-to-end — this PR alone is safe to merge first (it degrades togetDefaultConfig()on any fetch failure) but won't reflect real backend data until #149 is also merged.config/site-features.jsonwas being read/written directly from the Next.js server's local filesystem — unsafe across replicas/deploys. Follows the exact same pattern already used for model labels (seefix/wire-model-labels-to-backend, commit 63f557c).lib/site-features-server.ts:readSiteFeatures/writeSiteFeaturesnow call the backend viaapiFetch/authFetchinstead ofreadJsonConfig/writeJsonConfig. All existing defensive merge/normalize logic (missingfeatureskey, malformed sections, etc.) is preserved, just re-pointed at the backend response instead of file contents.app/api/site-features/route.ts: PUT now forwards the superuser token towriteSiteFeaturesand returns 502 on backend write failure.config/site-features.jsonis intentionally not deleted — same caution asconfig/model-labels.json(don't remove until every environment has migrated).No downstream changes needed:
contexts/site-features-context.tsxand the backoffice UI consume the internal/api/site-featuresroute, whose contract to its own callers is unchanged.Test plan
vitest run— full suite 114 files / 1155 tests passedtsc --noEmitcleaneslint/prettier --checkcleanNo new dependencies.