fix(appearance): font size setting now visibly scales UI text (closes #843)

* fix(appearance): font size setting now visibly scales UI text

Root cause: the original CSS override only changed :root{font-size} which
has no effect on the 232+ hardcoded px values throughout style.css. Only
the ~49 em/rem values were affected, which are not the main visible text.

Fix: add explicit px overrides for the key UI surfaces under each
data-font-size attribute selector:
  - .msg-body (chat messages) + headings, code, tables
  - .session-item, .session-meta (sidebar session list)
  - #msg (composer textarea)
  - .file-item (workspace file tree)

The :root override is kept so em/rem cascade correctly, but the targeted
element overrides are what actually make the text visibly larger/smaller.

Also: 8 new regression tests lock in the targeted CSS rules so this
cannot silently regress again.

* fix: composer large font was no-op — bump to 18px (default is 16px)

---------

Co-authored-by: nesquena-hermes <nesquena-hermes@users.noreply.github.com>
This commit is contained in:
nesquena-hermes
2026-04-21 23:39:39 -07:00
committed by GitHub
parent db57c47ff3
commit 85434dd03c
3 changed files with 108 additions and 4 deletions

View File

@@ -25,8 +25,9 @@ class TestFontSizeCssModifiers:
def test_small_is_smaller_than_default(self):
css = _read("static/style.css")
m_small = re.search(r':root\[data-font-size="small"\]\{font-size:(\d+)px', css)
m_large = re.search(r':root\[data-font-size="large"\]\{font-size:(\d+)px', css)
# Match both compact {font-size:12px} and spaced { font-size: 12px; } formats
m_small = re.search(r':root\[data-font-size="small"\][^{]*\{[^}]*font-size:\s*(\d+)px', css)
m_large = re.search(r':root\[data-font-size="large"\][^{]*\{[^}]*font-size:\s*(\d+)px', css)
assert m_small and m_large, "Both small and large font-size rules must set px values"
assert int(m_small.group(1)) < 14, "Small font size must be < 14px (default)"
assert int(m_large.group(1)) > 14, "Large font size must be > 14px (default)"
@@ -171,3 +172,57 @@ class TestFontSizeI18nCoverage:
src = _read("static/i18n.js")
count = src.count("font_size_large")
assert count >= 6, f"font_size_large must appear in all 6 locales, found {count}"
class TestFontSizeCssTargetedOverrides:
"""CSS must override px-unit text in key UI elements, not just :root font-size.
The original PR only set :root font-size, but the stylesheet uses hardcoded px
values throughout — changing :root has no effect on those. This test class locks
in the targeted overrides for the most visible UI surfaces.
"""
def test_msg_body_overridden_for_small(self):
css = _read("static/style.css")
assert ':root[data-font-size="small"] .msg-body' in css, \
"Chat message text must be explicitly scaled for small"
def test_msg_body_overridden_for_large(self):
css = _read("static/style.css")
assert ':root[data-font-size="large"] .msg-body' in css, \
"Chat message text must be explicitly scaled for large"
def test_session_item_overridden_for_small(self):
css = _read("static/style.css")
assert ':root[data-font-size="small"] .session-item' in css, \
"Sidebar session list text must be explicitly scaled for small"
def test_session_item_overridden_for_large(self):
css = _read("static/style.css")
assert ':root[data-font-size="large"] .session-item' in css, \
"Sidebar session list text must be explicitly scaled for large"
def test_composer_overridden_for_small(self):
css = _read("static/style.css")
assert ':root[data-font-size="small"] #msg' in css, \
"Composer textarea must be explicitly scaled for small"
def test_composer_overridden_for_large(self):
css = _read("static/style.css")
assert ':root[data-font-size="large"] #msg' in css, \
"Composer textarea must be explicitly scaled for large"
# Large composer must not equal the default 16px — that's a no-op
import re
m = re.search(r':root\[data-font-size="large"\] #msg \{ font-size: (\d+)px', css)
assert m and int(m.group(1)) != 16, \
"Large composer font-size must differ from default (16px) to have visible effect"
def test_file_item_overridden_for_small(self):
css = _read("static/style.css")
assert ':root[data-font-size="small"] .file-item' in css, \
"Workspace file tree text must be explicitly scaled for small"
def test_file_item_overridden_for_large(self):
css = _read("static/style.css")
assert ':root[data-font-size="large"] .file-item' in css, \
"Workspace file tree text must be explicitly scaled for large"