Skip to content

fix(frontend): format sidebar date group labels with the user's locale - #14437

Open
gaoanze888 wants to merge 1 commit into
Significant-Gravitas:devfrom
gaoanze888:fix/13519-sidebar-locale-date-format
Open

fix(frontend): format sidebar date group labels with the user's locale#14437
gaoanze888 wants to merge 1 commit into
Significant-Gravitas:devfrom
gaoanze888:fix/13519-sidebar-locale-date-format

Conversation

@gaoanze888

Copy link
Copy Markdown

Problem

The new sidebar's "Recent chats" day-group labels mix a localized month name with hand-assembled English date parts, producing a format that is incorrect for every locale (#13519):

const day = date.getDate();
const month = date.toLocaleDateString(undefined, { month: "long" });
const label = `${day}${ordinalSuffix(day)} ${month}`;   // "26th June"

The month name follows the user's locale, but the day + English ordinal + "day month year" assembly does not. A zh-CN user sees 20th 六月 (correct would be 6月20日); a de-DE user sees 20th Juni (correct: 20. Juni).

This is reproducible on master — the existing unit tests actually fail on machines with a non-English locale (expected '20th 六月' to be '20th June'), because the expectations hardcode English output.

Fix

Format the label with a single Intl.DateTimeFormat(locale, …) options set, per the suggestion in #13519:

  • { day: "numeric", month: "long" } for dates in the current year
  • adds year: "numeric" for older dates

Result per locale: June 20 / December 1, 2024 (en-US), 20 June (en-GB), 20. Juni (de-DE), 6月20日 / 2024年12月1日 (zh-CN). The custom ordinalSuffix helper is gone — English ordinals can't be expressed via Intl, and keeping them is what made the format locale-invalid.

getDateGroupLabel and groupSessionsByDate now accept an optional locale (defaulting to the user's locale), mirroring formatHeaderDate in home/helpers.ts, which keeps tests deterministic.

Test plan

  • Updated RecentChats/helpers.test.ts: expectations pass an explicit "en-US" locale (no longer runner-locale-dependent), plus new assertions for en-GB, de-DE, and zh-CN covering the previously broken mixed format
  • pnpm vitest run src/components/layout/AppSidebar/... — 11/11 pass
  • pnpm format, pnpm lint, pnpm types — clean
  • Verified the 3 pre-existing failures in home/ tests are unrelated (they fail on unmodified master under a non-en-US locale — Intl.NumberFormat currency prefix; same class of issue as this one, out of scope here)

Fixes #13519

@gaoanze888
gaoanze888 requested a review from a team as a code owner September 8, 2026 07:05
@gaoanze888
gaoanze888 requested review from Pwuts and ntindle and removed request for a team September 8, 2026 07:05
@github-project-automation github-project-automation Bot moved this to 🆕 Needs initial review in AutoGPT development kanban Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

This PR targets the master branch but does not come from dev or a hotfix/* branch.

Automatically setting the base branch to dev.

@github-actions github-actions Bot added platform/frontend AutoGPT Platform - Front end cla: pending CLA not yet signed by all contributors labels Sep 8, 2026
@github-actions
github-actions Bot changed the base branch from master to dev September 8, 2026 07:05
@github-actions github-actions Bot added the size/m label Sep 8, 2026
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 02c11c62-1258-4206-8411-9fef41bf4599

📥 Commits

Reviewing files that changed from the base of the PR and between 6dc5fec and c8b8c9d.

📒 Files selected for processing (2)
  • autogpt_platform/frontend/src/components/layout/AppSidebar/components/RecentChats/__tests__/helpers.test.ts
  • autogpt_platform/frontend/src/components/layout/AppSidebar/components/RecentChats/helpers.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • autogpt_platform/frontend/src/components/layout/AppSidebar/components/RecentChats/helpers.ts
  • autogpt_platform/frontend/src/components/layout/AppSidebar/components/RecentChats/tests/helpers.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (10)
  • GitHub Check: check API types
  • GitHub Check: lint
  • GitHub Check: knip
  • GitHub Check: integration_test
  • GitHub Check: Build, smoke, and scan (linux/amd64)
  • GitHub Check: Build, smoke, and scan (linux/arm64)
  • GitHub Check: end-to-end tests
  • GitHub Check: Analyze (python)
  • GitHub Check: Check PR Status
  • GitHub Check: Analyze (typescript)
⚠️ CI failures not shown inline (1)

Commit Status: Vercel: Vercel

Conclusion: failure

Authorization required to deploy.

Walkthrough

Recent chat date grouping now uses locale-aware Intl.DateTimeFormat output. Optional locale parameters flow through date-label generation and session grouping. Tests cover English, German, British English, and Chinese formats.

Changes

Recent chat date localization

Layer / File(s) Summary
Localized date labels and grouping
autogpt_platform/frontend/src/components/layout/AppSidebar/components/RecentChats/helpers.ts, autogpt_platform/frontend/src/components/layout/AppSidebar/components/RecentChats/__tests__/helpers.test.ts
getDateGroupLabel uses Intl.DateTimeFormat and omits the year for current-year dates. getDateGroupLabel and groupSessionsByDate accept an optional locale. Tests validate localized labels and grouping behavior.

Priority: ➖ Normal — Impact reflects medium issue severity.

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 750a1

Recent Chat date labels now use locale-aware formatting with localized test coverage; no merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: formatting sidebar date-group labels with the user's locale.
Description check ✅ Passed The description explains the localization problem, the Intl.DateTimeFormat fix, affected APIs, tests, and verification results.
Linked Issues check ✅ Passed The changes satisfy issue #13519 by replacing hand-assembled date labels with consistent locale-aware formatting and adding locale coverage in tests.
Out of Scope Changes check ✅ Passed The changes are limited to Recent Chats date-label formatting, related API parameters, and corresponding tests. No unrelated changes are present.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@CLAassistant

CLAassistant commented Sep 8, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@gaoanze888
gaoanze888 force-pushed the fix/13519-sidebar-locale-date-format branch from 3f3406d to c8b8c9d Compare September 8, 2026 07:13
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@gaoanze888
gaoanze888 force-pushed the fix/13519-sidebar-locale-date-format branch from c8b8c9d to 58067a0 Compare September 8, 2026 07:19
The RecentChats day-group labels hand-assembled English-style date parts
around a localized month name (`26th June`, `${day}${suffix} ${month}`),
which is not a valid format for any locale — e.g. zh users saw "20th 六月".

Replace the hand-assembly with a single Intl.DateTimeFormat options set
(day/month/year), so each locale gets its own ordering and punctuation
("June 20", "20 June", "20. Juni", "6月20日"). The year is still only
included for dates outside the current year. Tests now pass an explicit
locale for determinism and cover en-GB/de-DE/zh-CN output.

Fixes Significant-Gravitas#13519
@gaoanze888
gaoanze888 force-pushed the fix/13519-sidebar-locale-date-format branch from 58067a0 to 750a1a1 Compare September 8, 2026 07:19
@github-actions github-actions Bot added cla: signed CLA signed by all contributors cla: pending CLA not yet signed by all contributors and removed cla: pending CLA not yet signed by all contributors labels Sep 8, 2026
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.34%. Comparing base (6dc5fec) to head (750a1a1).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev   #14437   +/-   ##
=======================================
  Coverage   81.34%   81.34%           
=======================================
  Files        3515     3515           
  Lines      263403   263394    -9     
  Branches    24413    24411    -2     
=======================================
- Hits       214278   214271    -7     
+ Misses      43780    43764   -16     
- Partials     5345     5359   +14     
Flag Coverage Δ
platform-frontend 60.37% <100.00%> (-0.01%) ⬇️
platform-frontend-e2e 28.67% <0.00%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Platform Backend 86.35% <ø> (ø)
Platform Frontend 62.74% <100.00%> (-0.01%) ⬇️
AutoGPT Libs ∅ <ø> (∅)
Classic AutoGPT 28.43% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: signed CLA signed by all contributors platform/frontend AutoGPT Platform - Front end size/m

Projects

Status: 🆕 Needs initial review
Status: No status

Development

Successfully merging this pull request may close these issues.

New sidebar shows half-localized date format that is incorrect for every locale

2 participants