Draw a long user message in slices, through a shared card-piece surface
The occasional bump left in an otherwise smooth transcript was the last unbounded item: a pasted log in a user bubble is one Text whose layout runs in the frame the row scrolls into -- 93,808px on the fixture, reported from the phone as a 112ms worst measure. Per frame it was already cheap (one node); the cost was entirely the entry. A message past USER_SPLIT_CHARS is now cut at line starts into slices of roughly 2,500 characters, each its own list unit. Lines lay out independently, so slices that own whole lines stack back into exactly the lines the single Text drew; the threshold is also what guarantees the bubble was at full width, which the slices must share to read as one card. Measured on the emulator, same fixture and gestures: worst transcript measure 57.6ms -> 12.6ms. Fill continuity across slice seams and uniform 63px line pitch verified from full-resolution screenshots; a short message keeps the ordinary wrapping bubble. The corner-and-padding geometry that lets one visual card be several list items now lives once, in Modifier.cardPiece -- Bryan asked for exactly this generalization so future row types are cheap to add. An opened peer message and a long user message are its two users; a new sliced kind needs only a unit type, a flatten branch, and a body wrapped in cardPiece. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7a48f8ff1f
commit
333d2de92b
4 files changed
+163
-15
No files matched your search
@@ -289,8 +289,13 @@ class ParsedReplies {
|
||||
*/
|
||||
private val parts = ConcurrentHashMap<String, List<MessagePart>>()
|
||||
|
||||
private val chunks = ConcurrentHashMap<String, List<String>>()
|
||||
|
||||
fun blocksOf(text: String): List<String> = blocks.computeIfAbsent(text) { markdownBlocks(it) }
|
||||
|
||||
/** How a long user message divides into slices; cached for the same reason as [blocksOf]. */
|
||||
fun chunksOf(text: String): List<String> = chunks.computeIfAbsent(text) { userChunks(it) }
|
||||
|
||||
fun partsOf(text: String): List<MessagePart> = parts.computeIfAbsent(text) { messageParts(it) }
|
||||
|
||||
/** The parse of [text] -- the one made ahead, or one made now. */
|
||||
@@ -320,5 +325,6 @@ class ParsedReplies {
|
||||
parsed.clear()
|
||||
blocks.clear()
|
||||
parts.clear()
|
||||
chunks.clear()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user