perf(macOS): collapse oversized user messages via text heuristic#24626
Conversation
Giant user bubbles (typically large tool results) were forced to fully lay out on first materialization so the intrinsic-height measurement could decide whether to show the collapse toggle. That measurement defeats collapse during upward scroll exactly when it is needed most. Skip intrinsic measurement for messages that exceed a cheap text threshold (3000 chars or 40 lines) and collapse them via a truncated preview (1200 chars / 24 lines) instead, reusing the existing toggle button.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 360107996f
ℹ️ 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".
| for character in text { | ||
| guard character.isNewline else { continue } | ||
| lineCount += 1 |
There was a problem hiding this comment.
Normalize CRLF before applying line-based collapse heuristic
The new heuristic counts line breaks by iterating characters and checking character.isNewline, which treats Windows \r\n as two breaks. For user messages pasted from terminals/logs with CRLF endings, collapse now triggers at roughly half the intended threshold (about 20 logical lines instead of 40), and the preview path will also truncate more aggressively than expected. This is a user-visible regression introduced by the heuristic path and can be avoided by counting logical lines via normalized line endings or enumerateLines.
Useful? React with 👍 / 👎.
Summary