Skip to content

feat(appearance): add global font size setting (#3120)#3396

Merged
graycyrus merged 1 commit into
tinyhumansai:mainfrom
graycyrus:feat/font-size-setting-3120
Jun 5, 2026
Merged

feat(appearance): add global font size setting (#3120)#3396
graycyrus merged 1 commit into
tinyhumansai:mainfrom
graycyrus:feat/font-size-setting-3120

Conversation

@graycyrus
Copy link
Copy Markdown
Contributor

@graycyrus graycyrus commented Jun 5, 2026

Summary

Adds a Font size control (Small / Medium / Large / Extra Large) to Settings → Appearance. The selection drives the root <html> font-size via ThemeProvider; because Tailwind's text scale is rem-based and :root is 16px, this scales all app text — chat messages, the composer and UI chrome — independently of the OS / system font setting.

This addresses the readability/accessibility asks in #3120 with a single, low-risk global control (per maintainer decision, no separate composer-size control).

Changes

  • store/themeSlice.tsFontSize type, fontSize state (default medium), setFontSize reducer, and a shared FONT_SIZE_PX map (14/16/18/20px) as the single source of truth.
  • store/index.ts — persist fontSize via the existing localStorage-backed theme config. No migration needed (redux-persist autoMergeLevel1 defaults the field in for existing users; medium == historical 16px).
  • providers/ThemeProvider.tsx — new effect applies the font size to <html>; existing theme/matchMedia logic untouched.
  • components/settings/panels/AppearancePanel.tsx — new Font size radiogroup reusing the existing theme-option markup, with sized "A" preview glyphs.
  • i18n — new keys in en.ts + real translations in all 13 locales.

Test plan

  • tsc --noEmit (typecheck) passes
  • ESLint clean on changed files
  • Prettier clean
  • Vitest: 13 new tests pass (slice, ThemeProvider DOM application, panel dispatch)
  • i18n:check — new keys have 0 missing / 0 extra (full parity)
  • i18n:english:check — all new font-size keys pass the English-detection gate

Note: i18n:english:check exits non-zero on this branch due to a pre-existing repo-wide baseline of ~1299 untranslated values that is identical on clean main — none of it is introduced by this PR. All keys added here pass the gate.

Closes #3120

Summary by CodeRabbit

  • New Features

    • Added font size selection to Appearance settings with four size options (Small, Medium, Large, Extra-Large).
    • Font size preferences now persist across app restarts.
  • Localization

    • Added font size setting translations in 14 languages.
  • Tests

    • Added test coverage for Appearance settings and theme configuration.

Add a Font size control (Small/Medium/Large/Extra Large) to Settings →
Appearance. The selection drives the root <html> font-size via
ThemeProvider; because Tailwind's text scale is rem-based, this scales all
app text — chat messages, composer and UI chrome — independently of the OS
font setting.

- themeSlice: FontSize type, fontSize state (default medium), setFontSize
  reducer, and a shared FONT_SIZE_PX map as the single source of truth
- persist fontSize via the existing localStorage-backed theme config
- AppearancePanel: new Font size radiogroup reusing the existing markup
- i18n keys added to en + real translations in all 13 locales
- tests for the slice, ThemeProvider DOM application and the panel

Closes tinyhumansai#3120
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR implements customizable font-size selection in the app's appearance settings. It adds Redux state management for font-size preferences, integrates font-size application into the root HTML element via ThemeProvider, provides a radio-group UI control in AppearancePanel, and includes full internationalization support across 14 languages.

Changes

Font Size Customization

Layer / File(s) Summary
Redux state and persistence
app/src/store/themeSlice.ts, app/src/store/themeSlice.test.ts, app/src/store/index.ts
FontSize union type and FONT_SIZE_PX mapping added to themeSlice; ThemeState extended with fontSize: 'medium' default; new setFontSize reducer/action exported; redux-persist whitelist updated to include fontSize.
Theme provider DOM synchronization
app/src/providers/ThemeProvider.tsx, app/src/providers/ThemeProvider.test.tsx
ThemeProvider now subscribes to theme.fontSize state and applies the corresponding pixel value to document.documentElement.style.fontSize using FONT_SIZE_PX lookup, with fallback to 'medium' and debug logging. Tests verify pixel value application across all four sizes and child rendering.
Appearance panel UI and tests
app/src/components/settings/panels/AppearancePanel.tsx, app/src/components/settings/panels/AppearancePanel.test.tsx, app/src/test/test-utils.tsx
AppearancePanel extended with FontSizeOption descriptor type, FONT_SIZE_OPTIONS array with localized labels/descriptions and glyph preview classes, and a new radio-group section that dispatches setFontSize on user selection. Tests cover radio rendering, selection state marking, and state updates. Test utilities wired with theme reducer for panel testing.
Internationalization
app/src/lib/i18n/ar.ts, app/src/lib/i18n/bn.ts, app/src/lib/i18n/de.ts, app/src/lib/i18n/en.ts, app/src/lib/i18n/es.ts, app/src/lib/i18n/fr.ts, app/src/lib/i18n/hi.ts, app/src/lib/i18n/id.ts, app/src/lib/i18n/it.ts, app/src/lib/i18n/ko.ts, app/src/lib/i18n/pl.ts, app/src/lib/i18n/pt.ts, app/src/lib/i18n/ru.ts, app/src/lib/i18n/zh-CN.ts
Consistent translation keys added across all 14 language bundles: settings.appearance.fontSize (heading), settings.appearance.fontSizeAria (ARIA label), four size option labels (small/medium/large/xlarge) and descriptions, and settings.appearance.fontSizeHelperText explaining app-wide independent scaling.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Font sizes now dance at your command,
Four gentle choices, all planned,
From tiny script to letters grand,
Across the world in every land!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a global font size setting to the appearance section.
Linked Issues check ✅ Passed The PR implements the primary objective from #3120: a font size setting with Small/Medium/Large/Extra Large options. Global font scaling via root font-size is functional and independent of system settings.
Out of Scope Changes check ✅ Passed All changes are scoped to font size functionality: theme state, UI controls, i18n, and providers. The PR explicitly does not include a separate composer-size control per maintainer decision, which aligns with scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

@graycyrus graycyrus marked this pull request as ready for review June 5, 2026 06:58
@graycyrus graycyrus requested a review from a team June 5, 2026 06:58
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
app/src/providers/ThemeProvider.tsx (1)

27-27: ⚡ Quick win

Use the app’s namespaced debug logger instead of console.debug.

This line bypasses the repo logging convention in app/src and may leak verbose logs outside intended dev diagnostics.

As per coding guidelines, in app/src use namespaced debug logs with dev-only detail for diagnostic logging.

🤖 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 `@app/src/providers/ThemeProvider.tsx` at line 27, Replace the direct
console.debug call in ThemeProvider (the line logging "[theme] applying root
font-size") with the app's namespaced debug logger (e.g., debug or themeLogger)
and pass the same message and data ({ fontSize, px }); add or update the import
for that logger at the top of the file and ensure the logger is used
consistently in ThemeProvider (or any helper function that applies the root
font-size) so diagnostic output follows the repo's dev-only namespaced logging
convention.
🤖 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.

Nitpick comments:
In `@app/src/providers/ThemeProvider.tsx`:
- Line 27: Replace the direct console.debug call in ThemeProvider (the line
logging "[theme] applying root font-size") with the app's namespaced debug
logger (e.g., debug or themeLogger) and pass the same message and data ({
fontSize, px }); add or update the import for that logger at the top of the file
and ensure the logger is used consistently in ThemeProvider (or any helper
function that applies the root font-size) so diagnostic output follows the
repo's dev-only namespaced logging convention.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1348fdc5-a1dd-432a-a0c1-fe5ec0cd4504

📥 Commits

Reviewing files that changed from the base of the PR and between 95118d5 and 2d63f21.

📒 Files selected for processing (22)
  • app/src/components/settings/panels/AppearancePanel.test.tsx
  • app/src/components/settings/panels/AppearancePanel.tsx
  • app/src/lib/i18n/ar.ts
  • app/src/lib/i18n/bn.ts
  • app/src/lib/i18n/de.ts
  • app/src/lib/i18n/en.ts
  • app/src/lib/i18n/es.ts
  • app/src/lib/i18n/fr.ts
  • app/src/lib/i18n/hi.ts
  • app/src/lib/i18n/id.ts
  • app/src/lib/i18n/it.ts
  • app/src/lib/i18n/ko.ts
  • app/src/lib/i18n/pl.ts
  • app/src/lib/i18n/pt.ts
  • app/src/lib/i18n/ru.ts
  • app/src/lib/i18n/zh-CN.ts
  • app/src/providers/ThemeProvider.test.tsx
  • app/src/providers/ThemeProvider.tsx
  • app/src/store/index.ts
  • app/src/store/themeSlice.test.ts
  • app/src/store/themeSlice.ts
  • app/src/test/test-utils.tsx

@graycyrus graycyrus requested a review from sanil-23 June 5, 2026 07:17
@graycyrus graycyrus merged commit 11fae79 into tinyhumansai:main Jun 5, 2026
26 of 31 checks passed
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.

Add customizable font size and chat text area scaling options

1 participant