Skip to content

fix: localize model catalog last-synced date and add colon (#1959) - #2109

Merged
larryro merged 1 commit into
mainfrom
tale/xs7dznhsw73bevay1dzbpabkbx896xds
Jun 24, 2026
Merged

larryro merged 1 commit into
mainfrom
tale/xs7dznhsw73bevay1dzbpabkbx896xds

Conversation

@larryro

@larryro larryro commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1959 — the model-catalog "last synced" line rendered its date in English regardless of the active locale and was missing a colon after the label.

Changes

  • useFormatDate: the active locale's dayjs data is registered lazily as a global side-effect that does not re-render React. A date could therefore paint with the eagerly-loaded en locale before the active locale's data arrived and stay stuck in English (e.g. a German "Zuletzt synchronisiert" line showing an English-formatted date). The hook now loads the locale and bumps a counter once it's ready, so dependent formatting re-runs with the correct locale. Already-loaded locales resolve synchronously, so this is a no-op beyond a single mount-time re-render. This fixes the catalog card and every other consumer of the formatter.
  • Locale strings (en, de, fr): added the colon to settings.providers.modelCatalog.lastSynced (e.g. Zuletzt synchronisiert: {when} · {count} Modelle.).

Acceptance criteria

  • German UI shows a German-formatted date and a colon after the label.
  • English (and other locales) render correctly and are unaffected by regressions.

Verification

  • tsc --noEmit (platform) — clean
  • oxlint --type-aware on changed files — 0 warnings/errors
  • vitest i18n parity suite (lib/i18n/messages.test.ts) — 23 passed
  • Locale JSON validity confirmed for en/de/fr

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@larryro, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 56 minutes and 56 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f205bfe6-0ab3-499f-b66a-50a379ae4aca

📥 Commits

Reviewing files that changed from the base of the PR and between 6b90e78 and 0738816.

📒 Files selected for processing (4)
  • services/platform/app/hooks/use-format-date.ts
  • services/platform/messages/de.json
  • services/platform/messages/en.json
  • services/platform/messages/fr.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tale/xs7dznhsw73bevay1dzbpabkbx896xds

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@larryro

larryro commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Desk Review — #1959 (localize model-catalog "last synced" date + add colon)

Verdict: READY TO MERGE.

CI: all green on this commit — 46 checks passed, 5 conditionally skipped (e.g. Docs container test), 0 failing/pending. Includes Build platform, Type check, Lint, Format, UI, Browser, and all 16 Playwright (platform) shards.

Tests run locally:

  • bunx vitest --run --project server lib/i18n/messages.test.ts → 23 passed (i18n key-parity across en/de/fr — guards the JSON edits; the colon was added symmetrically so parity holds).
  • bunx vitest --run --project client (covers app/hooks, app/features, app/components) → exit 0, no failures.

Review (2 rounds, 5 breadth lenses + confirmation)

Correctness — PASS. Root cause: dayjs locales load lazily (only en eager); main.tsx wires loadDayjsLocale to the locale provider's onChange, which never fires for the initial locale, so a session that boots in German formatted dates with the en locale. The hook's new useEffect loads the active locale on mount and bumps a useState counter once it resolves. A candidate "the counter value is unused / not in any dep array, so nothing re-renders" finding was independently re-verified and rejected: calling a useState setter re-renders the host component regardless of whether the value is read; the consumer (model-catalog-card.tsx:104/108) calls formatDate(...) directly in JSX (not memoized on callback identity); formatDate → applyLocale reads dayjs's global locale registry at call time; and setLocaleReady runs only inside .then() after the locale is registered. So the re-render re-formats correctly. Edge cases (already-loaded en, unknown locale, regional de-CH→de base fallback, empty locale) all degrade gracefully. No infinite-loop risk (effect dep is [locale] only). SPA, so no SSR/hydration mismatch.

Robustness — PASS. cancelled flag correctly guards setState-after-unmount. Rapid locale switches: counter is locale-agnostic, but dayjs locale is global and the callbacks use the current locale prop, so a late-resolving stale load only causes a harmless extra re-render with the correct locale. StrictMode double-invoke handled by the cancel flag.

Elegance — PASS (minor, non-blocking). Change is minimal and scoped. Comment is accurate. The force-rerender via useState counter is pragmatic and correct, though it diverges from the repo's useSyncExternalStore convention used elsewhere for similar "react to an external global change" cases — worth considering, not blocking.

Boundaries / resolution — PASS. i18n complete: en/de/fr updated; de-CH.json has no modelCatalog keys and inherits from de; global.json has no lastSynced; no other locale files contain the key. lastFailed correctly left unchanged (grammatical "at/um/à", not a label:value pair). French uses : (space-colon), matching existing fr convention (syncFailed). Locale→dynamic-import is whitelist-only (LOCALE_IMPORTS) with upstream isValidLocale validation — no injection surface. Fully fixes the reported issue, not a narrower symptom.

Tests — acceptable gap, non-blocking. i18n parity test guards the JSON change and passes. There is no unit test for useFormatDate / the locale-load-then-rerender behavior; this UI-effect is conventionally covered by Playwright/manual QA in this repo and the DoD treats e2e as optional. A focused hook test (assert a de date re-renders German after loadDayjsLocale resolves) would be a nice future addition.

Note: the pre-existing empty .catch() in lib/utils/date/dayjs-setup.ts violates the repo's "no empty catch" rule, but it is not part of this diff — out of scope.

@larryro
larryro merged commit 34ddc4b into main Jun 24, 2026
50 checks passed
@larryro
larryro deleted the tale/xs7dznhsw73bevay1dzbpabkbx896xds branch June 24, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Model catalog "last synced" date isn't localized and is missing a colon

1 participant