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.

feat(apps): network screens on the desktop, the terminal and the phones

leepokai4b6c81b4bc60
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AnalyticsEvent.kt b/apps/android/app/src/main/kotlin/com/codync/android/AnalyticsEvent.kt
index dae29f86..f7812986 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AnalyticsEvent.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AnalyticsEvent.kt
@@ -166,5 +166,5 @@ internal enum class AnalyticsScreen(override val wire: String) : CatalogValue {
Bots("bots"), State("state"), Chat("chat"), Trace("trace"), BotDetails("bot_details"), Memory("memory"),
Routines("routines"), Marketplace("marketplace"), Settings("settings"), Computers("computers"), Usage("usage"),
Account("account"), Pairing("pairing"), VoiceSettings("voice_settings"), RemoteScreen("remote_screen"),
- Library("library"), Artifact("artifact"),
+ Library("library"), Artifact("artifact"), Network("network"),
}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppState.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppState.kt
index e25f826a..d40bcbfb 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AppState.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppState.kt
@@ -52,6 +52,8 @@ data class AppState(
val voice: VoiceCallViewState? = null,
/** The computer's remote screen (`null`: the host predates it). */
val screen: ScreenState? = null,
+ /** The computer's network as phones see it (`null`: the host predates it). */
+ val network: NetworkView? = null,
/** The remote screen viewer is open (`codync://screen`, the chat header, Computers). */
val screenRequest: ScreenRequest? = null,
/** The host sent data this app can't read even after fetching everything again. */
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreConnection.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreConnection.kt
index e403153a..8d5e27cf 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreConnection.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreConnection.kt
@@ -136,6 +136,7 @@ fun AppStore.connect() {
reconcileMailbox(active)
acknowledgeVisible()
syncPush()
+ loadNetwork(active)
while (isActive) {
if (state.value.mismatch != null) { awaitUpdate(active); continue }
val cursor = withContext(Dispatchers.IO) { requireNotNull(database).revision() }
@@ -185,6 +186,7 @@ private suspend fun AppStore.consumeEvents(active: EncryptedChannel, cursor: Lon
withContext(Dispatchers.IO) { requireNotNull(database).apply(batch) }
refresh()
receiveArtifacts(batch)
+ receiveNetwork(batch)
hearCalls(batch)
acknowledgeVisible(readAfter(batch, state.value.readingChats))
if (resync) throw Resync()
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreNetwork.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreNetwork.kt
new file mode 100644
index 00000000..54fa78e7
--- /dev/null
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreNetwork.kt
@@ -0,0 +1,20 @@
+package com.codync.android
+
+import com.codync.android.core.*
+import kotlinx.coroutines.CancellationException
+import kotlinx.coroutines.flow.update
+
+// The computer's network as this phone sees it: read-only, fetched when the link is up, kept current by its event.
+
+/** `networkView` once the link is up; a host that predates it (or can't answer) leaves it unset, so nothing shows. */
+internal suspend fun AppStore.loadNetwork(active: EncryptedChannel) {
+ val view = try { NetworkView.decode(active.call("networkView")) }
+ catch (cancelled: CancellationException) { throw cancelled }
+ catch (_: Exception) { null }
+ mutableState.update { it.copy(network = view) }
+}
+
+internal fun AppStore.receiveNetwork(events: List<MirrorEvent>) {
+ val view = events.filterIsInstance<MirrorEvent.Network>().lastOrNull()?.view ?: return
+ mutableState.update { it.copy(network = view) }
+}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/MirrorDatabase.kt b/apps/android/app/src/main/kotlin/com/codync/android/MirrorDatabase.kt
index 397c6aad..0be3bebc 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/MirrorDatabase.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/MirrorDatabase.kt
@@ -84,8 +84,8 @@ class MirrorDatabase(context: Context, directory: File, computerId: String) :
is MirrorEvent.EntryChanged -> { writeEntry(db, event.entry); bump(db, event.entry.rev) }
is MirrorEvent.Usage -> setMeta(db, "usage", event.value.toString())
is MirrorEvent.Screen -> setMeta(db, "screen", event.value.toString())
- // Artifacts live in memory (`AppStore.receiveArtifacts`).
- MirrorEvent.Resync, MirrorEvent.Ignored, is MirrorEvent.ArtifactChanged, is MirrorEvent.Call -> Unit
+ // Artifacts and the network live in memory (`AppStore.receiveArtifacts`, `receiveNetwork`).
+ MirrorEvent.Resync, MirrorEvent.Ignored, is MirrorEvent.ArtifactChanged, is MirrorEvent.Call, is MirrorEvent.Network -> Unit
}
}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/NetworkSheet.kt b/apps/android/app/src/main/kotlin/com/codync/android/NetworkSheet.kt
new file mode 100644
index 00000000..4969b799
--- /dev/null
+++ b/apps/android/app/src/main/kotlin/com/codync/android/NetworkSheet.kt
@@ -0,0 +1,57 @@
+package com.codync.android
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.dp
+import com.codync.android.core.NetworkComputer
+import com.codync.android.core.NetworkView
+import com.codync.android.design.*
+import com.kyant.shapes.Capsule
+
+/**
+ * The paired computer's network, read-only (iOS `NetworkSheet`): the computers in it with the bots each offers, and
+ * whether cloud assistants may reach its bots. Who is in is changed on a computer.
+ */
+@Composable internal fun NetworkSheet(view: NetworkView) {
+ AnalyticsOnAppear(AnalyticsEvent.ScreenViewed(AnalyticsScreen.Network))
+ Column(Modifier.fillMaxSize().background(Palette.background)) {
+ ModalHeader("Network")
+ CardForm {
+ if (view.joined) CardSection("Computers", "Changes are made on a computer: in Codync's settings there, or with codync-host network.") {
+ for (computer in view.computers) row { NetworkComputerRow(computer) }
+ }
+ CardSection(footer = "ChatGPT or Claude in your Codync account can message this computer's bots when it's on. Codync's cloud can read these calls.") {
+ row { ValueRow("Cloud assistants", if (view.assistants) "On" else "Off") }
+ }
+ }
+ }
+}
+
+/** One computer: its name and role, whether it answers, and the bots it offers. */
+@Composable private fun NetworkComputerRow(computer: NetworkComputer) {
+ val bots = computer.agents.joinToString(", ") { it.name }.ifEmpty { tr("No bots") }
+ Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp)) {
+ Box(Modifier.padding(horizontal = 2.dp).size(8.dp).clip(Capsule())
+ .background(if (computer.me || computer.online) Palette.added else Palette.tertiary))
+ Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {
+ Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
+ Text(computer.name, Modifier.weight(1f, fill = false), style = Type.body.semibold, color = Palette.text,
+ maxLines = 1, overflow = TextOverflow.Ellipsis)
+ Text(tr(computer.roleTitle), style = Type.caption, color = Palette.secondary)
+ }
+ Text("${tr(computer.presence)} · $bots", style = Type.footnote, color = Palette.secondary, maxLines = 2, overflow = TextOverflow.Ellipsis)
+ }
+ }
+}
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 69bd9aef..b7fe84b5 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
@@ -68,6 +68,7 @@ import kotlinx.serialization.json.put
var coloring by remember { mutableStateOf(false) }
var confirmStartOver by remember { mutableStateOf(false) }
var voice by remember { mutableStateOf(false) }
+ var network by remember { mutableStateOf(false) }
var aboutAnalytics by remember { mutableStateOf(false) }
LaunchedEffect(state.contextId) { store.refreshCloud() }
Column(Modifier.fillMaxSize().background(Palette.background)) {
@@ -77,7 +78,7 @@ import kotlinx.serialization.json.put
else "Each bot runs on its own computer. Sign in to see the computers in your account.") {
if (paired != null) row {
val inAccount = state.cloudComputers.firstOrNull { it.computerId == paired.id }
- ComputerRow(state, store, inAccount != null, ComputerActions(extensions, store::openScreen, voice = { voice = true }, color = { coloring = true },
+ ComputerRow(state, store, inAccount != null, ComputerActions(extensions, store::openScreen, voice = { voice = true }, network = { network = true }, color = { coloring = true },
ask = inAccount?.let { c -> { ask(c) } },
revoke = inAccount?.takeIf { it.isGranted }?.let { c -> { confirmRevoke = c } }) { confirmForget = true })
}
@@ -153,6 +154,7 @@ import kotlinx.serialization.json.put
} }
}
CodyncSheet(voice, { voice = false }) { VoiceChatSettings(state, store) }
+ CodyncSheet(network, { network = false }) { state.network?.let { NetworkSheet(it) } }
SwatchPanel(coloring, paired?.color, { coloring = false }, store::setColor)
CodyncSheet(aboutAnalytics, { aboutAnalytics = false }) { AnalyticsSheet() }
CodyncDialog("Start over?", confirmStartOver, { confirmStartOver = false },
@@ -190,7 +192,7 @@ import kotlinx.serialization.json.put
}
/** What the paired computer's row and its menu open; `revoke` is set when this phone's account access can be revoked. */
-private class ComputerActions(val extensions: () -> Unit, val screen: () -> Unit, val voice: () -> Unit, val color: () -> Unit,
+private class ComputerActions(val extensions: () -> Unit, val screen: () -> Unit, val voice: () -> Unit, val network: () -> Unit, val color: () -> Unit,
val ask: (() -> Unit)?, val revoke: (() -> Unit)?, val remove: () -> Unit)
/** The paired computer: its connection, how it's reached, and whether it's in the account. */
@@ -199,6 +201,7 @@ private class ComputerActions(val extensions: () -> Unit, val screen: () -> Unit
val link = state.connection
val online = link is LinkState.Ready
val viewable = online && state.screen != null
+ val inNetwork = online && state.network?.shown == true
val detail = if (link is LinkState.Ready) {
val count = state.bots.count { !it.deleted && it.kind != "group" }
"$count bot${if (count == 1) "" else "s"} · ${routeLabel(link.route, computer.cloud)}"
@@ -209,6 +212,7 @@ private class ComputerActions(val extensions: () -> Unit, val screen: () -> Unit
if (online) MenuItem("Extensions", icon = "square.grid.2x2", action = actions.extensions) else null,
if (online) MenuItem("Voice chat", icon = "waveform", action = actions.voice) else null,
if (viewable) MenuItem("Screen", icon = "display", action = actions.screen) else null,
+ if (inNetwork) MenuItem("Network", icon = NETWORK_ICON, action = actions.network) else null,
actions.revoke?.let { MenuItem("Revoke this phone's access", icon = "lock.slash", destructive = true, divider = true, action = it) },
if (!inAccount) MenuItem("Remove", icon = "trash", destructive = true, divider = actions.revoke == null, action = actions.remove) else null,
)
@@ -244,6 +248,7 @@ private class ComputerActions(val extensions: () -> Unit, val screen: () -> Unit
if (state.connection is LinkState.Ready) {
IconButton("Extensions", "square.grid.2x2", action = actions.extensions)
if (state.screen != null) IconButton("Screen", "display", action = actions.screen)
+ if (state.network?.shown == true) IconButton("Network", NETWORK_ICON, action = actions.network)
}
DropdownMenu({ ConnectionRoute.entries.map { route -> MenuItem(routeTitle(route, computer.cloud), icon = route.icon, selected = route == computer.route) { store.setRoute(route) } } },
Modifier.size(36.dp), label = "Connection") {
@@ -345,6 +350,8 @@ private class ComputerActions(val extensions: () -> Unit, val screen: () -> Unit
}
}
+private const val NETWORK_ICON = "point.3.connected.trianglepath.dotted"
+
private val ConnectionRoute.icon get() = when (this) {
ConnectionRoute.Automatic -> "arrow.triangle.branch"
ConnectionRoute.CloudflareFirst -> "cloud"
diff --git a/apps/android/core/src/main/kotlin/com/codync/android/core/Conversation.kt b/apps/android/core/src/main/kotlin/com/codync/android/core/Conversation.kt
index 38523d66..c5279c5c 100644
--- a/apps/android/core/src/main/kotlin/com/codync/android/core/Conversation.kt
+++ b/apps/android/core/src/main/kotlin/com/codync/android/core/Conversation.kt
@@ -158,6 +158,8 @@ sealed interface MirrorEvent {
data class ArtifactChanged(val artifact: Artifact) : MirrorEvent
/** For the voice of a call on this device: live only, never a checkpoint. */
data class Call(val cue: CallCue) : MirrorEvent
+ /** The computer's network changed: live only, never a checkpoint. */
+ data class Network(val view: NetworkView) : MirrorEvent
data object Resync : MirrorEvent
data object Ignored : MirrorEvent
@@ -173,6 +175,8 @@ sealed interface MirrorEvent {
// One this app can't read is passed over rather than fetching everything again: a card or the Library reads it again.
"artifact" -> runCatching { ArtifactChanged(Artifact.decode(value.getValue("artifact"))) }.getOrDefault(Ignored)
"call" -> CallCue.decode(value)?.let(::Call) ?: Ignored
+ // One this app can't read is passed over: the sheet reads `networkView` when the link comes back.
+ "network" -> runCatching { Network(NetworkView.decode(value.getValue("network"))) }.getOrDefault(Ignored)
"resync" -> Resync
// Match the existing clients: unknown events do not advance the cursor.
else -> Ignored
diff --git a/apps/android/core/src/main/kotlin/com/codync/android/core/Network.kt b/apps/android/core/src/main/kotlin/com/codync/android/core/Network.kt
new file mode 100644
index 00000000..8fc543a5
--- /dev/null
+++ b/apps/android/core/src/main/kotlin/com/codync/android/core/Network.kt
@@ -0,0 +1,43 @@
+package com.codync.android.core
+
+import kotlinx.serialization.Serializable
+import kotlinx.serialization.json.JsonElement
+import kotlinx.serialization.json.decodeFromJsonElement
+
+/**
+ * The computer's network of the user's computers as phones see it (`networkView`, the `network` event): read-only,
+ * since who is in is decided at a computer (CodyncKit `NetworkView`).
+ */
+@Serializable
+data class NetworkView(
+ val joined: Boolean = false,
+ /** This computer's name in the network. */
+ val computer: String? = null,
+ val assistants: Boolean = false,
+ val computers: List<NetworkComputer> = emptyList(),
+) {
+ /** Something to show: the network, or cloud assistants turned on. */
+ val shown: Boolean get() = joined || assistants
+
+ companion object {
+ fun decode(value: JsonElement): NetworkView = WireJson.decodeFromJsonElement(value)
+ }
+}
+
+@Serializable
+data class NetworkComputer(
+ val name: String,
+ /** `owner`, `admin` or `member`. */
+ val role: String = "member",
+ /** The computer this phone is paired with. */
+ val me: Boolean = false,
+ val online: Boolean = false,
+ /** The bots it offers to the network. */
+ val agents: List<NetworkAgent> = emptyList(),
+) {
+ val roleTitle: String get() = when (role) { "owner" -> "Owner"; "admin" -> "Admin"; else -> "Member" }
+ val presence: String get() = when { me -> "This computer"; online -> "Online"; else -> "Away" }
+}
+
+@Serializable
+data class NetworkAgent(val id: String, val name: String = id)
diff --git a/apps/android/core/src/test/kotlin/com/codync/android/core/NetworkTest.kt b/apps/android/core/src/test/kotlin/com/codync/android/core/NetworkTest.kt
new file mode 100644
index 00000000..a91a7d66
--- /dev/null
+++ b/apps/android/core/src/test/kotlin/com/codync/android/core/NetworkTest.kt
@@ -0,0 +1,38 @@
+package com.codync.android.core
+
+import kotlinx.serialization.json.*
+import org.junit.Assert.*
+import org.junit.Test
+
+class NetworkTest {
+ private val view = WireJson.parseToJsonElement("""
+ {"joined": true, "computer": "desk", "role": "owner", "connector": "public", "assistants": false,
+ "computers": [
+ {"name": "desk", "role": "owner", "me": true, "online": true, "bots": ["reviewer"],
+ "agents": [{"id": "reviewer", "name": "Reviewer"}], "canRemove": false, "canPromote": false},
+ {"name": "laptop", "role": "admin", "me": false, "online": false, "bots": [], "agents": [],
+ "canRemove": true, "canPromote": false, "later": 1}]}
+ """)
+
+ @Test fun `a network view reads the computers, their roles and what they offer`() {
+ val read = NetworkView.decode(view)
+ assertTrue(read.joined && read.shown && !read.assistants)
+ assertEquals(listOf("desk", "laptop"), read.computers.map { it.name })
+ assertEquals(listOf("Owner", "Admin"), read.computers.map { it.roleTitle })
+ assertEquals(listOf("This computer", "Away"), read.computers.map { it.presence })
+ assertEquals(listOf(NetworkAgent("reviewer", "Reviewer")), read.computers[0].agents)
+ }
+
+ @Test fun `a computer in no network shows only when cloud assistants are on`() {
+ assertFalse(NetworkView.decode(buildJsonObject { put("joined", false); put("assistants", false) }).shown)
+ assertTrue(NetworkView.decode(buildJsonObject { put("joined", false); put("assistants", true) }).shown)
+ }
+
+ @Test fun `the network event is live state, and one this app can't read is passed over`() {
+ val event = MirrorEvent.decode(buildJsonObject { put("type", "network"); put("network", view) })
+ assertEquals("laptop", (event as MirrorEvent.Network).view.computers[1].name)
+ val broken = buildJsonObject { put("type", "network"); putJsonObject("network") { put("computers", "many") } }
+ assertEquals(MirrorEvent.Ignored, MirrorEvent.decode(broken))
+ assertEquals(MirrorEvent.Ignored, MirrorEvent.decode(buildJsonObject { put("type", "network") }))
+ }
+}
diff --git a/apps/desktop/src/renderer/client/host-client.ts b/apps/desktop/src/renderer/client/host-client.ts
index 72c90ba3..276e4031 100644
--- a/apps/desktop/src/renderer/client/host-client.ts
+++ b/apps/desktop/src/renderer/client/host-client.ts
@@ -5,6 +5,7 @@ import {
type AccessRequest,
type Bot,
type CloudStatus,
+ type NetworkView,
type Entry,
type Hello,
type ScreenState,
@@ -73,6 +74,8 @@ export type HostEvent =
| { type: 'screen'; screen: ScreenState }
| { type: 'accessRequests'; requests: AccessRequest[] }
| { type: 'cloud'; cloud: CloudStatus }
+ /** This computer's network changed (members, roles, presence, offered bots) or cloud assistants were switched. */
+ | { type: 'network'; network: NetworkView }
/** For the voice of a call in this app (only the computer's own apps receive this computer's calls' cues). */
| { type: 'call'; cue: CallCue }
| { type: 'resync' }
@@ -121,6 +124,8 @@ export function parseEvent(line: string): HostEvent | null {
return { type, requests: (raw.requests as AccessRequest[]) ?? [] }
case 'cloud':
return raw.cloud ? { type, cloud: raw.cloud as CloudStatus } : null
+ case 'network':
+ return raw.network ? { type, network: raw.network as NetworkView } : null
case 'call': {
const cue = parseCallCue(raw)
return cue ? { type, cue } : null
diff --git a/apps/desktop/src/renderer/components/Overlay.tsx b/apps/desktop/src/renderer/components/Overlay.tsx
index c4e3a192..6dcf9cea 100644
--- a/apps/desktop/src/renderer/components/Overlay.tsx
+++ b/apps/desktop/src/renderer/components/Overlay.tsx
@@ -374,7 +374,7 @@ export function SheetPage({ className, children }: { className?: string; childre
/**
* A modal's title row: an optional icon, the title (and a line under it), optional trailing
* actions, and a close button that dismisses the modal, or calls `onClose` for a panel that
- * isn't one.
+ * isn't one. `onClose={null}` leaves the close button out (a modal only its own action ends).
*/
export function ModalHeader({ title, subtitle, icon, trailing, onClose, closeTitle = 'Close' }: {
title: ReactNode
@@ -382,7 +382,7 @@ export function ModalHeader({ title, subtitle, icon, trailing, onClose, closeTit
/** An SF Symbol name (shown on a tile), or a picture of its own (an agent's logo). */
icon?: string | ReactElement
trailing?: ReactNode
- onClose?: () => void
+ onClose?: (() => void) | null
closeTitle?: string
}) {
const dismiss = useDismiss()
@@ -399,7 +399,7 @@ export function ModalHeader({ title, subtitle, icon, trailing, onClose, closeTit
{subtitle !== undefined ? <Text size="callout" tone="secondary" lines={2} title={typeof subtitle === 'string' ? subtitle : undefined}>{subtitle}</Text> : null}
</VStack>
{trailing}
- <IconButtonBase title={closeTitle} icon="xmark" onClick={onClose ?? dismiss} />
+ {onClose === null ? null : <IconButtonBase title={closeTitle} icon="xmark" onClick={onClose ?? dismiss} />}
</div>
)
}
diff --git a/apps/desktop/src/renderer/lib/network-copy.test.ts b/apps/desktop/src/renderer/lib/network-copy.test.ts
new file mode 100644
index 00000000..39b9b41d
--- /dev/null
+++ b/apps/desktop/src/renderer/lib/network-copy.test.ts
@@ -0,0 +1,28 @@
+import assert from 'node:assert/strict'
+import test from 'node:test'
+import type { NetworkComputer } from '@shared/models'
+import { botsTemplate, canInvite, canRecover, connectorFor, presenceTitle } from './network-copy.ts'
+
+const computer = (c: Partial<NetworkComputer>): NetworkComputer => ({
+ name: 'laptop', role: 'member', me: false, online: false, agents: [], canRemove: false, canPromote: false, ...c,
+})
+
+test('a relay connector needs an address; an empty one would quietly mean public', () => {
+ assert.deepEqual(connectorFor('public', 'ignored'), { connector: 'public' })
+ assert.deepEqual(connectorFor('private', ''), { connector: 'private' })
+ assert.deepEqual(connectorFor('relay', ' https://relay.example.com '), { connector: 'https://relay.example.com' })
+ assert.ok('problem' in connectorFor('relay', ' '))
+})
+
+test('rows say where each computer is and how many bots it offers', () => {
+ assert.equal(presenceTitle(computer({ me: true })), 'This computer')
+ assert.equal(presenceTitle(computer({ online: true })), 'Online')
+ assert.equal(presenceTitle(computer({})), 'Away')
+ assert.equal(botsTemplate(computer({ agents: [{ id: 'a', name: 'A' }] })), '1 bot')
+ assert.equal(botsTemplate(computer({})), '{count} bots')
+})
+
+test('the owner and admins invite; everyone but the owner may recover', () => {
+ assert.deepEqual([canInvite('owner'), canInvite('admin'), canInvite('member')], [true, true, false])
+ assert.deepEqual([canRecover('owner'), canRecover('admin'), canRecover(null)], [false, true, true])
+})
diff --git a/apps/desktop/src/renderer/lib/network-copy.ts b/apps/desktop/src/renderer/lib/network-copy.ts
new file mode 100644
index 00000000..6c52ea8e
--- /dev/null
+++ b/apps/desktop/src/renderer/lib/network-copy.ts
@@ -0,0 +1,33 @@
+/** What the Network section says about this computer's network (codync-network). */
+
+import type { NetworkComputer, NetworkRole } from '@shared/models'
+
+/** How computers reach each other without a direct path. */
+export type ConnectorChoice = 'public' | 'private' | 'relay'
+
+export const connectorChoices: { id: ConnectorChoice; label: string; detail: string }[] = [
+ { id: 'public', label: 'Public relays', detail: 'Direct when it can, through a shared relay otherwise.' },
+ { id: 'private', label: 'Private: direct only', detail: 'Same network, Tailscale or a VPN.' },
+ { id: 'relay', label: 'Your own relay', detail: 'An iroh-relay you run.' },
+]
+
+/** The host's `connector` for a choice, or what's missing. An empty URL would quietly mean `public`. */
+export function connectorFor(choice: ConnectorChoice, url: string): { connector: string } | { problem: string } {
+ if (choice !== 'relay') return { connector: choice }
+ const address = url.trim()
+ return address ? { connector: address } : { problem: "Enter your relay's address." }
+}
+
+export const roleTitle = (role: NetworkRole) => ({ owner: 'Owner', admin: 'Admin', member: 'Member' })[role]
+
+export const presenceTitle = (c: NetworkComputer) => (c.me ? 'This computer' : c.online ? 'Online' : 'Away')
+
+/** "3 bots", untranslated template first: the caller translates, then puts the count in. */
+export const botsTemplate = (c: NetworkComputer) => (c.agents.length === 1 ? '1 bot' : '{count} bots')
+
+/** The owner and admins invite; whoever isn't the owner may take ownership with the recovery code. */
+export const canInvite = (role: NetworkRole | null | undefined) => role === 'owner' || role === 'admin'
+export const canRecover = (role: NetworkRole | null | undefined) => role !== 'owner'
+
+/** "3:27 PM" for an invite's expiry (Unix ms). */
+export const expiryTime = (expiresAt: number) => new Date(expiresAt).toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' })
diff --git a/apps/desktop/src/renderer/store/bot-mirror.ts b/apps/desktop/src/renderer/store/bot-mirror.ts
index 76ac0765..7e05a394 100644
--- a/apps/desktop/src/renderer/store/bot-mirror.ts
+++ b/apps/desktop/src/renderer/store/bot-mirror.ts
@@ -6,6 +6,7 @@ import {
type Computer,
type Entry,
type Hello,
+ type NetworkView,
type ScreenState,
type Usage,
} from '@shared/models'
@@ -43,6 +44,8 @@ export class BotMirror extends Observable {
screen: ScreenState | null = null
accessRequests: AccessRequest[] = []
cloud: CloudStatus | null = null
+ /** This computer's network; null until known, and on hosts without `networkView`. */
+ network: NetworkView | null = null
historyComplete = new Set<string>()
routineDrafts = new Map<string, string>()
readonly composerDrafts: ComposerDrafts
@@ -200,6 +203,11 @@ export class BotMirror extends Observable {
this.changed()
}
+ setNetwork(network: NetworkView | null) {
+ this.network = network
+ this.changed()
+ }
+
// MARK: cache (instant launch, offline reading)
private get cacheKey() {
diff --git a/apps/desktop/src/renderer/store/bot-sync.ts b/apps/desktop/src/renderer/store/bot-sync.ts
index 91d981d9..f4883db0 100644
--- a/apps/desktop/src/renderer/store/bot-sync.ts
+++ b/apps/desktop/src/renderer/store/bot-sync.ts
@@ -1,4 +1,4 @@
-import { isChat, type AccessRequest, type CloudStatus, type Entry } from '@shared/models'
+import { isChat, type AccessRequest, type CloudStatus, type Entry, type NetworkView } from '@shared/models'
import { isOutsideLoadedWindow, snapshotFloors } from '@shared/mirror-window'
import { HostClient, HostError, type HostEvent } from '../client/host-client'
import { BotMirror, type Connection } from './bot-mirror'
@@ -134,6 +134,12 @@ export class BotSync extends BotMirror {
try {
this.cloud = await client.call<CloudStatus>('cloudStatus')
} catch {}
+ try {
+ this.network = await client.call<NetworkView>('networkView')
+ } catch {
+ // Hosts before the network screens don't have it: no Network section.
+ this.network = null
+ }
this.changed()
}
if (!alive()) return
@@ -241,6 +247,9 @@ export class BotSync extends BotMirror {
case 'cloud':
this.cloud = event.cloud
break
+ case 'network':
+ this.network = event.network
+ break
case 'call': {
const { cue } = event
const hear = this.callCues.get(cue.call)
diff --git a/apps/desktop/src/renderer/store/network.ts b/apps/desktop/src/renderer/store/network.ts
new file mode 100644
index 00000000..f593e420
--- /dev/null
+++ b/apps/desktop/src/renderer/store/network.ts
@@ -0,0 +1,46 @@
+import type { CloudStatus, NetworkView } from '@shared/models'
+import type { BotStore } from './bot-store'
+
+/**
+ * A managed computer's network (codync-network) through its host's loopback API: the calls
+ * behind the Network section. Membership is decided at a computer, so only loopback works; the
+ * `network` event keeps `store.network` current, and each change reads it again in case the
+ * event is still on its way.
+ */
+
+/** Joining asks the inviting computer; asking every computer waits for the ones that are away. */
+const SLOW = 30_000
+
+async function call<T>(store: BotStore, method: string, body: object = {}, timeout?: number) {
+ return (await store.ready()).call<T>(method, body, timeout)
+}
+
+/** Reads the view again; the host asks the other computers in the background when it's stale. */
+export async function refreshNetwork(store: BotStore) {
+ try {
+ store.setNetwork(await call<NetworkView>(store, 'networkView'))
+ } catch {
+ // A host without the network screens, or one that went away: the next connection reads it again.
+ }
+}
+
+async function changing<T>(store: BotStore, work: () => Promise<T>): Promise<T> {
+ const result = await work()
+ await refreshNetwork(store)
+ return result
+}
+
+export const network = {
+ /** Asks every computer now. */
+ peers: (store: BotStore) => changing(store, () => call(store, 'networkPeers', {}, SLOW)),
+ /** Returns the recovery code: show it once, keep it nowhere. */
+ create: (store: BotStore, name: string, connector: string) =>
+ changing(store, async () => (await call<{ recoveryCode: string }>(store, 'networkCreate', { name: name.trim() || null, connector }, SLOW)).recoveryCode),
+ join: (store: BotStore, invite: string, name: string, connector: string) =>
+ changing(store, () => call(store, 'networkJoin', { invite: invite.trim(), name: name.trim() || null, connector }, SLOW)),
+ invite: (store: BotStore) => call<{ invite: string; expiresAt: number }>(store, 'networkInvite'),
+ promote: (store: BotStore, computer: string) => changing(store, () => call(store, 'networkPromote', { computer })),
+ remove: (store: BotStore, computer: string, cascade: boolean) => changing(store, () => call(store, 'networkRemove', { computer, cascade })),
+ recover: (store: BotStore, code: string) => changing(store, () => call(store, 'networkRecover', { code: code.trim() })),
+ setAssistants: (store: BotStore, enabled: boolean) => changing(store, () => call<CloudStatus>(store, 'setAssistants', { enabled })),
+}
diff --git a/apps/desktop/src/renderer/views/settings/ComputersView.tsx b/apps/desktop/src/renderer/views/settings/ComputersView.tsx
index 3efc082f..9ab33de0 100644
--- a/apps/desktop/src/renderer/views/settings/ComputersView.tsx
+++ b/apps/desktop/src/renderer/views/settings/ComputersView.tsx
@@ -14,6 +14,7 @@ import { StoreContext, useApp } from '../../store/context'
import { ComputerBadge } from '../ComputerBadge'
import { PairingCode } from '../PairingCode'
import { AuthorizedDevicesSection } from './AuthorizedDevicesSection'
+import { AssistantsSwitch, NetworkSection } from './NetworkSection'
import { cloudStatusLine } from '../../lib/relay-copy'
import { useTr } from '../../lib/use-language'
import { errorText, liveClient, relativeDay, SectionHeader, statusText, thisMac } from './parts'
@@ -215,11 +216,15 @@ function ManagedComputerCard({ store, ssh: overSSH }: { store: BotStore; ssh: bo
</Text>
</span>
</Switch>,
+ // Hosts before 2.28.0 have no cloud assistants.
+ ...(cloud?.assistants != null ? [<AssistantsSwitch key="assistants" store={store} disabled={busy || !manageable} />] : []),
]
: []),
]}
</CardSection>
+ <NetworkSection store={store} />
+
<AuthorizedDevicesSection store={store} />
<Sheet open={showVoice} onClose={() => setShowVoice(false)}>
diff --git a/apps/desktop/src/renderer/views/settings/NetworkSection.tsx b/apps/desktop/src/renderer/views/settings/NetworkSection.tsx
new file mode 100644
index 00000000..915a63fd
--- /dev/null
+++ b/apps/desktop/src/renderer/views/settings/NetworkSection.tsx
@@ -0,0 +1,154 @@
+import { useEffect, useState } from 'react'
+import type { NetworkComputer } from '@shared/models'
+import { Button, CardSection, IconButton, Switch } from '../../components/Controls'
+import { Dialog, Sheet } from '../../components/Overlay'
+import { HStack, VStack } from '../../components/Stack'
+import { Text } from '../../components/Text'
+import { useModel } from '../../lib/observable'
+import { botsTemplate, canInvite, canRecover, presenceTitle, roleTitle } from '../../lib/network-copy'
+import { useTr } from '../../lib/use-language'
+import type { BotStore } from '../../store/bot-store'
+import { network, refreshNetwork } from '../../store/network'
+import { InviteSheet, NetworkSetupSheet, RecoverSheet, RecoveryCodeSheet } from './NetworkSheets'
+import { errorText } from './parts'
+import './network.css'
+
+type Open = 'create' | 'join' | 'invite' | 'recover'
+
+/**
+ * A managed computer's network of the user's computers (codync-network): set it up, invite,
+ * and who is in. Hidden on hosts without `networkView`. Membership is decided here, at the
+ * computer; phones only see it.
+ */
+export function NetworkSection({ store }: { store: BotStore }) {
+ const tr = useTr()
+ useModel(store)
+ const [open, setOpen] = useState<Open | null>(null)
+ const [recoveryCode, setRecoveryCode] = useState<string | null>(null)
+ const [removing, setRemoving] = useState<NetworkComputer | null>(null)
+ const [busy, setBusy] = useState(false)
+ const view = store.network
+ const manageable = store.connection.kind === 'online' && !store.mismatch
+
+ // Opening the page reads it again: the host asks the other computers when what it heard is stale.
+ useEffect(() => {
+ if (manageable) void refreshNetwork(store)
+ }, [store, manageable])
+
+ if (!view) return null
+
+ const run = (work: () => Promise<unknown>) => {
+ setBusy(true)
+ work()
+ .catch((e: unknown) => store.setError(errorText(e)))
+ .finally(() => setBusy(false))
+ }
+
+ const accessory = view.joined ? (
+ <HStack gap={2}>
+ {canInvite(view.role) ? <IconButton title="Invite a computer" icon="person.crop.circle.badge.plus" disabled={!manageable} onClick={() => setOpen('invite')} /> : null}
+ {canRecover(view.role) ? <IconButton title="Recover ownership" icon="key" disabled={!manageable} onClick={() => setOpen('recover')} /> : null}
+ <IconButton title="Refresh" icon="arrow.clockwise" disabled={busy || !manageable} onClick={() => run(() => network.peers(store))} />
+ </HStack>
+ ) : null
+
+ return (
+ <>
+ <CardSection title="Network" accessory={accessory} footer={view.joined ? 'Bots message the bots on these computers as bot@computer.' : null}>
+ {view.joined
+ ? (view.computers ?? []).map((c) => (
+ <ComputerRow
+ key={c.name}
+ computer={c}
+ disabled={busy || !manageable}
+ promote={() => run(() => network.promote(store, c.name))}
+ remove={() => setRemoving(c)}
+ />
+ ))
+ : [
+ <VStack key="setup" gap={10} className="settings-appear">
+ <Text size="callout" tone="secondary">{tr('Connect your computers so bots on one can message bots on another.')}</Text>
+ <HStack gap={8}>
+ <Button kind="secondary" disabled={!manageable} onClick={() => setOpen('create')}>Create network</Button>
+ <Button kind="secondary" disabled={!manageable} onClick={() => setOpen('join')}>Join with invite</Button>
+ </HStack>
+ </VStack>,
+ ]}
+ </CardSection>
+
+ <Sheet open={open === 'create' || open === 'join'} onClose={() => setOpen(null)}>
+ <NetworkSetupSheet key={open} store={store} joining={open === 'join'} created={setRecoveryCode} />
+ </Sheet>
+ <Sheet open={open === 'invite'} onClose={() => setOpen(null)}>
+ <InviteSheet store={store} />
+ </Sheet>
+ <Sheet open={open === 'recover'} onClose={() => setOpen(null)}>
+ <RecoverSheet store={store} />
+ </Sheet>
+ {/* Escape and the dim don't close it: only "I saved it" does. */}
+ <Sheet open={recoveryCode !== null} onClose={() => {}}>
+ {recoveryCode ? <RecoveryCodeSheet code={recoveryCode} name={store.hostName} done={() => setRecoveryCode(null)} /> : null}
+ </Sheet>
+ <Dialog
+ open={removing !== null}
+ title={tr('Remove {name} from the network?').replaceAll('{name}', removing?.name ?? '')}
+ message={tr("It can't come back with its current key. For a stolen computer, also remove the computers it invited.")}
+ actions={
+ removing
+ ? [
+ { title: 'Remove', destructive: true, action: () => run(() => network.remove(store, removing.name, false)) },
+ { title: 'Remove with its invites', destructive: true, action: () => run(() => network.remove(store, removing.name, true)) },
+ ]
+ : []
+ }
+ onClose={() => setRemoving(null)}
+ />
+ </>
+ )
+}
+
+function ComputerRow({ computer: c, disabled, promote, remove }: { computer: NetworkComputer; disabled: boolean; promote: () => void; remove: () => void }) {
+ const tr = useTr()
+ const bots = tr(botsTemplate(c)).replaceAll('{count}', String(c.agents.length))
+ const detail = [tr(roleTitle(c.role)), tr(presenceTitle(c)), bots].join(' · ')
+ return (
+ <HStack gap={8} className="settings-row settings-appear">
+ <span className={`network-dot${c.me || c.online ? ' online' : ''}`} aria-hidden />
+ <VStack grow className="settings-stack">
+ <Text>{c.name}</Text>
+ <Text size="caption" tone="secondary" truncate title={c.agents.map((a) => a.name).join(', ') || undefined}>{detail}</Text>
+ </VStack>
+ {c.canPromote ? <Button kind="secondary" disabled={disabled} onClick={promote}>Make admin</Button> : null}
+ {c.canRemove ? <IconButton title="Remove from the network" icon="trash" disabled={disabled} onClick={remove} /> : null}
+ </HStack>
+ )
+}
+
+/**
+ * Whether the user's cloud assistant may message this computer's bots. The cloud reads these
+ * calls, so the computer decides; shown only for a computer in the account (a private relay has none).
+ */
+export function AssistantsSwitch({ store, disabled }: { store: BotStore; disabled: boolean }) {
+ const tr = useTr()
+ const on = store.cloud?.assistants === true
+ const [busy, setBusy] = useState(false)
+ const set = (enabled: boolean) => {
+ setBusy(true)
+ network
+ .setAssistants(store, enabled)
+ .catch((e: unknown) => store.setError(errorText(e)))
+ .finally(() => setBusy(false))
+ }
+ return (
+ <Switch on={on} disabled={disabled || busy} onChange={set}>
+ <span className="settings-stack settings-appear">
+ <Text>{tr(`Cloud assistants`)}</Text>
+ <Text size="caption" tone={on ? 'attention' : 'secondary'}>
+ {on
+ ? tr(`ChatGPT or Claude in your Codync account can message this computer's bots. Codync's cloud can read these calls.`)
+ : tr(`Let ChatGPT or Claude message this computer's bots through your Codync account.`)}
+ </Text>
+ </span>
+ </Switch>
+ )
+}
diff --git a/apps/desktop/src/renderer/views/settings/NetworkSheets.tsx b/apps/desktop/src/renderer/views/settings/NetworkSheets.tsx
new file mode 100644
index 00000000..e77a8d39
--- /dev/null
+++ b/apps/desktop/src/renderer/views/settings/NetworkSheets.tsx
@@ -0,0 +1,188 @@
+import { useCallback, useEffect, useState } from 'react'
+import { Button, CardSection, ChoiceList, IconButton, Reveal, Spinner } from '../../components/Controls'
+import { ModalHeader, useDismiss } from '../../components/Overlay'
+import { HStack, VStack } from '../../components/Stack'
+import { Text } from '../../components/Text'
+import { connectorChoices, connectorFor, expiryTime, type ConnectorChoice } from '../../lib/network-copy'
+import { useTr } from '../../lib/use-language'
+import type { BotStore } from '../../store/bot-store'
+import { network } from '../../store/network'
+import { errorText } from './parts'
+
+const NETWORK_ICON = 'point.3.connected.trianglepath.dotted'
+
+function Field({ label, value, set, placeholder, mono = false }: { label: string; value: string; set: (v: string) => void; placeholder: string; mono?: boolean }) {
+ const tr = useTr()
+ return (
+ <HStack gap={12} className="settings-row">
+ <Text tone="text">{tr(label)}</Text>
+ <input
+ className={`settings-field${mono ? ' settings-mono' : ''}`}
+ aria-label={tr(label)}
+ placeholder={tr(placeholder)}
+ value={value}
+ spellCheck={false}
+ onChange={(e) => set(e.target.value)}
+ />
+ </HStack>
+ )
+}
+
+/** Create a network (this computer its owner) or join one with an invite. */
+export function NetworkSetupSheet({ store, joining, created }: { store: BotStore; joining: boolean; created: (recoveryCode: string) => void }) {
+ const tr = useTr()
+ const dismiss = useDismiss()
+ const [invite, setInvite] = useState('')
+ const [name, setName] = useState('')
+ const [choice, setChoice] = useState<ConnectorChoice>('public')
+ const [url, setUrl] = useState('')
+ const [busy, setBusy] = useState(false)
+ const [problem, setProblem] = useState<string | null>(null)
+
+ const save = async () => {
+ if (busy) return
+ if (joining && !invite.trim()) return setProblem(tr('Paste the invite from the other computer.'))
+ const connector = connectorFor(choice, url)
+ if ('problem' in connector) return setProblem(tr(connector.problem))
+ setBusy(true)
+ setProblem(null)
+ try {
+ if (joining) {
+ await network.join(store, invite, name, connector.connector)
+ dismiss()
+ } else {
+ const code = await network.create(store, name, connector.connector)
+ dismiss()
+ created(code)
+ }
+ } catch (e) {
+ setProblem(errorText(e))
+ } finally {
+ setBusy(false)
+ }
+ }
+
+ return (
+ <VStack className="network-sheet" onKeyDown={(e) => e.key === 'Enter' && e.target instanceof HTMLInputElement && void save()}>
+ <ModalHeader
+ icon={NETWORK_ICON}
+ title={joining ? 'Join with invite' : 'Create network'}
+ trailing={busy ? <Spinner /> : <IconButton title={joining ? 'Join' : 'Create'} icon="checkmark" onClick={() => void save()} />}
+ />
+ <VStack gap={16} className="network-sheet-body">
+ <CardSection footer={joining ? null : 'This computer becomes the owner: it invites the others.'}>
+ {[
+ ...(joining ? [<Field key="invite" label="Invite" value={invite} set={setInvite} placeholder="codync-network:…" mono />] : []),
+ <Field key="name" label="Computer name" value={name} set={setName} placeholder="Host name" />,
+ ]}
+ </CardSection>
+ <CardSection title="When there's no direct path">
+ <ChoiceList selection={choice} options={connectorChoices} onChange={setChoice} />
+ {choice === 'relay' ? <Field key="url" label="Relay address" value={url} set={setUrl} placeholder="https://" /> : null}
+ </CardSection>
+ <Reveal show={problem !== null}>
+ <Text size="caption" tone="danger">{problem}</Text>
+ </Reveal>
+ </VStack>
+ </VStack>
+ )
+}
+
+/** The recovery code, once: closing it is confirming it was saved. The host keeps it nowhere. */
+export function RecoveryCodeSheet({ code, name, done }: { code: string; name: string; done: () => void }) {
+ const tr = useTr()
+ return (
+ <VStack className="network-sheet">
+ <ModalHeader icon="key" title="Save your recovery code" onClose={null} />
+ <VStack gap={14} className="network-sheet-body">
+ <HStack gap={8}>
+ <Text as="div" className="settings-code network-code" mono>{code}</Text>
+ <IconButton title="Copy recovery code" icon="doc.on.doc" onClick={() => window.codync.app.copy(code)} />
+ </HStack>
+ <Text size="callout" tone="secondary">
+ {tr("It makes another computer the owner if {name} is lost. It's shown only once and kept on no computer.").replaceAll('{name}', name)}
+ </Text>
+ <HStack justify="end">
+ <Button onClick={done}>I saved it</Button>
+ </HStack>
+ </VStack>
+ </VStack>
+ )
+}
+
+/** A one-time invite for another computer, good for an hour while this one stays on. */
+export function InviteSheet({ store }: { store: BotStore }) {
+ const tr = useTr()
+ const [invite, setInvite] = useState<{ invite: string; expiresAt: number } | { error: string } | null>(null)
+ const make = useCallback(async () => {
+ setInvite(null)
+ try {
+ setInvite(await network.invite(store))
+ } catch (e) {
+ setInvite({ error: errorText(e) })
+ }
+ }, [store])
+ useEffect(() => void make(), [make])
+
+ return (
+ <VStack className="network-sheet">
+ <ModalHeader icon="person.crop.circle.badge.plus" title="Invite a computer" trailing={<IconButton title="New invite" icon="arrow.clockwise" onClick={() => void make()} />} />
+ <VStack gap={14} className="network-sheet-body">
+ {invite === null ? (
+ <Spinner />
+ ) : 'error' in invite ? (
+ <Text tone="danger">{invite.error}</Text>
+ ) : (
+ <>
+ <HStack gap={8}>
+ <Text as="div" className="settings-code network-code" mono>{invite.invite}</Text>
+ <IconButton title="Copy invite" icon="doc.on.doc" onClick={() => window.codync.app.copy(invite.invite)} />
+ </HStack>
+ <Text size="callout" tone="secondary">
+ {tr('One use. Works until {time} while {name} stays on.').replaceAll('{time}', expiryTime(invite.expiresAt)).replaceAll('{name}', store.hostName)}
+ </Text>
+ <Text size="callout" tone="secondary">{tr('On the other computer, choose Join with invite under Network.')}</Text>
+ </>
+ )}
+ </VStack>
+ </VStack>
+ )
+}
+
+/** Takes ownership with the recovery code, for when the owner was lost. */
+export function RecoverSheet({ store }: { store: BotStore }) {
+ const tr = useTr()
+ const [code, setCode] = useState('')
+ const [busy, setBusy] = useState(false)
+ const [result, setResult] = useState<{ ok: boolean; text: string } | null>(null)
+ const recover = async () => {
+ if (busy || !code.trim()) return
+ setBusy(true)
+ try {
+ await network.recover(store, code)
+ setResult({ ok: true, text: tr('{name} is the owner now. Remove the lost computer from the list.').replaceAll('{name}', store.hostName) })
+ } catch (e) {
+ setResult({ ok: false, text: errorText(e) })
+ } finally {
+ setBusy(false)
+ }
+ }
+
+ return (
+ <VStack className="network-sheet" onKeyDown={(e) => e.key === 'Enter' && e.target instanceof HTMLInputElement && void recover()}>
+ <ModalHeader
+ icon="key"
+ title="Recover ownership"
+ trailing={busy ? <Spinner /> : result?.ok ? null : <IconButton title="Recover" icon="checkmark" onClick={() => void recover()} />}
+ />
+ <VStack gap={16} className="network-sheet-body">
+ <CardSection footer="For when the owner is lost: this computer becomes the owner.">
+ <Field label="Recovery code" value={code} set={setCode} placeholder="00000000-…" mono />
+ </CardSection>
+ <Reveal show={result !== null}>
+ <Text size="caption" tone={result?.ok ? 'secondary' : 'danger'}>{result?.text}</Text>
+ </Reveal>
+ </VStack>
+ </VStack>
+ )
+}
diff --git a/apps/desktop/src/renderer/views/settings/network.css b/apps/desktop/src/renderer/views/settings/network.css
new file mode 100644
index 00000000..45901c38
--- /dev/null
+++ b/apps/desktop/src/renderer/views/settings/network.css
@@ -0,0 +1,22 @@
+/* Network: the computers in this computer's network, and the sheets that set it up. */
+.network-dot {
+ width: 7px;
+ height: 7px;
+ flex: none;
+ border-radius: var(--radius-pill);
+ background: var(--tertiary);
+}
+.network-dot.online {
+ background: var(--added);
+}
+.network-sheet {
+ width: 440px;
+}
+.network-sheet-body {
+ padding: 4px 20px 20px;
+}
+/* An invite or recovery code: long, and copied whole. */
+.network-code {
+ word-break: break-all;
+ user-select: all;
+}
diff --git a/apps/desktop/src/shared/models.ts b/apps/desktop/src/shared/models.ts
index d334e149..4ae471e8 100644
--- a/apps/desktop/src/shared/models.ts
+++ b/apps/desktop/src/shared/models.ts
@@ -540,6 +540,35 @@ export interface CloudStatus {
approval?: AccountApproval | null
/** Whose relay: a `private` one has no account, access requests or relayed screen. Absent from older hosts (always Codync's). */
relay?: 'codync' | 'private' | null
+ /** The user's cloud assistant may message this computer's bots (`setAssistants`). */
+ assistants?: boolean | null
+}
+
+export type NetworkRole = 'owner' | 'admin' | 'member'
+
+/** A computer in this computer's network (codync-network), as last heard. */
+export interface NetworkComputer {
+ name: string
+ role: NetworkRole
+ /** This computer. */
+ me: boolean
+ online: boolean
+ /** The bots it offers, by name. */
+ agents: { id: string; name: string }[]
+ /** What this computer may do to it; the host decides. */
+ canRemove: boolean
+ canPromote: boolean
+}
+
+/** `networkView` and the `network` event: this computer's network, and whether cloud assistants are on. */
+export interface NetworkView {
+ joined: boolean
+ assistants: boolean
+ computer?: string | null
+ role?: NetworkRole | null
+ /** `public`, `private` or a relay URL. */
+ connector?: string | null
+ computers?: NetworkComputer[]
}
export interface ClaimSignature {
diff --git a/apps/ios/Kit/Sources/CodyncKit/Analytics/AnalyticsEvent.swift b/apps/ios/Kit/Sources/CodyncKit/Analytics/AnalyticsEvent.swift
index 1413a495..6d5f66f3 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Analytics/AnalyticsEvent.swift
+++ b/apps/ios/Kit/Sources/CodyncKit/Analytics/AnalyticsEvent.swift
@@ -50,7 +50,7 @@ public enum AnalyticsEvent: Equatable, Sendable {
public enum Screen: String, Sendable {
case bots, state, chat, trace, botDetails = "bot_details", memory, routines, marketplace
case settings, computers, usage, account, pairing, voiceSettings = "voice_settings", remoteScreen = "remote_screen"
- case library, artifact
+ case library, artifact, network
}
public enum NotificationKind: String, Sendable {
diff --git a/apps/ios/Kit/Sources/CodyncKit/Client/HostClient.swift b/apps/ios/Kit/Sources/CodyncKit/Client/HostClient.swift
index d81deb2b..56f97dc1 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Client/HostClient.swift
+++ b/apps/ios/Kit/Sources/CodyncKit/Client/HostClient.swift
@@ -11,6 +11,8 @@ public enum HostEvent: Sendable {
case artifact(Artifact)
/// For the voice of a call on this device (only the device holding the call receives it).
case call(CallCue)
+ /// The computer's network changed (members, roles, presence, offered bots, cloud assistants).
+ case network(NetworkView)
case resync
/// An event this app version couldn't decode (host newer/older than the app).
case undecodable(type: String)
@@ -101,6 +103,7 @@ public struct HostClient: Sendable {
struct UsageWrap: Decodable { var usage: Usage }
struct ScreenWrap: Decodable { var screen: ScreenState }
struct ArtifactWrap: Decodable { var artifact: Artifact }
+ struct NetworkWrap: Decodable { var network: NetworkView }
let d = decoder
guard let env = try? d.decode(Envelope.self, from: data) else { return nil }
switch env.type {
@@ -124,6 +127,9 @@ public struct HostClient: Sendable {
return (try? d.decode(ArtifactWrap.self, from: data)).map { .artifact($0.artifact) }
case "call":
return (try? d.decode(CallCue.self, from: data)).map { .call($0) }
+ case "network":
+ // Not worth a rewind: the next connect asks for the view again.
+ return (try? d.decode(NetworkWrap.self, from: data)).map { .network($0.network) }
case "resync":
return .resync
default:
@@ -137,6 +143,9 @@ public struct HostClient: Sendable {
public extension HostClient {
func hello() async throws -> Hello { try await call("hello") }
+ /// The computer's network, read-only (hosts before it: "unknown method").
+ func networkView() async throws -> NetworkView { try await call("networkView") }
+
/// Updates a computer that's behind this app to the latest release (`Hello.canUpdate`).
func installHostUpdate() async throws {
let _: Empty = try await call("installHostUpdate")
diff --git a/apps/ios/Kit/Sources/CodyncKit/Models/Network.swift b/apps/ios/Kit/Sources/CodyncKit/Models/Network.swift
new file mode 100644
index 00000000..d82a1d5b
--- /dev/null
+++ b/apps/ios/Kit/Sources/CodyncKit/Models/Network.swift
@@ -0,0 +1,49 @@
+import Foundation
+
+/// The computer's network of the user's computers (`networkView`, and the `network` event): read-only
+/// on phones, since who is in is decided at a computer. Hosts before it answer "unknown method".
+public struct NetworkView: Codable, Hashable, Sendable {
+ public var joined: Bool
+ /// This computer's name in the network.
+ public var computer: String?
+ public var role: Role?
+ /// The user's cloud assistant may message this computer's bots.
+ public var assistants: Bool?
+ public var computers: [Computer]?
+
+ public enum Role: String, Codable, Hashable, Sendable {
+ case owner, admin, member
+ /// Any role a newer host adds reads as a plain member.
+ public init(from decoder: any Decoder) throws {
+ self = Role(rawValue: try decoder.singleValueContainer().decode(String.self)) ?? .member
+ }
+
+ public var title: String {
+ switch self {
+ case .owner: "Owner"
+ case .admin: "Admin"
+ case .member: "Member"
+ }
+ }
+ }
+
+ public struct Computer: Codable, Hashable, Sendable, Identifiable {
+ public var name: String
+ public var role: Role
+ public var me: Bool
+ public var online: Bool
+ /// The bots it offers, by address name and display name.
+ public var agents: [Agent]?
+
+ public var id: String { name }
+ }
+
+ public struct Agent: Codable, Hashable, Sendable, Identifiable {
+ public var id: String
+ public var name: String
+ }
+
+ public var isAssistantsOn: Bool { assistants ?? false }
+ /// Worth showing: in a network, or cloud assistants are on.
+ public var hasContent: Bool { joined || isAssistantsOn }
+}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
index c1532b78..56c1f5a7 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
@@ -1238,5 +1238,80 @@
"Install it first.": "Installiere es zuerst.",
"Not set up on {name} yet.": "Auf {name} noch nicht eingerichtet.",
"Downloads {name} on {host} if it needs to, then checks its sign-in.": "Lädt {name} bei Bedarf auf {host} herunter und prüft dann die Anmeldung.",
- "Rate on the App Store": "Im App Store bewerten"
+ "Rate on the App Store": "Im App Store bewerten",
+ "Network": "Netzwerk",
+ "Cloud assistants": "Cloud-Assistenten",
+ "Owner": "Eigentümer",
+ "Admin": "Admin",
+ "Member": "Mitglied",
+ "Away": "Nicht erreichbar",
+ "No bots": "Keine Bots",
+ "Changes are made on a computer: in Codync's settings there, or with codync-host network.": "Änderungen machst du an einem Computer: in den Codync-Einstellungen dort oder mit codync-host network.",
+ "ChatGPT or Claude in your Codync account can message this computer's bots when it's on. Codync's cloud can read these calls.": "Wenn das an ist, können ChatGPT oder Claude in deinem Codync-Konto den Bots dieses Computers schreiben. Die Codync-Cloud kann diese Aufrufe lesen.",
+ "ChatGPT or Claude in your Codync account can message this computer's bots. Codync's cloud can read these calls.": "ChatGPT oder Claude in deinem Codync-Konto können den Bots dieses Computers schreiben. Die Codync-Cloud kann diese Aufrufe lesen.",
+ "Let ChatGPT or Claude message this computer's bots through your Codync account.": "Lass ChatGPT oder Claude über dein Codync-Konto den Bots dieses Computers schreiben.",
+ "Public relays": "Öffentliche Relays",
+ "Direct when it can, through a shared relay otherwise.": "Direkt, wenn es geht, sonst über ein gemeinsames Relay.",
+ "Private: direct only": "Privat: nur direkt",
+ "Same network, Tailscale or a VPN.": "Gleiches Netzwerk, Tailscale oder ein VPN.",
+ "Your own relay": "Eigenes Relay",
+ "An iroh-relay you run.": "Ein iroh-relay, das du selbst betreibst.",
+ "Enter your relay's address.": "Gib die Adresse deines Relays ein.",
+ "1 bot": "1 Bot",
+ "{count} bots": "{count} Bots",
+ "Invite": "Einladung",
+ "Computer name": "Computername",
+ "Host name": "Hostname",
+ "Join with invite": "Mit Einladung beitreten",
+ "Create network": "Netzwerk erstellen",
+ "Join": "Beitreten",
+ "This computer becomes the owner: it invites the others.": "Dieser Computer wird Eigentümer: Er lädt die anderen ein.",
+ "When there's no direct path": "Wenn es keinen direkten Weg gibt",
+ "Paste the invite from the other computer.": "Füge die Einladung vom anderen Computer ein.",
+ "Save your recovery code": "Speichere deinen Wiederherstellungscode",
+ "Copy recovery code": "Wiederherstellungscode kopieren",
+ "It makes another computer the owner if {name} is lost. It's shown only once and kept on no computer.": "Damit wird ein anderer Computer Eigentümer, falls {name} verloren geht. Er wird nur einmal angezeigt und auf keinem Computer gespeichert.",
+ "I saved it": "Gespeichert",
+ "Invite a computer": "Computer einladen",
+ "New invite": "Neue Einladung",
+ "Copy invite": "Einladung kopieren",
+ "One use. Works until {time} while {name} stays on.": "Einmal verwendbar. Gilt bis {time}, solange {name} an bleibt.",
+ "On the other computer, choose Join with invite under Network.": "Wähle auf dem anderen Computer unter Netzwerk „Mit Einladung beitreten“.",
+ "Recover ownership": "Eigentum wiederherstellen",
+ "Recover": "Wiederherstellen",
+ "{name} is the owner now. Remove the lost computer from the list.": "{name} ist jetzt Eigentümer. Entferne den verlorenen Computer aus der Liste.",
+ "For when the owner is lost: this computer becomes the owner.": "Falls der Eigentümer verloren ist: Dieser Computer wird Eigentümer.",
+ "Recovery code": "Wiederherstellungscode",
+ "Refresh": "Aktualisieren",
+ "Bots message the bots on these computers as bot@computer.": "Bots schreiben den Bots auf diesen Computern als bot@computer.",
+ "Connect your computers so bots on one can message bots on another.": "Verbinde deine Computer, damit Bots auf einem den Bots auf einem anderen schreiben können.",
+ "Remove {name} from the network?": "{name} aus dem Netzwerk entfernen?",
+ "It can't come back with its current key. For a stolen computer, also remove the computers it invited.": "Mit seinem jetzigen Schlüssel kommt er nicht zurück. Bei einem gestohlenen Computer entferne auch die Computer, die er eingeladen hat.",
+ "Remove with its invites": "Mit seinen Einladungen entfernen",
+ "Make admin": "Zum Admin machen",
+ "Remove from the network": "Aus dem Netzwerk entfernen",
+ "y copy · s I saved it": "y kopieren · s gespeichert",
+ "Getting an invite…": "Einladung wird geholt…",
+ "y copy · n new invite · esc back": "y kopieren · n neue Einladung · esc zurück",
+ "↵ recover · esc back": "↵ wiederherstellen · esc zurück",
+ "It can't come back with its current key.": "Mit seinem jetzigen Schlüssel kommt er nicht zurück.",
+ "Also remove the computers it invited": "Auch die Computer entfernen, die er eingeladen hat",
+ "For a stolen computer.": "Für einen gestohlenen Computer.",
+ "↵ remove · c switches · esc cancel": "↵ entfernen · c umschalten · esc abbrechen",
+ "Not in a network.": "In keinem Netzwerk.",
+ "c create network · J join with invite · esc close": "c Netzwerk erstellen · J mit Einladung beitreten · esc schließen",
+ "i invite · p make admin · x remove · r refresh · esc close": "i einladen · p zum Admin machen · x entfernen · r aktualisieren · esc schließen",
+ "i invite · x remove · o recover ownership · r refresh · esc close": "i einladen · x entfernen · o Eigentum wiederherstellen · r aktualisieren · esc schließen",
+ "o recover ownership · r refresh · esc close": "o Eigentum wiederherstellen · r aktualisieren · esc schließen",
+ "Connector": "Verbindung",
+ "↵ done · tab next field · ←→ connector · esc back": "↵ fertig · tab nächstes Feld · ←→ Verbindung · esc zurück",
+ "Recovery code copied": "Wiederherstellungscode kopiert",
+ "Invite copied": "Einladung kopiert",
+ "This computer is the owner now. Remove the lost computer from the list.": "Dieser Computer ist jetzt Eigentümer. Entferne den verlorenen Computer aus der Liste.",
+ "Removed from the network": "Aus dem Netzwerk entfernt",
+ "Made an admin": "Zum Admin gemacht",
+ "Only the owner makes plain members admins": "Nur der Eigentümer macht einfache Mitglieder zu Admins",
+ "Remove this computer from another one": "Entferne diesen Computer von einem anderen aus",
+ "Only the owner removes admins; admins remove members": "Nur der Eigentümer entfernt Admins; Admins entfernen Mitglieder",
+ "Network: your other computers…": "Netzwerk: deine anderen Computer…"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
index 5d540799..8e8c0039 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
@@ -1238,5 +1238,80 @@
"Install it first.": "Instálalo primero.",
"Not set up on {name} yet.": "Aún no está configurado en {name}.",
"Downloads {name} on {host} if it needs to, then checks its sign-in.": "Descarga {name} en {host} si hace falta y luego comprueba su inicio de sesión.",
- "Rate on the App Store": "Valorar en el App Store"
+ "Rate on the App Store": "Valorar en el App Store",
+ "Network": "Red",
+ "Cloud assistants": "Asistentes en la nube",
+ "Owner": "Propietario",
+ "Admin": "Administrador",
+ "Member": "Miembro",
+ "Away": "Ausente",
+ "No bots": "Sin bots",
+ "Changes are made on a computer: in Codync's settings there, or with codync-host network.": "Los cambios se hacen en una computadora: en los ajustes de Codync de esa computadora o con codync-host network.",
+ "ChatGPT or Claude in your Codync account can message this computer's bots when it's on. Codync's cloud can read these calls.": "Si está activado, ChatGPT o Claude en tu cuenta de Codync pueden escribir a los bots de esta computadora. La nube de Codync puede leer estas llamadas.",
+ "ChatGPT or Claude in your Codync account can message this computer's bots. Codync's cloud can read these calls.": "ChatGPT o Claude en tu cuenta de Codync pueden escribir a los bots de esta computadora. La nube de Codync puede leer estas llamadas.",
+ "Let ChatGPT or Claude message this computer's bots through your Codync account.": "Deja que ChatGPT o Claude escriban a los bots de esta computadora a través de tu cuenta de Codync.",
+ "Public relays": "Relés públicos",
+ "Direct when it can, through a shared relay otherwise.": "Directo cuando se puede; si no, a través de un relé compartido.",
+ "Private: direct only": "Privado: solo directo",
+ "Same network, Tailscale or a VPN.": "La misma red, Tailscale o una VPN.",
+ "Your own relay": "Tu propio relé",
+ "An iroh-relay you run.": "Un iroh-relay que tú ejecutas.",
+ "Enter your relay's address.": "Escribe la dirección de tu relé.",
+ "1 bot": "1 bot",
+ "{count} bots": "{count} bots",
+ "Invite": "Invitación",
+ "Computer name": "Nombre de la computadora",
+ "Host name": "Nombre del host",
+ "Join with invite": "Unirse con una invitación",
+ "Create network": "Crear red",
+ "Join": "Unirse",
+ "This computer becomes the owner: it invites the others.": "Esta computadora pasa a ser la propietaria: invita a las demás.",
+ "When there's no direct path": "Cuando no hay conexión directa",
+ "Paste the invite from the other computer.": "Pega la invitación de la otra computadora.",
+ "Save your recovery code": "Guarda tu código de recuperación",
+ "Copy recovery code": "Copiar código de recuperación",
+ "It makes another computer the owner if {name} is lost. It's shown only once and kept on no computer.": "Hace propietaria a otra computadora si pierdes {name}. Solo se muestra una vez y no se guarda en ninguna computadora.",
+ "I saved it": "Ya lo guardé",
+ "Invite a computer": "Invitar una computadora",
+ "New invite": "Nueva invitación",
+ "Copy invite": "Copiar invitación",
+ "One use. Works until {time} while {name} stays on.": "Un solo uso. Sirve hasta las {time} mientras {name} siga encendida.",
+ "On the other computer, choose Join with invite under Network.": "En la otra computadora, elige Unirse con una invitación en Red.",
+ "Recover ownership": "Recuperar la propiedad",
+ "Recover": "Recuperar",
+ "{name} is the owner now. Remove the lost computer from the list.": "{name} es ahora la propietaria. Quita de la lista la computadora perdida.",
+ "For when the owner is lost: this computer becomes the owner.": "Si se perdió la propietaria: esta computadora pasa a serlo.",
+ "Recovery code": "Código de recuperación",
+ "Refresh": "Actualizar",
+ "Bots message the bots on these computers as bot@computer.": "Los bots escriben a los bots de estas computadoras como bot@computadora.",
+ "Connect your computers so bots on one can message bots on another.": "Conecta tus computadoras para que los bots de una puedan escribir a los de otra.",
+ "Remove {name} from the network?": "¿Quitar {name} de la red?",
+ "It can't come back with its current key. For a stolen computer, also remove the computers it invited.": "No podrá volver con su clave actual. Si la robaron, quita también las computadoras que invitó.",
+ "Remove with its invites": "Quitar con sus invitadas",
+ "Make admin": "Hacer administrador",
+ "Remove from the network": "Quitar de la red",
+ "y copy · s I saved it": "y copiar · s ya lo guardé",
+ "Getting an invite…": "Obteniendo una invitación…",
+ "y copy · n new invite · esc back": "y copiar · n nueva invitación · esc volver",
+ "↵ recover · esc back": "↵ recuperar · esc volver",
+ "It can't come back with its current key.": "No podrá volver con su clave actual.",
+ "Also remove the computers it invited": "Quitar también las computadoras que invitó",
+ "For a stolen computer.": "Para una computadora robada.",
+ "↵ remove · c switches · esc cancel": "↵ quitar · c cambiar · esc cancelar",
+ "Not in a network.": "No está en ninguna red.",
+ "c create network · J join with invite · esc close": "c crear red · J unirse con invitación · esc cerrar",
+ "i invite · p make admin · x remove · r refresh · esc close": "i invitar · p hacer administrador · x quitar · r actualizar · esc cerrar",
+ "i invite · x remove · o recover ownership · r refresh · esc close": "i invitar · x quitar · o recuperar la propiedad · r actualizar · esc cerrar",
+ "o recover ownership · r refresh · esc close": "o recuperar la propiedad · r actualizar · esc cerrar",
+ "Connector": "Conexión",
+ "↵ done · tab next field · ←→ connector · esc back": "↵ listo · tab siguiente campo · ←→ conexión · esc volver",
+ "Recovery code copied": "Código de recuperación copiado",
+ "Invite copied": "Invitación copiada",
+ "This computer is the owner now. Remove the lost computer from the list.": "Esta computadora es ahora la propietaria. Quita de la lista la computadora perdida.",
+ "Removed from the network": "Quitada de la red",
+ "Made an admin": "Ahora es administrador",
+ "Only the owner makes plain members admins": "Solo la propietaria puede hacer administradores a los miembros",
+ "Remove this computer from another one": "Quita esta computadora desde otra",
+ "Only the owner removes admins; admins remove members": "Solo la propietaria quita administradores; los administradores quitan miembros",
+ "Network: your other computers…": "Red: tus otras computadoras…"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
index 1e6c02aa..e9538c16 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
@@ -1238,5 +1238,80 @@
"Install it first.": "Installez-le d'abord.",
"Not set up on {name} yet.": "Pas encore configuré sur {name}.",
"Downloads {name} on {host} if it needs to, then checks its sign-in.": "Télécharge {name} sur {host} si besoin, puis vérifie sa connexion.",
- "Rate on the App Store": "Noter sur l’App Store"
+ "Rate on the App Store": "Noter sur l’App Store",
+ "Network": "Réseau",
+ "Cloud assistants": "Assistants cloud",
+ "Owner": "Propriétaire",
+ "Admin": "Admin",
+ "Member": "Membre",
+ "Away": "Absent",
+ "No bots": "Aucun bot",
+ "Changes are made on a computer: in Codync's settings there, or with codync-host network.": "Les changements se font sur un ordinateur : dans les réglages de Codync sur celui-ci, ou avec codync-host network.",
+ "ChatGPT or Claude in your Codync account can message this computer's bots when it's on. Codync's cloud can read these calls.": "Activé, ChatGPT ou Claude dans votre compte Codync peut écrire aux bots de cet ordinateur. Le cloud de Codync peut lire ces appels.",
+ "ChatGPT or Claude in your Codync account can message this computer's bots. Codync's cloud can read these calls.": "ChatGPT ou Claude dans votre compte Codync peut écrire aux bots de cet ordinateur. Le cloud de Codync peut lire ces appels.",
+ "Let ChatGPT or Claude message this computer's bots through your Codync account.": "Permettre à ChatGPT ou Claude d'écrire aux bots de cet ordinateur via votre compte Codync.",
+ "Public relays": "Relais publics",
+ "Direct when it can, through a shared relay otherwise.": "En direct si possible, sinon via un relais partagé.",
+ "Private: direct only": "Privé : direct uniquement",
+ "Same network, Tailscale or a VPN.": "Même réseau, Tailscale ou un VPN.",
+ "Your own relay": "Votre propre relais",
+ "An iroh-relay you run.": "Un iroh-relay que vous faites tourner.",
+ "Enter your relay's address.": "Saisissez l'adresse de votre relais.",
+ "1 bot": "1 bot",
+ "{count} bots": "{count} bots",
+ "Invite": "Invitation",
+ "Computer name": "Nom de l'ordinateur",
+ "Host name": "Nom d'hôte",
+ "Join with invite": "Rejoindre avec une invitation",
+ "Create network": "Créer un réseau",
+ "Join": "Rejoindre",
+ "This computer becomes the owner: it invites the others.": "Cet ordinateur devient propriétaire : c'est lui qui invite les autres.",
+ "When there's no direct path": "Sans chemin direct",
+ "Paste the invite from the other computer.": "Collez l'invitation de l'autre ordinateur.",
+ "Save your recovery code": "Enregistrez votre code de récupération",
+ "Copy recovery code": "Copier le code de récupération",
+ "It makes another computer the owner if {name} is lost. It's shown only once and kept on no computer.": "Il fait d'un autre ordinateur le propriétaire si {name} est perdu. Il n'est affiché qu'une fois et n'est gardé sur aucun ordinateur.",
+ "I saved it": "Je l'ai enregistré",
+ "Invite a computer": "Inviter un ordinateur",
+ "New invite": "Nouvelle invitation",
+ "Copy invite": "Copier l'invitation",
+ "One use. Works until {time} while {name} stays on.": "Usage unique. Valable jusqu'à {time} tant que {name} reste allumé.",
+ "On the other computer, choose Join with invite under Network.": "Sur l'autre ordinateur, choisissez Rejoindre avec une invitation dans Réseau.",
+ "Recover ownership": "Récupérer la propriété",
+ "Recover": "Récupérer",
+ "{name} is the owner now. Remove the lost computer from the list.": "{name} est maintenant propriétaire. Retirez l'ordinateur perdu de la liste.",
+ "For when the owner is lost: this computer becomes the owner.": "Si le propriétaire est perdu : cet ordinateur devient propriétaire.",
+ "Recovery code": "Code de récupération",
+ "Refresh": "Actualiser",
+ "Bots message the bots on these computers as bot@computer.": "Les bots écrivent aux bots de ces ordinateurs avec bot@ordinateur.",
+ "Connect your computers so bots on one can message bots on another.": "Reliez vos ordinateurs pour que les bots de l'un puissent écrire aux bots d'un autre.",
+ "Remove {name} from the network?": "Retirer {name} du réseau ?",
+ "It can't come back with its current key. For a stolen computer, also remove the computers it invited.": "Il ne pourra pas revenir avec sa clé actuelle. Pour un ordinateur volé, retirez aussi ceux qu'il a invités.",
+ "Remove with its invites": "Retirer avec ses invités",
+ "Make admin": "Nommer admin",
+ "Remove from the network": "Retirer du réseau",
+ "y copy · s I saved it": "y copier · s je l'ai enregistré",
+ "Getting an invite…": "Obtention d'une invitation…",
+ "y copy · n new invite · esc back": "y copier · n nouvelle invitation · esc retour",
+ "↵ recover · esc back": "↵ récupérer · esc retour",
+ "It can't come back with its current key.": "Il ne pourra pas revenir avec sa clé actuelle.",
+ "Also remove the computers it invited": "Retirer aussi les ordinateurs qu'il a invités",
+ "For a stolen computer.": "Pour un ordinateur volé.",
+ "↵ remove · c switches · esc cancel": "↵ retirer · c basculer · esc annuler",
+ "Not in a network.": "Dans aucun réseau.",
+ "c create network · J join with invite · esc close": "c créer un réseau · J rejoindre avec une invitation · esc fermer",
+ "i invite · p make admin · x remove · r refresh · esc close": "i inviter · p nommer admin · x retirer · r actualiser · esc fermer",
+ "i invite · x remove · o recover ownership · r refresh · esc close": "i inviter · x retirer · o récupérer la propriété · r actualiser · esc fermer",
+ "o recover ownership · r refresh · esc close": "o récupérer la propriété · r actualiser · esc fermer",
+ "Connector": "Connexion",
+ "↵ done · tab next field · ←→ connector · esc back": "↵ terminé · tab champ suivant · ←→ connexion · esc retour",
+ "Recovery code copied": "Code de récupération copié",
+ "Invite copied": "Invitation copiée",
+ "This computer is the owner now. Remove the lost computer from the list.": "Cet ordinateur est maintenant propriétaire. Retirez l'ordinateur perdu de la liste.",
+ "Removed from the network": "Retiré du réseau",
+ "Made an admin": "Nommé admin",
+ "Only the owner makes plain members admins": "Seul le propriétaire nomme des membres admins",
+ "Remove this computer from another one": "Retirez cet ordinateur depuis un autre",
+ "Only the owner removes admins; admins remove members": "Seul le propriétaire retire des admins ; les admins retirent des membres",
+ "Network: your other computers…": "Réseau : vos autres ordinateurs…"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
index 359a63f2..79f5d7d9 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
@@ -1238,5 +1238,80 @@
"Install it first.": "先にインストールしてください。",
"Not set up on {name} yet.": "{name} ではまだセットアップされていません。",
"Downloads {name} on {host} if it needs to, then checks its sign-in.": "必要なら {host} に {name} をダウンロードし、サインイン状態を確認します。",
- "Rate on the App Store": "App Store で評価"
+ "Rate on the App Store": "App Store で評価",
+ "Network": "ネットワーク",
+ "Cloud assistants": "クラウドアシスタント",
+ "Owner": "オーナー",
+ "Admin": "管理者",
+ "Member": "メンバー",
+ "Away": "応答なし",
+ "No bots": "ボットなし",
+ "Changes are made on a computer: in Codync's settings there, or with codync-host network.": "変更はコンピューター側で行います:そのコンピューターの Codync の設定、または codync-host network で。",
+ "ChatGPT or Claude in your Codync account can message this computer's bots when it's on. Codync's cloud can read these calls.": "オンにすると、Codync アカウントの ChatGPT や Claude がこのコンピューターのボットにメッセージを送れます。これらの呼び出しは Codync のクラウドから読み取れます。",
+ "ChatGPT or Claude in your Codync account can message this computer's bots. Codync's cloud can read these calls.": "Codync アカウントの ChatGPT や Claude がこのコンピューターのボットにメッセージを送れます。これらの呼び出しは Codync のクラウドから読み取れます。",
+ "Let ChatGPT or Claude message this computer's bots through your Codync account.": "Codync アカウントを通じて、ChatGPT や Claude がこのコンピューターのボットにメッセージを送れるようにします。",
+ "Public relays": "公開リレー",
+ "Direct when it can, through a shared relay otherwise.": "可能なら直接、だめなら共有リレー経由で接続します。",
+ "Private: direct only": "プライベート:直接接続のみ",
+ "Same network, Tailscale or a VPN.": "同じネットワーク、Tailscale、または VPN。",
+ "Your own relay": "自分のリレー",
+ "An iroh-relay you run.": "自分で動かしている iroh-relay。",
+ "Enter your relay's address.": "リレーのアドレスを入力してください。",
+ "1 bot": "1 ボット",
+ "{count} bots": "{count} ボット",
+ "Invite": "招待",
+ "Computer name": "コンピューター名",
+ "Host name": "ホスト名",
+ "Join with invite": "招待で参加",
+ "Create network": "ネットワークを作成",
+ "Join": "参加",
+ "This computer becomes the owner: it invites the others.": "このコンピューターがオーナーになり、ほかのコンピューターを招待します。",
+ "When there's no direct path": "直接つながらないとき",
+ "Paste the invite from the other computer.": "もう一方のコンピューターの招待を貼り付けてください。",
+ "Save your recovery code": "復旧コードを保存してください",
+ "Copy recovery code": "復旧コードをコピー",
+ "It makes another computer the owner if {name} is lost. It's shown only once and kept on no computer.": "{name} をなくしたとき、ほかのコンピューターをオーナーにできます。表示されるのは今回だけで、どのコンピューターにも保存されません。",
+ "I saved it": "保存しました",
+ "Invite a computer": "コンピューターを招待",
+ "New invite": "新しい招待",
+ "Copy invite": "招待をコピー",
+ "One use. Works until {time} while {name} stays on.": "1回限り。{name} がオンのあいだ {time} まで使えます。",
+ "On the other computer, choose Join with invite under Network.": "もう一方のコンピューターで「ネットワーク」の「招待で参加」を選んでください。",
+ "Recover ownership": "オーナー権を取り戻す",
+ "Recover": "復旧",
+ "{name} is the owner now. Remove the lost computer from the list.": "{name} がオーナーになりました。なくしたコンピューターを一覧から削除してください。",
+ "For when the owner is lost: this computer becomes the owner.": "オーナーをなくしたときに:このコンピューターがオーナーになります。",
+ "Recovery code": "復旧コード",
+ "Refresh": "更新",
+ "Bots message the bots on these computers as bot@computer.": "ボットは bot@コンピューター でこれらのコンピューターのボットにメッセージを送ります。",
+ "Connect your computers so bots on one can message bots on another.": "コンピューターをつなぐと、あるコンピューターのボットが別のコンピューターのボットにメッセージを送れます。",
+ "Remove {name} from the network?": "{name} をネットワークから削除しますか?",
+ "It can't come back with its current key. For a stolen computer, also remove the computers it invited.": "今の鍵では戻れません。盗まれたコンピューターなら、それが招待したコンピューターも削除してください。",
+ "Remove with its invites": "招待したものごと削除",
+ "Make admin": "管理者にする",
+ "Remove from the network": "ネットワークから削除",
+ "y copy · s I saved it": "y コピー · s 保存しました",
+ "Getting an invite…": "招待を取得しています…",
+ "y copy · n new invite · esc back": "y コピー · n 新しい招待 · esc 戻る",
+ "↵ recover · esc back": "↵ 復旧 · esc 戻る",
+ "It can't come back with its current key.": "今の鍵では戻れません。",
+ "Also remove the computers it invited": "招待したコンピューターも削除",
+ "For a stolen computer.": "盗まれたコンピューター向け。",
+ "↵ remove · c switches · esc cancel": "↵ 削除 · c 切り替え · esc キャンセル",
+ "Not in a network.": "ネットワークに入っていません。",
+ "c create network · J join with invite · esc close": "c ネットワークを作成 · J 招待で参加 · esc 閉じる",
+ "i invite · p make admin · x remove · r refresh · esc close": "i 招待 · p 管理者にする · x 削除 · r 更新 · esc 閉じる",
+ "i invite · x remove · o recover ownership · r refresh · esc close": "i 招待 · x 削除 · o オーナー権を取り戻す · r 更新 · esc 閉じる",
+ "o recover ownership · r refresh · esc close": "o オーナー権を取り戻す · r 更新 · esc 閉じる",
+ "Connector": "接続方法",
+ "↵ done · tab next field · ←→ connector · esc back": "↵ 完了 · tab 次の項目 · ←→ 接続方法 · esc 戻る",
+ "Recovery code copied": "復旧コードをコピーしました",
+ "Invite copied": "招待をコピーしました",
+ "This computer is the owner now. Remove the lost computer from the list.": "このコンピューターがオーナーになりました。なくしたコンピューターを一覧から削除してください。",
+ "Removed from the network": "ネットワークから削除しました",
+ "Made an admin": "管理者にしました",
+ "Only the owner makes plain members admins": "一般メンバーを管理者にできるのはオーナーだけです",
+ "Remove this computer from another one": "このコンピューターは別のコンピューターから削除してください",
+ "Only the owner removes admins; admins remove members": "管理者を削除できるのはオーナーだけで、管理者はメンバーを削除できます",
+ "Network: your other computers…": "ネットワーク:ほかのコンピューター…"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
index 8e7bc719..fc16caea 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
@@ -1238,5 +1238,80 @@
"Install it first.": "먼저 설치하세요.",
"Not set up on {name} yet.": "{name}에 아직 설정되지 않았습니다.",
"Downloads {name} on {host} if it needs to, then checks its sign-in.": "필요하면 {host}에 {name}을(를) 내려받은 뒤 로그인 상태를 확인합니다.",
- "Rate on the App Store": "App Store에서 평가하기"
+ "Rate on the App Store": "App Store에서 평가하기",
+ "Network": "네트워크",
+ "Cloud assistants": "클라우드 어시스턴트",
+ "Owner": "소유자",
+ "Admin": "관리자",
+ "Member": "멤버",
+ "Away": "자리 비움",
+ "No bots": "봇 없음",
+ "Changes are made on a computer: in Codync's settings there, or with codync-host network.": "변경은 컴퓨터에서 합니다: 해당 컴퓨터의 Codync 설정이나 codync-host network로.",
+ "ChatGPT or Claude in your Codync account can message this computer's bots when it's on. Codync's cloud can read these calls.": "켜면 Codync 계정의 ChatGPT나 Claude가 이 컴퓨터의 봇에게 메시지를 보낼 수 있습니다. Codync 클라우드는 이 호출을 읽을 수 있습니다.",
+ "ChatGPT or Claude in your Codync account can message this computer's bots. Codync's cloud can read these calls.": "Codync 계정의 ChatGPT나 Claude가 이 컴퓨터의 봇에게 메시지를 보낼 수 있습니다. Codync 클라우드는 이 호출을 읽을 수 있습니다.",
+ "Let ChatGPT or Claude message this computer's bots through your Codync account.": "Codync 계정을 통해 ChatGPT나 Claude가 이 컴퓨터의 봇에게 메시지를 보낼 수 있게 합니다.",
+ "Public relays": "공용 릴레이",
+ "Direct when it can, through a shared relay otherwise.": "가능하면 직접, 아니면 공유 릴레이를 거쳐 연결합니다.",
+ "Private: direct only": "비공개: 직접 연결만",
+ "Same network, Tailscale or a VPN.": "같은 네트워크, Tailscale 또는 VPN.",
+ "Your own relay": "내 릴레이",
+ "An iroh-relay you run.": "직접 운영하는 iroh-relay.",
+ "Enter your relay's address.": "릴레이 주소를 입력하세요.",
+ "1 bot": "봇 1개",
+ "{count} bots": "봇 {count}개",
+ "Invite": "초대",
+ "Computer name": "컴퓨터 이름",
+ "Host name": "호스트 이름",
+ "Join with invite": "초대로 참여",
+ "Create network": "네트워크 만들기",
+ "Join": "참여",
+ "This computer becomes the owner: it invites the others.": "이 컴퓨터가 소유자가 되어 다른 컴퓨터를 초대합니다.",
+ "When there's no direct path": "직접 연결이 안 될 때",
+ "Paste the invite from the other computer.": "다른 컴퓨터의 초대를 붙여 넣으세요.",
+ "Save your recovery code": "복구 코드를 저장하세요",
+ "Copy recovery code": "복구 코드 복사",
+ "It makes another computer the owner if {name} is lost. It's shown only once and kept on no computer.": "{name}을(를) 잃어버리면 다른 컴퓨터를 소유자로 만들 수 있습니다. 이번 한 번만 표시되며 어떤 컴퓨터에도 저장되지 않습니다.",
+ "I saved it": "저장했습니다",
+ "Invite a computer": "컴퓨터 초대",
+ "New invite": "새 초대",
+ "Copy invite": "초대 복사",
+ "One use. Works until {time} while {name} stays on.": "한 번만 쓸 수 있습니다. {name}이(가) 켜져 있는 동안 {time}까지 유효합니다.",
+ "On the other computer, choose Join with invite under Network.": "다른 컴퓨터의 네트워크에서 초대로 참여를 선택하세요.",
+ "Recover ownership": "소유권 복구",
+ "Recover": "복구",
+ "{name} is the owner now. Remove the lost computer from the list.": "이제 {name}이(가) 소유자입니다. 잃어버린 컴퓨터를 목록에서 제거하세요.",
+ "For when the owner is lost: this computer becomes the owner.": "소유자를 잃어버렸을 때: 이 컴퓨터가 소유자가 됩니다.",
+ "Recovery code": "복구 코드",
+ "Refresh": "새로고침",
+ "Bots message the bots on these computers as bot@computer.": "봇은 bot@컴퓨터 형식으로 이 컴퓨터들의 봇에게 메시지를 보냅니다.",
+ "Connect your computers so bots on one can message bots on another.": "컴퓨터를 연결하면 한 컴퓨터의 봇이 다른 컴퓨터의 봇에게 메시지를 보낼 수 있습니다.",
+ "Remove {name} from the network?": "{name}을(를) 네트워크에서 제거할까요?",
+ "It can't come back with its current key. For a stolen computer, also remove the computers it invited.": "현재 키로는 다시 참여할 수 없습니다. 도난당한 컴퓨터라면 그 컴퓨터가 초대한 컴퓨터도 함께 제거하세요.",
+ "Remove with its invites": "초대한 컴퓨터와 함께 제거",
+ "Make admin": "관리자로 지정",
+ "Remove from the network": "네트워크에서 제거",
+ "y copy · s I saved it": "y 복사 · s 저장했습니다",
+ "Getting an invite…": "초대를 받는 중…",
+ "y copy · n new invite · esc back": "y 복사 · n 새 초대 · esc 뒤로",
+ "↵ recover · esc back": "↵ 복구 · esc 뒤로",
+ "It can't come back with its current key.": "현재 키로는 다시 참여할 수 없습니다.",
+ "Also remove the computers it invited": "초대한 컴퓨터도 제거",
+ "For a stolen computer.": "도난당한 컴퓨터용.",
+ "↵ remove · c switches · esc cancel": "↵ 제거 · c 전환 · esc 취소",
+ "Not in a network.": "네트워크에 속해 있지 않습니다.",
+ "c create network · J join with invite · esc close": "c 네트워크 만들기 · J 초대로 참여 · esc 닫기",
+ "i invite · p make admin · x remove · r refresh · esc close": "i 초대 · p 관리자로 지정 · x 제거 · r 새로고침 · esc 닫기",
+ "i invite · x remove · o recover ownership · r refresh · esc close": "i 초대 · x 제거 · o 소유권 복구 · r 새로고침 · esc 닫기",
+ "o recover ownership · r refresh · esc close": "o 소유권 복구 · r 새로고침 · esc 닫기",
+ "Connector": "연결 방식",
+ "↵ done · tab next field · ←→ connector · esc back": "↵ 완료 · tab 다음 항목 · ←→ 연결 방식 · esc 뒤로",
+ "Recovery code copied": "복구 코드를 복사했습니다",
+ "Invite copied": "초대를 복사했습니다",
+ "This computer is the owner now. Remove the lost computer from the list.": "이제 이 컴퓨터가 소유자입니다. 잃어버린 컴퓨터를 목록에서 제거하세요.",
+ "Removed from the network": "네트워크에서 제거했습니다",
+ "Made an admin": "관리자로 지정했습니다",
+ "Only the owner makes plain members admins": "일반 멤버를 관리자로 지정할 수 있는 건 소유자뿐입니다",
+ "Remove this computer from another one": "이 컴퓨터는 다른 컴퓨터에서 제거하세요",
+ "Only the owner removes admins; admins remove members": "관리자는 소유자만 제거할 수 있고, 관리자는 멤버를 제거할 수 있습니다",
+ "Network: your other computers…": "네트워크: 내 다른 컴퓨터…"
}
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 0193d145..ebfd4ba8 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
@@ -1238,5 +1238,80 @@
"Install it first.": "请先安装。",
"Not set up on {name} yet.": "还没在 {name} 上设置。",
"Downloads {name} on {host} if it needs to, then checks its sign-in.": "需要的话会在 {host} 上下载 {name},再检查登录状态。",
- "Rate on the App Store": "在 App Store 评分"
+ "Rate on the App Store": "在 App Store 评分",
+ "Network": "网络",
+ "Cloud assistants": "云端助手",
+ "Owner": "所有者",
+ "Admin": "管理员",
+ "Member": "成员",
+ "Away": "不在线",
+ "No bots": "没有 Bot",
+ "Changes are made on a computer: in Codync's settings there, or with codync-host network.": "更改要在电脑上进行:在那台电脑的 Codync 设置里,或用 codync-host network。",
+ "ChatGPT or Claude in your Codync account can message this computer's bots when it's on. Codync's cloud can read these calls.": "开启后,你 Codync 账户里的 ChatGPT 或 Claude 可以给这台电脑的 Bot 发消息。Codync 的云端能读取这些调用。",
+ "ChatGPT or Claude in your Codync account can message this computer's bots. Codync's cloud can read these calls.": "你 Codync 账户里的 ChatGPT 或 Claude 可以给这台电脑的 Bot 发消息。Codync 的云端能读取这些调用。",
+ "Let ChatGPT or Claude message this computer's bots through your Codync account.": "让 ChatGPT 或 Claude 通过你的 Codync 账户给这台电脑的 Bot 发消息。",
+ "Public relays": "公共中继",
+ "Direct when it can, through a shared relay otherwise.": "能直连就直连,否则经过共享中继。",
+ "Private: direct only": "私有:仅直连",
+ "Same network, Tailscale or a VPN.": "同一个网络、Tailscale 或 VPN。",
+ "Your own relay": "自己的中继",
+ "An iroh-relay you run.": "你自己搭建的 iroh-relay。",
+ "Enter your relay's address.": "输入你中继的地址。",
+ "1 bot": "1 个 Bot",
+ "{count} bots": "{count} 个 Bot",
+ "Invite": "邀请",
+ "Computer name": "电脑名称",
+ "Host name": "主机名",
+ "Join with invite": "用邀请加入",
+ "Create network": "创建网络",
+ "Join": "加入",
+ "This computer becomes the owner: it invites the others.": "这台电脑会成为所有者:由它邀请其他电脑。",
+ "When there's no direct path": "没有直接连接时",
+ "Paste the invite from the other computer.": "粘贴另一台电脑的邀请。",
+ "Save your recovery code": "保存你的恢复码",
+ "Copy recovery code": "复制恢复码",
+ "It makes another computer the owner if {name} is lost. It's shown only once and kept on no computer.": "{name} 丢失时,它能让另一台电脑成为所有者。只会显示这一次,也不会存在任何电脑上。",
+ "I saved it": "我已保存",
+ "Invite a computer": "邀请电脑",
+ "New invite": "新的邀请",
+ "Copy invite": "复制邀请",
+ "One use. Works until {time} while {name} stays on.": "只能用一次。在 {time} 前、{name} 保持开机时有效。",
+ "On the other computer, choose Join with invite under Network.": "在另一台电脑的“网络”里选“用邀请加入”。",
+ "Recover ownership": "取回所有权",
+ "Recover": "恢复",
+ "{name} is the owner now. Remove the lost computer from the list.": "{name} 现在是所有者。请把丢失的电脑从列表中移除。",
+ "For when the owner is lost: this computer becomes the owner.": "所有者丢失时使用:让这台电脑成为所有者。",
+ "Recovery code": "恢复码",
+ "Refresh": "刷新",
+ "Bots message the bots on these computers as bot@computer.": "Bot 用 bot@电脑 给这些电脑上的 Bot 发消息。",
+ "Connect your computers so bots on one can message bots on another.": "把你的电脑连起来,让一台电脑上的 Bot 能给另一台上的 Bot 发消息。",
+ "Remove {name} from the network?": "要把 {name} 从网络移除吗?",
+ "It can't come back with its current key. For a stolen computer, also remove the computers it invited.": "它无法用当前的密钥再加入。如果是被偷的电脑,也一并移除它邀请的电脑。",
+ "Remove with its invites": "连同它邀请的一起移除",
+ "Make admin": "设为管理员",
+ "Remove from the network": "从网络移除",
+ "y copy · s I saved it": "y 复制 · s 我已保存",
+ "Getting an invite…": "正在获取邀请…",
+ "y copy · n new invite · esc back": "y 复制 · n 新的邀请 · esc 返回",
+ "↵ recover · esc back": "↵ 恢复 · esc 返回",
+ "It can't come back with its current key.": "它无法用当前的密钥再加入。",
+ "Also remove the computers it invited": "也移除它邀请的电脑",
+ "For a stolen computer.": "用于被偷的电脑。",
+ "↵ remove · c switches · esc cancel": "↵ 移除 · c 切换 · esc 取消",
+ "Not in a network.": "不在任何网络里。",
+ "c create network · J join with invite · esc close": "c 创建网络 · J 用邀请加入 · esc 关闭",
+ "i invite · p make admin · x remove · r refresh · esc close": "i 邀请 · p 设为管理员 · x 移除 · r 刷新 · esc 关闭",
+ "i invite · x remove · o recover ownership · r refresh · esc close": "i 邀请 · x 移除 · o 取回所有权 · r 刷新 · esc 关闭",
+ "o recover ownership · r refresh · esc close": "o 取回所有权 · r 刷新 · esc 关闭",
+ "Connector": "连接方式",
+ "↵ done · tab next field · ←→ connector · esc back": "↵ 完成 · tab 下一栏 · ←→ 连接方式 · esc 返回",
+ "Recovery code copied": "已复制恢复码",
+ "Invite copied": "已复制邀请",
+ "This computer is the owner now. Remove the lost computer from the list.": "这台电脑现在是所有者。请把丢失的电脑从列表中移除。",
+ "Removed from the network": "已从网络移除",
+ "Made an admin": "已设为管理员",
+ "Only the owner makes plain members admins": "只有所有者能把普通成员设为管理员",
+ "Remove this computer from another one": "请从另一台电脑移除这台电脑",
+ "Only the owner removes admins; admins remove members": "只有所有者能移除管理员;管理员能移除成员",
+ "Network: your other computers…": "网络:你的其他电脑…"
}
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 8791369b..41832ea2 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
@@ -1238,5 +1238,80 @@
"Install it first.": "請先安裝。",
"Not set up on {name} yet.": "還沒在 {name} 上設定。",
"Downloads {name} on {host} if it needs to, then checks its sign-in.": "需要的話會在 {host} 上下載 {name},再檢查登入狀態。",
- "Rate on the App Store": "在 App Store 評分"
+ "Rate on the App Store": "在 App Store 評分",
+ "Network": "網路",
+ "Cloud assistants": "雲端助理",
+ "Owner": "擁有者",
+ "Admin": "管理員",
+ "Member": "成員",
+ "Away": "不在線",
+ "No bots": "沒有 Bot",
+ "Changes are made on a computer: in Codync's settings there, or with codync-host network.": "變更要在電腦上進行:在那臺電腦的 Codync 設定裡,或用 codync-host network。",
+ "ChatGPT or Claude in your Codync account can message this computer's bots when it's on. Codync's cloud can read these calls.": "開啟後,你 Codync 賬戶裡的 ChatGPT 或 Claude 可以傳訊息給這臺電腦的 Bot。Codync 的雲端能讀取這些呼叫。",
+ "ChatGPT or Claude in your Codync account can message this computer's bots. Codync's cloud can read these calls.": "你 Codync 賬戶裡的 ChatGPT 或 Claude 可以傳訊息給這臺電腦的 Bot。Codync 的雲端能讀取這些呼叫。",
+ "Let ChatGPT or Claude message this computer's bots through your Codync account.": "讓 ChatGPT 或 Claude 透過你的 Codync 賬戶傳訊息給這臺電腦的 Bot。",
+ "Public relays": "公共中繼",
+ "Direct when it can, through a shared relay otherwise.": "能直連就直連,否則經過共用中繼。",
+ "Private: direct only": "私人:只直連",
+ "Same network, Tailscale or a VPN.": "同一個網路、Tailscale 或 VPN。",
+ "Your own relay": "自己的中繼",
+ "An iroh-relay you run.": "你自己架設的 iroh-relay。",
+ "Enter your relay's address.": "輸入你中繼的位址。",
+ "1 bot": "1 個 Bot",
+ "{count} bots": "{count} 個 Bot",
+ "Invite": "邀請",
+ "Computer name": "電腦名稱",
+ "Host name": "主機名稱",
+ "Join with invite": "用邀請加入",
+ "Create network": "建立網路",
+ "Join": "加入",
+ "This computer becomes the owner: it invites the others.": "這臺電腦會成為擁有者:由它邀請其他電腦。",
+ "When there's no direct path": "沒有直接連線時",
+ "Paste the invite from the other computer.": "貼上另一臺電腦的邀請。",
+ "Save your recovery code": "儲存你的復原碼",
+ "Copy recovery code": "複製復原碼",
+ "It makes another computer the owner if {name} is lost. It's shown only once and kept on no computer.": "{name} 遺失時,它能讓另一臺電腦成為擁有者。只會顯示這一次,也不會存在任何電腦上。",
+ "I saved it": "我已儲存",
+ "Invite a computer": "邀請電腦",
+ "New invite": "新的邀請",
+ "Copy invite": "複製邀請",
+ "One use. Works until {time} while {name} stays on.": "只能用一次。在 {time} 前、{name} 保持開機時有效。",
+ "On the other computer, choose Join with invite under Network.": "在另一臺電腦的「網路」裡選「用邀請加入」。",
+ "Recover ownership": "取回擁有權",
+ "Recover": "復原",
+ "{name} is the owner now. Remove the lost computer from the list.": "{name} 現在是擁有者。請把遺失的電腦從清單中移除。",
+ "For when the owner is lost: this computer becomes the owner.": "擁有者遺失時使用:讓這臺電腦成為擁有者。",
+ "Recovery code": "復原碼",
+ "Refresh": "重新整理",
+ "Bots message the bots on these computers as bot@computer.": "Bot 用 bot@電腦 傳訊息給這些電腦上的 Bot。",
+ "Connect your computers so bots on one can message bots on another.": "把你的電腦連起來,讓一臺電腦上的 Bot 能傳訊息給另一臺上的 Bot。",
+ "Remove {name} from the network?": "要把 {name} 從網路移除嗎?",
+ "It can't come back with its current key. For a stolen computer, also remove the computers it invited.": "它無法用目前的金鑰再加入。如果是被偷的電腦,也一併移除它邀請的電腦。",
+ "Remove with its invites": "連同它邀請的一起移除",
+ "Make admin": "設為管理員",
+ "Remove from the network": "從網路移除",
+ "y copy · s I saved it": "y 複製 · s 我已儲存",
+ "Getting an invite…": "正在取得邀請…",
+ "y copy · n new invite · esc back": "y 複製 · n 新的邀請 · esc 返回",
+ "↵ recover · esc back": "↵ 復原 · esc 返回",
+ "It can't come back with its current key.": "它無法用目前的金鑰再加入。",
+ "Also remove the computers it invited": "也移除它邀請的電腦",
+ "For a stolen computer.": "用於被偷的電腦。",
+ "↵ remove · c switches · esc cancel": "↵ 移除 · c 切換 · esc 取消",
+ "Not in a network.": "不在任何網路裡。",
+ "c create network · J join with invite · esc close": "c 建立網路 · J 用邀請加入 · esc 關閉",
+ "i invite · p make admin · x remove · r refresh · esc close": "i 邀請 · p 設為管理員 · x 移除 · r 重新整理 · esc 關閉",
+ "i invite · x remove · o recover ownership · r refresh · esc close": "i 邀請 · x 移除 · o 取回擁有權 · r 重新整理 · esc 關閉",
+ "o recover ownership · r refresh · esc close": "o 取回擁有權 · r 重新整理 · esc 關閉",
+ "Connector": "連線方式",
+ "↵ done · tab next field · ←→ connector · esc back": "↵ 完成 · tab 下一欄 · ←→ 連線方式 · esc 返回",
+ "Recovery code copied": "已複製復原碼",
+ "Invite copied": "已複製邀請",
+ "This computer is the owner now. Remove the lost computer from the list.": "這臺電腦現在是擁有者。請把遺失的電腦從清單中移除。",
+ "Removed from the network": "已從網路移除",
+ "Made an admin": "已設為管理員",
+ "Only the owner makes plain members admins": "只有擁有者能把一般成員設為管理員",
+ "Remove this computer from another one": "請從另一臺電腦移除這臺電腦",
+ "Only the owner removes admins; admins remove members": "只有擁有者能移除管理員;管理員能移除成員",
+ "Network: your other computers…": "網路:你的其他電腦…"
}
diff --git a/apps/ios/Kit/Sources/CodyncUI/NetworkSheet.swift b/apps/ios/Kit/Sources/CodyncUI/NetworkSheet.swift
new file mode 100644
index 00000000..0f24dbb9
--- /dev/null
+++ b/apps/ios/Kit/Sources/CodyncUI/NetworkSheet.swift
@@ -0,0 +1,73 @@
+import CodyncKit
+import SwiftUI
+
+/// A computer's network of the user's other computers, read-only: who is in it, whether each one
+/// answers and which bots it offers, and whether cloud assistants may reach this computer's bots.
+/// Changes are made at a computer. The computer is the `BotStore` in the environment.
+public struct NetworkSheet: View {
+ @Environment(BotStore.self) private var store
+
+ public init() {}
+
+ public var body: some View {
+ VStack(spacing: 0) {
+ ModalHeader {
+ HStack(spacing: 8) {
+ Image(systemName: "point.3.connected.trianglepath.dotted").font(.title2).accessibilityHidden(true)
+ Text(L10n.tr("Network"))
+ }
+ }
+ CardForm {
+ if let view = store.network, view.joined {
+ CardSection("Computers", footer: "Changes are made on a computer: in Codync's settings there, or with codync-host network.") {
+ ForEach(view.computers ?? []) { NetworkComputerRow(computer: $0) }
+ }
+ }
+ CardSection(footer: "ChatGPT or Claude in your Codync account can message this computer's bots when it's on. Codync's cloud can read these calls.") {
+ ValueRow("Cloud assistants", value: store.network?.isAssistantsOn == true ? "On" : "Off")
+ }
+ }
+ .animation(Motion.layout, value: store.network)
+ }
+ .background(Palette.background)
+ .tracked(.screenViewed(.network))
+ }
+}
+
+private struct NetworkComputerRow: View {
+ let computer: NetworkView.Computer
+
+ var body: some View {
+ VStack(alignment: .leading, spacing: 4) {
+ HStack(spacing: 8) {
+ Text(computer.name).font(.body.weight(.semibold)).foregroundStyle(Palette.text)
+ Spacer(minLength: 8)
+ Text(L10n.tr(computer.role.title)).font(.footnote).foregroundStyle(Palette.secondary)
+ }
+ HStack(alignment: .firstTextBaseline, spacing: 6) {
+ Circle()
+ .fill(computer.online ? Palette.added : Palette.tertiary)
+ .frame(width: 7, height: 7)
+ .accessibilityHidden(true)
+ Text(L10n.tr(presence))
+ .font(.footnote)
+ .foregroundStyle(Palette.secondary)
+ }
+ Text(bots)
+ .font(.footnote)
+ .foregroundStyle(Palette.tertiary)
+ .fixedSize(horizontal: false, vertical: true)
+ }
+ .padding(.vertical, 2)
+ .accessibilityElement(children: .combine)
+ }
+
+ private var presence: String {
+ computer.me ? "This computer" : computer.online ? "Online" : "Away"
+ }
+
+ private var bots: String {
+ let names = (computer.agents ?? []).map(\.name)
+ return names.isEmpty ? L10n.tr("No bots") : names.joined(separator: ", ")
+ }
+}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sync.swift b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sync.swift
index 73d1e816..53a77e85 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sync.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sync.swift
@@ -19,6 +19,10 @@ extension BotStore {
try await Task.sleep(for: hostUpdateOffer() == .updating ? Self.updatingRecheck : Self.mismatchRecheck)
continue
}
+ // Hosts before the network view answer "unknown method": nothing to show.
+ let view = try? await client.networkView()
+ guard !Task.isCancelled, !retired else { return }
+ network = view
requestedSince = rev
windowFloors = [:]
for try await event in client.events(since: requestedSince, client: "ios") {
@@ -124,6 +128,8 @@ extension BotStore {
setUsage(u)
case let .screen(s):
screen = s
+ case let .network(view):
+ network = view
case let .artifact(artifact):
artifacts.upsert(artifact)
case .resync:
diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift
index 5694d795..235c7af6 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift
@@ -65,6 +65,8 @@ public final class BotStore {
public internal(set) var usage: Usage
/// The computer's remote screen (`nil`: the host predates it).
public internal(set) var screen: ScreenState?
+ /// The computer's network of the user's computers (`nil`: the host predates it).
+ public internal(set) var network: NetworkView?
/// Installed on the computer, for the Plugins screen and bot settings.
public internal(set) var installedConnectors: [InstalledConnector] = []
public internal(set) var installedSkills: [InstalledSkill] = []
diff --git a/apps/ios/Kit/Tests/CodyncKitTests/NetworkTests.swift b/apps/ios/Kit/Tests/CodyncKitTests/NetworkTests.swift
new file mode 100644
index 00000000..6a3b3f0c
--- /dev/null
+++ b/apps/ios/Kit/Tests/CodyncKitTests/NetworkTests.swift
@@ -0,0 +1,22 @@
+import Foundation
+import Testing
+@testable import CodyncKit
+
+@Test func decodesTheNetworkViewAndItsEvent() throws {
+ let view = #"{"joined":true,"computer":"desk","role":"owner","connector":"public","assistants":true,"computers":[{"name":"desk","role":"owner","me":true,"online":true,"bots":["reviewer"],"agents":[{"id":"reviewer","name":"Reviewer"}],"canRemove":false,"canPromote":false},{"name":"laptop","role":"overlord","me":false,"online":false,"bots":[],"agents":[],"canRemove":true,"canPromote":true}]}"#
+ let decoded = try JSONDecoder().decode(NetworkView.self, from: Data(view.utf8))
+ #expect(decoded.joined && decoded.isAssistantsOn && decoded.role == .owner)
+ #expect(decoded.computers?.map(\.name) == ["desk", "laptop"])
+ #expect(decoded.computers?.first?.agents?.first?.name == "Reviewer")
+ #expect(decoded.computers?.last?.role == .member, "an unknown role reads as a member")
+
+ guard case let .network(event) = HostClient.parseEvent(Data(#"{"type":"network","network":\#(view)}"#.utf8)) else {
+ Issue.record("network event"); return
+ }
+ #expect(event == decoded)
+ // Outside a network, from a host that only says whether assistants are on.
+ let alone = try JSONDecoder().decode(NetworkView.self, from: Data(#"{"joined":false,"assistants":false}"#.utf8))
+ #expect(!alone.hasContent && alone.computers == nil)
+ // A network event this app can't read is skipped, never a rewind.
+ #expect(HostClient.parseEvent(Data(#"{"type":"network","network":{"joined":"yes"}}"#.utf8)) == nil)
+}
diff --git a/apps/ios/Views/SettingsView.swift b/apps/ios/Views/SettingsView.swift
index 24c7df80..5da95900 100644
--- a/apps/ios/Views/SettingsView.swift
+++ b/apps/ios/Views/SettingsView.swift
@@ -274,6 +274,7 @@ private struct ComputerRow: View {
@Environment(AccountStore.self) private var accounts
@State private var coloring = false
@State private var voiceSettings = false
+ @State private var networkSheet = false
var body: some View {
VStack(alignment: .leading, spacing: 6) {
@@ -320,6 +321,7 @@ private struct ComputerRow: View {
if store.connection == .online {
items.append(MenuItem("Extensions", icon: "square.grid.2x2", action: openMarketplace))
items.append(MenuItem("Voice chat", icon: "waveform") { voiceSettings = true })
+ if showsNetwork { items.append(MenuItem("Network", icon: Self.networkIcon) { networkSheet = true }) }
}
if store.screen != nil, store.connection == .online {
items.append(MenuItem("Screen", icon: "display", action: openScreen))
@@ -333,6 +335,7 @@ private struct ComputerRow: View {
return items
}
.codyncSheet(isPresented: $voiceSettings) { VoiceChatSettingsView().environment(store) }
+ .codyncSheet(isPresented: $networkSheet) { NetworkSheet().environment(store) }
.codyncOverlay(isPresented: $coloring) { close in
ZStack {
Color.black.opacity(0.35).ignoresSafeArea().onTapGesture(perform: close)
@@ -358,6 +361,7 @@ private struct ComputerRow: View {
if store.connection == .online {
IconButton("Extensions", systemImage: "square.grid.2x2", action: openMarketplace)
if store.screen != nil { IconButton("Screen", systemImage: "display", action: openScreen) }
+ if showsNetwork { IconButton("Network", systemImage: Self.networkIcon) { networkSheet = true } }
}
DropdownMenu {
ConnectionRoute.allCases.map { route in
@@ -377,6 +381,11 @@ private struct ComputerRow: View {
}
}
+ private static let networkIcon = "point.3.connected.trianglepath.dotted"
+
+ /// In a network of the user's computers, or cloud assistants on (hosts before it say nothing).
+ private var showsNetwork: Bool { store.network?.hasContent == true }
+
private var preference: ConnectionRoute { store.computer.route ?? .automatic }
private var stale: Bool { accounts.isStale(store.computer.id) }
diff --git a/host/src/tui/app/analytics.rs b/host/src/tui/app/analytics.rs
index 63d21f54..200ce59e 100644
--- a/host/src/tui/app/analytics.rs
+++ b/host/src/tui/app/analytics.rs
@@ -55,6 +55,7 @@ impl App {
let overlay = self.overlays.iter().rev().find_map(|o| match o {
Overlay::Usage(_) => Some(Screen::Usage),
Overlay::Pair(_) => Some(Screen::Pairing),
+ Overlay::Network(_) => Some(Screen::Network),
Overlay::Memory(_) => Some(Screen::Memory),
Overlay::Library(_) => Some(Screen::Library),
Overlay::Routines(_) => Some(Screen::Routines),
diff --git a/host/src/tui/app/events.rs b/host/src/tui/app/events.rs
index 459c6ab1..a4125581 100644
--- a/host/src/tui/app/events.rs
+++ b/host/src/tui/app/events.rs
@@ -62,6 +62,7 @@ impl App {
}
Some("usage") => self.usage = v["usage"].clone(),
Some("screen") => self.screen = v["screen"].clone(),
+ Some("network") => self.network_changed(&v["network"]),
Some("bot") => {
self.upsert_bot(&v["bot"]);
self.memory_moved(&v["bot"]);
@@ -159,6 +160,10 @@ impl App {
self.on_sheet_reply(s, r);
return;
}
+ if let After::Network(n) = after {
+ self.network_reply(n, r);
+ return;
+ }
let v = match r {
Ok(v) => v,
Err(e) => {
@@ -204,6 +209,7 @@ impl App {
| After::Tracked
| After::Answered(_)
| After::Sheet(_)
+ | After::Network(_)
| After::Sent(_)
| After::Connection(_, _) => {}
After::Installed => {
diff --git a/host/src/tui/app/input.rs b/host/src/tui/app/input.rs
index 60844f59..96e26b29 100644
--- a/host/src/tui/app/input.rs
+++ b/host/src/tui/app/input.rs
@@ -316,6 +316,7 @@ impl App {
self.step_pick(0);
}
KeyCode::Char('P') => self.open_pair(),
+ KeyCode::Char('N') => self.open_network(),
KeyCode::Char('s') => {
if let Some(b) = self.bot() {
if matches!(b.status, Status::Working | Status::NeedsInput) {
diff --git a/host/src/tui/app/mod.rs b/host/src/tui/app/mod.rs
index e53c6469..cf360f5c 100644
--- a/host/src/tui/app/mod.rs
+++ b/host/src/tui/app/mod.rs
@@ -480,7 +480,7 @@ pub fn tilde(path: &str, home: &str) -> String {
}
#[cfg(test)]
-fn test_app() -> App {
+pub(in crate::tui) fn test_app() -> App {
let (tx, _) = tokio::sync::mpsc::unbounded_channel();
App::new(Client::new("http://127.0.0.1:1", None), tx, String::new())
}
diff --git a/host/src/tui/app/model.rs b/host/src/tui/app/model.rs
index 9a5aecad..357d9143 100644
--- a/host/src/tui/app/model.rs
+++ b/host/src/tui/app/model.rs
@@ -47,6 +47,8 @@ pub enum After {
Installed,
/// Memory, routines, marketplace, sign-in (`manage`).
Sheet(Reply),
+ /// The network sheet's calls.
+ Network(super::super::manage::NetReply),
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
diff --git a/host/src/tui/app/overlay_keys.rs b/host/src/tui/app/overlay_keys.rs
index 97c42299..996f9614 100644
--- a/host/src/tui/app/overlay_keys.rs
+++ b/host/src/tui/app/overlay_keys.rs
@@ -53,6 +53,7 @@ impl App {
Action::Library => self.open_library(),
Action::RefreshAgents => self.call("refreshBackends", json!({}), After::Backends),
Action::Pair => self.open_pair(),
+ Action::Network => self.open_network(),
Action::Usage => self.overlays.push(Overlay::Usage(0)),
Action::CheckUpdate => self.call("checkHostUpdate", json!({}), After::Update),
Action::Analytics => self.toggle_analytics(),
@@ -128,6 +129,7 @@ impl App {
Overlay::Fields(f) => self.fields_key(f, k),
Overlay::Skill(s) => self.skill_key(s, k),
Overlay::Analytics(s) => s.key(k),
+ Overlay::Network(n) => self.network_key(n, k),
// A new code: after a failure, or in place of the one shown.
Overlay::Pair(_) if k.code == KeyCode::Char('r') => {
self.call("pairing", json!({}), After::Pairing);
diff --git a/host/src/tui/app/ui.rs b/host/src/tui/app/ui.rs
index 9c313ffd..3ca24c30 100644
--- a/host/src/tui/app/ui.rs
+++ b/host/src/tui/app/ui.rs
@@ -5,8 +5,8 @@ use std::collections::BTreeMap;
use std::time::Instant;
use super::super::manage::{
- AgentSetup, AnalyticsSheet, BotChatSheet, Fields, Library, Market, MemorySheet, RoutineForm, RoutineList,
- SkillSheet,
+ AgentSetup, AnalyticsSheet, BotChatSheet, Fields, Library, Market, MemorySheet, NetworkSheet, RoutineForm,
+ RoutineList, SkillSheet,
};
use super::{Editor, Mark};
@@ -55,6 +55,7 @@ pub enum Action {
Library,
RefreshAgents,
Pair,
+ Network,
Usage,
CheckUpdate,
Analytics,
@@ -65,7 +66,7 @@ pub enum Action {
Appearance(super::super::appearance::Appearance),
}
-pub const ACTIONS: [(&str, &str, Action); 18] = [
+pub const ACTIONS: [(&str, &str, Action); 19] = [
("New bot…", "n", Action::NewBot),
("New group chat…", "m", Action::NewGroup),
("Extensions: agents, connectors, skills…", "A", Action::Market),
@@ -74,6 +75,7 @@ pub const ACTIONS: [(&str, &str, Action); 18] = [
("Library of this bot: artifacts and files…", "L", Action::Library),
("Refresh agents", "", Action::RefreshAgents),
("Pair a phone…", "P", Action::Pair),
+ ("Network: your other computers…", "N", Action::Network),
("Usage", "U", Action::Usage),
("Check for updates", "", Action::CheckUpdate),
("Share usage analytics", "", Action::Analytics),
@@ -316,6 +318,7 @@ pub enum Overlay {
Fields(Box<Fields>),
Skill(SkillSheet),
Analytics(AnalyticsSheet),
+ Network(Box<NetworkSheet>),
}
pub struct Toast {
diff --git a/host/src/tui/manage/mod.rs b/host/src/tui/manage/mod.rs
index 360cf83d..788eecc0 100644
--- a/host/src/tui/manage/mod.rs
+++ b/host/src/tui/manage/mod.rs
@@ -12,6 +12,7 @@ mod fields;
mod library;
mod market;
mod memory;
+mod network;
mod pages;
mod replies;
mod routines;
@@ -22,6 +23,7 @@ pub use analytics::AnalyticsSheet;
pub use fields::handoff_fields;
pub use library::{ArtifactTitles, LibraryItem};
pub use memory::{MemoryMode, MemorySheet, Scroll, Section};
+pub use network::{CONNECTORS, NetReply, NetworkSheet, Setup, SetupField, Step};
pub use pages::Page;
pub use skill::SkillSheet;
pub use when::complete_zone;
diff --git a/host/src/tui/manage/network.rs b/host/src/tui/manage/network.rs
new file mode 100644
index 00000000..a9ce1dd7
--- /dev/null
+++ b/host/src/tui/manage/network.rs
@@ -0,0 +1,406 @@
+//! The network of the user's computers (codync-network): who is in, inviting, joining, roles,
+//! removal and recovery, and the cloud assistants switch. The TUI runs on the computer, so it
+//! gets everything the desktop app does.
+
+use crossterm::event::{KeyCode, KeyEvent};
+use serde_json::{Value, json};
+
+use super::super::app::{After, App, Editor, Overlay, copy};
+use super::super::l10n::tr;
+
+/// How computers reach each other without a direct path: what's shown, what the host takes
+/// (empty: the relay address typed under it) and what it means. The desktop app's words.
+pub const CONNECTORS: [(&str, &str, &str); 3] = [
+ ("Public relays", "public", "Direct when it can, through a shared relay otherwise."),
+ ("Private: direct only", "private", "Same network, Tailscale or a VPN."),
+ ("Your own relay", "", "An iroh-relay you run."),
+];
+
+#[derive(Default)]
+pub struct NetworkSheet {
+ /// `networkView`'s answer; `None` until it comes.
+ pub view: Option<Value>,
+ pub cursor: usize,
+ pub step: Step,
+ pub error: Option<String>,
+ pub busy: bool,
+}
+
+#[derive(Default)]
+pub enum Step {
+ #[default]
+ List,
+ Create(Setup),
+ Join(Setup),
+ /// The recovery code, shown once: only "I saved it" closes it.
+ Recovery(String),
+ /// A one-time invite (`None` while it comes) and when it stops working.
+ Invite(Option<(String, i64)>),
+ Recover(Editor),
+ Remove {
+ computer: String,
+ cascade: bool,
+ },
+}
+
+/// Creating a network, or joining one with an invite.
+#[derive(Default)]
+pub struct Setup {
+ pub invite: Editor,
+ pub name: Editor,
+ pub connector: usize,
+ pub relay: Editor,
+ pub field: SetupField,
+}
+
+#[derive(Clone, Copy, Default, PartialEq, Eq, Debug)]
+pub enum SetupField {
+ Invite,
+ #[default]
+ Name,
+ Connector,
+ Relay,
+}
+
+impl Setup {
+ fn join() -> Self {
+ Self { field: SetupField::Invite, ..Self::default() }
+ }
+
+ /// The fields in order: joining starts with the invite, a relay URL only for your own relay.
+ pub fn fields(&self, join: bool) -> Vec<SetupField> {
+ let mut fields = vec![SetupField::Name, SetupField::Connector];
+ if join {
+ fields.insert(0, SetupField::Invite);
+ }
+ if CONNECTORS[self.connector].1.is_empty() {
+ fields.push(SetupField::Relay);
+ }
+ fields
+ }
+
+ fn step(&mut self, join: bool, by: isize) {
+ let fields = self.fields(join);
+ let i = fields.iter().position(|f| *f == self.field).unwrap_or(0);
+ self.field = fields[super::super::app::cycle(i, by, fields.len())];
+ }
+
+ fn connector(&self) -> String {
+ match CONNECTORS[self.connector].1 {
+ "" => self.relay.text.trim().to_owned(),
+ name => name.to_owned(),
+ }
+ }
+
+ fn body(&self) -> Value {
+ let name = self.name.text.trim();
+ json!({"invite": self.invite.text.trim(), "name": (!name.is_empty()).then_some(name), "connector": self.connector()})
+ }
+}
+
+/// What a network call's answer is for.
+#[derive(Clone, Copy)]
+pub enum NetReply {
+ /// A view or status to show (`networkView`, `networkPeers`, `networkJoin`).
+ View,
+ Created,
+ Invite,
+ /// Done: flash this and show the list again.
+ Done(&'static str),
+ Assistants,
+}
+
+fn rows(view: &Value) -> &[Value] {
+ view["computers"].as_array().map_or(&[], Vec::as_slice)
+}
+
+impl NetworkSheet {
+ pub fn joined(&self) -> bool {
+ self.view.as_ref().is_some_and(|v| v["joined"] == true)
+ }
+
+ pub fn role(&self) -> &str {
+ self.view.as_ref().and_then(|v| v["role"].as_str()).unwrap_or_default()
+ }
+
+ pub fn computers(&self) -> &[Value] {
+ self.view.as_ref().map_or(&[], rows)
+ }
+
+ fn selected(&self) -> Option<&Value> {
+ self.computers().get(self.cursor)
+ }
+}
+
+impl App {
+ pub fn open_network(&mut self) {
+ self.net("networkView", json!({}), NetReply::View);
+ self.overlays.push(Overlay::Network(Box::default()));
+ }
+
+ fn net(&self, method: &'static str, body: Value, r: NetReply) {
+ self.call(method, body, After::Network(r));
+ }
+
+ /// The `network` event: what the open sheet shows.
+ pub(in crate::tui) fn network_changed(&mut self, view: &Value) {
+ for o in &mut self.overlays {
+ if let Overlay::Network(n) = o {
+ n.cursor = n.cursor.min(rows(view).len().saturating_sub(1));
+ n.view = Some(view.clone());
+ }
+ }
+ }
+
+ pub(in crate::tui) fn network_reply(&mut self, r: NetReply, res: Result<Value, String>) {
+ let Some(Overlay::Network(n)) = self.overlays.iter_mut().rev().find(|o| matches!(o, Overlay::Network(_)))
+ else {
+ return;
+ };
+ n.busy = false;
+ let v = match res {
+ Ok(v) => v,
+ Err(e) => {
+ n.error = Some(e);
+ return;
+ }
+ };
+ n.error = None;
+ let mut flash = None;
+ match r {
+ NetReply::View => {
+ // `networkStatus` and `networkPeers` don't carry the assistants switch: keep it.
+ let assistants = n.view.as_ref().map(|old| old["assistants"].clone());
+ let mut view = v;
+ if view.get("assistants").is_none() {
+ view["assistants"] = assistants.unwrap_or(Value::Bool(false));
+ }
+ n.cursor = n.cursor.min(rows(&view).len().saturating_sub(1));
+ n.view = Some(view);
+ if matches!(n.step, Step::Join(_)) {
+ n.step = Step::List;
+ }
+ }
+ NetReply::Created => {
+ n.step = Step::Recovery(v["recoveryCode"].as_str().unwrap_or_default().to_owned());
+ }
+ NetReply::Invite => {
+ let code = v["invite"].as_str().unwrap_or_default().to_owned();
+ n.step = Step::Invite(Some((code, v["expiresAt"].as_i64().unwrap_or_default())));
+ }
+ NetReply::Done(message) => {
+ n.step = Step::List;
+ flash = Some(message);
+ }
+ NetReply::Assistants => {
+ if let Some(view) = &mut n.view {
+ view["assistants"] = v["assistants"].clone();
+ }
+ }
+ }
+ if let Some(message) = flash {
+ self.flash(message);
+ self.net("networkView", json!({}), NetReply::View);
+ }
+ }
+
+ pub(in crate::tui) fn network_key(&mut self, mut n: Box<NetworkSheet>, k: KeyEvent) -> Option<Overlay> {
+ let step = std::mem::take(&mut n.step);
+ n.step = match step {
+ Step::List => return self.network_list_key(n, k),
+ Step::Create(s) => self.setup_key(&mut n, s, false, k),
+ Step::Join(s) => self.setup_key(&mut n, s, true, k),
+ Step::Recovery(code) => match k.code {
+ KeyCode::Char('y') => {
+ copy(&code);
+ self.flash("Recovery code copied");
+ Step::Recovery(code)
+ }
+ // Closed only once the user says they kept it.
+ KeyCode::Char('s') => Step::List,
+ _ => Step::Recovery(code),
+ },
+ Step::Invite(invite) => match (k.code, invite) {
+ (KeyCode::Esc | KeyCode::Char('q'), _) => Step::List,
+ (KeyCode::Char('y'), Some((code, until))) => {
+ copy(&code);
+ self.flash("Invite copied");
+ Step::Invite(Some((code, until)))
+ }
+ (KeyCode::Char('n'), _) => {
+ self.net("networkInvite", json!({}), NetReply::Invite);
+ Step::Invite(None)
+ }
+ (_, invite) => Step::Invite(invite),
+ },
+ Step::Recover(mut code) => match k.code {
+ KeyCode::Esc => Step::List,
+ KeyCode::Enter if !code.text.trim().is_empty() => {
+ n.busy = true;
+ let done =
+ NetReply::Done("This computer is the owner now. Remove the lost computer from the list.");
+ self.net("networkRecover", json!({"code": code.text.trim()}), done);
+ Step::Recover(code)
+ }
+ _ => {
+ code.key(k);
+ Step::Recover(code)
+ }
+ },
+ Step::Remove { computer, cascade } => match k.code {
+ KeyCode::Esc | KeyCode::Char('q') => Step::List,
+ KeyCode::Char('c' | ' ') => Step::Remove { computer, cascade: !cascade },
+ KeyCode::Enter => {
+ n.busy = true;
+ let body = json!({"computer": computer, "cascade": cascade});
+ self.net("networkRemove", body, NetReply::Done("Removed from the network"));
+ Step::Remove { computer, cascade }
+ }
+ _ => Step::Remove { computer, cascade },
+ },
+ };
+ Some(Overlay::Network(n))
+ }
+
+ fn network_list_key(&mut self, mut n: Box<NetworkSheet>, k: KeyEvent) -> Option<Overlay> {
+ let last = n.computers().len().saturating_sub(1);
+ let selected = n.selected().cloned();
+ let name = |c: &Value| c["name"].as_str().unwrap_or_default().to_owned();
+ match k.code {
+ KeyCode::Esc | KeyCode::Char('q' | 'N') => return None,
+ KeyCode::Down | KeyCode::Char('j') => n.cursor = (n.cursor + 1).min(last),
+ KeyCode::Up | KeyCode::Char('k') => n.cursor = n.cursor.saturating_sub(1),
+ KeyCode::Char('a') if n.view.is_some() => {
+ let on = n.view.as_ref().is_some_and(|v| v["assistants"] == true);
+ self.net("setAssistants", json!({"enabled": !on}), NetReply::Assistants);
+ }
+ KeyCode::Char('c') if n.view.is_some() && !n.joined() => n.step = Step::Create(Setup::default()),
+ KeyCode::Char('J') if n.view.is_some() && !n.joined() => n.step = Step::Join(Setup::join()),
+ KeyCode::Char('r') if n.joined() => {
+ n.busy = true;
+ self.net("networkPeers", json!({}), NetReply::View);
+ }
+ KeyCode::Char('i') if n.joined() && n.role() != "member" => {
+ self.net("networkInvite", json!({}), NetReply::Invite);
+ n.step = Step::Invite(None);
+ }
+ KeyCode::Char('o') if n.joined() && n.role() != "owner" => n.step = Step::Recover(Editor::default()),
+ KeyCode::Char('p') => match selected {
+ Some(c) if c["canPromote"] == true => {
+ self.net("networkPromote", json!({"computer": name(&c)}), NetReply::Done("Made an admin"));
+ }
+ Some(_) => self.flash("Only the owner makes plain members admins"),
+ None => {}
+ },
+ KeyCode::Char('x') => match selected {
+ Some(c) if c["canRemove"] == true => n.step = Step::Remove { computer: name(&c), cascade: false },
+ Some(c) if c["me"] == true => self.flash("Remove this computer from another one"),
+ Some(_) => self.flash("Only the owner removes admins; admins remove members"),
+ None => {}
+ },
+ _ => {}
+ }
+ Some(Overlay::Network(n))
+ }
+
+ /// Keys in the create or join form.
+ fn setup_key(&mut self, n: &mut NetworkSheet, mut s: Setup, join: bool, k: KeyEvent) -> Step {
+ match k.code {
+ KeyCode::Esc => return Step::List,
+ KeyCode::Tab | KeyCode::Down => s.step(join, 1),
+ KeyCode::BackTab | KeyCode::Up => s.step(join, -1),
+ KeyCode::Left | KeyCode::Right | KeyCode::Char(' ') if s.field == SetupField::Connector => {
+ let by = if k.code == KeyCode::Left { -1 } else { 1 };
+ s.connector = super::super::app::cycle(s.connector, by, CONNECTORS.len());
+ }
+ KeyCode::Enter => {
+ if join && s.invite.text.trim().is_empty() {
+ n.error = Some(tr("Paste the invite from the other computer.").into_owned());
+ } else if s.connector().is_empty() {
+ n.error = Some(tr("Enter your relay's address.").into_owned());
+ } else {
+ n.busy = true;
+ n.error = None;
+ if join {
+ self.net("networkJoin", s.body(), NetReply::View);
+ } else {
+ self.net("networkCreate", s.body(), NetReply::Created);
+ }
+ }
+ }
+ _ => {
+ let editor = match s.field {
+ SetupField::Invite => Some(&mut s.invite),
+ SetupField::Name => Some(&mut s.name),
+ SetupField::Relay => Some(&mut s.relay),
+ SetupField::Connector => None,
+ };
+ if let Some(e) = editor {
+ e.key(k);
+ }
+ }
+ }
+ if join { Step::Join(s) } else { Step::Create(s) }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::super::super::app::test_app;
+ use super::*;
+ use crossterm::event::KeyModifiers;
+
+ fn key(c: KeyCode) -> KeyEvent {
+ KeyEvent::new(c, KeyModifiers::NONE)
+ }
+
+ fn joined(role: &str) -> Value {
+ json!({"joined": true, "computer": "desk", "role": role, "assistants": false, "computers": [
+ {"name": "desk", "role": role, "me": true, "online": true, "agents": [], "canRemove": false, "canPromote": false},
+ {"name": "laptop", "role": "member", "me": false, "online": true, "agents": [{"id": "coder", "name": "Coder"}],
+ "canRemove": role != "member", "canPromote": role == "owner"},
+ ]})
+ }
+
+ fn sheet(view: Value) -> Box<NetworkSheet> {
+ Box::new(NetworkSheet { view: Some(view), ..NetworkSheet::default() })
+ }
+
+ #[tokio::test]
+ async fn removing_asks_first_and_cascade_is_a_choice() {
+ let mut app = test_app();
+ let mut n = sheet(joined("owner"));
+ n.cursor = 1;
+ let Some(Overlay::Network(n)) = app.network_key(n, key(KeyCode::Char('x'))) else { panic!("kept open") };
+ assert!(matches!(&n.step, Step::Remove { computer, cascade: false } if computer == "laptop"));
+ let Some(Overlay::Network(n)) = app.network_key(n, key(KeyCode::Char('c'))) else { panic!("kept open") };
+ assert!(matches!(n.step, Step::Remove { cascade: true, .. }));
+ let Some(Overlay::Network(n)) = app.network_key(n, key(KeyCode::Esc)) else { panic!("kept open") };
+ assert!(matches!(n.step, Step::List));
+ }
+
+ #[tokio::test]
+ async fn a_member_cant_remove_and_the_recovery_code_needs_saving() {
+ let mut app = test_app();
+ let mut n = sheet(joined("member"));
+ n.cursor = 1;
+ let Some(Overlay::Network(mut n)) = app.network_key(n, key(KeyCode::Char('x'))) else { panic!("kept open") };
+ assert!(matches!(n.step, Step::List), "the host said it can't");
+ n.step = Step::Recovery("1234".into());
+ let Some(Overlay::Network(n)) = app.network_key(n, key(KeyCode::Esc)) else { panic!("kept open") };
+ assert!(matches!(n.step, Step::Recovery(_)), "esc doesn't skip saving it");
+ let Some(Overlay::Network(n)) = app.network_key(n, key(KeyCode::Char('s'))) else { panic!("kept open") };
+ assert!(matches!(n.step, Step::List));
+ }
+
+ #[test]
+ fn a_relay_url_field_only_for_your_own_relay() {
+ let mut s = Setup::join();
+ assert_eq!(s.fields(true), [SetupField::Invite, SetupField::Name, SetupField::Connector]);
+ s.connector = 2;
+ assert_eq!(s.fields(false), [SetupField::Name, SetupField::Connector, SetupField::Relay]);
+ s.relay = Editor::with(" https://relay.example ");
+ assert_eq!(s.body()["connector"], "https://relay.example");
+ assert_eq!(s.body()["name"], Value::Null, "the host name when left empty");
+ }
+}
diff --git a/host/src/tui/view/help.rs b/host/src/tui/view/help.rs
index 1428f1a1..2ffc0ff3 100644
--- a/host/src/tui/view/help.rs
+++ b/host/src/tui/view/help.rs
@@ -10,7 +10,7 @@ use super::buffer::{centered, frame_box, put, u};
use super::overlay::field_line;
use super::style::theme;
-const HELP: [(&str, &str, &str); 68] = [
+const HELP: [(&str, &str, &str); 69] = [
("MOVE", "j k ↑ ↓", "next / previous bot"),
("MOVE", "[ ]", "previous / next bot"),
("MOVE", "1…9", "jump to bot 1–9"),
@@ -72,6 +72,7 @@ const HELP: [(&str, &str, &str); 68] = [
("VIEW", "b", "compact roster"),
("VIEW", "U", "usage"),
("VIEW", "P", "pair a phone"),
+ ("VIEW", "N", "network: your other computers"),
("VIEW", "^k share", "share usage analytics on / off"),
("VIEW", "^k about", "what usage analytics include"),
("VIEW", "language", "app language: follow system or choose one of eight languages"),
diff --git a/host/src/tui/view/mod.rs b/host/src/tui/view/mod.rs
index 63dfd2d7..e5e33759 100644
--- a/host/src/tui/view/mod.rs
+++ b/host/src/tui/view/mod.rs
@@ -17,6 +17,7 @@ mod forms;
mod goto;
mod help;
mod lead_agent;
+mod network;
mod new_bot;
mod overlay;
mod pair;
diff --git a/host/src/tui/view/network.rs b/host/src/tui/view/network.rs
new file mode 100644
index 00000000..1d969e05
--- /dev/null
+++ b/host/src/tui/view/network.rs
@@ -0,0 +1,221 @@
+//! The network sheet: this computer's network of the user's computers.
+
+use ratatui::buffer::Buffer;
+use ratatui::layout::Rect;
+use ratatui::style::Style;
+use ratatui::text::Span;
+use serde_json::Value;
+
+use super::super::l10n::tr;
+use super::super::manage::{CONNECTORS, NetworkSheet, Setup, SetupField, Step};
+use super::super::md;
+use super::buffer::{centered, frame_box, hline, put, put_line, restyle, rput};
+use super::overlay::input_line;
+use super::style::theme;
+use super::time::clock;
+
+pub(super) fn network(buf: &mut Buffer, area: Rect, n: &NetworkSheet) {
+ let t = theme();
+ let r = centered(area, 84, area.height.saturating_sub(4).min(26));
+ let inner = frame_box(buf, r, t.text, t.panel, Some((tr("Network").as_ref(), t.text)));
+ if inner.height < 8 {
+ return;
+ }
+ hline(buf, inner.x, inner.bottom() - 2, inner.width, t.dim.patch(t.panel));
+ let body = Rect::new(inner.x, inner.y, inner.width, inner.height - 2);
+ let mut y = body.y;
+ let keys = match &n.step {
+ Step::List => list(buf, body, n),
+ Step::Create(s) => setup(buf, body, s, false),
+ Step::Join(s) => setup(buf, body, s, true),
+ Step::Recovery(code) => {
+ let name = n.view.as_ref().and_then(|v| v["computer"].as_str()).unwrap_or("this computer");
+ line(buf, body, &mut y, &tr("Save your recovery code"), t.bold);
+ y += 1;
+ line(buf, body, &mut y, code, t.bold);
+ y += 1;
+ let note = tr(
+ "It makes another computer the owner if {name} is lost. It's shown only once and kept on no computer.",
+ );
+ wrapped(buf, body, &mut y, &note.replace("{name}", name), t.secondary);
+ "y copy · s I saved it"
+ }
+ Step::Invite(invite) => {
+ line(buf, body, &mut y, &tr("Invite a computer"), t.bold);
+ y += 1;
+ match invite {
+ None => line(buf, body, &mut y, &tr("Getting an invite…"), t.dim),
+ Some((code, until)) => {
+ wrapped(buf, body, &mut y, code, t.bold);
+ y += 1;
+ let name = n.view.as_ref().and_then(|v| v["computer"].as_str()).unwrap_or("this computer");
+ let note = tr("One use. Works until {time} while {name} stays on.")
+ .replace("{time}", &clock(*until))
+ .replace("{name}", name);
+ line(buf, body, &mut y, &note, t.secondary);
+ line(
+ buf,
+ body,
+ &mut y,
+ &tr("On the other computer, choose Join with invite under Network."),
+ t.secondary,
+ );
+ }
+ }
+ "y copy · n new invite · esc back"
+ }
+ Step::Recover(code) => {
+ line(buf, body, &mut y, &tr("Recover ownership"), t.bold);
+ let note = tr("For when the owner is lost: this computer becomes the owner.");
+ wrapped(buf, body, &mut y, &note, t.secondary);
+ y += 1;
+ input_line(buf, Rect::new(body.x, y, body.width, 1), y, code, "Recovery code", true, false);
+ "↵ recover · esc back"
+ }
+ Step::Remove { computer, cascade } => {
+ line(buf, body, &mut y, &tr("Remove {name} from the network?").replace("{name}", computer), t.red);
+ line(buf, body, &mut y, &tr("It can't come back with its current key."), t.text);
+ y += 1;
+ let mark = if *cascade { "◉" } else { "○" };
+ line(buf, body, &mut y, &format!("{mark} {}", tr("Also remove the computers it invited")), t.text);
+ line(buf, body, &mut y, &format!(" {}", tr("For a stolen computer.")), t.secondary);
+ "↵ remove · c switches · esc cancel"
+ }
+ };
+ if let Some(e) = &n.error {
+ put(buf, inner.x, inner.bottom() - 3, inner.width, e, t.red.patch(t.panel));
+ } else if n.busy {
+ put(buf, inner.x, inner.bottom() - 3, inner.width, &tr("Working…"), t.dim.patch(t.panel));
+ }
+ put(buf, inner.x, inner.bottom() - 1, inner.width, &format!(" {}", tr(keys)), t.dim.patch(t.panel));
+}
+
+/// The computers, or how to start; then the cloud assistants switch. Returns the key hints.
+fn list(buf: &mut Buffer, body: Rect, n: &NetworkSheet) -> &'static str {
+ let t = theme();
+ let mut y = body.y;
+ let Some(view) = &n.view else {
+ put(buf, body.x, y, body.width, &tr("Loading…"), t.dim.patch(t.panel));
+ return "esc close";
+ };
+ if n.joined() {
+ let me = view["computer"].as_str().unwrap_or_default();
+ let role = role_name(n.role());
+ let connector = view["connector"].as_str().unwrap_or("public");
+ put(buf, body.x, y, body.width, &format!("{me} · {role} · {connector}"), t.secondary.patch(t.panel));
+ y += 2;
+ let room = usize::from(body.height).saturating_sub(7).max(1);
+ let off = n.cursor.saturating_sub(room.saturating_sub(1));
+ for (i, c) in n.computers().iter().enumerate().skip(off).take(room) {
+ computer_row(buf, body, y, c, i == n.cursor);
+ y += 1;
+ }
+ } else {
+ put(buf, body.x, y, body.width, &tr("Not in a network."), t.bold.patch(t.panel));
+ y += 1;
+ let note = tr("Connect your computers so bots on one can message bots on another.");
+ wrapped(buf, body, &mut y, &note, t.secondary);
+ }
+ y += 1;
+ let on = view["assistants"] == true;
+ put(buf, body.x, y, body.width, &tr("Cloud assistants"), t.text.patch(t.panel));
+ let x = rput(buf, body.right(), y, " a switches", t.dim.patch(t.panel));
+ rput(buf, x, y, if on { "◉ On" } else { "○ Off" }, if on { t.text } else { t.secondary }.patch(t.panel));
+ y += 1;
+ let about = tr(
+ "ChatGPT or Claude in your Codync account can message this computer's bots. Codync's cloud can read these calls.",
+ );
+ wrapped(buf, body, &mut y, &about, t.secondary);
+ match (n.joined(), n.role()) {
+ (false, _) => "c create network · J join with invite · esc close",
+ (true, "owner") => "i invite · p make admin · x remove · r refresh · esc close",
+ (true, "admin") => "i invite · x remove · o recover ownership · r refresh · esc close",
+ (true, _) => "o recover ownership · r refresh · esc close",
+ }
+}
+
+fn computer_row(buf: &mut Buffer, body: Rect, y: u16, c: &Value, sel: bool) {
+ let t = theme();
+ let base = if sel { t.sel } else { t.panel };
+ if sel {
+ restyle(buf, Rect::new(body.x - 1, y, body.width + 2, 1), t.sel);
+ }
+ let name = c["name"].as_str().unwrap_or_default();
+ let state = if c["me"] == true {
+ tr("This computer")
+ } else if c["online"] == true {
+ format!("● {}", tr("Online")).into()
+ } else {
+ format!("○ {}", tr("Away")).into()
+ };
+ let bots: Vec<&str> = c["agents"].as_array().into_iter().flatten().filter_map(|a| a["name"].as_str()).collect();
+ let offered = if bots.is_empty() { tr("No bots").into_owned() } else { bots.join(", ") };
+ put(buf, body.x, y, 2, if sel { "▸" } else { " " }, t.secondary.patch(base));
+ put(buf, body.x + 2, y, 20, name, t.bold.patch(base));
+ put(buf, body.x + 22, y, 8, &role_name(c["role"].as_str().unwrap_or_default()), t.text.patch(base));
+ put(buf, body.x + 30, y, 16, &state, t.secondary.patch(base));
+ put(buf, body.x + 46, y, body.width.saturating_sub(46), &md::truncate(&offered, 60), t.secondary.patch(base));
+}
+
+fn role_name(role: &str) -> String {
+ tr(match role {
+ "owner" => "Owner",
+ "admin" => "Admin",
+ _ => "Member",
+ })
+ .into_owned()
+}
+
+fn setup(buf: &mut Buffer, body: Rect, s: &Setup, join: bool) -> &'static str {
+ let t = theme();
+ let mut y = body.y;
+ let title = if join { "Join with invite" } else { "Create network" };
+ put(buf, body.x, y, body.width, &tr(title), t.bold.patch(t.panel));
+ y += 2;
+ for field in s.fields(join) {
+ let active = field == s.field;
+ let label = match field {
+ SetupField::Invite => "Invite",
+ SetupField::Name => "Computer name",
+ SetupField::Connector => "Connector",
+ SetupField::Relay => "Relay address",
+ };
+ let style = if active { t.bold } else { t.secondary };
+ put(buf, body.x, y, 18, &tr(label), style.patch(t.panel));
+ let r = Rect::new(body.x + 18, y, body.width.saturating_sub(18), 1);
+ match field {
+ SetupField::Invite => {
+ input_line(buf, r, y, &s.invite, "Paste the invite from the other computer.", active, false);
+ }
+ SetupField::Name => input_line(buf, r, y, &s.name, "Host name", active, false),
+ SetupField::Relay => input_line(buf, r, y, &s.relay, "https://relay.example.com", active, false),
+ SetupField::Connector => {
+ let shown = format!("‹ {} ›", tr(CONNECTORS[s.connector].0));
+ put(buf, r.x, y, r.width, &shown, if active { t.bold } else { t.text }.patch(t.panel));
+ }
+ }
+ y += 1;
+ }
+ y += 1;
+ wrapped(buf, body, &mut y, &tr(CONNECTORS[s.connector].2), t.secondary);
+ "↵ done · tab next field · ←→ connector · esc back"
+}
+
+fn line(buf: &mut Buffer, body: Rect, y: &mut u16, text: &str, style: Style) {
+ if *y < body.bottom() {
+ put(buf, body.x, *y, body.width, text, style.patch(theme().panel));
+ *y += 1;
+ }
+}
+
+fn wrapped(buf: &mut Buffer, body: Rect, y: &mut u16, text: &str, style: Style) {
+ let t = theme();
+ let width = usize::from(body.width);
+ for l in md::wrap(&[Span::styled(text.to_owned(), style.patch(t.panel))], width, &[], &[]) {
+ if *y >= body.bottom() {
+ return;
+ }
+ put_line(buf, body.x, *y, body.width, &l);
+ *y += 1;
+ }
+}
diff --git a/host/src/tui/view/overlay.rs b/host/src/tui/view/overlay.rs
index 257e60c7..e6da35a0 100644
--- a/host/src/tui/view/overlay.rs
+++ b/host/src/tui/view/overlay.rs
@@ -138,6 +138,7 @@ pub(super) fn overlay(buf: &mut Buffer, area: Rect, app: &mut App, top: &Overlay
Overlay::Fields(f) => super::super::sheets::fields(buf, area, f),
Overlay::Skill(s) => super::skill::skill(buf, area, app, s),
Overlay::Analytics(s) => super::analytics::analytics(buf, area, s),
+ Overlay::Network(n) => super::network::network(buf, area, n),
}
}