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(settings): open AI Configuration directly on an unconfigured first run

Durganshu Mishra2be75876941f
diff --git a/app/src/androidTest/java/com/gotcha/SettingsFlowTest.kt b/app/src/androidTest/java/com/gotcha/SettingsFlowTest.kt
index dd9b092..11e69ff 100644
--- a/app/src/androidTest/java/com/gotcha/SettingsFlowTest.kt
+++ b/app/src/androidTest/java/com/gotcha/SettingsFlowTest.kt
@@ -2,6 +2,7 @@ package com.gotcha
import androidx.compose.ui.test.junit4.createEmptyComposeRule
import androidx.compose.ui.test.onNodeWithTag
+import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollTo
import androidx.compose.ui.test.performTextReplacement
@@ -39,10 +40,8 @@ class SettingsFlowTest {
scenario = ActivityScenario.launch(MainActivity::class.java)
composeRule.waitForIdle()
- // AI Configuration is its own page now, reached from the settings home list.
- composeRule.onNodeWithTag("settings_ai_config_row").performClick()
- composeRule.waitForIdle()
-
+ // An unconfigured install opens on the AI Configuration page itself, so
+ // there is no category row to click through first.
composeRule.onNodeWithTag("settings_base_url").performTextReplacement(testBaseUrl)
composeRule.onNodeWithTag("settings_model").performTextReplacement(testModel)
// The Save button sits below the fold in the scrollable Settings column;
@@ -62,4 +61,26 @@ class SettingsFlowTest {
composeRule.waitForIdle()
composeRule.onNodeWithTag("chat_input").assertExists()
}
+
+ @Test
+ fun settingsSubPage_opensFromTheListAndBackReturnsToIt() {
+ val context = ApplicationProvider.getApplicationContext<android.content.Context>()
+ TestSeed.seedUnconfigured(context)
+
+ scenario = ActivityScenario.launch(MainActivity::class.java)
+ composeRule.waitForIdle()
+
+ // First run opens on AI Configuration; Back from a sub-page lands on the
+ // category list rather than leaving Settings.
+ composeRule.onNodeWithTag("settings_base_url").assertExists()
+ composeRule.onNodeWithText("← Back").performClick()
+ composeRule.waitForIdle()
+ composeRule.onNodeWithTag("settings_ai_config_row").assertExists()
+
+ // Opening another category replaces the list with that page.
+ composeRule.onNodeWithTag("settings_speech_row").performScrollTo().performClick()
+ composeRule.waitForIdle()
+ composeRule.onNodeWithTag("settings_ai_config_row").assertDoesNotExist()
+ composeRule.onNodeWithText("TTS Provider").assertExists()
+ }
}
diff --git a/app/src/androidTest/java/com/gotcha/SmokeLaunchTest.kt b/app/src/androidTest/java/com/gotcha/SmokeLaunchTest.kt
index 1339bb2..39f5ec2 100644
--- a/app/src/androidTest/java/com/gotcha/SmokeLaunchTest.kt
+++ b/app/src/androidTest/java/com/gotcha/SmokeLaunchTest.kt
@@ -47,6 +47,8 @@ class SmokeLaunchTest {
scenario = ActivityScenario.launch(MainActivity::class.java)
composeRule.waitForIdle()
- composeRule.onNodeWithTag("settings_ai_config_row").assertExists()
+ // Straight to the AI Configuration page, not the settings category list:
+ // the API key and model are the only things a first run has to supply.
+ composeRule.onNodeWithTag("settings_base_url").assertExists()
}
}
diff --git a/app/src/main/java/com/gotcha/MainActivity.kt b/app/src/main/java/com/gotcha/MainActivity.kt
index 9be3e28..d3bad59 100644
--- a/app/src/main/java/com/gotcha/MainActivity.kt
+++ b/app/src/main/java/com/gotcha/MainActivity.kt
@@ -47,6 +47,7 @@ import com.gotcha.tools.ToolResult
import com.gotcha.ui.AppDrawerContent
import com.gotcha.ui.ChatScreen
import com.gotcha.ui.ConnectorsScreen
+import com.gotcha.ui.SettingsPage
import com.gotcha.ui.SettingsScreen
import com.gotcha.ui.theme.GotchaTheme
import kotlinx.coroutines.Dispatchers
@@ -346,8 +347,11 @@ class MainActivity : ComponentActivity() {
val state by chatViewModel.uiState.collectAsState()
val sessions by chatViewModel.sessions.collectAsState()
+ // An unconfigured install opens Settings; send it straight to the page
+ // holding the API key and model rather than to the category list.
+ val unconfigured = remember { !settingsRepository.load().isConfigured }
var currentRoute by remember {
- mutableStateOf(if (settingsRepository.load().isConfigured) Route.HOME else Route.SETTINGS)
+ mutableStateOf(if (unconfigured) Route.SETTINGS else Route.HOME)
}
var assistiveBallOn by remember { mutableStateOf(settingsRepository.load().assistiveBallEnabled) }
val drawerState = rememberDrawerState(DrawerValue.Closed)
@@ -511,7 +515,8 @@ class MainActivity : ComponentActivity() {
chatViewModel.refreshSettings()
},
onTestVoice = { language -> chatViewModel.testAndroidTts(language) },
- packageName = packageName
+ packageName = packageName,
+ initialPage = if (unconfigured) SettingsPage.AI_CONFIG else null
)
}
Route.CONNECTORS -> {
diff --git a/app/src/main/java/com/gotcha/ui/SettingsScreen.kt b/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
index 27eefc8..82fb890 100644
--- a/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
+++ b/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
@@ -74,10 +74,17 @@ fun SettingsScreen(
* (synchronous, always-true) lets callers ignore voice testing.
*/
onTestVoice: suspend (Language) -> Boolean? = { null },
- packageName: String = ""
+ packageName: String = "",
+ /**
+ * Page to open on, instead of the home list. For the unconfigured first run,
+ * where the one thing the user must do is enter an API key and a model, and
+ * the home list would only ask them to guess which category that lives under.
+ * Back still returns to the list, so the rest of Settings stays reachable.
+ */
+ initialPage: SettingsPage? = null
) {
// null = the home list. Saveable so a rotation doesn't bounce the user back out.
- var page by rememberSaveable { mutableStateOf<SettingsPage?>(null) }
+ var page by rememberSaveable { mutableStateOf(initialPage) }
val backToHome = { page = null }
// Back leaves the sub-page for the list; only the list itself exits Settings.