Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.
Fix dead drawer taps: one detector per chat row
Rishabh Bajpaic6be6aca76d3
diff --git a/app/src/main/java/com/gotcha/ui/AppDrawer.kt b/app/src/main/java/com/gotcha/ui/AppDrawer.ktindex f66d98e..a8ed24f 100644--- a/app/src/main/java/com/gotcha/ui/AppDrawer.kt+++ b/app/src/main/java/com/gotcha/ui/AppDrawer.kt@@ -5,6 +5,7 @@ import androidx.compose.foundation.combinedClickableimport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.defaultMinSizeimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.height@@ -32,6 +33,7 @@ import androidx.compose.material3.NavigationDrawerItemimport androidx.compose.material3.NavigationDrawerItemDefaultsimport androidx.compose.material3.OutlinedTextFieldimport androidx.compose.material3.OutlinedTextFieldDefaults+import androidx.compose.material3.Surfaceimport androidx.compose.material3.Textimport androidx.compose.material3.TextButtonimport androidx.compose.runtime.Composable@@ -217,66 +219,18 @@ fun AppDrawerContent(items(rows, key = { it.first.id }) { (session, snippet) ->val tokens = liveTokenBySession[session.id]?: (if (session.id == activeSessionId) activeTokenCount else session.tokenCount)- val usage = formatContextUsage(tokens, maxContextTokens)- // No trailing delete button: the badge cost every row 48dp- // of name width. Deleting is a long-press, which asks the- // same confirmation as before.- NavigationDrawerItem(- label = {- Column {- Text(- ChatTitle.display(session.title, LocalContext.current.stringLookup()),- maxLines = 1,- overflow = TextOverflow.Ellipsis- )- // Why this chat matched, when the title didn't:- // the line of chat text holding the query.- if (snippet != null) {- Text(- snippet,- style = MaterialTheme.typography.labelSmall,- color = MaterialTheme.colorScheme.onSurfaceVariant,- maxLines = 2,- overflow = TextOverflow.Ellipsis,- modifier = Modifier.testTag("drawer_search_snippet")- )- }- // The one thing that distinguishes a seeded chat- // from one the user held: said on the row rather- // than only inside, so the list itself is honest.- if (session.isSample) {- Text(- stringResource(R.string.drawer_sample_chat),- style = MaterialTheme.typography.labelSmall,- color = MaterialTheme.colorScheme.primary,- maxLines = 1- )- }- if (usage != null) {- // Tabular figures: this counter ticks while a- // reply streams, and proportional digits make- // the whole line twitch as it does.- Text(- usage,- style = MaterialTheme.typography.labelSmall,- fontFamily = GotchaMono,- color = MaterialTheme.colorScheme.onSurfaceVariant,- maxLines = 1,- overflow = TextOverflow.Ellipsis- )- }- }- },+ ChatRow(+ session = session,+ snippet = snippet,+ tokens = tokens,+ maxContextTokens = maxContextTokens,selected = session.id == activeSessionId,- onClick = {},- colors = itemColors,- modifier = itemModifier.combinedClickable(- onClick = {- query = ""- onSessionClick(session.id)- },- onLongClick = { sessionToDelete = session.id }- )+ onOpen = {+ query = ""+ onSessionClick(session.id)+ },+ onDelete = { sessionToDelete = session.id },+ modifier = itemModifier)}}@@ -353,6 +307,88 @@ fun AppDrawerContent(/** How long typing must settle before the drawer searches, in milliseconds. */private const val SEARCH_DEBOUNCE_MS = 120L+/**+ * One chat row: the drawer's selected-pill look on a single combined tap and+ * long-press handler. A plain Surface rather than NavigationDrawerItem, which+ * already owns a click handler — nesting a second detector outside it+ * starves the outer one, which is how taps silently died. No trailing delete+ * button: the badge cost every row 48dp of name width, and a long-press asks+ * the same confirmation as before.+ */+@OptIn(ExperimentalFoundationApi::class)+@Composable+private fun ChatRow(+ session: ChatSession,+ snippet: String?,+ tokens: Int,+ maxContextTokens: Int,+ selected: Boolean,+ onOpen: () -> Unit,+ onDelete: () -> Unit,+ modifier: Modifier = Modifier+) {+ val rowColor = if (selected) {+ MaterialTheme.colorScheme.primary.copy(alpha = 0.18f)+ } else {+ Color.Transparent+ }+ Surface(+ color = rowColor,+ contentColor = MaterialTheme.colorScheme.onSurface,+ shape = RoundedCornerShape(28.dp),+ modifier = modifier+ .defaultMinSize(minHeight = 56.dp)+ .combinedClickable(onClick = onOpen, onLongClick = onDelete)+ ) {+ Column(+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)+ ) {+ Text(+ ChatTitle.display(session.title, LocalContext.current.stringLookup()),+ style = MaterialTheme.typography.labelLarge,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis+ )+ // Why this chat matched, when the title didn't:+ // the line of chat text holding the query.+ if (snippet != null) {+ Text(+ snippet,+ style = MaterialTheme.typography.labelSmall,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ maxLines = 2,+ overflow = TextOverflow.Ellipsis,+ modifier = Modifier.testTag("drawer_search_snippet")+ )+ }+ // The one thing that distinguishes a seeded chat+ // from one the user held: said on the row rather+ // than only inside, so the list itself is honest.+ if (session.isSample) {+ Text(+ stringResource(R.string.drawer_sample_chat),+ style = MaterialTheme.typography.labelSmall,+ color = MaterialTheme.colorScheme.primary,+ maxLines = 1+ )+ }+ formatContextUsage(tokens, maxContextTokens)?.let { usage ->+ // Tabular figures: this counter ticks while a+ // reply streams, and proportional digits make+ // the whole line twitch as it does.+ Text(+ usage,+ style = MaterialTheme.typography.labelSmall,+ fontFamily = GotchaMono,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis+ )+ }+ }+ }+}+/*** The drawer's chat search field: one line, always visible above the list, so* a chat can be found by its title or by anything said in it. A full pill with