feat: add Saturday week-start option - #1416
Conversation
📝 WalkthroughWalkthroughThe week-start preference now supports Sunday, Monday, and Saturday through shared typed constants, runtime validation, rehydration safeguards, dynamic selector options, and updated localization. ChangesWeek Start Preference
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Checkov (3.3.8)i18n/de-DE.jsonTraceback (most recent call last): i18n/el-GR.jsonTraceback (most recent call last): i18n/es-ES.jsonTraceback (most recent call last):
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoAdd Saturday as a first-day-of-week preference (centralized config)
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
Context used✅ Tickets:
🎫 feat: First day of week 1. Unvalidated hydrated weekStartsOn
|
| weekStartsOn: WeekStartDay; | ||
| setWeekStartsOn: (weekStartsOn: WeekStartDay) => void; |
There was a problem hiding this comment.
1. Unvalidated hydrated weekstartson 🐞 Bug ☼ Reliability
weekStartsOn is persisted to localStorage and rehydrated without runtime validation, so values outside WEEK_START_DAYS can enter the store despite the WeekStartDay type. This can lead to missing labels in the Preferences select and inconsistent week calculations (e.g., app using an unsupported start day).
Agent Prompt
### Issue description
`weekStartsOn` is typed as `WeekStartDay` but Zustand `persist` rehydrates from localStorage without validating the value. A stale/tampered/legacy stored value can therefore bypass `isWeekStartDay`, causing undefined UI labels and unsupported week-start behavior.
### Issue Context
- UI validation exists only in the preferences dropdown `onValueChange`.
- The store is the canonical source for week calculations across the app.
### Fix Focus Areas
- Add a persist `merge` or `migrate` (or `onRehydrateStorage`) step that coerces `weekStartsOn` to a safe default (e.g. `0`) when `!isWeekStartDay(persisted.weekStartsOn)`.
- Optionally harden `setWeekStartsOn` with a runtime guard as a second line of defense.
- (Optional) Add a defensive fallback when rendering the label in the preferences UI.
- apps/web/src/store/user-preferences.ts[4-9]
- apps/web/src/store/user-preferences.ts[48-123]
- apps/web/src/routes/_layout/_authenticated/dashboard/settings/account/preferences.tsx[204-235]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| "selectFirstDayOfWeek": "Select first day", | ||
| "weekStartsOnSunday": "Sunday", | ||
| "weekStartsOnMonday": "Monday", | ||
| "weekStartsOnSaturday": "Saturday", |
There was a problem hiding this comment.
2. I18n schema missing saturday key 🐞 Bug ⚙ Maintainability
en-US.json adds weekStartsOnSaturday, but i18n/schema.json does not define/require that key while also setting additionalProperties: false, making the translation file inconsistent with the schema. Any schema-driven translation validation/tooling will flag this mismatch.
Agent Prompt
### Issue description
A new translation key was added in `en-US.json`, but the i18n JSON schema still declares the preferences page as a closed object (`additionalProperties: false`) and does not include the new key in `properties`/`required`.
### Issue Context
The schema and locale files need to evolve together to avoid breaking schema-based validation or editor tooling.
### Fix Focus Areas
- Add `weekStartsOnSaturday` to the relevant `preferencesPage.properties` section.
- Add `weekStartsOnSaturday` to the corresponding `required` list if the other week-start labels are required.
- i18n/en-US.json[445-453]
- i18n/schema.json[1702-1817]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| "firstDayOfWeekDescription": "Choose which day calendars and weekly ranges start on", | ||
| "selectFirstDayOfWeek": "Select first day", |
There was a problem hiding this comment.
3. Non-english week description outdated 🐞 Bug ≡ Correctness
Only en-US updates firstDayOfWeekDescription to no longer mention Sunday/Monday, while other locales still state the week starts on Sunday or Monday even though Saturday is now selectable. This results in misleading settings copy for those locales.
Agent Prompt
### Issue description
After adding Saturday as a supported first day of week, several non-English locale strings for `firstDayOfWeekDescription` still explicitly say "Sunday or Monday", which is now incorrect.
### Issue Context
This is user-facing settings copy and should match the available options.
### Fix Focus Areas
- Update `firstDayOfWeekDescription` translations in other locale JSON files to a generic phrasing (similar to en-US).
- (Optional) Add localized `weekStartsOnSaturday` values per locale; otherwise fallback will show English.
- i18n/en-US.json[445-452]
- i18n/de-DE.json[441-449]
- i18n/es-ES.json[338-346]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@i18n/el-GR.json`:
- Around line 432-435: Add the missing weekStartsOnSaturday localization entry
to i18n/el-GR.json lines 432-435 as “Σάββατο”, i18n/es-ES.json lines 342-345 as
“Sábado”, i18n/fr-FR.json lines 434-437 as “Samedi”, i18n/id-ID.json lines
434-437 as “Sabtu”, i18n/ko-KR.json lines 432-435 as “토요일”, and i18n/mk-MK.json
lines 432-435 as “Сабота”, preserving the existing Sunday and Monday entries and
JSON structure.
In `@i18n/nl-NL.json`:
- Around line 342-345: Add the missing weekStartsOnSaturday translation
alongside the existing weekStartsOnSunday and weekStartsOnMonday entries in
i18n/nl-NL.json lines 342-345 (“Zaterdag”), i18n/ru-RU.json lines 432-435
(“Суббота”), i18n/tr-TR.json lines 433-436 (“Cumartesi”), and i18n/uk-UA.json
lines 432-435 (“Субота”).
In `@i18n/schema.json`:
- Around line 1717-1719: Update i18n/de-DE.json near the existing weekday
translations to add the required weekStartsOnSaturday key with the German value
"Samstag"; keep the weekStartsOnSaturday property and required entry in
i18n/schema.json unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 36ab98f7-98a3-43a8-ac97-69146f1d7a44
📒 Files selected for processing (13)
apps/web/src/store/user-preferences.tsi18n/de-DE.jsoni18n/el-GR.jsoni18n/es-ES.jsoni18n/fr-FR.jsoni18n/id-ID.jsoni18n/ko-KR.jsoni18n/mk-MK.jsoni18n/nl-NL.jsoni18n/ru-RU.jsoni18n/schema.jsoni18n/tr-TR.jsoni18n/uk-UA.json
| "firstDayOfWeekDescription": "Επιλέξτε ποια ημέρα ξεκινούν τα ημερολόγια και οι εβδομάδες", | ||
| "selectFirstDayOfWeek": "Επιλέξτε την πρώτη ημέρα", | ||
| "weekStartsOnSunday": "Κυριακή", | ||
| "weekStartsOnMonday": "Δευτέρα", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Add weekStartsOnSaturday to every changed locale.
The new Saturday option is supported by the selector, but these locale files still define only Sunday and Monday. Add the missing key to preserve the localization contract:
i18n/el-GR.json#L432-L435: add"weekStartsOnSaturday": "Σάββατο".i18n/es-ES.json#L342-L345: add"weekStartsOnSaturday": "Sábado".i18n/fr-FR.json#L434-L437: add"weekStartsOnSaturday": "Samedi".i18n/id-ID.json#L434-L437: add"weekStartsOnSaturday": "Sabtu".i18n/ko-KR.json#L432-L435: add"weekStartsOnSaturday": "토요일".i18n/mk-MK.json#L432-L435: add"weekStartsOnSaturday": "Сабота".
📍 Affects 6 files
i18n/el-GR.json#L432-L435(this comment)i18n/es-ES.json#L342-L345i18n/fr-FR.json#L434-L437i18n/id-ID.json#L434-L437i18n/ko-KR.json#L432-L435i18n/mk-MK.json#L432-L435
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@i18n/el-GR.json` around lines 432 - 435, Add the missing weekStartsOnSaturday
localization entry to i18n/el-GR.json lines 432-435 as “Σάββατο”,
i18n/es-ES.json lines 342-345 as “Sábado”, i18n/fr-FR.json lines 434-437 as
“Samedi”, i18n/id-ID.json lines 434-437 as “Sabtu”, i18n/ko-KR.json lines
432-435 as “토요일”, and i18n/mk-MK.json lines 432-435 as “Сабота”, preserving the
existing Sunday and Monday entries and JSON structure.
| "firstDayOfWeekDescription": "Kies op welke dag kalenders en weekoverzichten beginnen", | ||
| "selectFirstDayOfWeek": "Selecteer de eerste dag", | ||
| "weekStartsOnSunday": "Zondag", | ||
| "weekStartsOnMonday": "Maandag", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Add weekStartsOnSaturday to every affected locale.
The Saturday option is now supported by the selector, but these locale files still define only Sunday and Monday labels. Add the localized Saturday key at each site:
i18n/nl-NL.json#L342-L345: add"weekStartsOnSaturday": "Zaterdag".i18n/ru-RU.json#L432-L435: add"weekStartsOnSaturday": "Суббота".i18n/tr-TR.json#L433-L436: add"weekStartsOnSaturday": "Cumartesi".i18n/uk-UA.json#L432-L435: add"weekStartsOnSaturday": "Субота".
📍 Affects 4 files
i18n/nl-NL.json#L342-L345(this comment)i18n/ru-RU.json#L432-L435i18n/tr-TR.json#L433-L436i18n/uk-UA.json#L432-L435
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@i18n/nl-NL.json` around lines 342 - 345, Add the missing weekStartsOnSaturday
translation alongside the existing weekStartsOnSunday and weekStartsOnMonday
entries in i18n/nl-NL.json lines 342-345 (“Zaterdag”), i18n/ru-RU.json lines
432-435 (“Суббота”), i18n/tr-TR.json lines 433-436 (“Cumartesi”), and
i18n/uk-UA.json lines 432-435 (“Субота”).
| "weekStartsOnSaturday": { | ||
| "type": "string" | ||
| }, |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Synchronize the required Saturday key across the localization contract.
The schema now requires weekStartsOnSaturday, but the German locale does not define it, so locale validation will fail.
i18n/schema.json#L1717-L1719,1800-1800: Keep the new property and required entry only after all locales provide it.i18n/de-DE.json#L446-L446: Add"weekStartsOnSaturday": "Samstag"beside the existing weekday translations.
📍 Affects 2 files
i18n/schema.json#L1717-L1719(this comment)i18n/de-DE.json#L446-L446
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@i18n/schema.json` around lines 1717 - 1719, Update i18n/de-DE.json near the
existing weekday translations to add the required weekStartsOnSaturday key with
the German value "Samstag"; keep the weekStartsOnSaturday property and required
entry in i18n/schema.json unchanged.
|
@Navdeepannu Thank you for your contribution. This will certainly make Kaneo more regionally flexible. Please take a look at the review comments made by both AI Code Reviewer tools. |
Description
Adds Saturday as an available first-day-of-week preference, giving users more flexibility to match their regional, workweek, or personal calendar conventions.
This PR also refactors the week-start configuration so supported days are defined centrally in
WEEK_START_DAYS. TheWeekStartDaytype is derived from that list, andisWeekStartDayvalidates selected values at runtime.The preferences dropdown is now generated from the supported-days list instead of containing separate hardcoded options. To support another day in the future, contributors only need to:
WEEK_START_DAYS.The type, validation, and rendered dropdown options then remain synchronized automatically.
Additional changes:
weekStartsOnSaturdaytranslation key.Related Issue(s)
Fixes #1414
Type of Change
How Has This Been Tested?
Before submitting, manually verify:
Screenshots (if applicable)
Checklist
Additional Notes
Week-start values follow the JavaScript day numbering convention:
0: Sunday1: Monday6: SaturdayCentralizing these values avoids duplicating union types and individual dropdown components. Future week-start options can be added without rewriting the preference store, validation logic, or select rendering.
Summary by CodeRabbit