Skip to content

fix(css): make heading scale resilient — target markdown-block, not hook class#503

Merged
tmustier merged 1 commit intomainfrom
fix/heading-sizes
Mar 15, 2026
Merged

fix(css): make heading scale resilient — target markdown-block, not hook class#503
tmustier merged 1 commit intomainfrom
fix/heading-sizes

Conversation

@tmustier
Copy link
Copy Markdown
Owner

Problem

H1 headings in assistant messages render at browser-default size (~32px) instead of our sidebar scale (18px). This is a recurring regression — the same root cause has been behind multiple rendering issues.

Root cause

Tailwind v4's base reset (@layer base) sets h1 { font-size: inherit; font-weight: inherit }, stripping browser defaults. Our overrides used .pi-assistant-body h1 — which depends on applyMessageStyleHooks() successfully stamping the class. When the hook fails (streaming state, DOM structure changes from dep bumps, timing), headings get no sizing at all and inherit from the parent chain.

This is the same fragility pattern that caused:

All relied on hook-dependent class selectors matching specific DOM structures.

Fix

Target markdown-block h1 instead of .pi-assistant-body h1. markdown-block is a stable custom element tag in pi-web-ui's light DOM — it always exists in the render tree regardless of hook state, streaming, or upstream component changes.

Before After
.pi-assistant-body h1 (hook-dependent) markdown-block h1 (always matches)
Fails when hook doesn't run → browser defaults Always applies → 18px max

Testing

  • npm run build
  • npm run test:context ✅ (640/640)

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pi-for-excel Ready Ready Preview, Comment Mar 15, 2026 10:17pm

…ook class

The heading size overrides used .pi-assistant-body h1 which depends on
applyMessageStyleHooks() stamping the class on the right DOM node. When
the hook didn't run (streaming, DOM structure changes from dep bumps,
timing races), headings fell back to Tailwind v4's base reset
(font-size: inherit) or browser defaults (2em) — both much too large
for the sidebar.

Now target 'markdown-block h1' directly. markdown-block is a stable
custom element tag in pi-web-ui's light DOM that always exists in the
render tree, so headings are always capped regardless of hook state.

This is the root cause behind the recurring 'headings too large'
reports — the same fragility pattern (hook-dependent selectors failing
when upstream components change) also caused the KaTeX and thinking
block issues fixed earlier.
@tmustier tmustier force-pushed the fix/heading-sizes branch from e727016 to b68e249 Compare March 15, 2026 22:16
@tmustier tmustier merged commit d746da6 into main Mar 15, 2026
9 checks passed
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