Skip to content

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

fix(desktop): show an earlier identity of a computer as an older copy

leepokaiba0989c26f91
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/ConnectionPresentation.kt b/apps/android/app/src/main/kotlin/com/codync/android/ConnectionPresentation.kt
index 4c0f73a4..2534a4d8 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/ConnectionPresentation.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/ConnectionPresentation.kt
@@ -72,11 +72,17 @@ private fun AppState.renamedCopyOnline(id: String, name: String) =
/**
* An offline account computer named like one this phone uses or sees online: most likely the same
* machine under an earlier identity (its host keys were reset), left behind in the account.
+ * Seen after that one joined the account, it ran beside it: another machine with the same name.
*/
internal fun AppState.isOlderCopy(computer: CloudComputer): Boolean {
if (computer.online == true) return false
+ fun replacedBy(id: String): Boolean {
+ val seen = computer.lastSeenAt ?: return true
+ val claimed = cloudComputers.firstOrNull { it.computerId == id }?.claimedAt ?: return true
+ return seen <= claimed
+ }
// The current copy may be paired with its code without being listed in the account.
- return computers.any { it.id != computer.computerId && it.name == computer.name }
+ return computers.any { it.id != computer.computerId && it.name == computer.name && replacedBy(it.id) }
|| cloudComputers.any { other -> other.computerId != computer.computerId && other.name == computer.name
- && (computers.any { it.id == other.computerId } || other.online == true) }
+ && (computers.any { it.id == other.computerId } || other.online == true) && replacedBy(other.computerId) }
}
diff --git a/apps/android/app/src/test/kotlin/com/codync/android/ConnectionPresentationTest.kt b/apps/android/app/src/test/kotlin/com/codync/android/ConnectionPresentationTest.kt
index b54f4dbb..e7dc4b5c 100644
--- a/apps/android/app/src/test/kotlin/com/codync/android/ConnectionPresentationTest.kt
+++ b/apps/android/app/src/test/kotlin/com/codync/android/ConnectionPresentationTest.kt
@@ -74,5 +74,9 @@ class ConnectionPresentationTest {
// Not paired here, but the new identity is online in the account.
val accountOnly = state(LinkState.Connecting, listOf(old, cloud("new", online = true)), computers = emptyList())
assertTrue(accountOnly.isOlderCopy(old))
+ // Seen after the current one joined the account: two machines that share a name.
+ val seen = old.copy(lastSeenAt = 200)
+ assertFalse(state(LinkState.Connecting, listOf(seen, cloud("fixture", online = true).copy(claimedAt = 100))).isOlderCopy(seen))
+ assertTrue(state(LinkState.Connecting, listOf(seen, cloud("fixture", online = true).copy(claimedAt = 300))).isOlderCopy(seen))
}
}
diff --git a/apps/desktop/src/renderer/lib/older-copy.test.ts b/apps/desktop/src/renderer/lib/older-copy.test.ts
new file mode 100644
index 00000000..d060699b
--- /dev/null
+++ b/apps/desktop/src/renderer/lib/older-copy.test.ts
@@ -0,0 +1,13 @@
+import assert from 'node:assert/strict'
+import { test } from 'node:test'
+import { isOlderCopy } from './older-copy.ts'
+
+test('an offline same-named computer is an older copy only if last seen before the current one joined', () => {
+ const old = { computerId: 'old', name: 'Mac', online: false, lastSeenAt: 200 }
+ const current = (claimedAt: number) => ({ computerId: 'new', name: 'Mac', online: true, claimedAt })
+ assert.equal(isOlderCopy(old, [old, current(100)], []), false)
+ assert.equal(isOlderCopy(old, [old, current(300)], []), true)
+ // Used here without being listed in the account.
+ assert.equal(isOlderCopy(old, [old], [{ id: 'new', name: 'Mac' }]), true)
+ assert.equal(isOlderCopy({ ...old, online: true }, [old, current(300)], []), false)
+})
diff --git a/apps/desktop/src/renderer/lib/older-copy.ts b/apps/desktop/src/renderer/lib/older-copy.ts
new file mode 100644
index 00000000..95027fbb
--- /dev/null
+++ b/apps/desktop/src/renderer/lib/older-copy.ts
@@ -0,0 +1,23 @@
+/** What the older-copy rule reads of an account computer. */
+export interface AccountEntry {
+ computerId: string
+ name: string
+ online?: boolean | null
+ lastSeenAt?: number | null
+ claimedAt?: number | null
+}
+
+/**
+ * An offline account computer named like one this app uses (`used`) or sees online: an earlier identity of it.
+ * Seen after that one joined the account, it ran beside it: another machine with the same name.
+ */
+export function isOlderCopy(c: AccountEntry, account: AccountEntry[], used: { id: string; name: string }[]) {
+ if (c.online) return false
+ const replacedBy = (id: string) => {
+ const claimedAt = account.find((o) => o.computerId === id)?.claimedAt
+ return !claimedAt || !c.lastSeenAt || c.lastSeenAt <= claimedAt
+ }
+ return used.some((x) => x.id !== c.computerId && x.name === c.name && replacedBy(x.id)) ||
+ account.some((o) => o.computerId !== c.computerId && o.name === c.name &&
+ (used.some((x) => x.id === o.computerId) || !!o.online) && replacedBy(o.computerId))
+}
diff --git a/apps/desktop/src/renderer/store/cloud.ts b/apps/desktop/src/renderer/store/cloud.ts
index d990b041..005f3bd5 100644
--- a/apps/desktop/src/renderer/store/cloud.ts
+++ b/apps/desktop/src/renderer/store/cloud.ts
@@ -1,5 +1,6 @@
import type { CloudStatus, ClaimSignature } from '@shared/models'
import { Observable } from '../lib/observable'
+import { isOlderCopy } from '../lib/older-copy'
import { pref } from '../lib/prefs'
import { account } from './account'
import type { AppModel } from './app-model'
@@ -256,11 +257,8 @@ export class CloudModel extends Observable {
}
}
- /** An offline account computer named like one this app uses or sees online: an earlier identity of it. */
isOlderCopy(c: CloudComputer) {
- if (c.online) return false
- return this.app.computers.some((x) => x.id !== c.computerId && x.name === c.name) ||
- this.computers.some((o) => o.computerId !== c.computerId && o.name === c.name && (this.app.store(o.computerId) !== null || !!o.online))
+ return isOlderCopy(c, this.computers, this.app.computers)
}
devices() {
diff --git a/apps/desktop/src/renderer/views/settings/ComputersView.tsx b/apps/desktop/src/renderer/views/settings/ComputersView.tsx
index bc84f4a8..b3824223 100644
--- a/apps/desktop/src/renderer/views/settings/ComputersView.tsx
+++ b/apps/desktop/src/renderer/views/settings/ComputersView.tsx
@@ -9,6 +9,7 @@ import { HStack, IconSlot, Spacer, VStack } from '../../components/Stack'
import { Text } from '../../components/Text'
import { useModel } from '../../lib/observable'
import { useAccount } from '../../store/account'
+import type { CloudComputer } from '../../store/cloud'
import type { BotStore } from '../../store/bot-store'
import { useScreenViewed } from '../../store/analytics'
import { StoreContext, useApp } from '../../store/context'
@@ -29,6 +30,7 @@ export function ComputersView() {
const sshState = useSSH()
const cloud = useModel(app.cloud)
const [editing, setEditing] = useState<{ profile: SSHProfile; isNew: boolean } | null>(null)
+ const [removingCopy, setRemovingCopy] = useState<CloudComputer | null>(null)
const managed = app.managedStores
const managedIds = new Set(managed.map((s) => s.computer.id))
const reached = app.computers.filter((c) => !managedIds.has(c.id))
@@ -76,7 +78,7 @@ export function ComputersView() {
<div className="settings-stack">
<Text size="callout" weight="medium">{store.hostName}</Text>
<Text size="caption" tone={stale ? 'attention' : 'secondary'}>
- {stale ? `Older copy of this computer · ${statusText(store)}` : statusText(store)}
+ {stale ? `Older copy · ${statusText(store)}` : statusText(store)}
</Text>
</div>
<RouteIcon store={store} />
@@ -87,16 +89,7 @@ export function ComputersView() {
)
})}
{others.map((computer) => (
- // An account computer this app isn't authorized on. Asking for access lives in the cloud model.
- <div key={computer.computerId} className="settings-card settings-appear">
- <div className="settings-row">
- <ComputerBadge computer={{ id: computer.computerId, name: computer.name, signKey: computer.signKey, urls: [], device: computer.device ?? null }} size={22} />
- <div className="settings-stack">
- <Text size="callout" weight="medium">{computer.name}</Text>
- <Text size="caption" tone="secondary">{computer.online ? 'Online' : 'Offline'}</Text>
- </div>
- </div>
- </div>
+ <AccountComputerRow key={computer.computerId} computer={computer} olderCopy={cloud.isOlderCopy(computer)} onRemove={() => setRemovingCopy(computer)} />
))}
</div>
</VStack>
@@ -104,6 +97,13 @@ export function ComputersView() {
<Sheet open={editing !== null} onClose={() => setEditing(null)} width={460}>
{editing ? <SSHProfileEditor key={editing.profile.id} profile={editing.profile} isNew={editing.isNew} /> : null}
</Sheet>
+ <Dialog
+ open={removingCopy !== null}
+ title={`Remove the older ${removingCopy?.name ?? 'computer'}?`}
+ message={`It's an earlier identity of ${removingCopy?.name ?? 'a computer'} and can't be reached anymore. Removing it only cleans up your account.`}
+ actions={removingCopy ? [{ title: 'Remove', destructive: true, action: () => void cloud.removeFromAccount(removingCopy.computerId) }] : []}
+ onClose={() => setRemovingCopy(null)}
+ />
</div>
)
}
@@ -308,6 +308,31 @@ function ManagedComputerCard({ store, ssh: overSSH }: { store: BotStore; ssh: bo
)
}
+/** An account computer this app isn't authorized on, or one it uses under an earlier identity (`olderCopy`). */
+function AccountComputerRow({ computer, olderCopy, onRemove }: { computer: CloudComputer; olderCopy: boolean; onRemove: () => void }) {
+ return (
+ <div className="settings-card settings-appear">
+ <div className="settings-row">
+ <span className={olderCopy ? 'settings-off' : undefined}>
+ <ComputerBadge computer={{ id: computer.computerId, name: computer.name, signKey: computer.signKey, urls: [], device: computer.device ?? null }} size={22} />
+ </span>
+ <div className="settings-stack">
+ <Text size="callout" weight="medium" tone={olderCopy ? 'secondary' : undefined}>{computer.name}</Text>
+ <Text size="caption" tone={olderCopy ? 'tertiary' : 'secondary'}>{accountComputerStatus(computer, olderCopy)}</Text>
+ </div>
+ <Spacer />
+ {olderCopy ? <IconButton title="Remove from account" icon="trash" onClick={onRemove} /> : null}
+ </div>
+ </div>
+ )
+}
+
+/** "Older copy", not the phones' "Older copy of this computer": on the desktop "this computer" reads as this Mac. */
+function accountComputerStatus(computer: CloudComputer, olderCopy: boolean) {
+ if (!olderCopy) return computer.online ? 'Online' : 'Offline'
+ return computer.lastSeenAt ? `Older copy · last seen ${relativeDay(new Date(computer.lastSeenAt))}` : 'Older copy'
+}
+
function deviceDetail(device: AuthorizedDevice) {
const parts = [device.source === 'account' ? 'Approved through the account' : 'Paired with a QR code']
if (device.connected) parts.push('connected')
diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/AccountStore.swift b/apps/ios/Kit/Sources/CodyncUI/Store/AccountStore.swift
index 6ab101d2..ee67960e 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Store/AccountStore.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Store/AccountStore.swift
@@ -193,13 +193,19 @@ public final class AccountStore {
/// An offline account computer named like one this device uses or sees online: most likely the same
/// machine under an earlier identity (its host keys were reset), left behind in the account.
+ /// Seen after that one joined the account, it ran beside it: another machine with the same name.
public func isOlderCopy(_ computer: CloudComputer) -> Bool {
guard !computer.isOnline else { return false }
+ func replaced(by id: ComputerID) -> Bool {
+ guard let seen = computer.lastSeenAt,
+ let claimed = cloudComputers.first(where: { $0.computerId == id })?.claimedAt else { return true }
+ return seen <= claimed
+ }
// The current copy may be QR-paired without being listed in the account.
- return computers.contains { $0.id != computer.computerId && $0.name == computer.name }
+ return computers.contains { $0.id != computer.computerId && $0.name == computer.name && replaced(by: $0.id) }
|| cloudComputers.contains { other in
other.computerId != computer.computerId && other.name == computer.name
- && (stores[other.computerId] != nil || other.isOnline)
+ && (stores[other.computerId] != nil || other.isOnline) && replaced(by: other.computerId)
}
}
diff --git a/apps/ios/Kit/Tests/CodyncUITests/OlderCopyTests.swift b/apps/ios/Kit/Tests/CodyncUITests/OlderCopyTests.swift
new file mode 100644
index 00000000..66ca29f0
--- /dev/null
+++ b/apps/ios/Kit/Tests/CodyncUITests/OlderCopyTests.swift
@@ -0,0 +1,48 @@
+import Foundation
+import os
+import Testing
+@testable import CodyncKit
+@testable import CodyncUI
+
+/// The account lists an offline "Desk" last seen at 200 and an online "Desk" claimed at `claimedAt`.
+private final class OlderCopyCloudStub: URLProtocol {
+ static let claimedAt = OSAllocatedUnfairLock(initialState: 0)
+
+ override class func canInit(with request: URLRequest) -> Bool { true }
+ override class func canonicalRequest(for request: URLRequest) -> URLRequest { request }
+ override func stopLoading() {}
+
+ override func startLoading() {
+ let claimed = Self.claimedAt.withLock { $0 }
+ let json = request.url?.path.hasSuffix("/v1/computers") == true
+ ? #"{"computers":[{"computerId":"old","name":"Desk","signKey":"a","online":false,"lastSeenAt":200},"#
+ + #"{"computerId":"new","name":"Desk","signKey":"b","online":true,"claimedAt":\#(claimed)}]}"#
+ : "{}"
+ let response = HTTPURLResponse(url: request.url!, statusCode: 200, httpVersion: nil, headerFields: nil)!
+ client?.urlProtocol(self, didReceive: response, cacheStoragePolicy: .notAllowed)
+ client?.urlProtocol(self, didLoad: Data(json.utf8))
+ client?.urlProtocolDidFinishLoading(self)
+ }
+}
+
+/// A same-named offline computer is an older copy only if it was last seen before the online one
+/// joined the account; seen after, it ran beside it and is another machine.
+@MainActor @Test func olderCopyNeedsToBeLastSeenBeforeTheCurrentOneJoined() async throws {
+ let suite = "OlderCopy.\(UUID().uuidString)"
+ defer { UserDefaults(suiteName: suite)?.removePersistentDomain(forName: suite) }
+ let config = URLSessionConfiguration.ephemeral
+ config.protocolClasses = [OlderCopyCloudStub.self]
+ let cloud = CloudClient(baseURL: URL(string: "https://cloud.test")!, identity: DeviceIdentity(signing: .init(), push: .init()),
+ session: URLSession(configuration: config)) { "token" }
+ let accounts = AccountStore(storage: SharedStore.Context(accountID: "account", suite: suite), cloud: cloud)
+ defer { accounts.retire() }
+
+ OlderCopyCloudStub.claimedAt.withLock { $0 = 100 }
+ await accounts.refreshCloud()
+ let old = try #require(accounts.cloudComputers.first { $0.computerId == "old" })
+ #expect(!accounts.isOlderCopy(old))
+
+ OlderCopyCloudStub.claimedAt.withLock { $0 = 300 }
+ await accounts.refreshCloud()
+ #expect(accounts.isOlderCopy(old))
+}
diff --git a/docs/architecture/desktop-app.md b/docs/architecture/desktop-app.md
index c8696ad3..e44b321c 100644
--- a/docs/architecture/desktop-app.md
+++ b/docs/architecture/desktop-app.md
@@ -85,7 +85,8 @@ The TUI connects to one host at a time, so it keeps its single roster.
as an SMAppService agent; Linux starts its helper from the host, as before.
- **Other computers in the account** are reached through this computer's own host and SSH
tunnels only. The encrypted channel to account computers (`ChannelTransport`) wasn't ported:
- the product targets one computer, so "Ask for access" rows show status only.
+ the product targets one computer, so "Ask for access" rows show status only. An older copy of a
+ computer the app uses shows *Older copy · last seen …* with *Remove from account* (confirmed first).
- **Updates**: electron-updater reads the release GitHub marks latest, and only the release gate
(`tools/release-gate.py`) sets that mark
([holding releases](../reference/compatibility.md#holding-releases-for-the-app-store)).
diff --git a/docs/guides/accounts-and-ssh.md b/docs/guides/accounts-and-ssh.md
index 19be532a..33c6c89a 100644
--- a/docs/guides/accounts-and-ssh.md
+++ b/docs/guides/accounts-and-ssh.md
@@ -95,9 +95,10 @@ The desktop app's menu bar **Settings → Reset all data…** (confirmed in the
the computer's start over: it removes this computer from the account, revokes every
paired device, signs out, uninstalls the host, deletes its data folder and the app's
settings, and relaunches into the welcome screen. The host comes back with a new
-identity, so phones see the old computer as **No access** (if they were connected)
-or as an older copy once the new one is reachable, and offer to remove it; pair
-again or ask for access to reach the new one.
+identity, so phones see the old computer as **No access** (if they were connected),
+and phones and the desktop app see it as an older copy once the new one is reachable
+(offline, named like a computer they use or see online, and last seen before that one
+joined the account) and offer to remove it; pair again or ask for access to reach the new one.
On the computer, open Codync in the menu bar and choose **Pair iPhone…**, then scan the
code on the phone (or paste its `codync://pair` link). The host approves the phone's
@@ -184,7 +185,9 @@ A simulator build verifies compilation, not the Dashboard settings or OAuth flow
The desktop app attaches this computer's host and its SSH computers over loopback; they
follow into whichever account is active. The account's other computers are not reached
directly (the encrypted channel wasn't ported to the desktop app), so their
-"Ask for access" rows show status only. See [desktop app](../architecture/desktop-app.md).
+"Ask for access" rows show status only. An older copy of a computer the app uses shows
+*Older copy · last seen …* with *Remove from account* (`DELETE /v1/computers/{id}`, confirmed
+first). See [desktop app](../architecture/desktop-app.md).
**Computers & devices** (Settings) shows, for this computer and each SSH computer:
*Reach from anywhere* (`setCloud`, on/off; the host's build decides which cloud),