From 13da540ce5d4606953004cd6cf9be6b869b6d771 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Wed, 2 Dec 2026 12:05:25 +0100 Subject: [PATCH] fix(android): stop asking a turn card for intrinsic height An agent reply carrying a markdown table killed the chat screen: the agent turn's Row was measured at IntrinsicSize.Min so its accent bar could span the card, and the table renderer's wide variant is a SubcomposeLayout, which throws when asked for intrinsics. Draw the 2 dp bar behind the row instead and let the card take its height from its content. The web session's transcript carries such a table, so opening it crashed before the first frame. --- .../main/java/rs/rhema/phone/ui/ChatScreen.kt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/android/app/src/main/java/rs/rhema/phone/ui/ChatScreen.kt b/android/app/src/main/java/rs/rhema/phone/ui/ChatScreen.kt index f476584..50ab185 100644 --- a/android/app/src/main/java/rs/rhema/phone/ui/ChatScreen.kt +++ b/android/app/src/main/java/rs/rhema/phone/ui/ChatScreen.kt @@ -65,6 +65,8 @@ import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.draw.drawBehind +import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.ImageBitmap import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.layout.ContentScale @@ -497,6 +499,7 @@ private fun TurnGroupRow( stringResource(R.string.chat_user_dispatch) } val avatar = if (you) userFace.image else null + val accent = TogetherAccent when (group) { is TurnGroup.User -> Row( @@ -557,7 +560,6 @@ private fun TurnGroupRow( is TurnGroup.Agent -> Row( modifier = Modifier .fillMaxWidth() - .height(IntrinsicSize.Min) .background( TogetherSurface, RoundedCornerShape( @@ -566,12 +568,19 @@ private fun TurnGroupRow( bottomEnd = 10.dp, bottomStart = 0.dp, ), - ), + ) + // The accent bar is drawn, not a child measured against + // the row's intrinsic height: a markdown table renders + // through a SubcomposeLayout (its wide variant scrolls), + // and asking that for intrinsics throws on the main + // thread. The bar spans whatever height the content takes. + .drawBehind { + drawRect(accent, size = Size(2.dp.toPx(), size.height)) + }, ) { - AccentBar(TogetherAccent, width = 2.dp) Column( modifier = Modifier - .padding(12.dp) + .padding(start = 14.dp, top = 12.dp, end = 12.dp, bottom = 12.dp) .weight(1f), verticalArrangement = Arrangement.spacedBy(8.dp), ) {