Skip to content

fix(macos): stop zero-width measurements from poisoning chat cell caches#26316

Merged
siddseethepalli merged 1 commit into
mainfrom
do/fix-chat-cell-zero-width-overlap
Apr 18, 2026
Merged

fix(macos): stop zero-width measurements from poisoning chat cell caches#26316
siddseethepalli merged 1 commit into
mainfrom
do/fix-chat-cell-zero-width-overlap

Conversation

@siddseethepalli
Copy link
Copy Markdown
Contributor

@siddseethepalli siddseethepalli commented Apr 18, 2026

Summary

Changes

  • VSelectableTextView.measureSize guards maxWidth > 0 && attributedString.length > 0 and returns .zero without writing the cache. Also only persists non-zero heights in measurementSizeCache.
  • MarkdownSegmentView.resolveSelectableRunMeasurementResult adds size.height > 0 && to the measuredTextCache insertion guard.
  • Adds testZeroWidthReturnsZeroSizeWithoutPoisoningCaches regression test.

Test plan

  • Build and run the macOS app (clients/macos/build.sh), open a long multi-message conversation, confirm each assistant body renders at a distinct y with no overlap.
  • Resize window narrow → wide → narrow; no transient zero-height flash.
  • Stream a fresh assistant reply; streaming-tail path still bypasses the cache as before.
  • Run xcodebuild test for MarkdownSegmentViewTests — new regression test passes, existing tests unaffected.

🤖 Generated with Claude Code


Open in Devin Review

During the first LazyVStack layout pass, MessageListLayoutMetrics deliberately
reports bubbleMaxWidth = 0 until GeometryReader resolves the chat column width.
That zero flowed unchecked into MarkdownSegmentView.effectiveMaxWidth and
VSelectableTextView.measureSize(maxWidth: 0), where ensureLayout returned a
usedRect with height 0. Before the recent sizeThatFits-caching commit
(#26170), the degenerate result self-healed on the next body pass; with the
new caches, (0,0) was persisted at the attributedString + 0 + 4 key and the
MarkdownSegmentView NSCache entry keyed on effectiveMaxWidth = 0, collapsing
the cell and stacking every visible assistant message body at the same y.

Two small, orthogonal guards:

- VSelectableTextView.measureSize refuses maxWidth <= 0 or empty strings with
  an early .zero return (no cache write), and only writes non-zero heights
  into measurementSizeCache.

- MarkdownSegmentView.resolveSelectableRunMeasurementResult skips the
  measuredTextCache insertion when size.height == 0.

Both keep the perf wins from #26170 and #26242 (no revert). Adds a regression
test that measures at maxContentWidth: 0 and asserts no cache poisoning.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@siddseethepalli
Copy link
Copy Markdown
Contributor Author

Review focus / risk notes

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@siddseethepalli siddseethepalli merged commit c7eefb4 into main Apr 18, 2026
7 checks passed
@siddseethepalli siddseethepalli deleted the do/fix-chat-cell-zero-width-overlap branch April 18, 2026 05:55
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