Skip to content

Fix horizontal overflow of wide math content in citation modal - #142

Open
Dtem4ik wants to merge 1 commit into
agentset-ai:mainfrom
Dtem4ik:fix/citation-modal-overflow
Open

Dtem4ik wants to merge 1 commit into
agentset-ai:mainfrom
Dtem4ik:fix/citation-modal-overflow

Conversation

@Dtem4ik

@Dtem4ik Dtem4ik commented Jul 4, 2026 •

Copy link
Copy Markdown

Fixes #131

Wide KaTeX display math (and long unbroken strings) rendered inside the citation/source modal overflowed the dialog horizontally and broke its layout.

Root cause: Streamdown wraps tables and code blocks in overflow-x-auto containers, but KaTeX output has no overflow handling — .katex-display > .katex is a white-space: nowrap block. On top of that, DialogContent is a CSS grid, so the chunk wrapper (a grid item with default min-width: auto) stretched past the dialog's max-width.

Fix:

MessageResponse: add wrap-break-word and give .katex-display its own horizontal scroll (overflow-x-auto / overflow-y-hidden). This also fixes the same overflow in the chat and the document chunks drawer, which share the component.
Citation modal: add min-w-0 to the per-chunk wrapper so it can shrink inside the dialog grid.
Before/after screenshots attached (isolated reproduction using the exact component classes and real KaTeX rendering).

before after

Greptile Summary

This PR fixes horizontal overflow of wide KaTeX display-math (and long unbroken strings) in the citation modal, the chat view, and the document-chunks drawer that all share MessageResponse.

  • packages/ui/src/components/ai-elements/message.tsx: adds wrap-break-word (Tailwind v4's overflow-wrap: break-word) and a scoped [&_.katex-display]:overflow-x-auto selector so KaTeX display blocks scroll horizontally instead of bursting past the container.
  • apps/web/src/components/chat/citation-modal.tsx: adds min-w-0 to the per-chunk wrapper div so it can shrink inside the CSS grid created by DialogContent, preventing the grid item from pushing past the dialog's max-width.

Confidence Score: 4/5

The changes are narrowly scoped CSS-class additions; the core logic is unchanged and both fixes are well-understood patterns for grid and overflow layout.

The overflow-y-hidden companion to overflow-x-auto suppresses the implicit scrollbar but also clips vertical overflow. KaTeX typically sizes its container accurately, yet tall or annotated math expressions can produce ink that exceeds the computed height, and hidden would silently cut it off.

The overflow-y-hidden rule in packages/ui/src/components/ai-elements/message.tsx deserves a second look — overflow-y-clip would be a safer option.

Important Files Changed

Filename Overview
packages/ui/src/components/ai-elements/message.tsx Adds wrap-break-word (valid Tailwind v4 utility) and a [&_.katex-display]:overflow-x-auto/overflow-y-hidden selector to fix KaTeX display-math overflow in all contexts that use MessageResponse; the overflow-y-hidden carries a small risk of clipping unusually tall math elements.
apps/web/src/components/chat/citation-modal.tsx Adds min-w-0 to the per-chunk wrapper so it can shrink inside the CSS grid created by DialogContent — a standard and correct fix for the grid min-width: auto issue.

Reviews (1): Last reviewed commit: "Fix horizontal overflow of wide math con..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown

@Dtem4ik is attempting to deploy a commit to the Agentset Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread packages/ui/src/components/ai-elements/message.tsx

This branch has not been deployed

No deployments
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.

Widget overflow in citations

1 participant