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): name the devices that lose access when a computer leaves its account

leepokai8a2f77d39bf3
diff --git a/apps/desktop/src/renderer/lib/account-copy.test.ts b/apps/desktop/src/renderer/lib/account-copy.test.ts
index 264f6212..daba1615 100644
--- a/apps/desktop/src/renderer/lib/account-copy.test.ts
+++ b/apps/desktop/src/renderer/lib/account-copy.test.ts
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict'
import { test } from 'node:test'
-import { devicesLoseAccess, joinRemovesText, pairingAnswers, pairingAskText, spacedCode, withJoinRemoves } from './account-copy.ts'
+import { devicesLoseAccess, joinRemovesText, leavingRemovesText, pairingAnswers, pairingAskText, spacedCode, withJoinRemoves } from './account-copy.ts'
const tr = (text: string) => text
@@ -60,6 +60,12 @@ test('changing account drops every device of the old one', () => {
assert.equal(devicesLoseAccess(tr, null), 'Every device of that account loses access.')
})
+test('leaving an account names the devices it drops, when the computer could list them', () => {
+ assert.equal(leavingRemovesText(tr, '[email protected]', ['Pixel', 'iPad']), 'These phones lose access and must pair again: Pixel, iPad.')
+ assert.equal(leavingRemovesText(tr, '[email protected]', []), "Every device of [email protected]'s account loses access.")
+ assert.equal(leavingRemovesText(tr, null, null), 'Every device of that account loses access.')
+})
+
test('codes other than 6 digits stay as they are', () => {
assert.equal(spacedCode('12345'), '12345')
})
diff --git a/apps/desktop/src/renderer/lib/account-copy.ts b/apps/desktop/src/renderer/lib/account-copy.ts
index 46482d2d..baf88b00 100644
--- a/apps/desktop/src/renderer/lib/account-copy.ts
+++ b/apps/desktop/src/renderer/lib/account-copy.ts
@@ -46,6 +46,11 @@ export function pairingAnswers(request: Pick<PairingRequest, 'canJoin' | 'phoneO
return [...stayOut, { title: 'Add to account', join: true }]
}
+/** A computer leaving its account drops every device it has: by name when the computer could list them. */
+export function leavingRemovesText(tr: Tr, email: string | null | undefined, names: readonly string[] | null | undefined) {
+ return joinRemovesText(tr, names) || devicesLoseAccess(tr, email)
+}
+
/** A computer that changes its account drops every device of the old one, QR-paired ones included. */
export function devicesLoseAccess(tr: Tr, email: string | null | undefined) {
return email ? fill(tr("Every device of {email}'s account loses access."), { email }) : tr('Every device of that account loses access.')
diff --git a/apps/desktop/src/renderer/store/cloud.ts b/apps/desktop/src/renderer/store/cloud.ts
index e64c0ab4..75c3b489 100644
--- a/apps/desktop/src/renderer/store/cloud.ts
+++ b/apps/desktop/src/renderer/store/cloud.ts
@@ -242,7 +242,7 @@ export class CloudModel extends Observable {
}
/** The phones `store`'s computer would remove by joining the signed-in account. A host before this method removes the same phones and can't name them. */
- async joinWouldRemove(store: BotStore): Promise<string[]> {
+ joinWouldRemove = async (store: BotStore): Promise<string[]> => {
const userId = this.userId
if (!userId) return []
try {
@@ -253,6 +253,16 @@ export class CloudModel extends Observable {
}
}
+ /** The devices on `store`'s computer, which all go when it leaves its account. Empty when it can't say: the warning then stays general. */
+ deviceNames = async (store: BotStore): Promise<string[]> => {
+ try {
+ return (await (await store.ready()).call<{ devices: { name: string }[] }>('devices')).devices.map((device) => device.name)
+ } catch (error) {
+ this.fail(error, true)
+ return []
+ }
+ }
+
/** No to `joinOffer`: phones reach it only over Wi-Fi or Tailscale, and it isn't offered again (Add to account still adds it). */
declineJoin(store: BotStore) {
const user = this.userId
diff --git a/apps/desktop/src/renderer/views/MoveComputerPrompt.tsx b/apps/desktop/src/renderer/views/MoveComputerPrompt.tsx
index 625bc999..b021b68f 100644
--- a/apps/desktop/src/renderer/views/MoveComputerPrompt.tsx
+++ b/apps/desktop/src/renderer/views/MoveComputerPrompt.tsx
@@ -1,9 +1,10 @@
import { Dialog } from '../components/Overlay'
-import { devicesLoseAccess } from '../lib/account-copy'
+import { leavingRemovesText } from '../lib/account-copy'
import { useModel } from '../lib/observable'
import { useTr } from '../lib/use-language'
import { useAccount } from '../store/account'
import { useApp } from '../store/context'
+import { useLeaveRemoves } from './use-join-removes'
/** Signed in here with another account than the one this computer is in: move it over, or keep it there (`moveOffer`). */
export function MoveComputerPrompt() {
@@ -13,12 +14,13 @@ export function MoveComputerPrompt() {
useModel(app.cloud)
useModel(app.local)
const offer = app.cloud.moveOffer
+ const names = useLeaveRemoves(offer?.store ?? null, offer !== null)
const where = offer?.from ? tr("It's in {name}'s account.").replaceAll('{name}', offer.from) : tr("It's in another account.")
return (
<Dialog
open={offer !== null}
title={tr('Move this computer to your account?')}
- message={`${where} ${devicesLoseAccess(tr, offer?.from)} ${tr('New devices ask for access with a 6-digit code.')}`}
+ message={`${where} ${leavingRemovesText(tr, offer?.from, names)} ${tr('New devices ask for access with a 6-digit code.')}`}
// A choice either way: "keep it there" is remembered, so it isn't a dismissal.
cancel={null}
actions={offer ? [
diff --git a/apps/desktop/src/renderer/views/settings/ComputersView.tsx b/apps/desktop/src/renderer/views/settings/ComputersView.tsx
index 40907063..81d4802d 100644
--- a/apps/desktop/src/renderer/views/settings/ComputersView.tsx
+++ b/apps/desktop/src/renderer/views/settings/ComputersView.tsx
@@ -16,8 +16,8 @@ import { ComputerBadge } from '../ComputerBadge'
import { PairingCode } from '../PairingCode'
import { AuthorizedDevicesSection } from './AuthorizedDevicesSection'
import { ComputersUsedSection } from './ComputersUsedSection'
-import { devicesLoseAccess, withJoinRemoves } from '../../lib/account-copy'
-import { useJoinRemoves } from '../use-join-removes'
+import { leavingRemovesText, withJoinRemoves } from '../../lib/account-copy'
+import { useJoinRemoves, useLeaveRemoves } from '../use-join-removes'
import { cloudStatusLine } from '../../lib/relay-copy'
import { useTr } from '../../lib/use-language'
import { errorText, liveClient, relativeDay, SectionHeader, statusText, thisMac } from './parts'
@@ -41,6 +41,8 @@ export function ComputersView() {
const [removing, setRemoving] = useState<CloudComputer | null>(null)
const removingOlder = removing !== null && cloud.isOlderCopy(removing)
const managed = app.managedStores
+ // A computer this app reaches (an SSH one) can name what goes; any other gets the general warning.
+ const removingNames = useLeaveRemoves(managed.find((store) => store.computer.id === removing?.computerId) ?? null, removing !== null)
// Every computer in the account but this one, the SSH computers too: their cards above are about managing them.
const others = cloud.computers.filter((c) => c.computerId !== app.local?.computer.id)
const addSSH = (host: string) => setEditing({ profile: { ...newSSHProfile(window.codync.hostPort), host }, isNew: true })
@@ -95,7 +97,7 @@ export function ComputersView() {
message={removingOlder
? tr("It's an earlier identity of {name} and can't be reached anymore. Removing it only cleans up your account.").replaceAll('{name}', removing.name)
// Offline may only mean asleep: removal unclaims it, and its own app won't add it back by itself.
- : `${devicesLoseAccess(tr, account.user?.email)} ${tr('Access comes back only when you add {name} to the account again on {name} itself.').replaceAll('{name}', () => removing?.name ?? tr('a computer'))}`}
+ : `${leavingRemovesText(tr, account.user?.email, removingNames)} ${tr('Access comes back only when you add {name} to the account again on {name} itself.').replaceAll('{name}', () => removing?.name ?? tr('a computer'))}`}
actions={removing ? [{ title: 'Remove', destructive: true, action: () => void cloud.removeFromAccount(removing.computerId) }] : []}
onClose={() => setRemoving(null)}
/>
@@ -143,6 +145,7 @@ function ManagedComputerCard({ store, ssh: overSSH, nested = false }: { store: B
// account to add it to, and it stays in none; a saved session still restoring makes the switch wait.
const asksAccount = cloud?.joinsAccountOnEnable === true
const joinRemoves = useJoinRemoves(store, askAccount)
+ const leaveRemoves = useLeaveRemoves(store, confirmUnclaim)
const setReach = (on: boolean) => {
if (on && asksAccount && account.isSignedIn) setAskAccount(true)
else void run(() => app.cloud.setCloud(store, on))
@@ -295,7 +298,7 @@ function ManagedComputerCard({ store, ssh: overSSH, nested = false }: { store: B
<Dialog
open={confirmUnclaim}
title={tr('Remove {name} from the account?').replaceAll('{name}', name)}
- message={devicesLoseAccess(tr, owner?.email)}
+ message={leavingRemovesText(tr, owner?.email, leaveRemoves)}
actions={[{ title: 'Remove from account', destructive: true, action: () => run(() => app.cloud.unclaim(store)) }]}
onClose={() => setConfirmUnclaim(false)}
/>
diff --git a/apps/desktop/src/renderer/views/use-join-removes.ts b/apps/desktop/src/renderer/views/use-join-removes.ts
index 35529443..c9b0d94b 100644
--- a/apps/desktop/src/renderer/views/use-join-removes.ts
+++ b/apps/desktop/src/renderer/views/use-join-removes.ts
@@ -2,17 +2,28 @@ import { useEffect, useState } from 'react'
import type { BotStore } from '../store/bot-store'
import { useApp } from '../store/context'
-/** The names of the phones `store`'s computer would remove by joining the signed-in account, while `open`. */
-export function useJoinRemoves(store: BotStore | null, open: boolean) {
- const app = useApp()
+/** What `load` answers about `store`, while `open`. */
+function useNames(load: (store: BotStore) => Promise<string[]>, store: BotStore | null, open: boolean) {
const [names, setNames] = useState<string[]>([])
useEffect(() => {
if (!open || !store) return setNames([])
let current = true
- void app.cloud.joinWouldRemove(store).then((removed) => current && setNames(removed))
+ void load(store).then((found) => current && setNames(found))
return () => {
current = false
}
- }, [app, store, open])
+ }, [load, store, open])
return names
}
+
+/** The names of the phones `store`'s computer would remove by joining the signed-in account, while `open`. */
+export function useJoinRemoves(store: BotStore | null, open: boolean) {
+ const { cloud } = useApp()
+ return useNames(cloud.joinWouldRemove, store, open)
+}
+
+/** The names of the devices `store`'s computer would drop by leaving its account, while `open`. */
+export function useLeaveRemoves(store: BotStore | null, open: boolean) {
+ const { cloud } = useApp()
+ return useNames(cloud.deviceNames, store, open)
+}
diff --git a/web/content/docs/remote-access.mdx b/web/content/docs/remote-access.mdx
index b7272322..870095e8 100644
--- a/web/content/docs/remote-access.mdx
+++ b/web/content/docs/remote-access.mdx
@@ -46,7 +46,7 @@ Answer in the desktop app's dialog, in the terminal UI (`y` adds to the account
**Adding a computer later:** on a signed-in phone connected to a computer in no account, tap **Add to account** on its card in **Manage computers**. The computer asks the same way and shows the code, in the desktop app or the terminal UI; on a server, run `codync-host access approve <code>`. If the computer doesn't answer, it stays out of the account and the phone keeps connecting over Wi-Fi or Tailscale.
-Changing the account a computer belongs to (moving it, or **Remove from account**) takes away access from every device of the old account. A computer joining its first account warns first, and removes phones with no account or of another account: they pair again, signed in to that account. Phones paired before version 2.36 stay.
+Changing the account a computer belongs to (moving it, or **Remove from account**) takes away access from every device of the old account; the confirmation names them. A computer joining its first account warns first, and removes phones with no account or of another account: they pair again, signed in to that account. Phones paired before version 2.36 stay.
## Signing in