Skip to content

feat(frontend): add an app-wide font size preference - #501

Merged
chriswritescode-dev merged 1 commit into
mainfrom
feature/app-font-size
Dec 2, 2026
Merged

chriswritescode-dev merged 1 commit into
mainfrom
feature/app-font-size

Conversation

@chriswritescode-dev

@chriswritescode-dev chriswritescode-dev commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

User description

Summary

  • Add a fontSize preference (small, medium, large, extra large) that sets the root font size, so rem-based text and spacing across the app scale together.
  • Expose it as a Font size select in Settings → General, allow the assistant to set it, and document it in the settings skill.
  • Replay the stored scale from a new ocm-font-size key before first paint and apply it on preference change, so there is no flash.
  • Mobile input anti-zoom rules move to max(16px, 1rem), so inputs scale up but never drop below 16px.

Tests

Frontend theme, settings and hook tests pass, including new applyFontSize coverage. Shared, backend and frontend typecheck and lint are clean.


PR Type

Enhancement


Description

  • Add small/medium/large/xlarge font size preference

  • Scale root font-size so all rem-based UI scales

  • Persist scale to ocm-font-size and replay before first paint

  • Keep mobile inputs at max(16px, 1rem) to block zoom


Diagram Walkthrough

flowchart LR
  A["FontSizeSchema<br/>shared settings"] -- "validated enum" --> B["GeneralSettings<br/>Font size select"]
  A -- "optional preference" --> C["ThemeContext<br/>applyFontSize on change"]
  C -- "root style.fontSize" --> D["colorTheme.ts<br/>FONT_SIZE_SCALE"]
  D -- "persist scale" --> E["localStorage<br/>ocm-font-size"]
  E -- "replay before paint" --> F["index.html<br/>boot script"]
  A -- "patch schema" --> G["AssistantSettingsPatchSchema"]
  G -- "documented" --> H["assistant-mode.ts<br/>settings prompt"]
  D -- "scaled roots" --> I["index.css<br/>max(16px, 1rem) inputs"]
Loading

File Walkthrough

Relevant files
Enhancement
6 files
settings.ts
Add FontSizeSchema enum, type and medium default                 
+6/-0     
internal-assistant.ts
Allow assistant to patch fontSize preference                         
+1/-0     
colorTheme.ts
Add applyFontSize and shared storage helper                           
+23/-2   
ThemeContext.tsx
Apply font size when preferences change                                   
+8/-1     
GeneralSettings.tsx
Add validated Font size select to settings                             
+29/-0   
index.html
Replay stored font size before first paint                             
+2/-0     
Documentation
1 files
assistant-mode.ts
Document fontSize in assistant settings prompt                     
+1/-0     
Tests
1 files
colorTheme.test.ts
Cover font size application and boot key                                 
+27/-0   
Bug fix
1 files
index.css
Scale mobile input anti-zoom font size                                     
+2/-2     

Comment thread frontend/index.html
Comment on lines 28 to +30
var snapshot = JSON.parse(localStorage.getItem('ocm-appearance'));
var fontSize = localStorage.getItem('ocm-font-size');
if (fontSize) document.documentElement.style.fontSize = fontSize;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fragile boot order

The font size is read only after JSON.parse(localStorage.getItem('ocm-appearance')), and both share one try. If the appearance snapshot is corrupted, the parse throws and the stored font size is skipped, so the page flashes at the default size until React applies the preference. Reading and applying ocm-font-size before parsing the snapshot keeps the two values independent.

Suggested change
var snapshot = JSON.parse(localStorage.getItem('ocm-appearance'));
var fontSize = localStorage.getItem('ocm-font-size');
if (fontSize) document.documentElement.style.fontSize = fontSize;
var fontSize = localStorage.getItem('ocm-font-size');
if (fontSize) document.documentElement.style.fontSize = fontSize;
var snapshot = JSON.parse(localStorage.getItem('ocm-appearance'));

@lil-worker-cstech

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⚠️ Risk checks: 1 finding(s) detected
Risky shapes (1): Removed JS/TS function in frontend/src/lib/theme/colorTheme.ts
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
⚠️ Risk level: Low
✅ Merge recommendation: Needs review
Merge recommendation checks
✅ CI on reviewed head: passed
✅ Head is current with its base: up to date
✅ Human authors: all authors are human
⚠️ No sensitive paths or risky changes: 1 finding(s)
⚠️ Changed lines within cap: 104 changed lines exceeds cap 100
🔎 Failure modes

What: The saved font size is not applied before first paint. The page renders at 100% and then jumps to the chosen size once preferences load.
Where: frontend/index.html:inline boot script
Trigger: The `ocm-appearance` value in localStorage is malformed, so `JSON.parse` throws before `ocm-font-size` is read and the shared `try` block exits.
Detected by: Nothing. The current test only checks that `index.html` contains the `ocm-font-size` key, not the order of operations in the boot script.
Covered in this PR: No

What: Mobile inputs at Large or Extra large render at `1rem` (18px or 20px), which is bigger than the surrounding text. Any component that relied on the fixed 16px override for layout may now overflow.
Where: frontend/src/index.css:mobile input font-size rules
Trigger: A user on a small viewport picks the `large` or `xlarge` font size.
Detected by: Manual or visual testing on a mobile viewport. No automated check is visible.
Covered in this PR: No

🧪 PR contains tests
🔒 No security concerns identified

@chriswritescode-dev
chriswritescode-dev merged commit a6cdbc3 into main Dec 2, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant