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(connectors): add Connectors screen and update UI for connector tools

Durganshu Mishra88e128154c4f
diff --git a/app/src/main/assets/skills/gmail.json b/app/src/main/assets/skills/gmail.json
index d8460ec..e891ce9 100644
--- a/app/src/main/assets/skills/gmail.json
+++ b/app/src/main/assets/skills/gmail.json
@@ -3,5 +3,5 @@
"targetPackageNames": ["com.google.android.gm"],
"name": "Gmail Skills",
"description": "Prefer the email connector tools over driving the Gmail UI.",
- "instructions": "Never automate the Gmail app's UI (tapping, scrolling, typing) to read or send email — it's slow and fragile compared to the official tools. Instead:\n1. To read, search, or check unread email: use list_emails and read_email. These work with either a connected Gmail account (Settings → Connectors → Gmail BYO OAuth) or an IMAP account.\n2. To send email: use send_email. It always shows the user a confirmation dialog with recipient/subject/body before anything is sent — you don't need to ask permission separately.\n3. If no email connector is connected, list_emails/send_email will say so — in that case use compose_email to open the user's email app with a pre-filled draft, or suggest they connect an account in Settings → Connectors for full read/write access.\n4. To mark messages read/unread, use mark_email_read with the id from list_emails.\n5. For real-time 'did I get an email from X' questions when notifications are enabled, read_notifications with app='gmail' can be faster than list_emails.\nOnly fall back to UI automation (open_app + navigate_app) for things the tools genuinely can't do, e.g. Gmail-specific settings screens."
+ "instructions": "Never automate the Gmail app's UI (tapping, scrolling, typing) to read or send email — it's slow and fragile compared to the official tools. Instead:\n1. To read, search, or check unread email: use list_emails and read_email. These work with either a connected Gmail account (menu ▸ Connectors ▸ Gmail BYO OAuth) or an IMAP account.\n2. To send email: use send_email. It always shows the user a confirmation dialog with recipient/subject/body before anything is sent — you don't need to ask permission separately.\n3. If no email connector is connected, list_emails/send_email will say so — in that case use compose_email to open the user's email app with a pre-filled draft, or suggest they connect an account in the drawer menu ▸ Connectors for full read/write access.\n4. To mark messages read/unread, use mark_email_read with the id from list_emails.\n5. For real-time 'did I get an email from X' questions when notifications are enabled, read_notifications with app='gmail' can be faster than list_emails.\nOnly fall back to UI automation (open_app + navigate_app) for things the tools genuinely can't do, e.g. Gmail-specific settings screens."
}
diff --git a/app/src/main/assets/skills/notion.json b/app/src/main/assets/skills/notion.json
index 511f11e..c093607 100644
--- a/app/src/main/assets/skills/notion.json
+++ b/app/src/main/assets/skills/notion.json
@@ -3,5 +3,5 @@
"targetPackageNames": ["notion.id"],
"name": "Notion Skills",
"description": "Use the Notion connector tools instead of automating the Notion app UI.",
- "instructions": "Never automate the Notion app's UI. When the Notion connector is set up (Settings → Connectors) use these tools:\n1. notion_search finds pages by title. Always start here — the other tools need a page id from it.\n2. notion_read_page returns the page's text as Markdown.\n3. notion_create_page needs a parent_page_id: Notion gives integrations no workspace root to write into, so find a parent with notion_search first.\n4. notion_append_to_page adds to the end of a page and never overwrites existing content.\n\nThe one thing that trips users up: an integration can only see pages that have been explicitly shared with it (open the page in Notion → ⋯ → Connections → add the integration). If a search comes back empty or a read returns 'could not find page', that is almost always the cause — tell the user to share the page rather than concluding it does not exist.\n\nNotion is the right destination for notes, meeting summaries, research write-ups and reference material the user wants to keep. For short-lived items with a due date, prefer create_task (Microsoft To Do); for the agent's own working plan use todowrite."
+ "instructions": "Never automate the Notion app's UI. When the Notion connector is set up (drawer menu ▸ Connectors) use these tools:\n1. notion_search finds pages by title. Always start here — the other tools need a page id from it.\n2. notion_read_page returns the page's text as Markdown.\n3. notion_create_page needs a parent_page_id: Notion gives integrations no workspace root to write into, so find a parent with notion_search first.\n4. notion_append_to_page adds to the end of a page and never overwrites existing content.\n\nThe one thing that trips users up: an integration can only see pages that have been explicitly shared with it (open the page in Notion → ⋯ → Connections → add the integration). If a search comes back empty or a read returns 'could not find page', that is almost always the cause — tell the user to share the page rather than concluding it does not exist.\n\nNotion is the right destination for notes, meeting summaries, research write-ups and reference material the user wants to keep. For short-lived items with a due date, prefer create_task (Microsoft To Do); for the agent's own working plan use todowrite."
}
diff --git a/app/src/main/assets/skills/outlook.json b/app/src/main/assets/skills/outlook.json
index 173e7d9..ea8b165 100644
--- a/app/src/main/assets/skills/outlook.json
+++ b/app/src/main/assets/skills/outlook.json
@@ -3,5 +3,5 @@
"targetPackageNames": ["com.microsoft.office.outlook", "com.microsoft.todos"],
"name": "Outlook and Microsoft To Do Skills",
"description": "Use the Microsoft Graph connector tools instead of automating Outlook or To Do.",
- "instructions": "Never automate the Outlook or Microsoft To Do UI. When the Microsoft connector is set up (Settings → Connectors), these tools talk to the account directly:\n\nMail — the ordinary email tools cover Outlook, no separate tools exist:\n1. list_emails returns rows whose ids start with 'ms:' when Outlook is the active backend.\n2. read_email and mark_email_read route by that id prefix, so ids stay valid.\n3. send_email always shows the user a confirmation dialog before anything leaves the device.\nNote the backend order: if a Gmail connector is also set up, Gmail is used for new listings and sends. Existing 'ms:' ids still resolve to Outlook.\n\nTasks — list_tasks, create_task and complete_task read and write the user's real Microsoft To Do lists, which sync to their other devices. These are NOT the same as todowrite: todowrite is your own scratch plan for the current conversation and disappears afterwards. If the user says 'remind me to…', 'add to my to-do list', or 'put it on my list', they mean create_task. Use todowrite only to track your own steps through a multi-part request.\n\nCalendar — use list_calendar_events / create_calendar_event with source='microsoft', and check_availability for free/busy questions.\n\nIf a tool reports that the sign-in expired or needs reconnecting, tell the user to reconnect in Settings → Connectors; do not try to work around it through the UI."
+ "instructions": "Never automate the Outlook or Microsoft To Do UI. When the Microsoft connector is set up (drawer menu ▸ Connectors), these tools talk to the account directly:\n\nMail — the ordinary email tools cover Outlook, no separate tools exist:\n1. list_emails returns rows whose ids start with 'ms:' when Outlook is the active backend.\n2. read_email and mark_email_read route by that id prefix, so ids stay valid.\n3. send_email always shows the user a confirmation dialog before anything leaves the device.\nNote the backend order: if a Gmail connector is also set up, Gmail is used for new listings and sends. Existing 'ms:' ids still resolve to Outlook.\n\nTasks — list_tasks, create_task and complete_task read and write the user's real Microsoft To Do lists, which sync to their other devices. These are NOT the same as todowrite: todowrite is your own scratch plan for the current conversation and disappears afterwards. If the user says 'remind me to…', 'add to my to-do list', or 'put it on my list', they mean create_task. Use todowrite only to track your own steps through a multi-part request.\n\nCalendar — use list_calendar_events / create_calendar_event with source='microsoft', and check_availability for free/busy questions.\n\nIf a tool reports that the sign-in expired or needs reconnecting, tell the user to reconnect in the drawer menu ▸ Connectors; do not try to work around it through the UI."
}
diff --git a/app/src/main/java/com/gotcha/MainActivity.kt b/app/src/main/java/com/gotcha/MainActivity.kt
index a1c2508..c5d8680 100644
--- a/app/src/main/java/com/gotcha/MainActivity.kt
+++ b/app/src/main/java/com/gotcha/MainActivity.kt
@@ -46,6 +46,7 @@ import com.gotcha.tools.ScreenPerception
import com.gotcha.tools.ToolResult
import com.gotcha.ui.AppDrawerContent
import com.gotcha.ui.ChatScreen
+import com.gotcha.ui.ConnectorsScreen
import com.gotcha.ui.SettingsScreen
import com.gotcha.ui.theme.GotchaTheme
import kotlinx.coroutines.Dispatchers
@@ -54,7 +55,7 @@ import kotlinx.coroutines.withContext
import kotlinx.serialization.json.JsonPrimitive
import android.provider.Settings as AndroidSettings
-enum class Route { HOME, SETTINGS }
+enum class Route { HOME, SETTINGS, CONNECTORS }
class MainActivity : ComponentActivity() {
@@ -409,6 +410,10 @@ class MainActivity : ComponentActivity() {
scope.launch { drawerState.close() }
currentRoute = Route.SETTINGS
},
+ onOpenConnectors = {
+ scope.launch { drawerState.close() }
+ currentRoute = Route.CONNECTORS
+ },
maxContextTokens = state.maxContextTokens,
activeTokenCount = state.tokenCount
)
@@ -492,6 +497,10 @@ class MainActivity : ComponentActivity() {
packageName = packageName
)
}
+ Route.CONNECTORS -> {
+ BackHandler { currentRoute = Route.HOME }
+ ConnectorsScreen(onBack = { currentRoute = Route.HOME })
+ }
Route.HOME -> {
// Back from an active chat returns to a fresh home (new session,
// new greeting); on an empty home the default back exits the app.
diff --git a/app/src/main/java/com/gotcha/tools/ToolDefinitions.kt b/app/src/main/java/com/gotcha/tools/ToolDefinitions.kt
index abb3a26..554c779 100644
--- a/app/src/main/java/com/gotcha/tools/ToolDefinitions.kt
+++ b/app/src/main/java/com/gotcha/tools/ToolDefinitions.kt
@@ -1890,7 +1890,7 @@ object ToolDefinitions {
}
)
- // ---- Email connector tools (Settings → Connectors: Gmail BYO-OAuth or IMAP) ----
+ // ---- Email connector tools (menu ▸ Connectors: Gmail BYO-OAuth or IMAP) ----
val listEmails = tool(
"list_emails",
diff --git a/app/src/main/java/com/gotcha/ui/AppDrawer.kt b/app/src/main/java/com/gotcha/ui/AppDrawer.kt
index 6f5827e..fdbf159 100644
--- a/app/src/main/java/com/gotcha/ui/AppDrawer.kt
+++ b/app/src/main/java/com/gotcha/ui/AppDrawer.kt
@@ -10,6 +10,7 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
+import androidx.compose.material.icons.filled.Link
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material3.AlertDialog
@@ -42,6 +43,7 @@ fun AppDrawerContent(
onSessionClick: (String) -> Unit,
onDeleteSession: (String) -> Unit,
onOpenSettings: () -> Unit,
+ onOpenConnectors: () -> Unit,
maxContextTokens: Int = 0,
activeTokenCount: Int = 0
) {
@@ -105,6 +107,13 @@ fun AppDrawerContent(
}
}
HorizontalDivider()
+ NavigationDrawerItem(
+ label = { Text("Connectors") },
+ icon = { Icon(Icons.Default.Link, contentDescription = null) },
+ selected = false,
+ onClick = onOpenConnectors,
+ modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding)
+ )
NavigationDrawerItem(
label = { Text("Settings") },
icon = { Icon(Icons.Default.Settings, contentDescription = null) },
diff --git a/app/src/main/java/com/gotcha/ui/ConnectorCards.kt b/app/src/main/java/com/gotcha/ui/ConnectorCards.kt
index 221bcae..cc8e3a0 100644
--- a/app/src/main/java/com/gotcha/ui/ConnectorCards.kt
+++ b/app/src/main/java/com/gotcha/ui/ConnectorCards.kt
@@ -25,7 +25,7 @@ import com.gotcha.connectors.oauth.OAuthConnectFlow
import kotlinx.coroutines.launch
/**
- * The two reusable Settings → Connectors card shapes.
+ * The two reusable Connectors-screen card shapes.
*
* [TokenConnectorCard] — a set of text fields plus Connect/Disconnect, for
* connectors authenticated by a pasted secret (IMAP app password, Notion
@@ -63,7 +63,7 @@ fun TokenConnectorCard(
blurb: String? = null,
steps: List<String> = emptyList(),
canConnect: () -> Boolean = { fields.all { it.value.isNotBlank() } },
- aboveFields: @Composable () -> Unit = {},
+ /** Rendered between the fields and the Connect button (e.g. the Gmail preset shortcut). */
belowFields: @Composable () -> Unit = {}
) {
val scope = rememberCoroutineScope()
@@ -76,7 +76,6 @@ fun TokenConnectorCard(
key(refreshTick) { CardHeader(title, statusLine(), blurb, steps) }
if (!isConnected()) {
- aboveFields()
fields.forEach { field ->
OutlinedTextField(
value = field.value,
diff --git a/app/src/main/java/com/gotcha/ui/ConnectorsScreen.kt b/app/src/main/java/com/gotcha/ui/ConnectorsScreen.kt
new file mode 100644
index 0000000..bb11f7a
--- /dev/null
+++ b/app/src/main/java/com/gotcha/ui/ConnectorsScreen.kt
@@ -0,0 +1,52 @@
+package com.gotcha.ui
+
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Scaffold
+import androidx.compose.material3.Text
+import androidx.compose.material3.TextButton
+import androidx.compose.material3.TopAppBar
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.unit.dp
+
+/**
+ * Top-level Connectors screen, reached from the drawer alongside Settings.
+ * The cards themselves live in [ConnectorsSection]; connectors persist their
+ * own credentials, so there is nothing to save on the way out.
+ */
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+fun ConnectorsScreen(onBack: () -> Unit) {
+ Scaffold(
+ topBar = {
+ TopAppBar(
+ title = { Text("Connectors") },
+ navigationIcon = { TextButton(onClick = onBack) { Text("← Back") } }
+ )
+ }
+ ) { padding ->
+ Column(
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(padding)
+ .padding(16.dp)
+ .verticalScroll(rememberScrollState()),
+ verticalArrangement = Arrangement.spacedBy(12.dp)
+ ) {
+ Text(
+ "Connect your accounts so the assistant can read and act on your mail, " +
+ "calendars, tasks and notes.",
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ ConnectorsSection()
+ }
+ }
+}
diff --git a/app/src/main/java/com/gotcha/ui/ConnectorsSection.kt b/app/src/main/java/com/gotcha/ui/ConnectorsSection.kt
index 041898c..9af703b 100644
--- a/app/src/main/java/com/gotcha/ui/ConnectorsSection.kt
+++ b/app/src/main/java/com/gotcha/ui/ConnectorsSection.kt
@@ -31,9 +31,9 @@ import com.gotcha.connectors.notion.NotionConnector
import com.gotcha.connectors.oauth.OAuthConnectFlow
/**
- * Settings → Connectors: one card per connector, built from the two reusable
- * shapes in ConnectorCards.kt. Talks to [ConnectorRegistry] directly since
- * connectors own their own credential storage — there is nothing for the
+ * The body of the Connectors screen: one card per connector, built from the two
+ * reusable shapes in ConnectorCards.kt. Talks to [ConnectorRegistry] directly
+ * since connectors own their own credential storage — there is nothing for the
* Settings/SettingsRepository layer to persist.
*/
@Composable
@@ -102,7 +102,7 @@ private fun ImapCard(imap: ImapConnector) {
"Google Account ▸ Security ▸ 2-Step Verification ▸ App passwords.",
"Other providers: check their IMAP app-password documentation."
),
- aboveFields = {
+ belowFields = {
TextButton(onClick = {
imapHost.value = "imap.gmail.com"
imapPort.value = "993"
diff --git a/app/src/main/java/com/gotcha/ui/SettingsScreen.kt b/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
index d969587..d80fdb1 100644
--- a/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
+++ b/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
@@ -125,7 +125,6 @@ fun SettingsScreen(
var refreshingChatModels by remember { mutableStateOf(false) }
// Collapsible sections
var aiConfigExpanded by remember { mutableStateOf(false) }
- var connectorsExpanded by remember { mutableStateOf(false) }
var speechExpanded by remember { mutableStateOf(false) }
var skillsExpanded by remember { mutableStateOf(false) }
var proactiveExpanded by remember { mutableStateOf(false) }
@@ -595,18 +594,6 @@ fun SettingsScreen(
HorizontalDivider(thickness = 1.dp)
- // ---- Connectors (collapsible, collapsed by default) ----
- SectionHeader(
- title = "Connectors",
- expanded = connectorsExpanded,
- onToggle = { connectorsExpanded = !connectorsExpanded }
- )
- AnimatedVisibility(visible = connectorsExpanded) {
- ConnectorsSection()
- }
-
- HorizontalDivider(thickness = 1.dp)
-
// ---- Speech (collapsible, collapsed by default) ----
SectionHeader(
title = "Speech (TTS / STT)",