Skip to content

fix(studio): derive the chat tracking assertion from the measured font size - #7821

Closed
danielhanchen wants to merge 3 commits into
mainfrom
fix/chat-ui-letter-spacing-scale
Closed

danielhanchen wants to merge 3 commits into
mainfrom
fix/chat-ui-letter-spacing-scale

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Chat UI Tests is red on main:

AssertionError: [ui] FAIL: chat letter spacing theme-cycle-1/assistant:
                expected 0.3565px, got ['0.334219px']

Root cause

The authored tracking is in em, not px. thread.tsx sets tracking-[0.01em] and dark:tracking-[0.02em] on the message roots, and index.css sets letter-spacing: 0.023em for the dark Linux instance. The computed px therefore depends on the message font size.

#7359 moved the UI font size onto --ui-font-scale, so --text-ui-15p5 now resolves to 0.96875rem * 0.9375 = 14.53125px where it previously computed to 15.5px. That staled all three px literals at once, not only the one CI happens to report:

branch authored hardcoded (15.5px) actual (14.53125px)
light 0.01em 0.155px 0.145313px
dark 0.02em 0.31px 0.290625px
dark + render-linux 0.023em 0.3565px 0.334219px

The CSS is doing what it is meant to. The scale exists to bring 16px-base tokens to the 15px product default, exactly as index.css says where it declares the token:

/* The authored typography tokens use a 16px CSS base; the product default
   is 15px. An explicit user preference overrides this inline. */
--ui-font-scale: 0.9375;

The test is what went stale, so the fix belongs there.

The fix

The expectation is computed from the element's own font size times the authored em, compared with a small tolerance because the browser reports the computed value rounded (0.023em of 14.53125px comes back as "0.334219px").

A wrong tracking still fails. The assertion is only made immune to the size the em resolves against, which is the thing that legitimately changes.

Deriving from a measurement would otherwise hide a font-size regression completely, so the size itself is bounded to 12-18px: wide enough that a deliberate scale change does not trip it, tight enough to catch chat text rendering at a heading or caption size.

Verification

Exercised the new logic against the reported values, including that a genuinely wrong tracking still fails:

dark + render-linux (the CI failure)   expected 0.334219px, got 0.334219px  -> pass
dark, baseline typography              expected 0.290625px, got 0.290625px  -> pass
light                                  expected 0.145313px, got 0.145313px  -> pass
old 15.5px body still consistent       expected 0.3565px,   got 0.3565px    -> pass
wrong tracking must still fail         expected 0.334219px, got 0.290625px  -> fail
zero tracking spelled normal           expected 0px,        got normal      -> pass

CI on this PR is the real check, since the assertion only runs under Playwright.

danielhanchen and others added 3 commits August 4, 2026 06:39
…t size

Chat UI Tests has been failing on main:

  chat letter spacing theme-cycle-1/assistant: expected 0.3565px,
                                               got ['0.334219px']

The authored tracking is in em, not px: thread.tsx sets tracking-[0.01em] and
dark:tracking-[0.02em] on the message roots, and index.css sets 0.023em for the
dark Linux instance. The computed px therefore depends on the message font size,
and #7359 moved the UI size onto --ui-font-scale, so --text-ui-15p5 now resolves
to 0.96875rem * 0.9375 = 14.53125px where it used to be 15.5px.

That staled all three px literals at once, not just the one CI reports:

  light                0.01em    0.155px  -> 0.145313px
  dark                 0.02em    0.31px   -> 0.290625px
  dark + render-linux  0.023em   0.3565px -> 0.334219px

The CSS is doing what it is meant to: the scale exists to bring 16px-base tokens
to the 15px product default, as index.css says where it declares the token. The
test is what went stale.

So the expectation is now computed from the element's own font size times the
authored em, compared with a small tolerance because the browser reports the
computed value rounded. A wrong tracking still fails; the assertion is only
immune to the size the em resolves against.

Deriving from a measurement would otherwise hide a font-size regression
completely, so the size itself is bounded to 12-18px: wide enough that a
deliberate scale change does not trip it, tight enough to catch chat text
rendering at a heading or caption size.
Opening comment pass. A line wrap had left "dark:tracking-" and "-[0.02em]" on
consecutive lines, reading as a doubled hyphen; the citation is now the file
rather than a spelled-out class that wraps badly.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 77b4374ef5

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

@danielhanchen

Copy link
Copy Markdown
Member Author

Superseded by #7826, which landed the same fix: read the font size off the element and assert the authored em instead of a px literal, with the same diagnosis (aa4e6af set --ui-font-scale to 0.9375, so every computed value became 15/16 of the pinned one).

Closing rather than resolving the conflict, since resolving it would only re-land a duplicate.

Two small things in this branch are not in #7826, and I will put them up separately rather than lose them:

  • A font-size bound. Both versions now derive the expectation from the measured size, so a font-size regression is invisible to this check where the old px literal implicitly caught it. A coarse 12-18px bound restores that without pinning an exact value.
  • "normal" handling. float("normal".removesuffix("px")) raises ValueError, and "normal" is how a browser reports zero tracking, so that path would surface as a test error rather than a clean assertion failure.

For the record, this branch was verified green before being closed: staging CI on the exact head returned 6/6 including Chat UI Tests passing in 7m2s, against the same job failing on main.

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