Skip to content

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.

feat: skins own shape, tool failures join the ledger

Durganshu Mishra65c3e027360b
diff --git a/app/src/main/java/com/gotcha/ui/ChatScreen.kt b/app/src/main/java/com/gotcha/ui/ChatScreen.kt
index 6044f73..56de5e4 100644
--- a/app/src/main/java/com/gotcha/ui/ChatScreen.kt
+++ b/app/src/main/java/com/gotcha/ui/ChatScreen.kt
@@ -74,6 +74,7 @@ import com.gotcha.R
import com.gotcha.agent.ChatUiState
import com.gotcha.tools.AgentMode
import com.gotcha.ui.theme.GotchaMono
+import com.gotcha.ui.theme.LocalSkin
import kotlinx.coroutines.delay
import androidx.compose.foundation.Image as ComposeImage
@@ -100,6 +101,7 @@ fun ChatScreen(
onExportChat: () -> Unit = {},
onReturnToRunning: () -> Unit = {}
) {
+ val skin = LocalSkin.current
val isHome = state.messages.isEmpty()
// A run is active in a DIFFERENT chat than the one being viewed: sending here
// is blocked (one agent at a time), and a banner offers a jump back.
@@ -249,7 +251,10 @@ fun ChatScreen(
greeting,
style = MaterialTheme.typography.headlineMedium,
textAlign = TextAlign.Center,
- color = MaterialTheme.colorScheme.onSurfaceVariant
+ // The largest text on the home screen, so it takes the
+ // primary ink. Secondary ink over a wallpaper was the
+ // weakest thing on the screen.
+ color = MaterialTheme.colorScheme.onSurface
)
Spacer(modifier = Modifier.height(24.dp))
AgentModeSelector(
@@ -295,19 +300,22 @@ fun ChatScreen(
Column(
modifier = Modifier
.fillMaxWidth()
- .background(Color(0xFF1A1A2E), RoundedCornerShape(8.dp))
+ .background(
+ MaterialTheme.colorScheme.secondaryContainer,
+ RoundedCornerShape(skin.cornerSmall)
+ )
.padding(horizontal = 16.dp, vertical = 8.dp)
) {
Row(verticalAlignment = Alignment.CenterVertically) {
CircularProgressIndicator(
modifier = Modifier.width(16.dp),
- color = Color(0xFFE0D4FF)
+ color = MaterialTheme.colorScheme.onSecondaryContainer
)
Spacer(modifier = Modifier.width(8.dp))
Text(
"⚡ ${state.subAgentRunning}",
style = MaterialTheme.typography.bodySmall,
- color = Color(0xFFE0D4FF)
+ color = MaterialTheme.colorScheme.onSecondaryContainer
)
}
state.subAgentCurrentAction?.let { action ->
@@ -315,7 +323,7 @@ fun ChatScreen(
Text(
action,
style = MaterialTheme.typography.bodySmall,
- color = Color(0xFFE0D4FF).copy(alpha = 0.7f),
+ color = MaterialTheme.colorScheme.onSecondaryContainer.copy(alpha = 0.7f),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
@@ -338,7 +346,7 @@ fun ChatScreen(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 12.dp, vertical = 4.dp)
- .clip(RoundedCornerShape(8.dp))
+ .clip(RoundedCornerShape(skin.cornerSmall))
.background(MaterialTheme.colorScheme.secondaryContainer)
.clickable { onReturnToRunning() }
.padding(horizontal = 12.dp, vertical = 8.dp),
@@ -377,7 +385,7 @@ fun ChatScreen(
contentDescription = "Attached image",
modifier = Modifier
.height(120.dp)
- .clip(RoundedCornerShape(8.dp)),
+ .clip(RoundedCornerShape(skin.cornerSmall)),
contentScale = ContentScale.Fit
)
}
diff --git a/app/src/main/java/com/gotcha/ui/MessageBubble.kt b/app/src/main/java/com/gotcha/ui/MessageBubble.kt
index 99d6a6e..6a98888 100644
--- a/app/src/main/java/com/gotcha/ui/MessageBubble.kt
+++ b/app/src/main/java/com/gotcha/ui/MessageBubble.kt
@@ -55,6 +55,7 @@ import androidx.compose.ui.unit.dp
import com.gotcha.agent.MessageKind
import com.gotcha.agent.UiMessage
import com.gotcha.ui.theme.GotchaMono
+import com.gotcha.ui.theme.LocalSkin
import com.halilibo.richtext.markdown.Markdown
import com.halilibo.richtext.ui.material3.Material3RichText
@@ -70,6 +71,11 @@ fun MessageBubble(
val isUser = message.kind == MessageKind.USER
val isAssistant = message.kind == MessageKind.ASSISTANT
val isTool = message.kind == MessageKind.TOOL
+ // A failed tool call arrives as ERROR (see AgentEngine), which used to make
+ // it a fat red bubble in the middle of a column of ledger lines — the one
+ // row you most want to find, rendered as the one row that breaks the scan.
+ // App-level errors are prose and keep their bubble; tool failures do not.
+ val isToolFailure = message.kind == MessageKind.ERROR && looksLikeToolOutput(message.text)
val isSubAgent = message.kind == MessageKind.SUBAGENT
val colors = MaterialTheme.colorScheme
// Only the user gets a bubble. An assistant reply can run to several
@@ -80,14 +86,18 @@ fun MessageBubble(
MessageKind.USER -> colors.primaryContainer to colors.onPrimaryContainer
MessageKind.ASSISTANT -> Color.Transparent to colors.onSurface
MessageKind.TOOL -> Color.Transparent to colors.onSurfaceVariant
- MessageKind.ERROR -> colors.errorContainer to colors.onErrorContainer
- MessageKind.SUBAGENT -> {
- val bg = Color(0xFF1A1A2E)
- val fg = Color(0xFFE0D4FF)
- bg to fg
- }
+ MessageKind.ERROR ->
+ if (isToolFailure) {
+ Color.Transparent to colors.error
+ } else {
+ colors.errorContainer to colors.onErrorContainer
+ }
+ // Was a hardcoded navy/lilac pair, which looked deliberate only while
+ // every theme happened to be navy.
+ MessageKind.SUBAGENT -> colors.secondaryContainer to colors.onSecondaryContainer
}
- val unbubbled = isAssistant || isTool
+ val unbubbled = isAssistant || isTool || isToolFailure
+ val skin = LocalSkin.current
val expanded = remember { mutableStateOf(!isTool && !isSubAgent) }
var showMenu by remember { mutableStateOf(false) }
@@ -101,11 +111,13 @@ fun MessageBubble(
color = container,
contentColor = contentColor,
shadowElevation = if (unbubbled) 0.dp else 2.dp,
+ // The skin owns the shape as well as the colour: Orchid is generous,
+ // Nocturne is tight, Deep Space is exactly what it always was.
shape = RoundedCornerShape(
- topStart = 20.dp,
- topEnd = 20.dp,
- bottomStart = if (isUser) 20.dp else 4.dp,
- bottomEnd = if (isUser) 4.dp else 20.dp
+ topStart = skin.corner,
+ topEnd = skin.corner,
+ bottomStart = if (isUser) skin.corner else 4.dp,
+ bottomEnd = if (isUser) 4.dp else skin.corner
)
) {
Column(
@@ -155,7 +167,7 @@ fun MessageBubble(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 8.dp)
- .clip(RoundedCornerShape(8.dp))
+ .clip(RoundedCornerShape(skin.cornerSmall))
.background(contentColor.copy(alpha = 0.05f))
) {
Row(
@@ -196,11 +208,11 @@ fun MessageBubble(
val firstLine = displayText.substringBefore("\n").trimEnd()
val hasMore = displayText.contains("\n")
- if (isTool) {
+ if (isTool || isToolFailure) {
ToolLedger(
text = if (expanded.value) displayText else firstLine,
hint = if (!expanded.value && hasMore) "tap to expand" else null,
- railColor = colors.primary,
+ railColor = if (isToolFailure) colors.error else colors.primary,
contentColor = contentColor,
collapsed = !expanded.value
)
@@ -280,6 +292,17 @@ fun MessageBubble(
* these, and twenty bubbles bury the two sentences of prose that answered the
* question.
*/
+/**
+ * Tool output is formatted `name: message` by the engine, so an ERROR that opens
+ * with a bare identifier and a colon came from a tool. App errors are sentences
+ * — "No API key configured.", "Transcription failed: …" — and never match, since
+ * they start with a capital or contain a space before the colon.
+ */
+private val ToolOutputPrefix = Regex("^[a-z][a-z0-9_.]{1,40}:")
+
+private fun looksLikeToolOutput(text: String): Boolean =
+ ToolOutputPrefix.containsMatchIn(text)
+
@Composable
private fun ToolLedger(
text: String,
diff --git a/app/src/main/java/com/gotcha/ui/theme/Skin.kt b/app/src/main/java/com/gotcha/ui/theme/Skin.kt
index e9ff137..2f9bf0b 100644
--- a/app/src/main/java/com/gotcha/ui/theme/Skin.kt
+++ b/app/src/main/java/com/gotcha/ui/theme/Skin.kt
@@ -62,6 +62,14 @@ data class Skin(
val scrim: Float = 0f,
val corner: Dp = 20.dp
) {
+ /**
+ * Radius for the small stuff — inline images, the reasoning block, status
+ * panels. Derived rather than declared so a skin cannot describe a shape
+ * language that contradicts itself.
+ */
+ val cornerSmall: Dp
+ get() = corner / 2
+
/** True when the chrome is meant to be see-through. */
val isGlass: Boolean
get() = backdrop != Backdrop.NONE
@@ -304,7 +312,9 @@ object Skins {
// it. Same cell size everywhere — amplitude is what reads as coarseness,
// and the vignette carries the depth that the grain used to carry alone.
grain = 0.12f,
- corner = 22.dp
+ // The Arc read is a generous radius; it is half of why that look reads
+ // as soft even though the colour is shouting.
+ corner = 26.dp
)
/** The launcher icon's low-poly geometry, blown up to wallpaper scale. */
@@ -321,7 +331,9 @@ object Skins {
grain = 0.06f,
// Enough veil to keep every shard behind the text rather than beside it.
scrim = 0.18f,
- corner = 20.dp
+ // Tighter than the rest: the wallpaper is hard edges, and round chrome
+ // over it reads as two unrelated designs.
+ corner = 16.dp
)
/**