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: Add frost effect customization and enhance UI components for better user experience

Durganshu Mishra58b7510a14d8
diff --git a/app/src/main/java/com/gotcha/MainActivity.kt b/app/src/main/java/com/gotcha/MainActivity.kt
index 30ddd2b..97a0684 100644
--- a/app/src/main/java/com/gotcha/MainActivity.kt
+++ b/app/src/main/java/com/gotcha/MainActivity.kt
@@ -83,7 +83,8 @@ class MainActivity : ComponentActivity() {
val themeMode: ThemeMode = ThemeMode.SYSTEM,
val skinId: String = Skins.DEFAULT_ID,
val matchSystemBrightness: Boolean = true,
- val reduceTransparency: Boolean = false
+ val reduceTransparency: Boolean = false,
+ val frostPercent: Int = 100
)
/**
@@ -113,7 +114,8 @@ class MainActivity : ComponentActivity() {
themeMode = themeMode,
skinId = skinId,
matchSystemBrightness = matchSystemBrightness,
- reduceTransparency = reduceTransparency
+ reduceTransparency = reduceTransparency,
+ frostPercent = frostPercent
)
/** MediaProjection consent result — stores intent for screenshot capture. */
@@ -218,7 +220,8 @@ class MainActivity : ComponentActivity() {
darkTheme = darkTheme,
skinId = appearance.skinId,
matchSystemBrightness = appearance.matchSystemBrightness,
- reduceTransparency = appearance.reduceTransparency
+ reduceTransparency = appearance.reduceTransparency,
+ frostPercent = appearance.frostPercent
) {
Surface(
modifier = Modifier.fillMaxSize(),
diff --git a/app/src/main/java/com/gotcha/data/SettingsRepository.kt b/app/src/main/java/com/gotcha/data/SettingsRepository.kt
index 6fa4763..4206874 100644
--- a/app/src/main/java/com/gotcha/data/SettingsRepository.kt
+++ b/app/src/main/java/com/gotcha/data/SettingsRepository.kt
@@ -78,6 +78,12 @@ data class Settings(
* transparency", so this is the only way for someone to ask for one.
*/
val reduceTransparency: Boolean = false,
+ /**
+ * How much of the skin's own frost to apply, as a percentage. 100 is what
+ * the skin was designed with; 0 leaves the wallpaper sharp behind the glass.
+ * Only bites where the device can blur live — see GlassTier.
+ */
+ val frostPercent: Int = 100,
val disabledSkills: Set<String> = emptySet(),
/**
* Ids of connectors the user switched off. Credentials survive (re-enabling
@@ -275,6 +281,7 @@ class SettingsRepository(context: Context) {
skinId = string(KEY_SKIN_ID, "deepspace"),
matchSystemBrightness = prefs.getBoolean(KEY_MATCH_SYSTEM_BRIGHTNESS, true),
reduceTransparency = prefs.getBoolean(KEY_REDUCE_TRANSPARENCY, false),
+ frostPercent = prefs.getInt(KEY_FROST_PERCENT, 100),
disabledSkills = stringSet(KEY_DISABLED_SKILLS),
disabledConnectors = stringSet(KEY_DISABLED_CONNECTORS),
proactiveEnabled = prefs.getBoolean(KEY_PROACTIVE_ENABLED, true),
@@ -328,6 +335,7 @@ class SettingsRepository(context: Context) {
.putString(KEY_SKIN_ID, settings.skinId)
.putBoolean(KEY_MATCH_SYSTEM_BRIGHTNESS, settings.matchSystemBrightness)
.putBoolean(KEY_REDUCE_TRANSPARENCY, settings.reduceTransparency)
+ .putInt(KEY_FROST_PERCENT, settings.frostPercent)
.putStringSet(KEY_DISABLED_SKILLS, settings.disabledSkills)
.putStringSet(KEY_DISABLED_CONNECTORS, settings.disabledConnectors)
.putBoolean(KEY_PROACTIVE_ENABLED, settings.proactiveEnabled)
@@ -397,6 +405,7 @@ class SettingsRepository(context: Context) {
const val KEY_SKIN_ID = "skin_id"
const val KEY_MATCH_SYSTEM_BRIGHTNESS = "match_system_brightness"
const val KEY_REDUCE_TRANSPARENCY = "reduce_transparency"
+ const val KEY_FROST_PERCENT = "frost_percent"
const val KEY_DISABLED_SKILLS = "disabled_skills"
const val KEY_DISABLED_CONNECTORS = "disabled_connectors"
const val KEY_PROACTIVE_ENABLED = "proactive_enabled"
diff --git a/app/src/main/java/com/gotcha/ui/AppDrawer.kt b/app/src/main/java/com/gotcha/ui/AppDrawer.kt
index 25562f0..7261883 100644
--- a/app/src/main/java/com/gotcha/ui/AppDrawer.kt
+++ b/app/src/main/java/com/gotcha/ui/AppDrawer.kt
@@ -35,6 +35,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.gotcha.data.ChatSession
+import com.gotcha.ui.theme.GotchaMono
import com.gotcha.ui.theme.LocalSkin
@Composable
@@ -95,9 +96,13 @@ fun AppDrawerContent(
overflow = TextOverflow.Ellipsis
)
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
)
}
diff --git a/app/src/main/java/com/gotcha/ui/AppearanceScreen.kt b/app/src/main/java/com/gotcha/ui/AppearanceScreen.kt
index 4abba47..83c4bfa 100644
--- a/app/src/main/java/com/gotcha/ui/AppearanceScreen.kt
+++ b/app/src/main/java/com/gotcha/ui/AppearanceScreen.kt
@@ -20,9 +20,11 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SegmentedButton
import androidx.compose.material3.SegmentedButtonDefaults
import androidx.compose.material3.SingleChoiceSegmentedButtonRow
+import androidx.compose.material3.Slider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
@@ -37,10 +39,12 @@ import com.gotcha.data.Settings
import com.gotcha.data.ThemeMode
import com.gotcha.ui.theme.Brightness
import com.gotcha.ui.theme.GlassTier
+import com.gotcha.ui.theme.GotchaMono
import com.gotcha.ui.theme.LocalGlassTier
import com.gotcha.ui.theme.Skin
import com.gotcha.ui.theme.SkinMiniature
import com.gotcha.ui.theme.Skins
+import kotlin.math.roundToInt
/**
* The Appearance page: light or dark, which skin, and how much glass.
@@ -65,6 +69,7 @@ fun AppearanceScreen(
var skinId by remember { mutableStateOf(initial.skinId) }
var matchSystem by remember { mutableStateOf(initial.matchSystemBrightness) }
var reduceTransparency by remember { mutableStateOf(initial.reduceTransparency) }
+ var frostPercent by remember { mutableIntStateOf(initial.frostPercent) }
val overlay = rememberSettingsOverlayState()
val tier = LocalGlassTier.current
@@ -140,6 +145,28 @@ fun AppearanceScreen(
)
}
+ if (selected.isGlass && !reduceTransparency) {
+ Text(
+ "Frost",
+ style = MaterialTheme.typography.bodyLarge
+ )
+ Slider(
+ value = frostPercent.toFloat(),
+ onValueChange = { frostPercent = it.roundToInt() },
+ // Persist on release rather than per pixel: the preview follows the
+ // thumb, but a hundred writes per drag is a hundred writes.
+ onValueChangeFinished = { apply { s -> s.copy(frostPercent = frostPercent) } },
+ valueRange = 0f..100f,
+ modifier = Modifier.testTag("appearance_frost")
+ )
+ Text(
+ "$frostPercent% of ${selected.label}'s frost",
+ style = MaterialTheme.typography.bodySmall,
+ fontFamily = GotchaMono,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ }
+
SettingsToggleRow(
label = "Reduce transparency",
checked = reduceTransparency,
diff --git a/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt b/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt
index 7cf6d73..8a3fc76 100644
--- a/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt
+++ b/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt
@@ -21,6 +21,7 @@ import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.ScrollView
import android.widget.TextView
+import androidx.compose.ui.graphics.toArgb
import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.ColorUtils
import com.gotcha.R
@@ -29,6 +30,7 @@ import com.gotcha.data.ThemeMode
import com.gotcha.service.EntityType
import com.gotcha.service.ProactiveSessionItem
import com.gotcha.service.SmartActionDetector
+import com.gotcha.ui.theme.Skins
import kotlin.math.abs
import kotlin.math.hypot
@@ -98,24 +100,42 @@ class AssistiveBallOverlay(context: Context) {
}
}
- private fun palette(): OverlayPalette = if (isDarkTheme()) {
- OverlayPalette(
- surface = 0xFF1E293B.toInt(),
- onSurface = 0xFFE2E8F0.toInt(),
- outline = 0xFF334155.toInt(),
- buttonBg = 0xFF334155.toInt(),
- buttonText = 0xFFE2E8F0.toInt()
- )
- } else {
- OverlayPalette(
- surface = 0xFFFBFDF9.toInt(),
- onSurface = 0xFF191C1A.toInt(),
- outline = 0xFFDBE5E0.toInt(),
- buttonBg = 0xFFE8F6F2.toInt(),
- buttonText = 0xFF002117.toInt()
+ /**
+ * The ball is a window over other apps, so it takes its colours from the
+ * chosen skin rather than from a pair of hardcoded Deep Space palettes.
+ *
+ * Always the [Skin.opaque] variant: there is no wallpaper of ours behind
+ * this window, only whatever app the user is looking at, and translucent
+ * chrome over someone else's screen is unreadable.
+ */
+ private fun palette(): OverlayPalette {
+ val dark = isDarkTheme()
+ val settings = runCatching { settingsRepository.load() }.getOrNull()
+ val scheme = Skins.resolve(
+ settings?.skinId ?: Skins.DEFAULT_ID,
+ settings?.matchSystemBrightness ?: true,
+ dark
+ ).opaque().scheme(dark)
+ return OverlayPalette(
+ surface = scheme.surface.toArgb(),
+ onSurface = scheme.onSurface.toArgb(),
+ outline = scheme.outline.toArgb(),
+ buttonBg = scheme.secondaryContainer.toArgb(),
+ buttonText = scheme.onSecondaryContainer.toArgb()
)
}
+ /** The skin's own accent, for the ring and any other tinted overlay part. */
+ private fun accentColor(): Int {
+ val dark = isDarkTheme()
+ val settings = runCatching { settingsRepository.load() }.getOrNull()
+ return Skins.resolve(
+ settings?.skinId ?: Skins.DEFAULT_ID,
+ settings?.matchSystemBrightness ?: true,
+ dark
+ ).opaque().scheme(dark).primary.toArgb()
+ }
+
fun canShow(): Boolean = Settings.canDrawOverlays(appContext)
/**
@@ -501,7 +521,7 @@ class AssistiveBallOverlay(context: Context) {
val ballPx = dp(BALL_SIZE_DP)
val drawable = RingDrawable().apply {
fillColor = Color.TRANSPARENT
- strokeColor = Color.WHITE
+ strokeColor = accentColor()
strokeWidth = 2.5f * density
}
val view = View(appContext).apply { background = drawable }
diff --git a/app/src/main/java/com/gotcha/ui/ChatComponents.kt b/app/src/main/java/com/gotcha/ui/ChatComponents.kt
new file mode 100644
index 0000000..f1f21dc
--- /dev/null
+++ b/app/src/main/java/com/gotcha/ui/ChatComponents.kt
@@ -0,0 +1,99 @@
+package com.gotcha.ui
+
+import androidx.compose.animation.core.RepeatMode
+import androidx.compose.animation.core.animateFloat
+import androidx.compose.animation.core.infiniteRepeatable
+import androidx.compose.animation.core.rememberInfiniteTransition
+import androidx.compose.animation.core.tween
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.unit.dp
+import com.gotcha.ui.theme.WarningAmber
+import kotlin.math.roundToInt
+
+/**
+ * Pieces the chat screen is assembled from. They exist here rather than inline
+ * so the same shape can be reused by the drawer and the overlays without three
+ * copies drifting apart.
+ */
+
+private const val METER_SEGMENTS = 12
+private const val METER_WARN_AT = 0.75f
+private const val METER_CRITICAL_AT = 0.9f
+
+/**
+ * How much of the context window this chat has spent.
+ *
+ * Twelve segments rather than a continuous bar: a bar answers "roughly how
+ * full", which nobody acts on, while segments answer "how many turns do I have
+ * left", which is the question actually being asked. Colour carries the same
+ * information a second way, for the three-quarters of it that matters.
+ */
+@Composable
+fun ContextMeter(fraction: Float, modifier: Modifier = Modifier) {
+ val clamped = fraction.coerceIn(0f, 1f)
+ val filled = (clamped * METER_SEGMENTS).roundToInt()
+ val colors = MaterialTheme.colorScheme
+ val fillColor = when {
+ clamped >= METER_CRITICAL_AT -> colors.error
+ clamped >= METER_WARN_AT -> WarningAmber
+ else -> colors.primary
+ }
+ val emptyColor = colors.onSurfaceVariant.copy(alpha = 0.22f)
+
+ Row(
+ modifier = modifier
+ .fillMaxWidth()
+ .padding(horizontal = 12.dp, vertical = 6.dp),
+ horizontalArrangement = Arrangement.spacedBy(3.dp)
+ ) {
+ repeat(METER_SEGMENTS) { index ->
+ Box(
+ Modifier
+ .weight(1f)
+ .height(3.dp)
+ .clip(RoundedCornerShape(2.dp))
+ .background(if (index < filled) fillColor else emptyColor)
+ )
+ }
+ }
+}
+
+/**
+ * The agent is working. A dot that breathes says so with one moving part, where
+ * a spinner says "loading" — a different claim, and the wrong one for something
+ * that may be thinking for a minute.
+ */
+@Composable
+fun ActivityPulse(color: Color, modifier: Modifier = Modifier) {
+ val transition = rememberInfiniteTransition(label = "activity")
+ val alpha by transition.animateFloat(
+ initialValue = 0.32f,
+ targetValue = 1f,
+ animationSpec = infiniteRepeatable(
+ animation = tween(durationMillis = 900),
+ repeatMode = RepeatMode.Reverse
+ ),
+ label = "alpha"
+ )
+ Box(
+ modifier
+ .size(8.dp)
+ .clip(CircleShape)
+ .background(color.copy(alpha = alpha))
+ )
+}
diff --git a/app/src/main/java/com/gotcha/ui/ChatScreen.kt b/app/src/main/java/com/gotcha/ui/ChatScreen.kt
index 4accb55..6044f73 100644
--- a/app/src/main/java/com/gotcha/ui/ChatScreen.kt
+++ b/app/src/main/java/com/gotcha/ui/ChatScreen.kt
@@ -3,6 +3,7 @@ package com.gotcha.ui
import android.net.Uri
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
+import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
@@ -41,9 +42,9 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilterChip
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
-import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
+import androidx.compose.material3.OutlinedTextFieldDefaults
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
@@ -72,6 +73,7 @@ import androidx.compose.ui.unit.dp
import com.gotcha.R
import com.gotcha.agent.ChatUiState
import com.gotcha.tools.AgentMode
+import com.gotcha.ui.theme.GotchaMono
import kotlinx.coroutines.delay
import androidx.compose.foundation.Image as ComposeImage
@@ -167,21 +169,45 @@ fun ChatScreen(
)
}
} else {
+ // Operator can change the device, Monitor cannot. An icon
+ // that only changes shape is not enough signal for that, so
+ // the riskier of the two says its own name.
val isOperator = state.activeAgent == AgentMode.OPERATOR
- IconButton(onClick = onSwitchAgent, enabled = !state.isBusy) {
- Icon(
- if (isOperator) Icons.Filled.TouchApp else Icons.Outlined.Visibility,
- contentDescription = if (isOperator) {
- "Operator mode — tap to switch to Monitor"
- } else {
- "Monitor mode — tap to switch to Operator"
- },
- tint = if (isOperator) {
- MaterialTheme.colorScheme.primary
- } else {
- MaterialTheme.colorScheme.onSurfaceVariant
+ if (isOperator) {
+ Surface(
+ color = MaterialTheme.colorScheme.primaryContainer,
+ contentColor = MaterialTheme.colorScheme.onPrimaryContainer,
+ shape = RoundedCornerShape(999.dp),
+ modifier = Modifier
+ .padding(end = 4.dp)
+ .clickable(enabled = !state.isBusy, onClick = onSwitchAgent)
+ .testTag("agent_mode_badge")
+ ) {
+ Row(
+ modifier = Modifier.padding(horizontal = 10.dp, vertical = 5.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Icon(
+ Icons.Filled.TouchApp,
+ contentDescription = "Operator mode — tap to switch to Monitor",
+ modifier = Modifier.size(15.dp)
+ )
+ Spacer(modifier = Modifier.width(5.dp))
+ Text(
+ "Operator",
+ style = MaterialTheme.typography.labelMedium,
+ fontWeight = FontWeight.Bold
+ )
}
- )
+ }
+ } else {
+ IconButton(onClick = onSwitchAgent, enabled = !state.isBusy) {
+ Icon(
+ Icons.Outlined.Visibility,
+ contentDescription = "Monitor mode — tap to switch to Operator",
+ tint = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ }
}
if (state.isSpeaking) {
IconButton(onClick = onStopSpeaking) {
@@ -202,11 +228,7 @@ fun ChatScreen(
) { padding ->
Column(modifier = Modifier.fillMaxSize().padding(padding)) {
if (!isHome) {
- LinearProgressIndicator(
- progress = { state.contextUsagePercent },
- modifier = Modifier.fillMaxWidth(),
- color = if (state.contextUsagePercent > 0.8f) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.primary
- )
+ ContextMeter(fraction = state.contextUsagePercent)
}
if (isHome) {
val greeting = rememberSaveable(state.activeSessionId) { HOME_GREETINGS.random() }
@@ -253,12 +275,19 @@ fun ChatScreen(
if (state.activity != null) {
Row(
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 4.dp),
+ modifier = Modifier.padding(horizontal = 18.dp, vertical = 6.dp),
verticalAlignment = Alignment.CenterVertically
) {
- CircularProgressIndicator(modifier = Modifier.width(16.dp))
- Spacer(modifier = Modifier.width(8.dp))
- Text(state.activity, style = MaterialTheme.typography.bodySmall)
+ ActivityPulse(color = MaterialTheme.colorScheme.primary)
+ Spacer(modifier = Modifier.width(10.dp))
+ Text(
+ state.activity,
+ style = MaterialTheme.typography.bodySmall,
+ fontFamily = GotchaMono,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
}
}
@@ -411,109 +440,130 @@ fun ChatScreen(
}
}
- Row(
- modifier = Modifier.fillMaxWidth().padding(8.dp),
- verticalAlignment = Alignment.CenterVertically
+ // One pill rather than a docked row: it floats clear of the bottom
+ // edge, and the send button is the only saturated fill on the screen.
+ Surface(
+ color = MaterialTheme.colorScheme.surfaceVariant,
+ shape = RoundedCornerShape(28.dp),
+ border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant),
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 12.dp, vertical = 10.dp)
) {
- IconButton(
- onClick = { imagePickerLauncher.launch("image/*") },
- enabled = !state.isBusy && state.isConfigured && !otherChatRunning
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 4.dp, vertical = 4.dp),
+ verticalAlignment = Alignment.CenterVertically
) {
- Text("+", style = MaterialTheme.typography.titleLarge)
- }
- OutlinedTextField(
- value = input,
- onValueChange = { input = it },
- modifier = Modifier.weight(1f).testTag("chat_input"),
- shape = RoundedCornerShape(24.dp),
- placeholder = {
- Text(
- when {
- state.isTranscribing -> "Transcribing…"
- otherChatRunning -> "Finish the running chat first…"
- else -> "Let's Go"
- }
+ IconButton(
+ onClick = { imagePickerLauncher.launch("image/*") },
+ enabled = !state.isBusy && state.isConfigured && !otherChatRunning
+ ) {
+ Text("+", style = MaterialTheme.typography.titleLarge)
+ }
+ OutlinedTextField(
+ value = input,
+ onValueChange = { input = it },
+ modifier = Modifier.weight(1f).testTag("chat_input"),
+ shape = RoundedCornerShape(24.dp),
+ placeholder = {
+ Text(
+ when {
+ state.isTranscribing -> "Transcribing…"
+ otherChatRunning -> "Finish the running chat first…"
+ else -> "Let's Go"
+ }
+ )
+ },
+ enabled = !state.isBusy && !state.isTranscribing && state.isConfigured && !otherChatRunning,
+ maxLines = 6,
+ singleLine = false,
+ // The pill is the container now; a second outline inside it
+ // reads as a box in a box.
+ colors = OutlinedTextFieldDefaults.colors(
+ focusedBorderColor = Color.Transparent,
+ unfocusedBorderColor = Color.Transparent,
+ disabledBorderColor = Color.Transparent,
+ focusedContainerColor = Color.Transparent,
+ unfocusedContainerColor = Color.Transparent,
+ disabledContainerColor = Color.Transparent
)
- },
- enabled = !state.isBusy && !state.isTranscribing && state.isConfigured && !otherChatRunning,
- maxLines = 6,
- singleLine = false
- )
- Spacer(modifier = Modifier.width(8.dp))
- // All action buttons use the same 40dp box so the layout never resizes
- Box(modifier = Modifier.size(40.dp)) {
- when {
- state.isBusy -> {
- Button(
- onClick = onStop,
- modifier = Modifier.size(40.dp),
- contentPadding = ButtonDefaults.TextButtonContentPadding,
- shape = CircleShape
- ) {
- Icon(
- Icons.Default.Stop,
- contentDescription = "Stop",
- modifier = Modifier.size(20.dp)
- )
+ )
+ Spacer(modifier = Modifier.width(8.dp))
+ // All action buttons use the same 40dp box so the layout never resizes
+ Box(modifier = Modifier.size(40.dp)) {
+ when {
+ state.isBusy -> {
+ Button(
+ onClick = onStop,
+ modifier = Modifier.size(40.dp),
+ contentPadding = ButtonDefaults.TextButtonContentPadding,
+ shape = CircleShape
+ ) {
+ Icon(
+ Icons.Default.Stop,
+ contentDescription = "Stop",
+ modifier = Modifier.size(20.dp)
+ )
+ }
}
- }
- state.isRecording || state.isListening -> {
- // Recording in progress — show red stop button for both providers
- Button(
- onClick = {
- onStopRecording { text ->
- if (input.isNotEmpty()) {
- input += " " + text
- } else {
- input = text
+ state.isRecording || state.isListening -> {
+ // Recording in progress — show red stop button for both providers
+ Button(
+ onClick = {
+ onStopRecording { text ->
+ if (input.isNotEmpty()) {
+ input += " " + text
+ } else {
+ input = text
+ }
}
- }
- },
- modifier = Modifier.size(40.dp),
- contentPadding = ButtonDefaults.TextButtonContentPadding,
- shape = CircleShape,
- colors = ButtonDefaults.buttonColors(
- containerColor = MaterialTheme.colorScheme.error
- )
- ) {
- Icon(
- Icons.Default.Stop,
- contentDescription = "Stop recording",
- modifier = Modifier.size(20.dp),
- tint = Color.White
- )
+ },
+ modifier = Modifier.size(40.dp),
+ contentPadding = ButtonDefaults.TextButtonContentPadding,
+ shape = CircleShape,
+ colors = ButtonDefaults.buttonColors(
+ containerColor = MaterialTheme.colorScheme.error
+ )
+ ) {
+ Icon(
+ Icons.Default.Stop,
+ contentDescription = "Stop recording",
+ modifier = Modifier.size(20.dp),
+ tint = Color.White
+ )
+ }
}
- }
- state.isTranscribing -> {
- // Recording has stopped but STT hasn't returned text yet —
- // without this the button would blink back to the mic icon
- // and look like the recording was dropped.
- Box(modifier = Modifier.size(40.dp), contentAlignment = Alignment.Center) {
- CircularProgressIndicator(modifier = Modifier.size(20.dp))
+ state.isTranscribing -> {
+ // Recording has stopped but STT hasn't returned text yet —
+ // without this the button would blink back to the mic icon
+ // and look like the recording was dropped.
+ Box(modifier = Modifier.size(40.dp), contentAlignment = Alignment.Center) {
+ CircularProgressIndicator(modifier = Modifier.size(20.dp))
+ }
}
- }
- input.isBlank() && pendingImageBase64 == null -> {
- IconButton(
- onClick = onStartListening,
- modifier = Modifier.size(40.dp),
- enabled = state.isConfigured && !otherChatRunning
- ) {
- Icon(Icons.Default.Mic, contentDescription = "Voice input")
+ input.isBlank() && pendingImageBase64 == null -> {
+ IconButton(
+ onClick = onStartListening,
+ modifier = Modifier.size(40.dp),
+ enabled = state.isConfigured && !otherChatRunning
+ ) {
+ Icon(Icons.Default.Mic, contentDescription = "Voice input")
+ }
}
- }
- else -> {
- IconButton(
- onClick = {
- onSend(input, pendingImageBase64)
- input = ""
- pendingImageUri = null
- pendingImageBase64 = null
- },
- modifier = Modifier.size(40.dp).testTag("send_button"),
- enabled = state.isConfigured && !otherChatRunning &&
- (input.isNotBlank() || pendingImageBase64 != null)
- ) {
- Icon(Icons.Default.Send, contentDescription = "Send")
+ else -> {
+ IconButton(
+ onClick = {
+ onSend(input, pendingImageBase64)
+ input = ""
+ pendingImageUri = null
+ pendingImageBase64 = null
+ },
+ modifier = Modifier.size(40.dp).testTag("send_button"),
+ enabled = state.isConfigured && !otherChatRunning &&
+ (input.isNotBlank() || pendingImageBase64 != null)
+ ) {
+ Icon(Icons.Default.Send, contentDescription = "Send")
+ }
}
}
}
diff --git a/app/src/main/java/com/gotcha/ui/MessageBubble.kt b/app/src/main/java/com/gotcha/ui/MessageBubble.kt
index 073d129..99d6a6e 100644
--- a/app/src/main/java/com/gotcha/ui/MessageBubble.kt
+++ b/app/src/main/java/com/gotcha/ui/MessageBubble.kt
@@ -10,9 +10,12 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
@@ -51,6 +54,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.gotcha.agent.MessageKind
import com.gotcha.agent.UiMessage
+import com.gotcha.ui.theme.GotchaMono
import com.halilibo.richtext.markdown.Markdown
import com.halilibo.richtext.ui.material3.Material3RichText
@@ -68,10 +72,14 @@ fun MessageBubble(
val isTool = message.kind == MessageKind.TOOL
val isSubAgent = message.kind == MessageKind.SUBAGENT
val colors = MaterialTheme.colorScheme
+ // Only the user gets a bubble. An assistant reply can run to several
+ // paragraphs, and wrapping that in a container turns reading into scanning a
+ // receipt; set on the ground it reads like prose, which is what it is.
+ // A tool call is neither — see the ledger rail below.
val (container, contentColor) = when (message.kind) {
MessageKind.USER -> colors.primaryContainer to colors.onPrimaryContainer
- MessageKind.ASSISTANT -> colors.surfaceVariant to colors.onSurfaceVariant
- MessageKind.TOOL -> colors.secondaryContainer to colors.onSecondaryContainer
+ 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)
@@ -79,6 +87,7 @@ fun MessageBubble(
bg to fg
}
}
+ val unbubbled = isAssistant || isTool
val expanded = remember { mutableStateOf(!isTool && !isSubAgent) }
var showMenu by remember { mutableStateOf(false) }
@@ -91,7 +100,7 @@ fun MessageBubble(
Surface(
color = container,
contentColor = contentColor,
- shadowElevation = 2.dp,
+ shadowElevation = if (unbubbled) 0.dp else 2.dp,
shape = RoundedCornerShape(
topStart = 20.dp,
topEnd = 20.dp,
@@ -101,7 +110,10 @@ fun MessageBubble(
) {
Column(
modifier = Modifier
- .widthIn(max = 320.dp)
+ .then(
+ // Prose wants the full column; a bubble wants to stay a bubble.
+ if (isAssistant) Modifier.fillMaxWidth() else Modifier.widthIn(max = 320.dp)
+ )
.then(
if (isTool || isSubAgent) {
Modifier.combinedClickable(
@@ -115,7 +127,10 @@ fun MessageBubble(
)
}
)
- .padding(16.dp)
+ .padding(
+ horizontal = if (unbubbled) 6.dp else 16.dp,
+ vertical = if (unbubbled) 6.dp else 16.dp
+ )
) {
message.imageBase64?.let { base64 ->
val bitmap = try {
@@ -177,38 +192,24 @@ fun MessageBubble(
}
}
if (message.text.isNotEmpty()) {
- val displayText = when (message.kind) {
- MessageKind.TOOL -> "🔧 ${message.text}"
- else -> message.text
- }
+ val displayText = message.text
val firstLine = displayText.substringBefore("\n").trimEnd()
val hasMore = displayText.contains("\n")
- if (isTool && !expanded.value) {
- Text(
- text = firstLine,
- style = MaterialTheme.typography.bodySmall,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis
+ if (isTool) {
+ ToolLedger(
+ text = if (expanded.value) displayText else firstLine,
+ hint = if (!expanded.value && hasMore) "tap to expand" else null,
+ railColor = colors.primary,
+ contentColor = contentColor,
+ collapsed = !expanded.value
)
- if (hasMore) {
- Text(
- text = "… tap to expand",
- style = MaterialTheme.typography.labelSmall,
- color = contentColor.copy(alpha = 0.6f)
- )
- }
} else if (isSubAgent) {
SubAgentContent(
message = message,
contentColor = contentColor,
expanded = expanded
)
- } else if (isTool || isSubAgent) {
- Text(
- text = displayText,
- style = MaterialTheme.typography.bodySmall
- )
} else {
Material3RichText {
Markdown(displayText)
@@ -273,6 +274,50 @@ fun MessageBubble(
}
}
+/**
+ * A tool call, rendered as a ledger line rather than a chat bubble: an accent
+ * rail, the call in monospace, one line until tapped. A turn can make twenty of
+ * these, and twenty bubbles bury the two sentences of prose that answered the
+ * question.
+ */
+@Composable
+private fun ToolLedger(
+ text: String,
+ hint: String?,
+ railColor: Color,
+ contentColor: Color,
+ collapsed: Boolean
+) {
+ Row(modifier = Modifier.height(IntrinsicSize.Min)) {
+ Box(
+ modifier = Modifier
+ .width(2.dp)
+ .fillMaxHeight()
+ .clip(RoundedCornerShape(1.dp))
+ .background(railColor.copy(alpha = 0.7f))
+ )
+ Spacer(modifier = Modifier.width(10.dp))
+ Column {
+ Text(
+ text = text,
+ style = MaterialTheme.typography.bodySmall,
+ fontFamily = GotchaMono,
+ color = contentColor,
+ maxLines = if (collapsed) 1 else Int.MAX_VALUE,
+ overflow = TextOverflow.Ellipsis
+ )
+ if (hint != null) {
+ Text(
+ text = hint,
+ style = MaterialTheme.typography.labelSmall,
+ fontFamily = GotchaMono,
+ color = contentColor.copy(alpha = 0.55f)
+ )
+ }
+ }
+ }
+}
+
@Composable
private fun SubAgentContent(
message: UiMessage,
diff --git a/app/src/main/java/com/gotcha/ui/theme/Color.kt b/app/src/main/java/com/gotcha/ui/theme/Color.kt
index fd11d56..4e135ff 100644
--- a/app/src/main/java/com/gotcha/ui/theme/Color.kt
+++ b/app/src/main/java/com/gotcha/ui/theme/Color.kt
@@ -138,3 +138,10 @@ val NocturneContainerHighest = Color(0xFF2A1F35)
*/
val BrandError = Color(0xFFFF6B4A)
val BrandOnError = Color(0xFF3E0A00)
+
+/**
+ * "Getting full", for the context meter. Semantic colour is deliberately its own
+ * axis: it has to mean the same thing in every skin, so it cannot be the accent
+ * — which is a different hue in each of them.
+ */
+val WarningAmber = Color(0xFFFFB020)
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 7e3fb9c..ec40c5f 100644
--- a/app/src/main/java/com/gotcha/ui/theme/Skin.kt
+++ b/app/src/main/java/com/gotcha/ui/theme/Skin.kt
@@ -104,6 +104,18 @@ data class Skin(
fun launchGround(dark: Boolean): Color =
if (isGlass) ground else scheme(dark).background
+ /**
+ * The same skin with its frost dialled to [percent] of what it was designed
+ * with. The scrim scales with it: they are two halves of one effect, and
+ * leaving the veil at full strength over a sharp wallpaper reads as haze
+ * rather than as a choice.
+ */
+ fun withFrost(percent: Int): Skin {
+ if (percent >= 100 || !isGlass) return this
+ val factor = (percent.coerceIn(0, 100)) / 100f
+ return copy(frost = frost * factor, scrim = scrim * factor)
+ }
+
/**
* The same skin with the glass taken out: panels composited down onto their
* own ground, no wallpaper, no grain. The palette and the layout are
diff --git a/app/src/main/java/com/gotcha/ui/theme/Theme.kt b/app/src/main/java/com/gotcha/ui/theme/Theme.kt
index 5c3d482..8c8fe20 100644
--- a/app/src/main/java/com/gotcha/ui/theme/Theme.kt
+++ b/app/src/main/java/com/gotcha/ui/theme/Theme.kt
@@ -48,6 +48,7 @@ internal val LightColorScheme = lightColorScheme(
* @param skinId which entry of [Skins] the user picked.
* @param matchSystemBrightness swap a paired skin for its twin when the device
* flips between light and dark, instead of keeping one skin in both.
+ * @param frostPercent scales the skin's frost and scrim, 0–100.
* @param reduceTransparency our own accessibility switch — Android has no
* system-level equivalent, so this is the only way to ask for solid panels.
*/
@@ -57,10 +58,12 @@ fun GotchaTheme(
skinId: String = Skins.DEFAULT_ID,
matchSystemBrightness: Boolean = true,
reduceTransparency: Boolean = false,
+ frostPercent: Int = 100,
content: @Composable () -> Unit
) {
val tier = rememberGlassTier(reduceTransparency)
val picked = Skins.resolve(skinId, matchSystemBrightness, darkTheme)
+ .withFrost(frostPercent)
// The tier decides what the skin is made of, not whether the user gets it.
val skin = if (tier == GlassTier.SOLID) picked.opaque() else picked
diff --git a/app/src/main/java/com/gotcha/ui/theme/Type.kt b/app/src/main/java/com/gotcha/ui/theme/Type.kt
index c556a5b..36f4b7c 100644
--- a/app/src/main/java/com/gotcha/ui/theme/Type.kt
+++ b/app/src/main/java/com/gotcha/ui/theme/Type.kt
@@ -31,6 +31,26 @@ private fun variableFamily(resId: Int) = FontFamily(
/** Figtree — the app-wide typeface (OFL-licensed; see assets/licenses). */
val Figtree = variableFamily(R.font.figtree)
+/**
+ * Machine text: tool names, exit codes, file paths, terminal output, token
+ * counts. Figtree is for what the agent *said*; this is for what it *did*, and
+ * the eye separates the two before it has read either.
+ *
+ * The platform family rather than a bundled face — it is the one typeface every
+ * Android device already has a real monospace for, and a second font file is a
+ * poor trade for text that is deliberately secondary.
+ */
+val GotchaMono = FontFamily.Monospace
+
+/**
+ * Digits that hold their column. Counters that tick while a reply streams jitter
+ * badly in a proportional face, because the glyphs are different widths.
+ */
+val TabularNumerals = TextStyle(
+ fontFamily = GotchaMono,
+ fontFeatureSettings = "tnum"
+)
+
private val baseline = Typography()
val Typography = Typography(