Skip to content

Studio: register text-ui tokens with tailwind-merge so cn() keeps them - #7396

Merged
shimmyshimmer merged 2 commits into
mainfrom
studio-cn-text-ui-tokens
Jul 24, 2026
Merged

shimmyshimmer merged 2 commits into
mainfrom
studio-cn-text-ui-tokens

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Jul 24, 2026 •

Copy link
Copy Markdown
Member

Follow up to #7359. The token classes introduced there could be silently deleted by tailwind-merge, which made some text render oversized when the UI font size preference was lowered. Also renames the Models page to Model hub.

Symptom

With UI font size set to 12, most of the app scales down correctly but a few elements render at a large unscaled size, for example the Discover and On Device tabs on the Model hub page and the capability pills like Conversational in the model inspector.

Root cause

Stock tailwind-merge does not know the custom text-ui-* utilities, so it classifies them as text colors. Any cn() call that combines a text-ui-* size with a real color class, such as:

cn("... text-ui-12p5 ...", active ? "text-foreground" : "text-muted-foreground")

resolved the two as conflicting color classes and kept only the last one. The size class was stripped from the DOM, the element fell back to the inherited 16px root font, and it ignored the preference entirely. The same merge could also strip the color class when the order was reversed. Plain className strings that never pass through cn() were unaffected, which is why the breakage looked random.

Fix

Register the token families with tailwind-merge in the cn() helper, so text-ui-* resolves in the font-size group and leading-ui-* in the line-height group. One-line behavior change, no component edits needed.

Audit for other affected utilities

  • Static: every distinct class token in the frontend source was merged against same-prefix probes of each kind (color, size, weight, family, width) under the extended config. No other token family is misclassified; the custom font-heading resolves as a font family, custom color tokens resolve as colors, and tracking utilities behave.
  • Runtime: snapshotted every visible text element on the main, Model hub and Train pages at UI font sizes 16, 12 and 20 and asserted each element's font size and line height scale by exactly size/16. 1058 element checks, zero violations, with the half rate logo lockup as the only designed exception.

Rename

The Models page is now titled Model hub: page heading, sidebar navigation label in all 11 locales, and the two chat toasts that point at the tab. List headings that count model results keep the plain Models label.

Tests

  • Contract test asserting the cn() helper registers both token families.
  • Playwright regression step that sets UI font size 12, opens the Model hub page, and asserts the tab labels compute to 12.5px x 0.75 instead of the unscaled fallback.

Verification

  • Repro confirmed before the fix (tabs computed 16px at UI 12) and gone after (9.375px).
  • tests/studio contract suite, frontend typecheck and build all pass; cross-engine checks green on Chromium, WebKit and Firefox.

Stock tailwind-merge classifies text-ui-* as a text color, so cn() dropped
the size class whenever a color utility followed it in the same call. The
element then fell back to the unscaled 16px root font, which made hub tabs
and capability pills look oversized at small UI font sizes. Extend the
merge config so text-ui-* and leading-ui-* resolve as font-size and
line-height groups, and cover the failure in the contract and Playwright
regression tests.
Page heading, sidebar navigation label in all locales, and the chat
download toasts that point at the tab.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: b4dad1d198

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: b4dad1d198

ℹ️ 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".

@shimmyshimmer
shimmyshimmer merged commit 140b3fb into main Jul 24, 2026
39 of 40 checks passed
@shimmyshimmer
shimmyshimmer deleted the studio-cn-text-ui-tokens branch July 24, 2026 07:48
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.

1 participant