Repository navigation
Studio: drive UI font size through a typography scale instead of the root font size - #7359
Conversation
…ont size Follow up to #7355. The preference now writes --ui-font-scale (selected / 16) and a data-ui-font-size attribute on the root instead of mutating the root font size, and the applier clears any stale inline root font-size left by older builds. Because the rem base never moves, every layout-only rem-to-px conversion from #7355 is reverted to its original form: the spacing, radius and container tokens, sidebar and thread widths, grid tracks, calc margins and hub.css dimensions match pre-#7355 main again, which also restores rem-based accessibility scaling for users with a larger browser default font size. Typography scales through tokens in index.css, all exact at 16px: - The named Tailwind sizes (--text-xs through --text-4xl) multiply their defaults by the scale, so standard utilities scale - One token per design px size (--text-ui-8 ... --text-ui-34) replaces every arbitrary text-[Npx] class; leading-ui-* mirrors the exact line heights and the numeric --leading-3..10 scale as well - CSS font-size and line-height declarations multiply by the scale - Chart labels scale through a .recharts-text rule; streamdown and react-flow px text is re-based via scaled overrides; KaTeX's 1px layout trick stays fixed by design - The logo lockups keep their half-rate behavior via the scale var - The explicit Code font size remains unmultiplied Keeps the #7355 behavior fixes: color chip min width, voice select min/max widths, and the select and dropdown menus scrolling an inner viewport so their corners stay rounded. The whitespace-password and IME rename guards that merged alongside are preserved.
test_ui_font_scale_contract.py pins the mechanism (scale var written, root font size never mutated, tokens scaled, code font size not multiplied, the Radix select viewport owning scroll state) and guards against new raw pixel typography, with a documented allowlist for the recharts fontSize props covered by the stylesheet override and the offscreen clipboard textarea. playwright_ui_font_scale.py drives the real appearance controls: root font size fixed at 12/16/20, text and line height scale by size/16, sidebar width invariant, explicit code font size stays fixed, an overflowing dictation select scrolls its Radix viewport by keyboard and wheel, and the default restores exactly. Wired into the UI smoke workflow against the second studio boot. The thinking-compact and descender contracts move back to the rem and token forms now that layout values no longer need px pinning.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Resolve the same two frontend conflicts against main's typography-scale refactor (unslothai#7359): - folder-browser.tsx: keep the showModelHints guard, adopt main's text-ui-9 badge sizing. - resources-tab.tsx: keep the cache-aware models-folder widget the feature needs; main only restyled the old span.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8aaf2f78eb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| dismissWaitToast(); | ||
| if (text.trim().length > 0 || attachments.length > 0) { | ||
| clearStoredDraft(); | ||
| aui.composer().send(); |
There was a problem hiding this comment.
Restore draft clearing before sends
The autosave/restore logic above still persists composerText per thread and restores it whenever [draftKey, aui] changes, but this send path no longer clears the stored draft before aui.composer().send(). When the first message causes the runtime to rebind before the debounce writes the now-empty composer, the sent prompt can be read back from localStorage and reappear in the input, making duplicate sends easy; keep clearing the draft synchronously before sending/queuing.
Useful? React with 👍 / 👎.
Both review points, and they are the same finding from two sides: a range is wrong at the edges and useless in the middle. UI_FONT_SIZE_RANGE is 12 to 20 and the store sets --ui-font-scale to preference / 16, so text-ui-15p5 spans 11.625px to 19.375px. The 12-18px bound rejected both endpoints, failing a UI that is rendering its configured size correctly. At the default scale it also admitted text-ui-13 at 12.1875px and text-ui-18 at 16.875px, so the token swap it was meant to catch passed, and the tracking assertion passed with it because the expectation derives from the same measured size. So read --ui-font-scale off the root and assert the size is text-ui-15p5 at that scale. That holds at every supported preference and pins the token, which is what the check was for. Exercised at preferences 12, 15 and 20, at the pre-#7359 base, with a zero tracking spelled "normal", against swaps to text-ui-13 and text-ui-18, and against a wrong tracking. The three intended failures fail, each naming its cause.
…7828) * test(studio): bound the chat font size and accept a normal tracking Two follow-ups to #7826, which is otherwise the right fix. Asserting the em means the font size itself is no longer checked. The px literal it replaced caught that implicitly, since 0.3565px only matched at 15.5px, so the check quietly lost the ability to notice chat text rendering at the wrong size. Bounding the size to 12-18px restores a coarse version of that: a deliberate scale change or a user font-size preference passes, chat text at a caption or heading size does not. float("normal") also raises, and "normal" is how a browser reports a zero tracking, so that path would surface as a test error rather than as this check failing with its own message. Exercised against the values that occur: the three current theme branches, the pre-#7359 15.5px body, a raised user preference, a zero tracking spelled "normal", a wrong tracking, and chat text at caption and heading sizes. Only the last three fail, each with the message that names the cause. * Assert the chat size token rather than a range Both review points, and they are the same finding from two sides: a range is wrong at the edges and useless in the middle. UI_FONT_SIZE_RANGE is 12 to 20 and the store sets --ui-font-scale to preference / 16, so text-ui-15p5 spans 11.625px to 19.375px. The 12-18px bound rejected both endpoints, failing a UI that is rendering its configured size correctly. At the default scale it also admitted text-ui-13 at 12.1875px and text-ui-18 at 16.875px, so the token swap it was meant to catch passed, and the tracking assertion passed with it because the expectation derives from the same measured size. So read --ui-font-scale off the root and assert the size is text-ui-15p5 at that scale. That holds at every supported preference and pins the token, which is what the check was for. Exercised at preferences 12, 15 and 20, at the pre-#7359 base, with a zero tracking spelled "normal", against swaps to text-ui-13 and text-ui-18, and against a wrong tracking. The three intended failures fail, each naming its cause. * Tighten the size-assertion comment Post-convergence comment pass. The embedded JavaScript comment is left alone: it sits inside a Python string literal, so editing it is a code change and the comment-only gate correctly rejects it. * test(studio): match the UI font size default the store actually uses The font-scale test drove the size input to 16 and then asserted that data-ui-font-size had been dropped, but the store only removes the attribute at UI_FONT_SIZE_RANGE.default, which is 15. The static --ui-font-scale of 0.9375 in index.css is the same 15/16. * Tighten typography test comments
Follow up to #7355, replacing its scaling mechanism with an explicit typography scale.
Previous root cause
The UI font size preference worked by mutating the root font size, which made rem the scaling channel. That forced #7355 to convert hundreds of layout rem values to px so geometry would not scale, and any text not reachable through rem needed conversion. It also meant layout no longer followed a user's larger browser default font size, and any missed rem value was a latent layout bug.
New architecture
The preference now writes two things to the root element and nothing else:
--ui-font-scale: selected / 16(unset at the default)data-ui-font-size="<px>"for conditional stylingThe root font size is never touched, and the applier clears any stale inline root font-size left by older builds. The root computed font size measures 16px at settings 12, 16 and 20.
Typography scales because it references tokens in
index.css, each exact at the 16px default:--text-xsthrough--text-4xlmultiply their defaults by the scale, sotext-smand friends scale automatically, line-height companions stay unitless ratios and follow--text-ui-8through--text-ui-34, replacing every arbitrarytext-[Npx]class;--leading-ui-*mirrors the exact line heights; numeric--leading-3..10scale as well so a scaled font never sits in a frozen line boxfont-sizeandline-heightdeclarations multiply by the scale.recharts-textrule that outranks thefontSizepresentation attributes; the one inline style label scales itselffont-size: 1pxlayout trick is the documented fixed exceptionLayout conversions reverted versus retained
Because the rem base never moves, all layout-only px conversions from #7355 are reverted to their original rem forms: spacing, radius and container tokens, sidebar and thread widths, grid tracks, calc margins and hub.css dimensions match pre-#7355 main. This also restores rem-based accessibility scaling for users with a larger browser default font. Retained from #7355: the color chip min width, the voice select min/max widths, the select and dropdown inner-viewport scrolling that keeps rounded corners, and the dropdown submenu max width that was already px on main-adjacent tests.
Tests
tests/studio/test_ui_font_scale_contract.py: pins the mechanism and guards against new raw pixel typography (documented allowlist: rechartsfontSizeprops covered by the stylesheet override, and the offscreen clipboard textarea)tests/studio/playwright_ui_font_scale.py(wired into the UI smoke workflow): drives the real Settings controls and asserts root font size fixed at 12/16/20, text and line height scale by size/16, sidebar width invariant, explicit Code font size fixed, an overflowing select scrolls its Radix viewport by keyboard and wheel, and the default restores exactlyVerification
Through the real Settings control in Chromium, WebKit and Firefox plus a Chromium pass at devicePixelRatio 1.25: 381 assertions covering the font sweep at 12/14/16/18/20 (text exactly size/16, root fixed at 16), layout invariance (sidebar, dialog, radii, nav items), logo half-rate values, zero clipped text across the chat page and all settings tabs at both extremes, menu and select scrolling with rounded corners, code font independence, and garbage persisted values clamping. Also ran: frontend typecheck, build, i18n parity, the tests/studio static suite (242 passed;
test_cli_repo_variant.pyfails collection locally on a typer version mismatch that reproduces on pristine main), and Biome (720 errors versus 724 on main, both pre-existing drift, non-blocking in CI).