Repository navigation
#1043 Cut long user messages in the timeline and open them in full - #1049
Conversation
A user message is one timeline row with no height limit, and UIKit rejects a self-sized row taller than about 2.8 million points: a pasted log of ~150,000 lines crashed the app on every open of the session. Only the user's own messages are limited. MessageTextLimit (same name, constants and vectors on iOS and Android) counts a line break as one line and every 40 characters as one more, in one pass that stops as soon as the message is over: up to 30 lines shows in full, longer shows the first 25 (a long line is cut at a word and ends with "…"). The timeline shows only that prefix, never parses it as markdown, and ends the bubble with a new design-system OpenCodeTruncationRow, "Show full message", that opens the whole text in the Select text sheet titled "Full message". Copy message, Select text, revert and fork keep acting on the whole text. Very long text in the Select text sheet now opens at the half detent and lays out only what is in view: a UITextView that scrolls itself on iOS, a lazy list of line chunks on Android, sized from a new body-height value the bottom sheet exposes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Automated review: no finding that 2+ of 2 passes agreed on.
2 finding(s) from a single pass, not posted
android/app/src/main/java/dev/opencode/mobile/domain/message/pipeline/MessageTextLimit.kt:72medium: CRLF line endings make Android overcount line cost, truncating messages iOS shows in full (deepseek-v4.1-flash)android/app/src/main/java/dev/opencode/mobile/domain/message/pipeline/MessageContentPreparer.kt:213low: Cut decision uses message.text while the timeline cuts each block's text, so markdown can be dropped without any truncation (deepseek-v4.1-flash)
opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.149 · 1 pass(es) stopped early · 1 pass(es) failed
|
@cursor review |
…ash on Copy all Found while checking the pull request on a simulator and an emulator: - The Show full message row filled the bubble's full width on both platforms, so a cut bubble stretched to the maximum width and its text sat at the far edge with an empty area beside it. A cut bubble is now as wide as the wider of its text and the row, like an uncut bubble. - Android: the long Select text body is a list of 40-line pieces, and each piece trimmed its outer line spacing, so every 40th line sat closer to the next. Pieces now keep it. - Android: Copy all (and Copy message) on a text of a few MB crashed the app with TransactionTooLargeException from the clipboard. It now shows "Too long to copy. Select a part of it instead." (Android-only string). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Device verification (iPhone 18 Pro Max simulator, iOS 27.2 · Android emulator API 37, 192 MB heap)Real apps against a scenario-harness v2 server (opencode v2.2.5), generated filler sent over REST. v2 only: no v1 server binary is installed here, and the change is presentation only. Screenshots are after fix commit 29c132a. Tests
What was checked (both platforms unless noted)
Fixed in 29c132a
iOS
Android
Not checked / open
|
…cost A cut user message now goes through the same markdown decision and rendering as an uncut one, applied to its shown part only: the detector, parser and highlighter read `markdownSourceText` (the cut prefix of an over-limit user message, else the whole text) on every preparer and history-publish path. The document attaches to the cut text only when that text is the same shown part, so it never lands on a collapsed command or an uncut bubble. Copy, Select text, Full message, revert and fork keep the whole text. Whole-text passes on the load and frame path are removed or bounded for over-limit user messages: row revisions hash the shown part plus the whole length (both platforms), row equality and the iOS yield check use the O(1) UTF-8 length, iOS cut counts use UTF-16 as Android does, the prepared-history cache and snapshot score stop grapheme-counting, and iOS text-part and command trims no longer copy text with nothing to trim. Android's cut bubble sizes without intrinsic measurement, which rendered tables cannot answer. Android now counts CRLF as one line break, as iOS does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A long paste that opened with more blank lines than the tolerance kept only those blank lines, which the trailing-whitespace trim then emptied: the bubble was blank and read "0 of N characters shown". Leading blank lines still count toward the cut decision, but the shown part now starts at the first line with a non-blank character (keeping its indentation), and the skipped blank lines count as shown. Same rule and test vectors on both platforms. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
/review |
|
@cursor review |
There was a problem hiding this comment.
Automated review: 1 finding(s) that 2+ of 3 passes agreed on.
Outside the diff lines:
ios/OpenCode Mobile/OpenCode Mobile/UI/SessionChat/Timeline/SessionChatTimelineBlocks.swift:2493medium: Cut row counts UTF-16/UTF-8 over the whole multi-MB text per build
7 finding(s) from a single pass, not posted
android/app/src/main/java/dev/opencode/mobile/ui/sessionchat/view/SessionChatSelectTextSheet.kt:182medium: Scrolling sheet drops a newline at every chunk boundary (muse-spark-1.3-contributor)ios/OpenCode Mobile/OpenCode Mobile/Domain/Message/Pipeline/MessageTextLimit.swift:64medium: All-blank long text reads the whole string and grows to its size (muse-spark-1.3-contributor)android/app/src/main/java/dev/opencode/mobile/domain/message/pipeline/MessageTextLimit.kt:166medium: All-blank fallback scans the entire message (muse-spark-1.3-contributor)ios/OpenCode Mobile/OpenCode Mobile/UI/SessionChat/Region/SessionChatComposer.swift:1140medium: Optimistic send row may attach a document parsed from the full text to a cut block (deepseek-v4.1-flash)android/app/src/main/java/dev/opencode/mobile/ui/components/chat/OpenCodeOutgoingMessage.kt:597low: Limited-text layout measures text before choosing width and can measure the row twice at different widths (deepseek-v4.1-flash)android/app/src/main/java/dev/opencode/mobile/ui/sessionchat/view/SessionChatSelectTextSheet.kt:1345low: Chunk splitter drops the line break at every CRLF boundary (deepseek-v4.1-flash)android/app/src/main/java/dev/opencode/mobile/ui/components/chat/OpenCodeTruncationRow.kt:88low: Semantics onClick lambda shadows the component's onClick parameter (deepseek-v4.1-flash)
opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.163 · 1 pass(es) stopped early
…blank skip Android: Copy all in Select text dismissed the sheet even when the copy was too long and the toast asked the user to select a part instead; the sheet now stays open then. The scrolling sheet's chunks end before a CRLF, so no stray CR sits at every chunk boundary of a Windows log. Both platforms: the search for the first line with content stops after 64 KiB past the decision pass, so a multi-MB blank paste is not read in full. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
/review |
|
@cursor review |
Device check of 75b728b (iOS simulator, iOS 27.2 · Android emulator, API 37, 192 MB heap)Real apps against a scenario-harness v2 server (opencode v2.2.5); generated filler seeded over REST. v2 only: no v1 server binary is installed here, and the change is presentation only. No code changes pushed from this run. Commits pushed after 75b728b (92dd36d, the merge from Tests
Load time: tap the 190,000-line (2.85 MB) session on Home → timeline shown"Video" = measured from a screen recording, from the first frame that leaves Home to the first frame showing the bubble (the tap delay of the automation tool excluded). "Tool" = wall clock from dispatching the tap to the "Show full message" row being found, including the tool's own overhead (~0.5–1 s). Load = host 1-minute load average.
Visual checks
Open for a decision
Not checked
iOS
Android
|
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 8a03e09. Configure here.
There was a problem hiding this comment.
Automated review: no finding that 2+ of 2 passes agreed on.
4 finding(s) from a single pass, not posted
ios/OpenCode Mobile/OpenCode Mobile/UI/SessionChat/Timeline/SessionChatTimelineBlocks.swift:2493medium: Full-text scan on every timeline build defeats cut budget (muse-spark-1.3-contributor)ios/OpenCode Mobile/OpenCode Mobile/UI/SessionChat/Timeline/DisplayFrame.swift:28medium: ContentRevision hashes full text length with O(n) utf8.count (muse-spark-1.3-contributor)android/app/src/main/java/dev/opencode/mobile/ui/sessionchat/timeline/SessionChatTimelineBlocks.kt:1706low: Cut message's markdown is dropped when the first line starts with whitespace (glm-5.3-flash)ios/OpenCode Mobile/OpenCode Mobile/UI/SessionChat/Timeline/DisplayFrame.swift:201low: matchingMarkdown guard compares cut of raw text against trimmed block text (glm-5.3-flash)
opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.160 · 2 pass(es) stopped early · 1 pass(es) failed



























































Summary
The crash. iOS threw
NSInternalInconsistencyException: Content view returned an invalid size {408, 3617166}inMessageListTimelineHostCell.preferredLayoutAttributesFitting. One message is one timeline row with no height limit, and UIKit rejects a self-sized row taller than about 2,777,777 pt. A user message of roughly 74,000–147,000 lines (a pasted log) is enough, and the session then crashes every time it is opened. Android had the same uncapped rows.The rule (
MessageTextLimit, same name, constants and test vectors on both platforms, in the message pipeline where a message becomes its timeline presentation):max(1, ceil(length / 40)).limit = 25,tolerance = 30. A message costing at most 30 shows in full. A longer one shows the prefix costing at most 25.String.count, split, copy or markdown parse of the whole text to decide. iOS counts Characters; Android counts UTF-16 units and never splits a surrogate pair.Timeline. A cut user message shows only the prefix, rendered like any other user message: the markdown detector, parser and highlighter are given the prefix only (about 1,230 characters at most), so the timeline never lays out, measures or parses the hidden part. A cut inside a code fence renders as a code block running to the cut. Optimistic send rows are cut the same way. The row keeps the whole text, so Copy message, Select text, revert and fork still act on all of it. Tapping the bubble anywhere except the new row still opens the Message sheet.
New component:
OpenCodeTruncationRow(iOS + Android, variant-first:.fullMessage(shownCharacters:totalCharacters:)/OpenCodeTruncationRowVariant.FullMessage). It is a full-width row inside the bubble, 8 pt under the text, corner radius 8, filled with the strong text colour at 6% (the same subtle fill the composer chips use), 12/8 padding, at least 40 tall. It shows "Show full message" in the button font, the caption "1,000 of 588,638 characters shown" in weak caption text, and the existingexpandContenticon at 16 pt. It is added to both Component Galleries ("Truncation Row"). Accessibility: on iOS the bubble stays one element with a "Show full message" custom action; on Android the row is its own button node with a click label.Sheet. Tapping the row opens the existing Select text sheet with the whole text, titled "Full message" (the Message sheet entry stays "Select text"). The body and the pinned Copy all button are unchanged. Analytics:
chat_show_full_messageon the Session Chat screen; the Select text screen view and its existing actions apply as before.How the sheet handles very large text. Text above 32 KB (iOS: UTF-8 bytes, read without a scan; Android: UTF-16 length) opens the sheet at the half detent (it drags to full). The body then fills the sheet's body viewport exactly, through a new body-height value the bottom sheet exposes (
openCodeBottomSheetBodyHeight/LocalOpenCodeBottomSheetBodyHeight), and scrolls itself:UITextView(TextKit 2) with scrolling on, so it lays out only what is in view. Range selection with handles and the edit menu work as in the short body. Limits: TextKit 2 estimates the height of text it has not laid out, so the scroll indicator can jump on very long texts. A code-block focus is brought in withscrollRangeToVisible.LazyColumnof 40-line pieces (a line longer than 4,000 characters is split, never inside a surrogate pair) insideOpenCodeSelectionContainer. It lays out only the pieces in view. Limits: a drag selection reaches only the pieces on screen, and copying a selection that spans two pieces drops the line break between them. Copy all always copies the exact whole text.Text), so short messages look exactly as before.No protocol work: this is presentation only, and behaves the same on v1 and v2 servers.
Checks
xcodebuild buildandxcodebuild build-for-testing(scheme OpenCode Mobile,generic/platform=iOS Simulator): both succeed../gradlew :app:assembleDebugand:app:assembleDebugAndroidTestsucceed.:app:testDebugUnitTestfordev.opencode.mobile.ui.sessionchat.*,dev.opencode.mobile.domain.message.*,dev.opencode.mobile.ui.components.*,dev.opencode.mobile.ui.componentgallery.*: 1,558 tests, 0 failures (includes the newMessageTextLimitTest,SessionChatMessageLimitPresentationTest, and new cases inSessionChatSelectTextSheetTestandMessageContentPreparerTest).OpenCodeSelectionContainerTestpasses.OpenCodeBottomSheetTestfailed 1 of 15 on the first of four runs and passed the other three; it looks flaky.29c132a4e: the row stretched every cut bubble to full width (both platforms); every 40th line in the long Android sheet body sat too close to the next; and on Android, copying a text of a few MB crashed withTransactionTooLargeException(it now shows a "Too long to copy" toast).ktlintCheck: no violations on any changed line (the files keep their earlier violations).node scripts/check-string-keys.mjs: keys match (4 new keys on both platforms).gitleaks git --pre-commit --staged: no leaks.New tests:
SessionChatLongUserMessageRowHeightTests): a user message of 190,000 short lines, hosted in the realSessionChatTimelineViewandMessageListTimelineHostCell, must size its row between 100 and 1,000 pt.Evidence
Screenshots for both platforms, light and dark: #1049 (comment)
Issue
Fixes #1043
Risks / Follow-ups
75b728bc6moves the detector after the cut; the new load time is not measured yet.75b728bc6has not been run on a device yet. It renders markdown in the visible part of a cut message, keeps whole-text passes off the load path for over-limit user messages (hashing and equality use the prefix and byte length), and makes Android count\r\nas one line break. Still to check on devices: the iOS tests, a cut markdown bubble (heading, list, code fence, table) on both platforms, and the load time below.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Broad changes across timeline layout, message markdown pipeline, and sheet scrolling for multi-MB texts; regression risk mainly in row sizing, markdown on cut bubbles, and copy/select behavior.
Overview
Fixes timeline crashes from uncapped user message row height by introducing shared
MessageTextLimitrules (line-cost budget) that show only a prefix of long user prompts, while keeping the full text for copy, revert, and fork.Timeline & pipeline: User text blocks gain a
SessionChatTextLimit/OpenCodeOutgoingMessageLimitand anOpenCodeTruncationRow(“Show full message”) that opens Select text titled Full message (chat_show_full_messageanalytics). Markdown detection, parsing, enrichment, and viewport budgets now usemarkdownSourceText/MarkdownInputProbeso the hidden tail is never laid out or parsed; optimistic sends are cut the same way.Very long text sheet: Select text switches to a half-height, self-scrolling body (chunked
LazyColumnon Android; sheetLocalOpenCodeBottomSheetBodyHeight) above a 32 KB threshold; Copy all on Android catches oversized clipboard failures with a toast.Parity: Matching iOS changes (limited text block type, truncation row, gallery entries, perf tweaks using UTF-8 counts / cheaper trim). Unit tests cover cut vectors, presentation, pipeline probes, and select-text chunking.
Reviewed by Cursor Bugbot for commit 8a03e09. Bugbot is set up for automated code reviews on this repo. Configure here.