Skip to content

fix: language persistence and mobile responsiveness#1

Merged
zhaiker01 merged 1 commit into
mainfrom
fix/i18n-persistence-and-mobile-responsive
May 21, 2026
Merged

fix: language persistence and mobile responsiveness#1
zhaiker01 merged 1 commit into
mainfrom
fix/i18n-persistence-and-mobile-responsive

Conversation

@kiro-agent
Copy link
Copy Markdown

@kiro-agent kiro-agent Bot commented May 21, 2026

This pull request was created by @kiro-agent on behalf of @zhaiker01 👻

Comment with /kiro fix to address specific feedback or /kiro all to address everything.
Learn about Kiro autonomous agent


Summary

Fixes two issues:

1. Language setting not persisting across refresh

Root cause: i18next-browser-languagedetector and zustand's persist middleware were both independently writing language preferences to localStorage, creating a race condition on page load. The detector would read its own key (i18nextLng) before zustand rehydrated, often defaulting to English.

Fix:

  • Removed i18next-browser-languagedetector entirely
  • i18n now reads initial language directly from zustand's persisted store (chat2api-settings in localStorage)
  • Falls back to browser navigator.language for first-time users
  • Zustand's onRehydrateStorage still syncs i18n after hydration as a safety net

2. Mobile responsiveness

Problem: Sidebar, tables, dialogs, and other components had no responsive design - unusable on mobile.

Fix:

  • Added MobileSidebar component (slide-in overlay with backdrop)
  • Added hamburger menu button in Header (visible only below md breakpoint)
  • Desktop sidebar hidden on mobile (hidden md:block)
  • Dialog: responsive width with w-[calc(100%-2rem)] on mobile
  • Tables: hide less-important columns on small screens (hidden sm:table-cell)
  • Settings tabs: 3-col grid on mobile → 5-col on sm+
  • Responsive padding, spacing, and text sizing throughout
  • Mobile CSS optimizations (reduced bokeh effects, smaller table cells, disabled tooltips)

Files Changed

File Change
i18n/index.ts Replaced LanguageDetector with direct localStorage read
stores/settingsStore.ts Added mobileSidebarOpen state, partialize to exclude transient state
components/layout/MainLayout.tsx Responsive sidebar visibility
components/layout/MobileSidebar.tsx New - mobile navigation overlay
components/layout/Header.tsx Added hamburger menu, responsive spacing
components/ui/dialog.tsx Responsive mobile width
index.css Mobile media queries
pages/Settings.tsx Responsive tabs grid
pages/ApiKeys.tsx Responsive table columns, stacked header
components/logs/RequestLogList.tsx Responsive table columns, search bar
i18n/locales/*.json Added nav.menu key

Testing

  • TypeScript type check passes (tsc --noEmit)
  • Manual verification of code correctness

1. Fix i18n language persistence:
   - Remove i18next-browser-languagedetector to eliminate race condition
     with zustand's persist middleware (both were writing to localStorage
     independently causing conflicts on reload)
   - Read initial language directly from zustand's persisted localStorage
     key (chat2api-settings) with browser navigator fallback
   - Zustand onRehydrateStorage callback still syncs i18n on hydration

2. Fix mobile responsiveness:
   - Add MobileSidebar component with slide-in overlay for mobile nav
   - Add hamburger menu button in Header (visible only on mobile)
   - Hide desktop Sidebar on screens < md breakpoint
   - Make Dialog component width responsive (calc(100%-2rem) on mobile)
   - Hide less-important table columns (provider, account, usage, date)
     on small screens using hidden sm:table-cell / md:table-cell
   - Responsive main content padding (p-3 → sm:p-4 → md:p-6)
   - Settings tabs: 3-col grid on mobile, 5-col on sm+
   - Add mobile CSS: reduce bokeh effects, smaller table cells,
     disable tooltips on touch devices
   - Responsive header spacing and proxy status display

3. Minor improvements:
   - Add nav.menu translation key for mobile sidebar title
   - Exclude mobileSidebarOpen from zustand persistence
   - ApiKeys card header stacks vertically on mobile

Co-authored-by: zhaiker01 <285887163+zhaiker01@users.noreply.github.com>
@zhaiker01 zhaiker01 merged commit 5f98470 into main May 21, 2026
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.

2 participants