Repository navigation
#1043 Cut emoji text alike on both platforms, close markers a cut leaves open - #1072
Merged
Merged
Conversation
…ves open Count a cut user message in UTF-16 units on iOS as on Android, so the same text is cut at the same place and shows the same counts. The cut never ends inside a grapheme cluster: the cut line up to the cut is segmented with each platform's own rules (Swift Character, regex \X). Before the shown part of a line cut part way reaches the markdown parser, the shared parser closes the bold, italic and inline code the cut left open and drops the opener of a cut link, so the bubble renders as the whole message does up to the cut. The plain shown text and the full text are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ivanfenenko
marked this pull request as ready for review
November 16, 2026 08:34
There was a problem hiding this comment.
Automated review: no finding that 2+ of 3 passes agreed on.
4 finding(s) from a single pass, not posted
shared/markdown-core/src/commonMain/kotlin/dev/opencode/mobile/markdown/OpenCodeMarkdown.kt:398high: Opener on earlier paragraph line never closed (muse-spark-1.3-contributor)shared/markdown-core/src/commonMain/kotlin/dev/opencode/mobile/markdown/OpenCodeMarkdown.kt:504medium: Cut bare URL keeps ellipsis inside link destination (muse-spark-1.3-contributor)shared/markdown-core/src/commonMain/kotlin/dev/opencode/mobile/markdown/OpenCodeMarkdown.kt:547medium: Intra-word opener treated literal while parser pairs it (muse-spark-1.3-contributor)shared/markdown-core/src/commonMain/kotlin/dev/opencode/mobile/markdown/OpenCodeMarkdown.kt:499low: A literal '[' cut mid-line is dropped from the rendered bubble (deepseek-v4.1-flash)
opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.091 · 2 pass(es) stopped early
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.
Summary
Follow-up to #1049 for #1043. It fixes two defects a device check of the cut user messages found.
1. The same emoji-heavy message was cut in different places. iOS counted line cost in grapheme clusters and Android in UTF-16 units, so the same message showed 25 lines and "1,031 of 1,493 characters shown" on iOS but 17 lines and "695 of 1,493" on Android.
Stringand Swift'sString.utf16both read UTF-16 one unit at a time without decoding, so the pass stays cheap and still stops early. Counting grapheme clusters would mean segmenting every character read. The choice is recorded in the doc comment next to the constants.MessageTextLimitnow mirrors the Android algorithm. It works on the UTF-16 units read so far and reads more only when it needs them, so a multi-megabyte message still reads about 1,230 units.Characteron iOS and regex\Xon Android. This replaces Android's surrogate-pair check.text.prefix(n).utf16.count.2. A marker left open by a cut mid-line showed literally, for example a
**before bold words. The cut now records whether it ended mid-line (endsMidLine). If it did,MessageTextCut.markdownSourcepasses the shown part throughOpenCodeMarkdownParser.closeMarkersLeftOpen, a new function in the shared markdown-core parser, before adding the "…". Both apps call this one implementation.\*), after a letter or digit (snake_case), or followed by a space;~~, because the parser has no strikethrough, so the whole message shows the tildes too.Checks
./gradlew :app:assembleDebugsucceeds.:app:testDebugUnitTestfordev.opencode.mobile.domain.message.*anddev.opencode.mobile.ui.sessionchat.*: 0 failures.:markdown-core:testDebugUnitTest: passes.xcodebuild buildandbuild-for-testingforgeneric/platform=iOS Simulator: both succeed. The iOS tests were not run locally (no simulator was available); CI runs them.MessageTextLimitTest(s),MessageTextCutMarkdownTest(s), and one row-count case in the presentation tests). Each asserts the shown text and both counts:Risks / Follow-ups
🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.