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(chat): offer starter prompts on the empty home screen
Durganshub573d89ded4a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 57d023a..4b92322 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -23,6 +23,17 @@ All notable changes to Gotcha are documented here.## [1.2.0]### Added+- **Starter prompts on the home screen.** A new chat used to be a greeting and an+ empty composer, which says nothing about what Gotcha can be asked for. Three+ suggestion chips now sit under the agent selector — drawn per session from a+ set covering the things people least expect: driving the device, reading the+ screen, going through the filesystem (`Find the largest files in my Downloads+ folder and tell me what's safe to delete`, `Read the most recent PDF in my+ Downloads and summarise it`) and handling messages. Tapping one **fills the+ composer and stops there**: nothing is sent until you've read it, edited the+ parts left blank, and pressed send yourself. Nor does a chip change the agent+ mode on your behalf — the two device actions need Operator, the rest answer in+ Monitor, and which mode you're in stays the selector's business.- **Podcast generation.** Gotcha can now turn text into listenable audio. Askfor a topic, an article or your notes as a podcast and the assistant writesthe script and speaks it through your configured text-to-speech API — as adiff --git a/app/src/androidTest/java/com/gotcha/ChatRoundTripTest.kt b/app/src/androidTest/java/com/gotcha/ChatRoundTripTest.ktindex 6f88bce..3a272e4 100644--- a/app/src/androidTest/java/com/gotcha/ChatRoundTripTest.kt+++ b/app/src/androidTest/java/com/gotcha/ChatRoundTripTest.kt@@ -1,5 +1,6 @@package com.gotcha+import androidx.compose.ui.test.assertimport androidx.compose.ui.test.hasTestTagimport androidx.compose.ui.test.hasTextimport androidx.compose.ui.test.isEnabled@@ -17,7 +18,9 @@ import androidx.test.ext.junit.runners.AndroidJUnit4import com.gotcha.testutil.MOCK_REPLY_OKimport com.gotcha.testutil.MockLlmimport com.gotcha.testutil.TestSeed+import com.gotcha.ui.STARTER_PROMPTSimport org.junit.After+import org.junit.Assert.assertEqualsimport org.junit.Assert.assertFalseimport org.junit.Assert.assertTrueimport org.junit.Rule@@ -88,6 +91,40 @@ class ChatRoundTripTest {assertTrue(request.body.readUtf8().contains("test-model"))}+ @Test+ fun starterPrompt_fillsComposerWithoutSending() {+ mockLlm.start()+ val context = ApplicationProvider.getApplicationContext<android.content.Context>()+ TestSeed.seedConfigured(context, baseUrl = mockLlm.baseUrl, model = "test-model")++ scenario = ActivityScenario.launch(MainActivity::class.java)+ composeRule.waitForIdle()++ // Which three are on offer is drawn per session, so the test follows the+ // screen rather than assuming a particular chip is there.+ composeRule.onNodeWithTag("starter_prompts").assertExists()+ val shown = STARTER_PROMPTS.first { prompt ->+ composeRule.onAllNodes(hasTestTag("starter_prompt_${prompt.label}"))+ .fetchSemanticsNodes().isNotEmpty()+ }++ composeRule.onNodeWithTag("starter_prompt_${shown.label}").performClick()+ composeRule.waitForIdle()++ // Filled, not sent: the template is in the composer, the transcript is+ // still empty, and nothing went to the LLM.+ composeRule.onNodeWithTag("chat_input").assert(hasText(shown.template))+ assertTrue(+ "tapping a starter must not open the transcript",+ composeRule.onAllNodes(hasTestTag("message_list")).fetchSemanticsNodes().isEmpty()+ )+ assertEquals(+ "tapping a starter must not send anything to the LLM",+ 0,+ mockLlm.server.requestCount+ )+ }+@Testfun editMessage_truncatesHistoryAndRegenerates() {mockLlm.start()diff --git a/app/src/main/java/com/gotcha/ui/ChatScreen.kt b/app/src/main/java/com/gotcha/ui/ChatScreen.ktindex 0133388..3a5361c 100644--- a/app/src/main/java/com/gotcha/ui/ChatScreen.kt+++ b/app/src/main/java/com/gotcha/ui/ChatScreen.kt@@ -319,6 +319,30 @@ fun ChatScreen(selected = state.activeAgent,onSelect = onSetAgent)+ // Starters are an offer to fill the composer, so they are+ // only shown when the composer can actually be used: no API+ // key means typing is disabled, and a run in another chat+ // blocks sending from here.+ if (state.isConfigured && !otherChatRunning) {+ // Re-drawn per session rather than per recomposition, so+ // the three on offer don't reshuffle under a rotation.+ val starters = rememberSaveable(+ state.activeSessionId,+ saver = StarterPromptLabelsSaver+ ) {+ STARTER_PROMPTS.shuffled().take(STARTER_PROMPT_COUNT)+ }+ Spacer(modifier = Modifier.height(24.dp))+ StarterPromptRow(+ prompts = starters,+ onPick = { prompt ->+ // Fill, never send: the template is a draft the+ // user is expected to edit first.+ input = prompt.template+ inputWasVoice = false+ }+ )+ }}} else {LazyColumn(diff --git a/app/src/main/java/com/gotcha/ui/StarterPrompt.kt b/app/src/main/java/com/gotcha/ui/StarterPrompt.ktnew file mode 100644index 0000000..f94c699--- /dev/null+++ b/app/src/main/java/com/gotcha/ui/StarterPrompt.kt@@ -0,0 +1,144 @@+package com.gotcha.ui++import androidx.compose.foundation.BorderStroke+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.ExperimentalLayoutApi+import androidx.compose.foundation.layout.FlowRow+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.shape.CircleShape+import androidx.compose.material3.MaterialTheme+import androidx.compose.material3.Surface+import androidx.compose.material3.Text+import androidx.compose.runtime.Composable+import androidx.compose.runtime.saveable.listSaver+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.platform.testTag+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.unit.dp++/**+ * One tap-to-fill suggestion on the empty home screen.+ *+ * [label] is what the chip says; [template] is what lands in the composer. They+ * are deliberately different — the chip has to stay short enough to sit three to+ * a screen, while the template is a first draft of a real prompt. Tapping fills+ * the composer and stops there: the user edits and sends, so a template may+ * carry an unfilled `…` where a name or a message belongs.+ */+internal data class StarterPrompt(val label: String, val template: String)++/**+ * The starters offered on an empty chat. Between them they demo the three things+ * people most often don't realise Gotcha can do — drive the device, answer+ * questions about what's on screen or on disk, and handle messages.+ *+ * Four of the seven (screen, both filesystem ones, notifications) are read-only,+ * so they answer in Monitor as well as Operator. The two device actions need+ * Operator; the chip does not switch mode on the user's behalf, the selector+ * directly above it does.+ */+internal val STARTER_PROMPTS = listOf(+ StarterPrompt(+ label = "Turn on Wi-Fi",+ template = "Open settings and turn on Wi-Fi"+ ),+ StarterPrompt(+ label = "Set an alarm",+ template = "Set an alarm for 7am tomorrow"+ ),+ StarterPrompt(+ label = "Read my screen",+ template = "What's on my screen?"+ ),+ StarterPrompt(+ label = "Find big files",+ template = "Find the largest files in my Downloads folder and tell me what's safe to delete"+ ),+ StarterPrompt(+ label = "Summarise a PDF",+ template = "Read the most recent PDF in my Downloads and summarise it"+ ),+ StarterPrompt(+ label = "Send a WhatsApp",+ template = "Send a WhatsApp to … saying …"+ ),+ StarterPrompt(+ label = "Catch me up",+ template = "Catch me up on my unread notifications"+ )+)++/** How many of [STARTER_PROMPTS] a single home screen offers. */+internal const val STARTER_PROMPT_COUNT = 3++/**+ * rememberSaveable saver for the drawn starters. Only the labels are stored —+ * they are unique, and the prompts themselves are a compile-time list, so a+ * restore is a lookup. A label that no longer exists (the list changed across an+ * app update, with saved state from the old one) simply drops out.+ */+internal val StarterPromptLabelsSaver = listSaver<List<StarterPrompt>, String>(+ save = { prompts -> prompts.map { it.label } },+ restore = { labels ->+ labels.mapNotNull { label -> STARTER_PROMPTS.firstOrNull { it.label == label } }+ }+)++/**+ * The tap-to-fill chip row under the agent selector on the home screen.+ *+ * Styled like the *unchosen* half of [AgentModeSelector] — hairline outline, no+ * fill, dimmed ink — for the reason spelled out there: Material's own chips mark+ * themselves with `secondaryContainer`, which every glass skin leaves+ * translucent. These are suggestions, not the screen's main event, so they stay+ * quieter than the mode selector above them and the composer below.+ */+@OptIn(ExperimentalLayoutApi::class)+@Composable+internal fun StarterPromptRow(+ prompts: List<StarterPrompt>,+ onPick: (StarterPrompt) -> Unit,+ modifier: Modifier = Modifier+) {+ val scheme = MaterialTheme.colorScheme+ Column(+ modifier = modifier.testTag("starter_prompts"),+ horizontalAlignment = Alignment.CenterHorizontally+ ) {+ Text(+ "Try",+ style = MaterialTheme.typography.labelMedium,+ color = scheme.onSurfaceVariant+ )+ Spacer(modifier = Modifier.height(8.dp))+ FlowRow(+ modifier = Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterHorizontally),+ verticalArrangement = Arrangement.spacedBy(8.dp)+ ) {+ prompts.forEach { prompt ->+ Surface(+ onClick = { onPick(prompt) },+ shape = CircleShape,+ color = Color.Transparent,+ contentColor = scheme.onSurfaceVariant.copy(alpha = 0.75f),+ border = BorderStroke(1.dp, scheme.outlineVariant.copy(alpha = 0.6f)),+ modifier = Modifier.testTag("starter_prompt_${prompt.label}")+ ) {+ Text(+ prompt.label,+ style = MaterialTheme.typography.labelLarge,+ textAlign = TextAlign.Center,+ modifier = Modifier.padding(horizontal = 14.dp, vertical = 8.dp)+ )+ }+ }+ }+ }+}diff --git a/app/src/test/java/com/gotcha/ui/StarterPromptsTest.kt b/app/src/test/java/com/gotcha/ui/StarterPromptsTest.ktnew file mode 100644index 0000000..ddd3133--- /dev/null+++ b/app/src/test/java/com/gotcha/ui/StarterPromptsTest.kt@@ -0,0 +1,52 @@+package com.gotcha.ui++import androidx.compose.runtime.saveable.SaverScope+import org.junit.Assert.assertEquals+import org.junit.Assert.assertTrue+import org.junit.Test++/**+ * [STARTER_PROMPTS] is a hand-edited list that the home screen draws from+ * blindly. These are the invariants that drawing relies on.+ */+class StarterPromptsTest {++ @Test+ fun `offers enough starters to draw from`() {+ assertTrue(+ "The home screen draws $STARTER_PROMPT_COUNT starters per session, " ++ "so the list must hold at least that many",+ STARTER_PROMPTS.size >= STARTER_PROMPT_COUNT+ )+ assertTrue("Expected a spread of starters to draw from", STARTER_PROMPTS.size >= 5)+ }++ @Test+ fun `every starter has a label and a template`() {+ STARTER_PROMPTS.forEach { prompt ->+ assertTrue("Blank label in $prompt", prompt.label.isNotBlank())+ assertTrue("Blank template in $prompt", prompt.template.isNotBlank())+ // The chip has to sit three to a row on a phone.+ assertTrue(+ "Label too long to fit a chip: '${prompt.label}'",+ prompt.label.length <= 20+ )+ }+ }++ @Test+ fun `labels are unique`() {+ // The saver restores a drawn starter by its label, and the chips are+ // test-tagged by it, so duplicates would make both ambiguous.+ val labels = STARTER_PROMPTS.map { it.label }+ assertEquals(labels.size, labels.distinct().size)+ }++ @Test+ fun `saver round-trips a drawn set`() {+ val drawn = STARTER_PROMPTS.take(STARTER_PROMPT_COUNT)+ val scope = SaverScope { true }+ val saved = requireNotNull(with(StarterPromptLabelsSaver) { scope.save(drawn) })+ assertEquals(drawn, StarterPromptLabelsSaver.restore(saved))+ }+}