Skip to content

perf(macOS): collapse oversized user messages via text heuristic#24626

Merged
siddseethepalli merged 1 commit into
mainfrom
sidd/heuristic-collapse-giant-user-messages
Apr 10, 2026
Merged

perf(macOS): collapse oversized user messages via text heuristic#24626
siddseethepalli merged 1 commit into
mainfrom
sidd/heuristic-collapse-giant-user-messages

Conversation

@siddseethepalli

Copy link
Copy Markdown
Contributor

Summary

  • Skip intrinsic-height measurement for very large user messages (>3000 chars or >40 lines) and collapse them via a truncated text preview instead.
  • Avoids forcing giant tool-result bubbles to fully lay out on first materialization during upward scroll, which defeated the collapse optimization in the case where it matters most.
  • Reuses the existing Show more/Show less toggle by extracting it into a shared view builder.

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.
@siddseethepalli siddseethepalli merged commit e49c4c6 into main Apr 10, 2026
@siddseethepalli siddseethepalli deleted the sidd/heuristic-collapse-giant-user-messages branch April 10, 2026 03:33

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +557 to +559
for character in text {
guard character.isNewline else { continue }
lineCount += 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

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