fix(flow-chat): resolve diff card text truncation on long lines#1185
Merged
Conversation
InlineDiffPreview used fixed-height virtualization rows (22px) while CSS allowed text wrapping (pre-wrap). Wrapped content beyond 22px was hidden by overflow:hidden, making long diff lines unreadable. Changes: - Switch virtualizer to dynamic measurement (measureElement) so wrapped rows report their real height instead of a fixed 22px estimate - Add ResizeObserver to invalidate cached measurements when the container width changes (wrapping depends on width) - Add content truncation for very large diffs (500 lines / 50k chars) with head+tail preview and a visible truncation notice - Remove overflow:hidden on diff-line__content; use overflow-wrap:anywhere - Apply measureElement ref to context-separator rows for measurement consistency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In the Chat interface, when a diff card renders a very long single-line change, the text beyond the first visual line is cut off and invisible.
Root Cause
InlineDiffPreviewuses@tanstack/react-virtualfor row virtualization with a fixed row height of 22px (estimateSize: () => ROW_HEIGHT). At the same time, CSS setswhite-space: pre-wrap+word-break: break-wordto allow text wrapping. These two are fundamentally incompatible:height: 22pxoverflow: hiddenclips everything beyond 22pxResult: wrapped content is invisible.
Solution
1. Dynamic row measurement (core fix)
measureElementso each row reports its actual rendered heightheight: virtualRow.sizefrom row containersref={virtualizer.measureElement}+data-indexto all row types (includingcontext-separator)2. Container resize handling
ResizeObserveron the scroll containervirtualizer.measure()to invalidate cached heights and re-measure (wrapping depends on width)3. Large diff truncation
truncateForDiff()with thresholds: 500 total lines or 50k total chars... truncated N lines ...markerdiffLines()andPrism.tokenize()for very large files4. CSS cleanup
overflow: hiddenwithoverflow-wrap: anywhereon.diff-line__contentword-break: break-word(subsumed byoverflow-wrap: anywhere).inline-diff-preview__truncation-noticestyleVerification
pnpm run type-check:web— passpnpm run lint:web— pass (0 errors)Files changed
src/web-ui/src/flow_chat/components/InlineDiffPreview.tsxsrc/web-ui/src/flow_chat/components/InlineDiffPreview.scss