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.

refactor(android): name the signed-in account in one place

leepokai126a7b6f6feb
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AccountSwitcherView.kt b/apps/android/app/src/main/kotlin/com/codync/android/AccountSwitcherView.kt
index 9ae4baa3..5f971fa0 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AccountSwitcherView.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AccountSwitcherView.kt
@@ -45,7 +45,7 @@ import com.kyant.shapes.RoundedRectangle
/** Who you're signed in as, and the other accounts on this phone (iOS `AccountSwitcherView`). */
@Composable internal fun AccountSwitcherView(state: AccountContext, store: AccountStore, pair: () -> Unit) {
val account = state.account
- val current = account.accounts.firstOrNull { it.userId == account.userId }
+ val current = account.current
val busy = "session" in state.busy
var confirmSignOut by remember { mutableStateOf(false) }
var confirmDelete by remember { mutableStateOf(false) }
@@ -132,7 +132,7 @@ import com.kyant.shapes.RoundedRectangle
/** The account face of the roster's top bar. */
@Composable internal fun AccountAvatar(state: AccountContext, size: Dp) {
- val current = state.account.accounts.firstOrNull { it.userId == state.account.userId }
+ val current = state.account.current
if (!state.account.ready || "session" in state.busy) {
Box(Modifier.size(size), contentAlignment = Alignment.Center) { ThinkingOrb(size = size * 0.6f) }
} else AccountAvatar(current?.avatar, current?.email, size)
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/BotListView.kt b/apps/android/app/src/main/kotlin/com/codync/android/BotListView.kt
index 57c5943a..3d9b2d32 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/BotListView.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/BotListView.kt
@@ -411,7 +411,7 @@ internal fun messagePreview(text: String): String {
/** The account capsule: who's signed in, opening the account sheet. */
@Composable internal fun AccountSwitcherButton(state: AccountContext, open: () -> Unit) {
val (source, pressed) = rememberPress()
- val email = state.account.accounts.firstOrNull { it.userId == state.account.userId }?.email
+ val email = state.account.current?.email
Row(Modifier.height(44.dp).glass(Capsule(), pressed = pressed)
.clickable(source, null, role = Role.Button, onClick = open)
.semantics { contentDescription = "Switch account"; stateDescription = email ?: "Local pairing" }
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/NativeAccounts.kt b/apps/android/app/src/main/kotlin/com/codync/android/NativeAccounts.kt
index 070ccc60..e99e977f 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/NativeAccounts.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/NativeAccounts.kt
@@ -25,12 +25,17 @@ import java.io.IOException
/** A sign-in that ended without an account, and why. */
internal class SignInError(val reason: SignInFailure, message: String, cause: Throwable? = null) : IOException(message, cause)
-data class SavedAccount(val userId: String, val sessionId: String, val email: String, val avatar: String?)
+data class SavedAccount(val userId: String, val sessionId: String, val email: String, val avatar: String?) {
+ /** The real address: [email] holds a label for an account without one (`observe`). */
+ val address: String? get() = email.takeIf { "@" in it }
+}
data class AccountState(val ready: Boolean = false, val configured: Boolean = NativeAccounts.configured,
val userId: String? = null, val accounts: List<SavedAccount> = emptyList(),
val multiple: Boolean = false, val error: String? = null) {
/** Clerk is still restoring the saved sign-in: the launch layer and the root wait, rather than show the welcome. */
val restoring: Boolean get() = configured && !ready && error == null
+ /** The signed-in account. */
+ val current: SavedAccount? get() = accounts.firstOrNull { it.userId == userId }
}
/** Clerk owns browser authentication, encrypted credentials and session restoration. */