Repository navigation
feat(settings): country-scoped locale preference invariants - #436
Merged
Merged
Conversation
Contributor
Greptile SummaryThe PR constrains locale display preferences to each active country’s declared options while preserving tenant-selected timezone behavior.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported timezone-preservation regression is corrected by comparing the current timezone with the previous country’s default before applying the new country’s default.
|
| Filename | Overview |
|---|---|
| main/routes/settings.ts | Adds shared country-scoped locale preference validation and normalization across business reads and settings writes. |
| frontend/src/app/(dashboard)/settings/page.tsx | Normalizes locale preferences when countries change while retaining the restored explicit-timezone preservation behavior. |
| tests/issue-390-locale-preference-invariants.test.ts | Exercises rejection, acceptance, country transitions, and legacy-value normalization through the backend settings API. |
| docs/API.md | Documents country-aware locale preference validation, defaults, and normalization behavior. |
| docs/i18n.md | Clarifies the boundary between tenant-authoritative timezone selection and country-constrained locale display preferences. |
| package.json | Registers the locale-preference invariant integration test in the repository test scripts. |
Reviews (2): Last reviewed commit: "no-mistakes(document): Updated API.md an..." | Re-trigger Greptile
Scope currency_display/number_digits/calendar validation and normalization to the active country locale options instead of a global option union. Explicit unsupported values now return HTTP 400; stale values from IR to other country transitions are silently normalized to neutral defaults. The settings page resets locale preference state on country change. Adds integration coverage for the IR/US transition matrix and legacy non-IR databases.
…-scoped locale preference validation
khaira777
force-pushed
the
feat/issue-390-locale-preference-invariants
branch
from
August 21, 2026 00:16
c128f8c to
466ad7e
Compare
khaira777
enabled auto-merge (squash)
August 21, 2026 00:19
This was referenced Aug 21, 2026
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.
Intent
Validate and deliver the country-scoped locale preference invariants while preserving existing UI locale and tenant regional settings boundaries
What Changed
PUT /api/settings/business,PUT /api/settings/:key) now validatecurrency_display,number_digits, andcalendaragainst the active country's declaredlocaleOptions; unsupported values return HTTP 400 with a country-specific error message, and stale legacy values are normalized to neutral defaults on read and write.rial,locale,locale).localeOptionsrather than being fully tenant-authoritative.Risk Assessment
✅ Low: Well-scoped change with correct locale preference normalization on both read (businessShape) and write (PUT handlers), properly restored timezone preservation, and comprehensive behavioral test coverage.
Testing
Ran the dedicated issue-390 integration test which exercises the backend settings API across 5 scenarios: US rejection of unsupported preferences, IR acceptance of toman/latin/persian, IR→US stale value normalization, US→IR re-acceptance, and legacy DB cleanse on both GET businessShape and PUT save. All assertions passed. Verified no regressions in the adjacent issue-389 timezone test. Confirmed frontend TypeScript compiles without errors. Worktree is clean.
Evidence: Issue-390 test output (filtered)
Evidence: Full test run evidence
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
🔧 **Rebase** - 3 issues found → auto-fixed ✅
frontend/src/app/(dashboard)/settings/page.tsx- merge conflict rebasing onto origin/mainmain/routes/settings.ts- merge conflict rebasing onto origin/mainpackage.json- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
🔧 **Review** - 1 issue found → auto-fixed ✅
frontend/src/app/(dashboard)/settings/page.tsx:2273- Timezone preservation logic was removed from the country-change handler. The old code checkedtimezoneWasDefaultand only replaced the timezone if the user hadn't explicitly chosen a different one from the previous country's default. The new code unconditionally overwrites withcountry?.timezone || p.timezone. This is a behavioral regression unrelated to the locale preference invariants in issue fix(settings): enforce country-scoped regional preference invariants #390 — the explicit comment "The country profile timezone is only a suggestion. Only replace it when the user has not explicitly chosen a different timezone for the previous country" was also removed.🔧 Fix: Restore timezoneWasDefault guard in country-change handler
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
node tests/run-electron-node-test.cjs tests/issue-390-locale-preference-invariants.test.tsnode tests/run-electron-node-test.cjs tests/issue-389-timezone-override.test.tsnpx tsc --noEmit --project frontend/tsconfig.jsongit status --short(clean worktree)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.