From 8ad3efecf4854aa16f5f9bffeaf40fcf7c60c71f Mon Sep 17 00:00:00 2001 From: M57 <41645758+Hy4ri@users.noreply.github.com> Date: Tue, 23 Jun 2026 12:29:13 +0300 Subject: [PATCH] fix(#273): optimize gesture detector to prevent thrashing during streaming (#319) - Replaced `.combinedClickable` with `.pointerInput` keyed on the message `id`. - Removed `onClick = {}` interception, allowing tap events to naturally pass through to internal components like Markdown hyperlinks. - Removed unused `@OptIn(ExperimentalFoundationApi::class)`. --- .../m57/hermescontrol/ui/chat/ChatBubble.kt | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatBubble.kt b/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatBubble.kt index c138a7b2..01355b81 100644 --- a/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatBubble.kt +++ b/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatBubble.kt @@ -10,10 +10,9 @@ import androidx.compose.animation.fadeOut import androidx.compose.animation.scaleIn import androidx.compose.animation.scaleOut import androidx.compose.foundation.BorderStroke -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background import androidx.compose.foundation.clickable -import androidx.compose.foundation.combinedClickable +import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -53,6 +52,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.luminance +import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.platform.LocalClipboardManager import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalUriHandler @@ -129,7 +129,6 @@ fun ChatBubble( } } -@OptIn(ExperimentalFoundationApi::class) @Composable private fun UserBubble( message: ChatMessage, @@ -203,13 +202,13 @@ private fun UserBubble( ), ).background(brush = gradientBrush) .testTag("chat_bubble_user") - .combinedClickable( - role = Role.Button, - onClick = {}, - onLongClick = { - showCopyButton = true - }, - ), + .pointerInput(message.id) { + detectTapGestures( + onLongPress = { + showCopyButton = true + }, + ) + }, color = Color.Transparent, tonalElevation = 0.dp, ) { @@ -270,7 +269,6 @@ private fun UserBubble( } } -@OptIn(ExperimentalFoundationApi::class) @Composable private fun AssistantBubble( message: ChatMessage, @@ -327,13 +325,13 @@ private fun AssistantBubble( bottomEnd = 16.dp, ), ).testTag("chat_bubble_assistant") - .combinedClickable( - role = Role.Button, - onClick = {}, - onLongClick = { - showCopyButton = true - }, - ), + .pointerInput(message.id) { + detectTapGestures( + onLongPress = { + showCopyButton = true + }, + ) + }, color = bubbleColor, border = BorderStroke(