Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

fix(android): keep shortcut calls and shared text safe across cold starts, and translate the new pages

leepokai43dfeb865d8e
diff --git a/apps/android/app/src/androidTest/kotlin/com/codync/android/AccountScreenTest.kt b/apps/android/app/src/androidTest/kotlin/com/codync/android/AccountScreenTest.kt
index b768e3e1..1443997c 100644
--- a/apps/android/app/src/androidTest/kotlin/com/codync/android/AccountScreenTest.kt
+++ b/apps/android/app/src/androidTest/kotlin/com/codync/android/AccountScreenTest.kt
@@ -142,7 +142,7 @@ class AccountScreenTest {
@Test fun theSettingsTabHoldsOnlyThisPhonesSettingsAndKeepsResetBehindAConfirmation() {
val state = fixture().copy(computers = listOf(computer))
- compose.setContent { Hosted { SettingsView(state, viewModel(), 0.dp) } }
+ compose.setContent { Hosted { SettingsView(state, emptyList(), viewModel(), 0.dp) } }
compose.onNodeWithText("Settings").assertIsDisplayed()
listOf("Pair a computer", "Hidden scout", "Push notifications", "Voice chat").forEach { compose.onNodeWithText(it).assertDoesNotExist() }
if (!BuildConfig.PUSH_CONFIGURED) compose.onNodeWithText("Push isn't set up in this build. Bots and chats still update while Codync is open.").performScrollTo().assertIsDisplayed()
diff --git a/apps/android/app/src/androidTest/kotlin/com/codync/android/ComputerRosterTest.kt b/apps/android/app/src/androidTest/kotlin/com/codync/android/ComputerRosterTest.kt
index 7ee95e69..7801ea6b 100644
--- a/apps/android/app/src/androidTest/kotlin/com/codync/android/ComputerRosterTest.kt
+++ b/apps/android/app/src/androidTest/kotlin/com/codync/android/ComputerRosterTest.kt
@@ -1,6 +1,8 @@
package com.codync.android
import androidx.activity.ComponentActivity
+import androidx.compose.runtime.collectAsState
+import androidx.compose.runtime.getValue
import androidx.compose.ui.test.*
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.unit.dp
@@ -69,11 +71,10 @@ class ComputerRosterTest {
accounts.close(linux.id)
}
assertTrue(accounts.state.value.removedChat)
+ // The account's own state, as the app shows it: Back clears it there.
compose.setContent {
- Hosted {
- MainTabs(app.copy(computers = listOf(mac), removedChat = true), listOf(state(mac, "Mac bot")), accounts, {}, {}, {}, {}, {},
- { _, _ -> }, {}, covered = true) {}
- }
+ val live by accounts.state.collectAsState()
+ Hosted { MainTabs(live, listOf(state(mac, "Mac bot")), accounts, {}, {}, {}, {}, {}, { _, _ -> }, {}, covered = true) {} }
}
compose.onNodeWithText("This computer was removed").assertIsDisplayed()
compose.onNodeWithContentDescription("Back").performClick()
diff --git a/apps/android/app/src/androidTest/kotlin/com/codync/android/LocalStoreTest.kt b/apps/android/app/src/androidTest/kotlin/com/codync/android/LocalStoreTest.kt
index 7624005d..16307dd0 100644
--- a/apps/android/app/src/androidTest/kotlin/com/codync/android/LocalStoreTest.kt
+++ b/apps/android/app/src/androidTest/kotlin/com/codync/android/LocalStoreTest.kt
@@ -9,6 +9,7 @@ import kotlinx.serialization.json.jsonPrimitive
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotEquals
+import org.junit.Assert.assertNull
import org.junit.Test
import org.junit.runner.RunWith
@@ -30,6 +31,18 @@ class LocalStoreTest {
} finally { store.erase() }
}
+ @Test fun theShortcutsLeadIsSavedPerAccountAndAutomaticIsNone() {
+ val context = InstrumentationRegistry.getInstrumentation().targetContext
+ val store = LocalStore(context, "test-${java.util.UUID.randomUUID()}")
+ try {
+ assertNull(store.shortcutLead())
+ store.saveShortcutLead("linux")
+ assertEquals("linux", store.shortcutLead())
+ store.saveShortcutLead(null)
+ assertNull(store.shortcutLead())
+ } finally { store.erase() }
+ }
+
@Test fun cryptoOpensTheSharedPushVectorOnAndroidWithoutARegisteredProvider() {
val assets = InstrumentationRegistry.getInstrumentation().context.assets
val fixture = assets.open("remote-relay-vectors.json").bufferedReader().use { Json.parseToJsonElement(it.readText()).jsonObject }
diff --git a/apps/android/app/src/androidTest/kotlin/com/codync/android/ShortcutAndShareTest.kt b/apps/android/app/src/androidTest/kotlin/com/codync/android/ShortcutAndShareTest.kt
new file mode 100644
index 00000000..0b476ac7
--- /dev/null
+++ b/apps/android/app/src/androidTest/kotlin/com/codync/android/ShortcutAndShareTest.kt
@@ -0,0 +1,98 @@
+package com.codync.android
+
+import androidx.activity.ComponentActivity
+import androidx.compose.ui.test.junit4.createAndroidComposeRule
+import com.codync.android.core.*
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.flow.update
+import kotlinx.coroutines.runBlocking
+import kotlinx.coroutines.withTimeout
+import org.junit.Assert.*
+import org.junit.Rule
+import org.junit.Test
+
+/**
+ * "Talk to Codync" and text shared from another app (iOS `LiveShortcutNavigationTests`): which chat opens, when its call
+ * starts and when it never does, and where the text goes. Nothing links: the test says when a computer is connected.
+ */
+class ShortcutAndShareTest {
+ @get:Rule val compose = createAndroidComposeRule<ComponentActivity>()
+ private val mac = Computer("shortcut-test-mac-0001", "Mac fixture", "mac")
+ private val linux = Computer("shortcut-test-linux-01", "Linux fixture", "linux")
+
+ private fun connect(store: AppStore) = store.mutableState.update { it.copy(actualConnection = LinkState.Ready(HostRoute.Direct)) }
+
+ @Test fun leavingTheChatDropsItsCallWhetherItWaitsForTheComputerOrForTheChat() = runBlocking(Dispatchers.Main) {
+ for (openAnother in listOf(false, true)) {
+ val store = previewStore(mac)
+ fun leaveAndReturn() { store.openBot(if (openAnother) "other" else null); store.openBot("lead") }
+ store.openBot("lead")
+ store.requestCall("lead")
+ leaveAndReturn()
+ connect(store)
+ store.callWait?.join()
+ assertFalse(store.takeCallRequest("lead"))
+ // A new one starts, once.
+ store.requestCall("lead"); store.callWait?.join()
+ assertTrue(store.takeCallRequest("lead"))
+ assertFalse(store.takeCallRequest("lead"))
+ // One the chat hasn't taken yet goes the same way.
+ store.requestCall("lead"); store.callWait?.join()
+ leaveAndReturn()
+ assertFalse(store.takeCallRequest("lead"))
+ store.openBot(null)
+ }
+ }
+
+ @Test fun aComputerThatCantBeReachedIsAnErrorNotACall() = runBlocking(Dispatchers.Main) {
+ val store = previewStore(mac)
+ store.openBot("lead")
+ store.requestCall("lead")
+ withTimeout(25_000) { store.callWait?.join() }
+ assertEquals("Can't reach the computer. Check that it's on, then try again.", store.state.value.error)
+ assertFalse(store.takeCallRequest("lead"))
+ }
+
+ @Test fun talkToCodyncOpensThePickedLeadsChatAndCallsOnceItsComputerIsConnected() = compose.withPreviewAccounts(mac, linux) { accounts ->
+ val previous = accounts.state.value.shortcutLeadComputer
+ val store = requireNotNull(accounts.store(linux.id))
+ try {
+ runBlocking(Dispatchers.Main) {
+ activate(accounts)
+ requireNotNull(accounts.store(mac.id)).mutableState.update { it.copy(bots = listOf(Bot("lead-mac", "Mac lead", lead = true))) }
+ store.mutableState.update { it.copy(bots = listOf(Bot("lead-linux", "Linux lead", lead = true))) }
+ accounts.chooseShortcutLead(linux.id)
+ accounts.talkToLead()
+ withTimeout(10_000) { accounts.linkJob?.join() }
+ assertEquals(LinkPage.Bots, accounts.state.value.navigationPage)
+ assertEquals("lead-linux", store.state.value.selectedBot)
+ assertNull(requireNotNull(accounts.store(mac.id)).state.value.selectedBot)
+ assertNull(store.state.value.callRequest)
+ connect(store); store.callWait?.join()
+ assertEquals("lead-linux", store.state.value.callRequest)
+ // Back drops a call the chat didn't take.
+ accounts.openBot(null)
+ assertNull(store.state.value.callRequest)
+ }
+ } finally { runBlocking(Dispatchers.Main) { accounts.chooseShortcutLead(previous) } }
+ }
+
+ @Test fun sharedTextGoesAfterTheTypedTextAndOpensThatChat() = compose.withPreviewAccounts(mac, linux) { accounts ->
+ val store = requireNotNull(accounts.store(linux.id))
+ runBlocking(Dispatchers.Main) {
+ activate(accounts)
+ store.editDraft("bot", "typed")
+ accounts.share("shared")
+ withTimeout(10_000) { accounts.linkJob?.join() }
+ assertEquals("shared", accounts.state.value.sharing)
+ accounts.sendShared(BotDestination(accounts.state.value.contextId, linux.id, "bot"))
+ assertEquals("typed shared", store.state.value.drafts["bot"]?.text)
+ assertEquals("bot", store.state.value.selectedBot)
+ assertNull(accounts.state.value.sharing)
+ accounts.openBot(null)
+ }
+ }
+
+ /** The test activity doesn't start sign-in: the account it has is ready, as links wait for (`activated`). */
+ private fun activate(accounts: AccountStore) = accounts.mutableState.update { it.copy(account = it.account.copy(ready = true)) }
+}
diff --git a/apps/android/app/src/main/AndroidManifest.xml b/apps/android/app/src/main/AndroidManifest.xml
index 3168f979..eab6a096 100644
--- a/apps/android/app/src/main/AndroidManifest.xml
+++ b/apps/android/app/src/main/AndroidManifest.xml
@@ -74,6 +74,16 @@
<activity android:name=".WidgetConfigurationActivity" android:exported="true">
<intent-filter><action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" /></intent-filter>
</activity>
+ <!-- Text shared from another app goes to a bot's message box (the iPhone's Send Text to Bot). The share sheet
+ starts this in the sender's task; it hands the text to MainActivity in Codync's own and closes. -->
+ <activity android:name=".ShareActivity" android:exported="true" android:theme="@android:style/Theme.NoDisplay"
+ android:taskAffinity="" android:excludeFromRecents="true">
+ <intent-filter>
+ <action android:name="android.intent.action.SEND" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:mimeType="text/plain" />
+ </intent-filter>
+ </activity>
<!-- Direct ws:// channels already encrypt every inner request with Codync E2E.
Core accepts HTTP only for validated direct candidates; cloud remains HTTPS. -->
<!-- Portrait on phones, as on iPhone, except while the screen viewer is open (ScreenView);
@@ -85,12 +95,6 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
- <!-- Text shared from another app goes to a bot's message box (the iPhone's Send Text to Bot). -->
- <intent-filter>
- <action android:name="android.intent.action.SEND" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="text/plain" />
- </intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AccountStore.kt b/apps/android/app/src/main/kotlin/com/codync/android/AccountStore.kt
index 65730cde..c95fa7aa 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AccountStore.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AccountStore.kt
@@ -88,8 +88,8 @@ class AccountStore(application: Application) : AndroidViewModel(application) {
withContext(Dispatchers.IO) { AttachmentFiles(getApplication(), local.directory).retainPending(stores.value.flatMap { it.pendingFiles() }) }
if (userId != null) configureCloud(userId)
mutableState.update { it.copy(loading = false) }
- LiveShortcut.publish(getApplication(), computers.isNotEmpty())
observeWidgets(requireNotNull(widgetOwner))
+ observeShortcut()
refreshCloud()
} catch (error: CancellationException) { throw error }
catch (error: Exception) { showError(error) }
@@ -151,7 +151,6 @@ class AccountStore(application: Application) : AndroidViewModel(application) {
DraftBook.delete(local.directory, id)
}
mutableState.update { it.copy(computers = computers) }
- LiveShortcut.publish(getApplication(), computers.isNotEmpty())
}
}
@@ -161,7 +160,6 @@ class AccountStore(application: Application) : AndroidViewModel(application) {
val computers = if (saved.any { it.id == computer.id }) saved.map { if (it.id == computer.id) computer else it } else saved + computer
withContext(Dispatchers.IO) { local.saveComputers(computers) }
mutableState.update { it.copy(computers = computers) }
- LiveShortcut.publish(getApplication(), true)
}
/**
@@ -273,6 +271,14 @@ class AccountStore(application: Application) : AndroidViewModel(application) {
}
}
+ /** The app icon's "Talk to Codync" is there while a computer is paired. */
+ private fun observeShortcut() {
+ contextScope.launch {
+ state.filter { !it.loading }.map { it.computers.isNotEmpty() }.distinctUntilChanged()
+ .collect { paired -> withContext(Dispatchers.IO) { LiveShortcut.publish(getApplication(), paired) } }
+ }
+ }
+
/** A usage read just finished on [store]: the Usage widget shows it as fresh when that's its computer. */
private suspend fun publishUsage(store: AppStore) {
val owner = widgetOwner ?: return
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AccountStoreLinks.kt b/apps/android/app/src/main/kotlin/com/codync/android/AccountStoreLinks.kt
index 293cecc3..34922b81 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AccountStoreLinks.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AccountStoreLinks.kt
@@ -97,24 +97,44 @@ fun AccountStore.openLink(uri: Uri) {
}
}
-/** Text another app shared waits for a bot to go to (`ShareToBot`), once the account has loaded. */
-fun AccountStore.share(text: String) {
+/**
+ * Runs [open] once the account has loaded, in place of any link still waiting; it outlives a context switch on the way
+ * (the signed-in account loading after the local one), and a link the account doesn't load for in time is dropped.
+ */
+private fun AccountStore.whenActivated(open: (AccountContext) -> Unit) {
linkJob?.cancel()
- linkJob = viewModelScope.launch {
- withTimeoutOrNull(30_000) { activated() } ?: return@launch
- navigate(LinkPage.Bots)
- mutableState.update { it.copy(sharing = text) }
- }
+ linkJob = viewModelScope.launch { withTimeoutOrNull(30_000) { activated() }?.let(open) }
+}
+
+/** Text another app shared waits for a bot to go to (`ShareToBot`), once the account has loaded. */
+fun AccountStore.share(text: String) = whenActivated {
+ navigate(LinkPage.Bots)
+ mutableState.update { it.copy(sharing = text) }
+}
+
+/** The shared text goes after what's in [to]'s message box, and its chat opens. */
+fun AccountStore.sendShared(to: BotDestination) {
+ val text = state.value.sharing ?: return
+ store(to.computerId)?.appendDraft(to.botId, text)
+ openBot(to)
+ finishSharing()
}
fun AccountStore.finishSharing() = mutableState.update { it.copy(sharing = null) }
+/**
+ * The app icon's "Talk to Codync" (`LiveShortcut`): the lead's chat, with a call once its computer is connected, as Open
+ * Live Mode without a bot does (`requestCall`); with no lead (deleted, not synced yet), Bots to pick one.
+ */
+fun AccountStore.talkToLead() = whenActivated { ready ->
+ navigate(LinkPage.Bots)
+ val (state, lead) = shortcutLead(stores.value.map { it.state.value }, ready.shortcutLeadComputer) ?: return@whenActivated
+ val store = store(state.computer.id) ?: return@whenActivated
+ store.openBot(lead.id)
+ store.requestCall(lead.id)
+}
+
/** `codync://computers` and `codync://plugins`: Computer management, or the last active computer's extensions, over the roster. */
-fun AccountStore.openPage(page: LinkPage) {
- linkJob?.cancel()
- linkJob = viewModelScope.launch {
- val ready = withTimeoutOrNull(30_000) { activated() } ?: return@launch
- if (page == LinkPage.Extensions && ready.computers.isEmpty()) return@launch
- navigate(page)
- }
+fun AccountStore.openPage(page: LinkPage) = whenActivated { ready ->
+ if (page != LinkPage.Extensions || ready.computers.isNotEmpty()) navigate(page)
}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppStore.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppStore.kt
index df7f4fcf..04c6efdd 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AppStore.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppStore.kt
@@ -54,6 +54,8 @@ class AppStore internal constructor(
internal var oauthRequestId: String? = null
internal var voiceBinding: VoiceBinding? = null
internal var voiceGeneration: Int? = null
+ /** A "Talk to Codync" call waiting for the link (`requestCall`). */
+ internal var callWait: Job? = null
internal val transportRequired: Boolean get() = foreground || state.value.voice != null
internal val sends = mutableSetOf<String>()
internal val actions = mutableMapOf<String, Job>()
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreBots.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreBots.kt
index ea2c1e8b..430a8337 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreBots.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreBots.kt
@@ -14,18 +14,23 @@ fun AppStore.command(method: String, body: JsonObject = JsonObject(emptyMap()),
val response = try { ready().call(method, body) }
catch (error: CancellationException) { throw error }
catch (error: Exception) { onFailure(); throw error }
- response.jsonObject["bot"]?.let { value ->
- withContext(Dispatchers.IO) { requireNotNull(database).receive(HostClient.decode(value.jsonObject)) }
- }
- response.jsonObject["entry"]?.let { value ->
- withContext(Dispatchers.IO) { requireNotNull(database).receive(listOf(Entry.decode(value.jsonObject))) }
- }
- refresh()
+ receiveReply(response)
onSuccess()
}
if (!started) onFailure()
}
+/** Takes in the bot or entry a command's reply carries, then shows it. */
+private suspend fun AppStore.receiveReply(response: JsonElement) {
+ response.jsonObject["bot"]?.let { value ->
+ withContext(Dispatchers.IO) { requireNotNull(database).receive(HostClient.decode(value.jsonObject)) }
+ }
+ response.jsonObject["entry"]?.let { value ->
+ withContext(Dispatchers.IO) { requireNotNull(database).receive(listOf(Entry.decode(value.jsonObject))) }
+ }
+ refresh()
+}
+
/** Moves a bot into the roster section [section], or out of any (null). */
fun AppStore.setSection(botId: String, section: String?) = moveSections(listOf(botId), section, "updateBot", sectionUpdate(botId, section))
@@ -69,9 +74,7 @@ fun AppStore.saveBot(draft: BotDraft, onSaved: () -> Unit) = action("editor") {
/** A saved bot's settings from its details, saved as they're edited; [done] gets the error, or null once it took. */
fun AppStore.saveSettings(draft: BotDraft, done: (String?) -> Unit) = action("settings:" + draft.id) {
try {
- val result = ready().call("updateBot", draft.body())
- result.jsonObject["bot"]?.let { withContext(Dispatchers.IO) { requireNotNull(database).receive(HostClient.decode(it.jsonObject)) } }
- refresh()
+ receiveReply(ready().call("updateBot", draft.body()))
done(null)
} catch (cancelled: CancellationException) { throw cancelled }
catch (error: Exception) { done(error.message ?: "Couldn't save the changes.") }
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreChat.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreChat.kt
index 991bb8be..c69c3487 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreChat.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreChat.kt
@@ -12,23 +12,34 @@ import kotlinx.serialization.json.*
/** Opens a chat on this computer (the account closes any other computer's) or, with null, closes it. */
fun AppStore.openBot(id: String?) {
if (id == null && state.value.selectedBot == null) return
- mutableState.update { it.copy(selectedBot = id, trace = false) }
+ // Leaving a chat drops the call "Talk to Codync" asked for there, waiting or not (iOS `cancelVoiceCallRequest`).
+ val leaving = id != state.value.selectedBot
+ if (leaving) callWait?.cancel()
+ mutableState.update { it.copy(selectedBot = id, trace = false, callRequest = it.callRequest.takeUnless { leaving }) }
if (id != null) { opened(this); acknowledgeVisible() }
}
fun AppStore.showTrace(show: Boolean) { mutableState.update { it.copy(trace = show) } }
-/** Starts a call in [botId]'s chat once it shows; the chat takes it (`takeCallRequest`). */
-fun AppStore.requestCall(botId: String) { mutableState.update { it.copy(callRequest = botId) } }
+/**
+ * Starts a call in [botId]'s open chat once this computer is connected (iOS `requestVoiceCall`); the chat takes it
+ * (`takeCallRequest`). A computer that can't be reached is an error instead.
+ */
+fun AppStore.requestCall(botId: String) {
+ callWait?.cancel()
+ callWait = contextScope.launch {
+ val connected = withTimeoutOrNull(20_000) { state.first { it.actualConnection is LinkState.Ready } }
+ if (connected == null) showError(IOException("Can't reach the computer. Check that it's on, then try again."))
+ else mutableState.update { it.copy(callRequest = botId) }
+ }
+}
+
+/** Once: a chat that already has a call takes it too, so it can't start one later. */
fun AppStore.takeCallRequest(botId: String): Boolean {
if (state.value.callRequest != botId) return false
mutableState.update { it.copy(callRequest = null) }
return true
}
-/** Puts [text] after what's in [botId]'s message box (text shared from another app). */
-fun AppStore.appendDraft(botId: String, text: String) =
- editDraft(botId, com.codync.android.core.DictationText.join(state.value.drafts[botId]?.text.orEmpty(), text))
-
/** The chat being read (iOS `ReadingConversation`): the open one, still on screen under Full conversation. */
internal val AppState.readingChats: List<String> get() = listOfNotNull(selectedBot)
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreDrafts.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreDrafts.kt
index 6dcf66f0..a1d55a14 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreDrafts.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreDrafts.kt
@@ -2,6 +2,9 @@ package com.codync.android
import android.net.Uri
import java.io.File
+import java.nio.ByteBuffer
+import java.nio.CharBuffer
+import java.nio.charset.CodingErrorAction
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import com.codync.android.core.*
@@ -19,6 +22,18 @@ fun AppStore.editDraft(botId: String, text: String) {
catch (error: Exception) { showError(error) }
}
+/** Puts [text] after what's in [botId]'s message box (text shared from another app), as much of it as the box holds. */
+fun AppStore.appendDraft(botId: String, text: String) = editDraft(botId, sharedDraft(state.value.drafts[botId]?.text.orEmpty(), text))
+
+/** [shared] after [before], cut at a character's edge to the most a draft holds (`DraftBook.TEXT_BYTES` of UTF-8). */
+internal fun sharedDraft(before: String, shared: String): String {
+ val joined = DictationText.join(before, shared)
+ val input = CharBuffer.wrap(joined)
+ // The encoder stops before the first character that doesn't fit, never inside one; a lone surrogate counts as the '?' it's saved as.
+ Charsets.UTF_8.newEncoder().onMalformedInput(CodingErrorAction.REPLACE).encode(input, ByteBuffer.allocate(DraftBook.TEXT_BYTES), true)
+ return joined.substring(0, input.position())
+}
+
fun AppStore.addDraftFiles(botId: String, files: List<OutgoingFile>) {
check(!state.value.loading) { "Wait for the account to finish opening before adding files." }
val current = state.value.drafts[botId] ?: ComposerDraft(botId)
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/BotDetailsView.kt b/apps/android/app/src/main/kotlin/com/codync/android/BotDetailsView.kt
index 8fd9029c..8e4a9428 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/BotDetailsView.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/BotDetailsView.kt
@@ -15,6 +15,7 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
+import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -33,6 +34,7 @@ import com.codync.android.core.LinkState
import com.codync.android.core.ScreenState
import com.codync.android.core.hasLibrary
import com.codync.android.design.*
+import java.io.IOException
import kotlinx.coroutines.delay
/** The details sheet's pages, as on the desktop inspector (iOS `BotDetailsView.Tab`). */
@@ -58,14 +60,17 @@ internal data class DetailsRequest(val tab: DetailsTab = DetailsTab.Details, val
var draft by rememberBotDraft(saved, state)
var template by remember { mutableStateOf<BotDraft?>(null) }
val online = state.actualConnection is LinkState.Ready
+ // What the last save said, on the page where it was made (iOS `saveError`); one that fails after the page closed
+ // shows over the app instead.
+ var saveError by remember(bot.id) { mutableStateOf<String?>(null) }
+ val shown = remember { mutableStateOf(true) }
+ DisposableEffect(Unit) { onDispose { shown.value = false } }
// Saves a moment after the last change, like the desktop inspector. Keyed on the saved bot too: an edit made while
// the previous save was still out (and so skipped) is sent once that save lands.
- // What the last save said, shown on the page where it was made (iOS `saveError`), not over the app.
- var saveError by remember(bot.id) { mutableStateOf<String?>(null) }
LaunchedEffect(draft, online, saved) {
if (!online || !draft.isValid || draft == saved) return@LaunchedEffect
delay(600)
- store.saveSettings(draft) { saveError = it }
+ store.saveSettings(draft) { error -> if (shown.value) saveError = error else error?.let { store.showError(IOException(it)) } }
}
val tabs = listOfNotNull(DetailsTab.Details, DetailsTab.Library.takeIf { hasLibrary(state.hello?.text("version")) }, DetailsTab.Memory, DetailsTab.Settings)
Box(Modifier.fillMaxSize().background(Palette.background)) {
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/BotSettingsForm.kt b/apps/android/app/src/main/kotlin/com/codync/android/BotSettingsForm.kt
index d1b440f4..f3be51e0 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/BotSettingsForm.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/BotSettingsForm.kt
@@ -62,7 +62,6 @@ internal enum class FormPart { All, Often, Rarely }
notifyRow(draft, change); computerUseRow(state, draft, change); manageTeamRow(state, draft, change); reachRows(state, draft, change)
}
Plugins(state, draft, change) { viewingSkill = it }
- error?.let { Text(tr(it), style = Type.footnote, color = Palette.danger) }
}
FormPart.Often -> {
CardSection("Instructions") { instructionsRow(draft, change) }
@@ -71,8 +70,6 @@ internal enum class FormPart { All, Often, Rarely }
agentRows(state, store, draft, change, bot) { addingFallback = true }
if (!online) row { OfflineNote() }
}
- // A save that didn't take, where it was made (iOS `saveError`).
- error?.let { Text(tr(it), style = Type.footnote, color = Palette.danger) }
}
FormPart.Rarely -> {
CardSection("Profile") {
@@ -83,9 +80,10 @@ internal enum class FormPart { All, Often, Rarely }
CardSection("Workspace") { computerRow(state, online); placeRows(draft, change) { folders = true } }
CardSection("Activity") { notifyRow(draft, change); manageTeamRow(state, draft, change); reachRows(state, draft, change) }
Plugins(state, draft, change) { viewingSkill = it }
- error?.let { Text(tr(it), style = Type.footnote, color = Palette.danger) }
}
}
+ // A save that didn't take, under the form (iOS `error`).
+ error?.let { Text(tr(it), style = Type.footnote, color = Palette.danger) }
}
CodyncSheet(folders, { folders = false }) {
FolderPicker(draft.cwd.ifEmpty { state.hello?.get("home")?.jsonPrimitive?.contentOrNull }, online, state.hello?.get("name")?.jsonPrimitive?.contentOrNull ?: "Computer", store::listDirs, store::selectWorkspace) {
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/ChatScreen.kt b/apps/android/app/src/main/kotlin/com/codync/android/ChatScreen.kt
index 23f86904..066def95 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/ChatScreen.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/ChatScreen.kt
@@ -87,8 +87,8 @@ import com.kyant.shapes.Capsule
var connector by remember { mutableStateOf<MarketConnector?>(null) }
val connect = ConnectionRequestActions({ id, item -> setupEntry = id; app = item }, { id, item -> setupEntry = id; connector = item })
val startCall = rememberStartVoice(bot.id, state, store) { micDenied = true }
- // "Talk to Codync" asked for a call here.
- LaunchedEffect(state.callRequest) { if (state.voice == null && store.takeCallRequest(bot.id)) startCall() }
+ // "Talk to Codync" asked for a call here: taken even during a call, so it can't start one after it.
+ LaunchedEffect(state.callRequest) { if (store.takeCallRequest(bot.id) && state.voice == null) startCall() }
val top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
var composerHeight by remember { mutableIntStateOf(0) }
val density = LocalDensity.current
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/DraftBook.kt b/apps/android/app/src/main/kotlin/com/codync/android/DraftBook.kt
index 6de9238b..a0c69568 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/DraftBook.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/DraftBook.kt
@@ -58,7 +58,7 @@ class DraftBook(private val directory: File, computerId: String) {
for (draft in drafts) {
require(draft.botId.isNotBlank() && draft.botId.length <= 128)
require(UUID.fromString(draft.nonce).toString() == draft.nonce) { "A saved draft has an invalid message ID." }
- require(draft.text.toByteArray().size <= 64 * 1024) { "Draft messages must be 64 KiB or smaller." }
+ require(draft.text.toByteArray().size <= TEXT_BYTES) { "Draft messages must be 64 KiB or smaller." }
require(draft.files.size <= 20) { "Choose at most 20 files for one message." }
for (attachment in draft.files) {
require(attachment.size in 0..MAX_FILE_BYTES && attachment.name.isNotBlank())
@@ -69,6 +69,8 @@ class DraftBook(private val directory: File, computerId: String) {
companion object {
private const val MAX_BYTES = 8 * 1024 * 1024
+ /** The most UTF-8 a draft's message holds. */
+ const val TEXT_BYTES = 64 * 1024
private fun bookFile(directory: File, computerId: String): AtomicFile {
require(computerId.matches(Regex("[A-Za-z0-9_-]{22}")))
return AtomicFile(File(directory, "drafts-$computerId.json"))
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/LiveShortcut.kt b/apps/android/app/src/main/kotlin/com/codync/android/LiveShortcut.kt
index 1971a7e7..6f2a568f 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/LiveShortcut.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/LiveShortcut.kt
@@ -2,22 +2,17 @@ package com.codync.android
import android.content.Context
import android.content.Intent
-import androidx.compose.runtime.Composable
+import android.util.Log
import androidx.core.content.pm.ShortcutInfoCompat
import androidx.core.content.pm.ShortcutManagerCompat
import androidx.core.graphics.drawable.IconCompat
import com.codync.android.core.Bot
-import com.codync.android.core.BotDestination
-import com.codync.android.core.LinkState
-import com.codync.android.design.*
-import kotlinx.coroutines.flow.first
+import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
-import kotlinx.coroutines.withTimeoutOrNull
-// Android's counterparts of the iPhone's Shortcuts actions (docs/features/ios-shortcuts.md): "Talk to Codync" in the
-// app icon's shortcuts calls the lead bot like Open Live Mode, and text shared from another app goes to a bot's
-// message box like Send Text to Bot with Open Chat on.
+// "Talk to Codync" in the app icon's shortcuts: Android's counterpart of the iPhone's Open Live Mode without a bot
+// (docs/features/ios-shortcuts.md). It calls a computer's lead (`talkToLead`); Settings picks whose (`ShortcutLeadSettings`).
/** The app icon's "Talk to Codync" shortcut. */
internal object LiveShortcut {
@@ -25,90 +20,32 @@ internal object LiveShortcut {
/** Published while a computer is paired; the launcher keeps it until the next account without one. */
fun publish(context: Context, paired: Boolean) {
- if (!paired) { ShortcutManagerCompat.removeDynamicShortcuts(context, listOf(ID)); return }
- val shortcut = ShortcutInfoCompat.Builder(context, ID).setShortLabel(context.getString(R.string.talk_shortcut))
- .setIcon(IconCompat.createWithResource(context, com.codync.android.design.R.drawable.sf_waveform))
- .setIntent(Intent(ACTION).setClass(context, MainActivity::class.java)).build()
- runCatching { ShortcutManagerCompat.pushDynamicShortcut(context, shortcut) }
+ // The launcher refuses shortcuts while the phone is still locked after a restart: the shortcut is a convenience,
+ // so the app goes on without it until the next publish.
+ runCatching {
+ if (!paired) ShortcutManagerCompat.removeDynamicShortcuts(context, listOf(ID))
+ else ShortcutManagerCompat.pushDynamicShortcut(context, ShortcutInfoCompat.Builder(context, ID)
+ .setShortLabel(context.getString(R.string.talk_shortcut))
+ .setIcon(IconCompat.createWithResource(context, com.codync.android.design.R.drawable.sf_waveform))
+ // Into Codync's own task and its one MainActivity, as the widgets open it.
+ .setIntent(Intent(ACTION).setClass(context, MainActivity::class.java)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)).build())
+ }.onFailure { Log.w("Codync", "Couldn't publish the Talk to Codync shortcut", it) }
}
private const val ID = "talk"
}
-/** The lead the shortcut calls: the one on the computer picked in Settings, else the first computer's in the user's order that has one (iOS `ShortcutBotQuery.lead`). */
-internal fun shortcutLead(computers: List<AppState>, chosen: String?): Pair<AppState, Bot>? {
- val leads = computers.mapNotNull { state -> state.bots.firstOrNull { it.lead && !it.deleted }?.let { state to it } }
- return leads.firstOrNull { it.first.computer.id == chosen } ?: leads.firstOrNull()
-}
+/** Each computer's lead, in the user's computer order. */
+internal fun leads(computers: List<AppState>): List<Pair<AppState, Bot>> =
+ computers.mapNotNull { state -> state.bots.firstOrNull { it.lead && !it.deleted }?.let { state to it } }
-/**
- * Opens the lead's chat and starts a call once its computer is connected, as Open Live Mode without a bot does;
- * with no lead (deleted, not synced yet) it opens Bots to pick one, and an unreachable computer is an error.
- */
-fun AccountStore.talkToLead() {
- linkJob?.cancel()
- linkJob = contextScope.launch {
- val ready = withTimeoutOrNull(30_000) { activated() } ?: return@launch
- val (state, lead) = shortcutLead(ready.computers.mapNotNull { store(it.id)?.state?.value }, ready.shortcutLeadComputer)
- ?: return@launch openPage(LinkPage.Bots)
- val store = store(state.computer.id) ?: return@launch
- openBot(BotDestination(ready.contextId, store.id, lead.id))
- val connected = withTimeoutOrNull(20_000) { store.state.first { it.actualConnection is LinkState.Ready } }
- if (connected == null) store.showError(java.io.IOException("Can't reach the computer. Check that it's on, then try again."))
- else store.requestCall(lead.id)
- }
-}
+/** The lead the shortcut calls: the one on the computer picked in Settings, else the first computer's in the user's order that has one (iOS `ShortcutBotQuery.lead`). */
+internal fun shortcutLead(computers: List<AppState>, chosen: String?): Pair<AppState, Bot>? =
+ leads(computers).let { all -> all.firstOrNull { it.first.computer.id == chosen } ?: all.firstOrNull() }
/** Saved per account, like the iPhone's `shortcutLeadComputer`; null is Automatic. */
fun AccountStore.chooseShortcutLead(computerId: String?) {
mutableState.update { it.copy(shortcutLeadComputer = computerId) }
- contextScope.launch(kotlinx.coroutines.Dispatchers.IO) { local.saveShortcutLead(computerId) }
-}
-
-/**
- * Settings' Shortcuts card (iOS `ShortcutLeadSettings`): which lead "Talk to Codync" calls, shown once more than one
- * computer has a lead. A computer whose lead is gone shows as Automatic, which is what the shortcut does then.
- */
-@Composable internal fun ShortcutLeadSettings(app: AccountContext, states: List<AppState>, accounts: AccountStore) {
- val leads = states.mapNotNull { state -> state.bots.firstOrNull { it.lead && !it.deleted }?.let { state to it } }
- if (leads.size < 2) return
- val chosen = app.shortcutLeadComputer?.takeIf { id -> leads.any { it.first.computer.id == id } }.orEmpty()
- CardSection("Shortcuts", footer = "Talk to Codync, in the app icon's shortcuts, calls this lead. Automatic calls the lead of the first computer in your list.") {
- row {
- ValueRow("Lead to call") {
- ChoicePicker(chosen, listOf("" to tr("Automatic")) + leads.map { (state, bot) -> state.computer.id to "${bot.name} · ${state.hostName}" },
- { accounts.chooseShortcutLead(it.ifEmpty { null }) }, label = "Lead to call")
- }
- }
- }
-}
-
-/**
- * Text shared from another app (Android's share sheet): pick a bot and its chat opens with the text in its message
- * box, after anything typed there, for you to send.
- */
-@Composable internal fun ShareToBot(text: String, states: List<AppState>, accounts: AccountStore) {
- val dismiss = LocalDismissModal.current
- androidx.compose.foundation.layout.Column {
- ModalHeader("Send to a bot")
- CardForm {
- CardSection(footer = "The message waits in the chat's box until you send it.") {
- row { androidx.compose.material3.Text(text, style = Type.footnote, color = Palette.secondary, maxLines = 4,
- overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis) }
- }
- for (state in states) {
- val bots = roster(state.bots).filter { it.kind != "group" || it.members.isNotEmpty() }
- if (bots.isNotEmpty()) CardSection(if (states.size > 1) state.hostName else null) {
- for (bot in bots) row {
- androidx.compose.foundation.layout.Box(androidx.compose.ui.Modifier.plainButton {
- accounts.store(state.computer.id)?.let { store -> store.appendDraft(bot.id, text) }
- accounts.openBot(BotDestination(state.contextId, state.computer.id, bot.id))
- accounts.finishSharing()
- dismiss()
- }) { BotRow(bot, state) }
- }
- }
- }
- }
- }
+ contextScope.launch(Dispatchers.IO) { local.saveShortcutLead(computerId) }
}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/MainActivity.kt b/apps/android/app/src/main/kotlin/com/codync/android/MainActivity.kt
index 64515e19..a7968006 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/MainActivity.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/MainActivity.kt
@@ -99,8 +99,11 @@ class MainActivity : ComponentActivity() {
}
}
}
- // Rotation keeps its ViewModel/navigation; process restoration gets a fresh owner.
- if (savedInstanceState?.getString("codync:activityOwner") != accounts.activityOwnerId) handle(intent)
+ // Rotation keeps its ViewModel/navigation; process restoration gets a fresh owner and the activity's first intent
+ // again, as does a return from Recents: its links open again, but a call or a share happened once.
+ val replayed = savedInstanceState != null || intent.flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY != 0
+ if (savedInstanceState?.getString("codync:activityOwner") != accounts.activityOwnerId &&
+ !(replayed && intent.action in setOf(LiveShortcut.ACTION, Intent.ACTION_SEND))) handle(intent)
}
override fun onSaveInstanceState(outState: Bundle) {
outState.putString("codync:activityOwner", accounts.activityOwnerId)
@@ -122,10 +125,10 @@ class MainActivity : ComponentActivity() {
super.onStop()
}
private fun handle(intent: Intent?) {
- if (intent?.action == LiveShortcut.ACTION) { intent.action = null; accounts.talkToLead(); return }
+ if (intent?.action == LiveShortcut.ACTION) { accounts.talkToLead(); return }
+ // Text shared from another app, handed over by `ShareActivity`.
if (intent?.action == Intent.ACTION_SEND) {
- intent.getStringExtra(Intent.EXTRA_TEXT)?.takeIf { it.isNotBlank() }?.let { accounts.share(it.take(64 * 1024)) }
- intent.action = null
+ intent.getStringExtra(Intent.EXTRA_TEXT)?.takeIf { it.isNotBlank() }?.let(accounts::share)
return
}
val uri = intent?.data ?: return
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/MainTabs.kt b/apps/android/app/src/main/kotlin/com/codync/android/MainTabs.kt
index eb32de50..aa8ccfeb 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/MainTabs.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/MainTabs.kt
@@ -13,8 +13,6 @@ import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.statusBarsPadding
-import androidx.compose.material3.Text
-import androidx.compose.ui.text.style.TextAlign
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
@@ -107,7 +105,7 @@ private enum class AppTab { Bots, State, Settings }
Box(Modifier.fillMaxSize().tabLayer(tab == AppTab.State)) {
StateScreen(app, states.firstOrNull { it.computer.id == app.currentComputerId }?.usage, accounts, usage, barSpace, active = tab == AppTab.State)
}
- Box(Modifier.fillMaxSize().tabLayer(tab == AppTab.Settings)) { SettingsView(app, accounts, barSpace, states) }
+ Box(Modifier.fillMaxSize().tabLayer(tab == AppTab.Settings)) { SettingsView(app, states, accounts, barSpace) }
}
}
@@ -117,11 +115,7 @@ private const val REMOVED_CHAT = "removed"
@Composable private fun RemovedComputer(back: () -> Unit) {
Column(Modifier.fillMaxSize().background(Palette.background).statusBarsPadding()) {
ScreenHeader(leading = { BackButton(back) })
- Column(Modifier.fillMaxSize().padding(24.dp), horizontalAlignment = Alignment.CenterHorizontally,
- verticalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterVertically)) {
- Symbol("desktopcomputer.trianglebadge.exclamationmark", size = 48.dp, tint = Palette.tertiary)
- Text(tr("This computer was removed"), style = Type.title3.semibold, color = Palette.text, textAlign = TextAlign.Center)
- }
+ EmptyState("desktopcomputer.trianglebadge.exclamationmark", "This computer was removed", Modifier.fillMaxSize())
}
}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/SettingsView.kt b/apps/android/app/src/main/kotlin/com/codync/android/SettingsView.kt
index a1582fd4..bbae2f48 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/SettingsView.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/SettingsView.kt
@@ -35,7 +35,7 @@ import com.codync.android.design.*
* analytics, Start over; iOS `SettingsView`). Each computer's own settings (voice chat, push, connection,
* hidden bots) are in Computer management (`ComputersView`).
*/
-@Composable internal fun SettingsView(state: AccountContext, store: AccountStore, bottomInset: Dp, computers: List<AppState> = emptyList()) {
+@Composable internal fun SettingsView(state: AccountContext, computers: List<AppState>, store: AccountStore, bottomInset: Dp) {
val uri = LocalUriHandler.current
var confirmStartOver by remember { mutableStateOf(false) }
var aboutAnalytics by remember { mutableStateOf(false) }
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/ShareActivity.kt b/apps/android/app/src/main/kotlin/com/codync/android/ShareActivity.kt
new file mode 100644
index 00000000..f2d77d9b
--- /dev/null
+++ b/apps/android/app/src/main/kotlin/com/codync/android/ShareActivity.kt
@@ -0,0 +1,20 @@
+package com.codync.android
+
+import android.app.Activity
+import android.content.Intent
+import android.os.Bundle
+
+/**
+ * Where another app's share sheet sends text (the iPhone's Send Text to Bot). The sheet starts it in the sender's task,
+ * so it hands the text on to Codync's own task and its one MainActivity (and account), then closes; `ShareToBot` picks the bot.
+ */
+class ShareActivity : Activity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ // Styled text arrives as a CharSequence, which getStringExtra drops.
+ val text = intent.getCharSequenceExtra(Intent.EXTRA_TEXT)?.toString()
+ if (!text.isNullOrBlank()) startActivity(Intent(this, MainActivity::class.java).setAction(Intent.ACTION_SEND)
+ .putExtra(Intent.EXTRA_TEXT, text).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP))
+ finish()
+ }
+}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/ShareToBot.kt b/apps/android/app/src/main/kotlin/com/codync/android/ShareToBot.kt
new file mode 100644
index 00000000..6f680c34
--- /dev/null
+++ b/apps/android/app/src/main/kotlin/com/codync/android/ShareToBot.kt
@@ -0,0 +1,37 @@
+package com.codync.android
+
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.text.style.TextOverflow
+import com.codync.android.core.BotDestination
+import com.codync.android.design.*
+
+/**
+ * Text shared from another app (`ShareActivity`; the iPhone's Send Text to Bot with Open Chat on): pick a bot and its
+ * chat opens with the text in its message box, after anything typed there, for you to send.
+ */
+@Composable internal fun ShareToBot(text: String, states: List<AppState>, accounts: AccountStore) {
+ val dismiss = LocalDismissModal.current
+ Column {
+ ModalHeader("Send to a bot")
+ CardForm {
+ CardSection(footer = "The message waits in the chat's box until you send it.") {
+ row { Text(text, style = Type.footnote, color = Palette.secondary, maxLines = 4, overflow = TextOverflow.Ellipsis) }
+ }
+ for (state in states) {
+ val bots = roster(state.bots).filter { it.kind != "group" || it.members.isNotEmpty() }
+ if (bots.isNotEmpty()) CardSection(if (states.size > 1) state.hostName else null) {
+ for (bot in bots) row {
+ Box(Modifier.plainButton {
+ accounts.sendShared(BotDestination(state.contextId, state.computer.id, bot.id))
+ dismiss()
+ }) { BotRow(bot, state) }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/ShortcutLeadSettings.kt b/apps/android/app/src/main/kotlin/com/codync/android/ShortcutLeadSettings.kt
new file mode 100644
index 00000000..276e3ce3
--- /dev/null
+++ b/apps/android/app/src/main/kotlin/com/codync/android/ShortcutLeadSettings.kt
@@ -0,0 +1,22 @@
+package com.codync.android
+
+import androidx.compose.runtime.Composable
+import com.codync.android.design.*
+
+/**
+ * Settings' Shortcuts card (iOS `ShortcutLeadSettings`): which lead "Talk to Codync" calls, shown once more than one
+ * computer has a lead. A computer whose lead is gone shows as Automatic, which is what the shortcut does then.
+ */
+@Composable internal fun ShortcutLeadSettings(app: AccountContext, states: List<AppState>, accounts: AccountStore) {
+ val leads = leads(states)
+ if (leads.size < 2) return
+ val chosen = app.shortcutLeadComputer?.takeIf { id -> leads.any { it.first.computer.id == id } }
+ CardSection("Shortcuts", footer = "Talk to Codync, in the app icon's shortcuts, calls this lead. Automatic calls the lead of the first computer in your list.") {
+ row {
+ ValueRow("Lead to call") {
+ ChoicePicker<String?>(chosen, listOf(null to tr("Automatic")) + leads.map { (state, bot) -> state.computer.id to "${bot.name} · ${state.hostName}" },
+ accounts::chooseShortcutLead, label = "Lead to call")
+ }
+ }
+ }
+}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/UsageScreen.kt b/apps/android/app/src/main/kotlin/com/codync/android/UsageScreen.kt
index bf9a0810..e25e5440 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/UsageScreen.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/UsageScreen.kt
@@ -71,14 +71,8 @@ import kotlin.math.roundToInt
}
}
-@Composable private fun EmptyUsage(title: String, message: String) {
- Column(Modifier.fillMaxWidth().padding(top = 60.dp, start = 24.dp, end = 24.dp), horizontalAlignment = Alignment.CenterHorizontally,
- verticalArrangement = Arrangement.spacedBy(8.dp)) {
- Symbol("chart.bar", size = 48.dp, tint = Palette.tertiary)
- Text(tr(title), style = Type.title3.semibold, color = Palette.text, textAlign = TextAlign.Center)
- Text(tr(message), style = Type.subheadline, color = Palette.secondary, textAlign = TextAlign.Center)
- }
-}
+@Composable private fun EmptyUsage(title: String, message: String) =
+ EmptyState("chart.bar", title, Modifier.fillMaxWidth().padding(top = 60.dp), message)
@Composable private fun ProviderCard(provider: UsageProvider) {
var collapsed by rememberSaveable(provider.id) { mutableStateOf(false) }
diff --git a/apps/android/app/src/test/kotlin/com/codync/android/ShortcutLeadTest.kt b/apps/android/app/src/test/kotlin/com/codync/android/ShortcutsTest.kt
similarity index 50%
rename from apps/android/app/src/test/kotlin/com/codync/android/ShortcutLeadTest.kt
rename to apps/android/app/src/test/kotlin/com/codync/android/ShortcutsTest.kt
index fc35722a..bbcd3c96 100644
--- a/apps/android/app/src/test/kotlin/com/codync/android/ShortcutLeadTest.kt
+++ b/apps/android/app/src/test/kotlin/com/codync/android/ShortcutsTest.kt
@@ -4,9 +4,11 @@ import com.codync.android.core.Bot
import com.codync.android.core.Computer
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
+import org.junit.Assert.assertTrue
import org.junit.Test
-class ShortcutLeadTest {
+/** Android's counterparts of the iPhone's Shortcuts actions: the lead "Talk to Codync" calls, and shared text in a draft. */
+class ShortcutsTest {
private fun computer(id: String, vararg bots: Bot) = AppState(Computer(id, id, id), loading = false, bots = bots.toList())
private val mac = computer("mac", Bot("a", "Mac helper"), Bot("lead-mac", "Mac lead", lead = true))
private val linux = computer("linux", Bot("lead-linux", "Linux lead", lead = true))
@@ -18,5 +20,20 @@ class ShortcutLeadTest {
assertEquals("lead-linux", shortcutLead(listOf(computer("mac", Bot("a", "Helper")), linux), "mac")?.second?.id)
assertEquals("lead-mac", shortcutLead(listOf(linux.copy(bots = listOf(Bot("lead-linux", "Gone", lead = true, deleted = true))), mac), null)?.second?.id)
assertNull(shortcutLead(listOf(computer("mac", Bot("a", "Helper"))), null))
+ // Settings lists the same leads the shortcut picks from.
+ assertEquals(listOf("lead-mac", "lead-linux"), leads(listOf(mac, linux)).map { it.second.id })
+ }
+
+ @Test fun `shared text goes after what's typed, cut at a character to what a draft holds`() {
+ assertEquals("typed hello", sharedDraft("typed", "hello"))
+ assertEquals("typed\nhello", sharedDraft("typed\n", "hello"))
+ assertEquals("hello", sharedDraft("", "hello"))
+ // 30,000 Chinese characters are about 90 KB of UTF-8, three bytes each: whole ones up to 64 KiB.
+ val chinese = sharedDraft("", "字".repeat(30_000))
+ assertEquals(DraftBook.TEXT_BYTES / 3, chinese.length)
+ assertTrue(chinese.toByteArray().size <= DraftBook.TEXT_BYTES)
+ // An emoji (two UTF-16 units, four bytes) is kept whole or left out, after the typed text.
+ val typed = "a".repeat(DraftBook.TEXT_BYTES - 6)
+ assertEquals("$typed \uD83D\uDE00", sharedDraft(typed, "\uD83D\uDE00\uD83D\uDE00"))
}
}
diff --git a/apps/android/design/src/main/kotlin/com/codync/android/design/Chrome.kt b/apps/android/design/src/main/kotlin/com/codync/android/design/Chrome.kt
index d3f09051..d240edb8 100644
--- a/apps/android/design/src/main/kotlin/com/codync/android/design/Chrome.kt
+++ b/apps/android/design/src/main/kotlin/com/codync/android/design/Chrome.kt
@@ -37,6 +37,7 @@ import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.heading
import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
@@ -75,6 +76,16 @@ import kotlin.math.roundToInt
}
}
+/** A screen with nothing to show (iOS `EmptyState`): a large symbol, a title and, under it, an optional line. */
+@Composable fun EmptyState(symbol: String, title: String, modifier: Modifier = Modifier, message: String? = null) {
+ Column(modifier.padding(horizontal = 24.dp), horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterVertically)) {
+ Symbol(symbol, size = 48.dp, tint = Palette.tertiary)
+ Text(tr(title), style = Type.title3.semibold, color = Palette.text, textAlign = TextAlign.Center)
+ message?.let { Text(tr(it), style = Type.subheadline, color = Palette.secondary, textAlign = TextAlign.Center) }
+ }
+}
+
/** The back button for a pushed screen. */
@Composable fun BackButton(action: () -> Unit) = IconButton("Back", "chevron.left", action = action)
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
index ff1dcb13..75d300ba 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
@@ -103,6 +103,10 @@
"Lead to call": "Anzurufender leitender Agent",
"Automatic": "Automatisch",
"Siri, the Action button and Open Live Mode without a bot call this lead. Automatic calls the lead of the first computer in your list.": "Siri, die Aktionstaste und Open Live Mode ohne Bot rufen diesen leitenden Agenten an. Automatisch ruft den leitenden Agenten des ersten Computers in Ihrer Liste an.",
+ "Talk to Codync, in the app icon's shortcuts, calls this lead. Automatic calls the lead of the first computer in your list.": "Talk to Codync in den Kurzbefehlen des App-Symbols ruft diesen leitenden Agenten an. Automatisch ruft den leitenden Agenten des ersten Computers in Ihrer Liste an.",
+ "Send to a bot": "An einen Bot senden",
+ "The message waits in the chat's box until you send it.": "Die Nachricht wartet im Eingabefeld des Chats, bis Sie sie senden.",
+ "This computer was removed": "Dieser Computer wurde entfernt",
"↑↓ scroll · esc close": "↑↓ scrollen · esc schließen",
"Your lead agent is your first point of contact. It follows your goals and unfinished tasks, suggests useful next steps, and coordinates work with your other bots. The lead Codync sets up has a Check in routine that runs twice a day by default; you can change or pause it in Routines.": "Ihr leitender Agent ist Ihre erste Anlaufstelle. Er verfolgt Ihre Ziele und offenen Aufgaben, schlägt hilfreiche nächste Schritte vor und koordiniert die Arbeit mit Ihren anderen Bots. Der leitende Agent, den Codync einrichtet, hat eine Check in-Routine, die standardmäßig zweimal täglich läuft; unter Routinen können Sie sie ändern oder pausieren.",
"Move to section": "In Abschnitt verschieben",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
index ade34501..ad11e98d 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
@@ -103,6 +103,10 @@
"Lead to call": "Agente principal al que llamar",
"Automatic": "Automático",
"Siri, the Action button and Open Live Mode without a bot call this lead. Automatic calls the lead of the first computer in your list.": "Siri, el botón de acción y Open Live Mode sin bot llaman a este agente principal. Automático llama al agente principal del primer ordenador de tu lista.",
+ "Talk to Codync, in the app icon's shortcuts, calls this lead. Automatic calls the lead of the first computer in your list.": "Talk to Codync, en los accesos directos del icono de la app, llama a este agente principal. Automático llama al agente principal del primer ordenador de tu lista.",
+ "Send to a bot": "Enviar a un bot",
+ "The message waits in the chat's box until you send it.": "El mensaje espera en el cuadro del chat hasta que lo envíes.",
+ "This computer was removed": "Este ordenador se ha eliminado",
"↑↓ scroll · esc close": "↑↓ desplazar · esc cerrar",
"Your lead agent is your first point of contact. It follows your goals and unfinished tasks, suggests useful next steps, and coordinates work with your other bots. The lead Codync sets up has a Check in routine that runs twice a day by default; you can change or pause it in Routines.": "Tu agente principal es tu primer punto de contacto. Sigue tus objetivos y tareas pendientes, sugiere próximos pasos útiles y coordina el trabajo con tus otros bots. El agente principal que crea Codync tiene una rutina Check in que se ejecuta dos veces al día de forma predeterminada; puedes cambiarla o pausarla en Rutinas.",
"Move to section": "Mover a una sección",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
index 9f83028e..ddb26c09 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
@@ -103,6 +103,10 @@
"Lead to call": "Agent principal à appeler",
"Automatic": "Automatique",
"Siri, the Action button and Open Live Mode without a bot call this lead. Automatic calls the lead of the first computer in your list.": "Siri, le bouton Action et Open Live Mode sans bot appellent cet agent principal. Automatique appelle l’agent principal du premier ordinateur de votre liste.",
+ "Talk to Codync, in the app icon's shortcuts, calls this lead. Automatic calls the lead of the first computer in your list.": "Talk to Codync, dans les raccourcis de l’icône de l’app, appelle cet agent principal. Automatique appelle l’agent principal du premier ordinateur de votre liste.",
+ "Send to a bot": "Envoyer à un bot",
+ "The message waits in the chat's box until you send it.": "Le message attend dans le champ de saisie du chat jusqu’à ce que vous l’envoyiez.",
+ "This computer was removed": "Cet ordinateur a été retiré",
"↑↓ scroll · esc close": "↑↓ défiler · esc fermer",
"Your lead agent is your first point of contact. It follows your goals and unfinished tasks, suggests useful next steps, and coordinates work with your other bots. The lead Codync sets up has a Check in routine that runs twice a day by default; you can change or pause it in Routines.": "Votre agent principal est votre premier interlocuteur. Il suit vos objectifs et vos tâches inachevées, propose les prochaines étapes utiles et coordonne le travail avec vos autres bots. L’agent principal créé par Codync a une routine Check in qui s’exécute deux fois par jour par défaut ; vous pouvez la modifier ou la suspendre dans Routines.",
"Move to section": "Déplacer vers une section",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
index 8f688d61..a13cd4c2 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
@@ -103,6 +103,10 @@
"Lead to call": "呼び出すリードエージェント",
"Automatic": "自動",
"Siri, the Action button and Open Live Mode without a bot call this lead. Automatic calls the lead of the first computer in your list.": "Siri、アクションボタン、ボットを指定しない「Open Live Mode」はこのリードエージェントを呼び出します。「自動」では、リストの最初のコンピュータのリードエージェントを呼び出します。",
+ "Talk to Codync, in the app icon's shortcuts, calls this lead. Automatic calls the lead of the first computer in your list.": "アプリアイコンのショートカットにある「Talk to Codync」は、このリードエージェントを呼び出します。「自動」では、リストの最初のコンピュータのリードエージェントを呼び出します。",
+ "Send to a bot": "ボットに送る",
+ "The message waits in the chat's box until you send it.": "メッセージは、送信するまでチャットの入力欄に残ります。",
+ "This computer was removed": "このコンピュータは削除されました",
"↑↓ scroll · esc close": "↑↓ スクロール · esc 閉じる",
"Your lead agent is your first point of contact. It follows your goals and unfinished tasks, suggests useful next steps, and coordinates work with your other bots. The lead Codync sets up has a Check in routine that runs twice a day by default; you can change or pause it in Routines.": "リードエージェントは最初の相談相手です。目標や未完了のタスクを追跡し、役立つ次の一歩を提案して、他のボットとの作業を調整します。Codync が用意したリードエージェントには「Check in」ルーチンがあり、初期設定で1日2回実行されます。ルーチンで変更または一時停止できます。",
"Move to section": "セクションに移動",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
index 2305586d..3bd75d33 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
@@ -103,6 +103,10 @@
"Lead to call": "호출할 리드 에이전트",
"Automatic": "자동",
"Siri, the Action button and Open Live Mode without a bot call this lead. Automatic calls the lead of the first computer in your list.": "Siri, 동작 버튼, 봇을 지정하지 않은 Open Live Mode는 이 리드 에이전트를 호출합니다. 자동은 목록에서 첫 번째 컴퓨터의 리드 에이전트를 호출합니다.",
+ "Talk to Codync, in the app icon's shortcuts, calls this lead. Automatic calls the lead of the first computer in your list.": "앱 아이콘 단축키의 Talk to Codync는 이 리드 에이전트를 호출합니다. 자동은 목록에서 첫 번째 컴퓨터의 리드 에이전트를 호출합니다.",
+ "Send to a bot": "봇에게 보내기",
+ "The message waits in the chat's box until you send it.": "메시지는 보낼 때까지 채팅 입력란에 남아 있습니다.",
+ "This computer was removed": "이 컴퓨터는 제거되었습니다",
"↑↓ scroll · esc close": "↑↓ 스크롤 · esc 닫기",
"Your lead agent is your first point of contact. It follows your goals and unfinished tasks, suggests useful next steps, and coordinates work with your other bots. The lead Codync sets up has a Check in routine that runs twice a day by default; you can change or pause it in Routines.": "리드 에이전트는 가장 먼저 연락할 도우미입니다. 목표와 미완료 작업을 추적하고 유용한 다음 단계를 제안하며 다른 봇과 작업을 조율합니다. Codync가 만든 리드 에이전트에는 Check in 루틴이 있어 기본적으로 하루 두 번 실행되며, 루틴에서 변경하거나 일시 중지할 수 있습니다.",
"Move to section": "섹션으로 이동",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
index 43f5a099..8343bfd7 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
@@ -103,6 +103,10 @@
"Lead to call": "要呼叫的主助理",
"Automatic": "自动",
"Siri, the Action button and Open Live Mode without a bot call this lead. Automatic calls the lead of the first computer in your list.": "Siri、操作按钮和未指定 Bot 的「Open Live Mode」会呼叫这个主助理。选「自动」时,会呼叫列表中第一台电脑的主助理。",
+ "Talk to Codync, in the app icon's shortcuts, calls this lead. Automatic calls the lead of the first computer in your list.": "应用图标快捷方式里的「Talk to Codync」会呼叫这个主助理。选「自动」时,会呼叫列表中第一台电脑的主助理。",
+ "Send to a bot": "发送给 Bot",
+ "The message waits in the chat's box until you send it.": "消息会留在聊天的输入框里,直到你发送。",
+ "This computer was removed": "这台电脑已被移除",
"↑↓ scroll · esc close": "↑↓ 滚动 · esc 关闭",
"Your lead agent is your first point of contact. It follows your goals and unfinished tasks, suggests useful next steps, and coordinates work with your other bots. The lead Codync sets up has a Check in routine that runs twice a day by default; you can change or pause it in Routines.": "主助理是你优先联系的 agent。它会跟进你的目标与未完成的任务、建议实用的下一步,并协调其他 bots 一起完成工作。Codync 创建的主助理带有「Check in」例行任务,默认每天执行两次;你可以在「例行任务」中调整或暂停。",
"Move to section": "移到分组",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
index c9f14360..6da0f6d1 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
@@ -103,6 +103,10 @@
"Lead to call": "要呼叫的主助理",
"Automatic": "自動",
"Siri, the Action button and Open Live Mode without a bot call this lead. Automatic calls the lead of the first computer in your list.": "Siri、動作按鈕和沒有指定 Bot 的「Open Live Mode」會呼叫這個主助理。選「自動」時,會呼叫清單中第一台電腦的主助理。",
+ "Talk to Codync, in the app icon's shortcuts, calls this lead. Automatic calls the lead of the first computer in your list.": "應用圖示捷徑裡的「Talk to Codync」會呼叫這個主助理。選「自動」時,會呼叫清單中第一台電腦的主助理。",
+ "Send to a bot": "傳送給 Bot",
+ "The message waits in the chat's box until you send it.": "訊息會留在聊天的輸入框裡,直到你傳送。",
+ "This computer was removed": "這台電腦已被移除",
"↑↓ scroll · esc close": "↑↓ 捲動 · esc 關閉",
"Your lead agent is your first point of contact. It follows your goals and unfinished tasks, suggests useful next steps, and coordinates work with your other bots. The lead Codync sets up has a Check in routine that runs twice a day by default; you can change or pause it in Routines.": "主助理是你優先聯絡的 agent。它會追蹤你的目標與未完成的任務、建議實用的下一步,並協調其他 bots 一起完成工作。Codync 建立的主助理帶有「Check in」例行任務,預設每天執行兩次;你可以在「例行任務」中調整或暫停。",
"Move to section": "移到分組",
diff --git a/apps/ios/Kit/Sources/CodyncUI/Bots/BotDetailsView.swift b/apps/ios/Kit/Sources/CodyncUI/Bots/BotDetailsView.swift
index 1218bb5b..e0f0f7f1 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Bots/BotDetailsView.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Bots/BotDetailsView.swift
@@ -28,6 +28,8 @@ struct BotDetailsView: View {
@Environment(\.dismissModal) private var dismiss
@State private var draft: BotDraft?
@State private var saveError: String?
+ /// Off once the page closes: a save that fails after that shows over the app instead.
+ @State private var presence = PagePresence()
@State private var saving: Task<Void, Never>?
@State private var template: EditorRequest?
@@ -64,6 +66,8 @@ struct BotDetailsView: View {
if let base, let fresh, base.id == fresh.id { draft = draft?.rebased(from: base, onto: fresh) }
}
.onChange(of: draft) { _, draft in autosave(draft) }
+ .onAppear { presence.shown = true }
+ .onDisappear { presence.shown = false }
.codyncSheet(item: $template) { BotTemplateView(draft: $0.draft) }
}
@@ -158,8 +162,13 @@ struct BotDetailsView: View {
_ = try await model.save(draft.normalized)
saveError = nil
} catch {
- saveError = error.localizedDescription
+ if presence.shown { saveError = error.localizedDescription } else { model.lastError = error.localizedDescription }
}
}
}
}
+
+/// Whether a page is on screen, for work that outlives it.
+@MainActor private final class PagePresence {
+ var shown = true
+}
diff --git a/docs/features/ios-shortcuts.md b/docs/features/ios-shortcuts.md
index 0b329087..7cf8ce16 100644
--- a/docs/features/ios-shortcuts.md
+++ b/docs/features/ios-shortcuts.md
@@ -17,4 +17,4 @@ The text action uses the existing message path, including nonce-based retry and
The adapter lives in the iOS app (`BotShortcuts` and `AppStore+Shortcuts`); the account-scoped entity query lives in CodyncKit. CodyncUI reuses BotStore's sending and connection logic and delivers a one-shot voice request to ThreadView. A pending shortcut send retains its target connection across background transitions, then releases it after acceptance, failure or cancellation; active calls retain their own connection. Both actions wait for account restoration before resolving the target, since an intent can run before the scene restores the account. The host continues to own message handling and agent work; the lead comes from the cached bots (`lead` in their JSON), and there is no new host method or compatibility-floor change for the shortcuts.
-This is an iOS system integration. Desktop already offers bot selection, text sending and voice calls in ThreadView/CallView. Android has its own counterparts (`LiveShortcut.kt`): **Talk to Codync** in the app icon's shortcuts calls the lead like Open Live Mode without a bot (Settings → Shortcuts → Lead to call picks it, as on the iPhone), and text shared from another app opens the picked bot's chat with the text in its box, like Send Text to Bot with Open Chat on. Neither client runs iOS App Intents. The terminal UI retains its existing bot selection and message sending and has no microphone voice UI. Their shared behavior and layouts are unchanged.
+This is an iOS system integration. Desktop already offers bot selection, text sending and voice calls in ThreadView/CallView. Android has its own counterparts: **Talk to Codync** (`LiveShortcut.kt`) in the app icon's shortcuts calls the lead like Open Live Mode without a bot (Settings → Shortcuts → Lead to call picks it, as on the iPhone), and text shared from another app (`ShareActivity`, `ShareToBot.kt`) opens the picked bot's chat with the text in its box, like Send Text to Bot with Open Chat on. Neither client runs iOS App Intents. The terminal UI retains its existing bot selection and message sending and has no microphone voice UI. Their shared behavior and layouts are unchanged.
diff --git a/docs/features/lead-bot.md b/docs/features/lead-bot.md
index 8f0b5e38..831ddacd 100644
--- a/docs/features/lead-bot.md
+++ b/docs/features/lead-bot.md
@@ -59,7 +59,9 @@ lead, and Siri's "Talk to Codync" does the same. Each computer may have its own
Shortcuts > *Lead to call* picks whose (`SharedStore.Context.shortcutLeadComputer`, kept on this iPhone). Automatic,
and a pick whose lead is gone, call the lead of the first computer, in the user's computer order, that has one. With
no lead anywhere (deleted, or not synced yet) it asks which bot. The Bot picker lists leads first. See
-[iOS Shortcuts](ios-shortcuts.md). Android has no Siri, Shortcuts or Action button, so it has no such setting. The desktop's voice input shortcut goes to the lead when no chat is open, or the
+[iOS Shortcuts](ios-shortcuts.md). On Android, **Talk to Codync** in the app icon's shortcuts calls the lead the same way
+(`LiveShortcut.kt`): the same Settings > Shortcuts > *Lead to call*, Automatic and fallback, saved per account in
+`LocalStore` (`shortcut-lead`); with no lead it opens Bots to pick one. The desktop's voice input shortcut goes to the lead when no chat is open, or the
top bot where no computer has one.
## Compatibility
diff --git a/docs/plans/android-app.md b/docs/plans/android-app.md
index 37cfbf87..5557288d 100644
--- a/docs/plans/android-app.md
+++ b/docs/plans/android-app.md
@@ -71,7 +71,7 @@ on one emulator, 2026-10-31).
- **`computers` / `plugins` links** open over the current tab; iOS switches to Bots first.
- **Shortcuts actions** (Open Live Mode, Send Text to Bot) are Apple App Intents; Android's counterparts are
**Talk to Codync** in the app icon's shortcuts (the lead, by Settings → Shortcuts → Lead to call) and text shared
- from another app, which opens the picked bot's chat with the text in its box ([iOS Shortcuts](../features/ios-shortcuts.md), `LiveShortcut.kt`).
+ from another app, which opens the picked bot's chat with the text in its box ([iOS Shortcuts](../features/ios-shortcuts.md), `LiveShortcut.kt`, `ShareToBot.kt`).
- **On-device voice**: languages other than English need Android 13+ and Android's on-device
recognizer; it never falls back to online recognition (iOS may use Apple's servers).
- **Jump to latest** is an opaque disc: it sits in the scrolling content, so there's no blur under it.