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(desktop): offer to move this computer when signing in with another account

leepokaiee0276ae57e2
diff --git a/apps/desktop/src/renderer/lib/auto-claim.test.ts b/apps/desktop/src/renderer/lib/auto-claim.test.ts
index 53ab1559..cfd6eda7 100644
--- a/apps/desktop/src/renderer/lib/auto-claim.test.ts
+++ b/apps/desktop/src/renderer/lib/auto-claim.test.ts
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict'
import { test } from 'node:test'
-import { mayAutoClaim } from './auto-claim.ts'
+import { mayAutoClaim, mayOfferMove } from './auto-claim.ts'
const host = { id: 'new', online: true, cloud: { enabled: true, owner: null } }
@@ -24,3 +24,13 @@ test('a computer on a private relay never joins: it has no accounts', () => {
assert.equal(mayAutoClaim({ ...host, cloud: { enabled: true, owner: null, relay: 'private' } }, [], []), false)
assert.equal(mayAutoClaim({ ...host, cloud: { enabled: true, owner: null, relay: 'codync' } }, [], []), true)
})
+
+test('a computer in another account offers to move into the signed-in one', () => {
+ const owned = (userId: string) => ({ ...host, cloud: { enabled: true, owner: { userId } } })
+ assert.equal(mayOfferMove(owned('a'), 'b', []), true)
+ assert.equal(mayOfferMove(owned('b'), 'b', []), false, 'already in this account')
+ assert.equal(mayOfferMove(host, 'b', []), false, 'in no account: auto-claim covers it')
+ assert.equal(mayOfferMove(owned('a'), 'b', ['new']), false, 'the user said no')
+ assert.equal(mayOfferMove({ ...owned('a'), online: false }, 'b', []), false)
+ assert.equal(mayOfferMove({ ...host, cloud: { enabled: true, owner: { userId: 'a' }, relay: 'private' } }, 'b', []), false)
+})
diff --git a/apps/desktop/src/renderer/lib/auto-claim.ts b/apps/desktop/src/renderer/lib/auto-claim.ts
index 6f7d63d7..d6674713 100644
--- a/apps/desktop/src/renderer/lib/auto-claim.ts
+++ b/apps/desktop/src/renderer/lib/auto-claim.ts
@@ -1,18 +1,35 @@
+import type { CloudStatus } from '@shared/models'
+
/** What the auto-claim rule reads of this computer's host. */
export interface ClaimCandidate {
id: string
online: boolean
- cloud: { enabled: boolean; owner?: unknown; relay?: string | null } | null
+ cloud: Pick<CloudStatus, 'enabled' | 'owner' | 'relay'> | null
}
/**
- * Whether this computer joins the signed-in account on its own. Only with the Codync cloud on: joining
+ * Whether this computer can join the signed-in account here at all. Only with the Codync cloud on: joining
* needs it (a private relay has no accounts), and turning it back on is never done silently. Never an
- * identity the user took out here (`keptOut`), nor one this app has seen in the account (`seen`): without
- * an owner now, it was removed, maybe from a phone, and stays out until it's added by hand. A new
- * identity (a host reset) joins.
+ * identity the user took out here (`keptOut`).
+ */
+function joinable(host: ClaimCandidate, keptOut: readonly string[]) {
+ return host.online && !!host.cloud?.enabled && host.cloud.relay !== 'private' && !keptOut.includes(host.id)
+}
+
+/**
+ * Whether this computer joins the signed-in account on its own (`joinable`). Never an identity this app
+ * has seen in the account (`seen`): without an owner now, it was removed, maybe from a phone, and stays
+ * out until it's added by hand. A new identity (a host reset) joins.
*/
export function mayAutoClaim(host: ClaimCandidate, keptOut: readonly string[], seen: readonly string[]) {
- const cloud = host.cloud
- return host.online && !!cloud?.enabled && cloud.relay !== 'private' && !cloud.owner && !keptOut.includes(host.id) && !seen.includes(host.id)
+ return joinable(host, keptOut) && !host.cloud?.owner && !seen.includes(host.id)
+}
+
+/**
+ * Whether to ask to move this computer into the signed-in account: it's in another one, and signing in
+ * here with a different account means it goes with that one now. Saying no keeps it out (`keptOut`).
+ */
+export function mayOfferMove(host: ClaimCandidate, userId: string, keptOut: readonly string[]) {
+ const owner = host.cloud?.owner
+ return joinable(host, keptOut) && !!owner && owner.userId !== userId
}
diff --git a/apps/desktop/src/renderer/store/cloud.ts b/apps/desktop/src/renderer/store/cloud.ts
index 602bbf16..44e1c537 100644
--- a/apps/desktop/src/renderer/store/cloud.ts
+++ b/apps/desktop/src/renderer/store/cloud.ts
@@ -1,5 +1,5 @@
import type { CloudStatus, ClaimSignature } from '@shared/models'
-import { mayAutoClaim } from '../lib/auto-claim'
+import { mayAutoClaim, mayOfferMove, type ClaimCandidate } from '../lib/auto-claim'
import { Observable } from '../lib/observable'
import { isOlderCopy } from '../lib/older-copy'
import { relayAddressToSave } from '../lib/relay-address'
@@ -93,6 +93,8 @@ export class CloudModel extends Observable {
private listing: Promise<boolean> = Promise.resolve(false)
private enablingCloud = false
private autoClaiming = false
+ /** This computer is on its way from another account into this one (`moveHere`). */
+ private moving = false
constructor(private app: AppModel) {
super()
@@ -213,9 +215,42 @@ export class CloudModel extends Observable {
private get autoClaimTarget(): BotStore | null {
const user = this.userId
const store = this.app.local
- if (!user || !store) return null
- const host = { id: store.computer.id, online: store.connection.kind === 'online', cloud: store.cloud }
- return mayAutoClaim(host, keptOut(user).get(), claimedIds(user).get()) ? store : null
+ if (!user || !store || this.moving) return null
+ return mayAutoClaim(candidate(store), keptOut(user).get(), claimedIds(user).get()) ? store : null
+ }
+
+ /** This computer, still in another account than the one signed in here: the user is asked to move it (`mayOfferMove`). */
+ get moveOffer(): { store: BotStore; from: string | null } | null {
+ const user = this.userId
+ const store = this.app.local
+ if (!user || !store || this.moving || !mayOfferMove(candidate(store), user, keptOut(user).get())) return null
+ return { store, from: store.cloud?.owner?.email ?? null }
+ }
+
+ /** No to `moveOffer`: this computer stays in its account and isn't offered again (Remove, then Add to account, still moves it). */
+ keepInOtherAccount(store: BotStore) {
+ const user = this.userId
+ if (user) include(keptOut(user), store.computer.id)
+ this.changed()
+ }
+
+ /**
+ * Yes to `moveOffer`: out of the other account, then into this one. Devices that account approved lose
+ * access; out of an account the host turns the 6-digit check back on, so the new account's devices show
+ * a code before getting in.
+ */
+ async moveHere(store: BotStore) {
+ this.moving = true
+ this.changed()
+ try {
+ await (await store.ready()).call('unclaim', {}, 30_000)
+ await this.claim(store)
+ } catch (error) {
+ this.fail(error)
+ } finally {
+ this.moving = false
+ this.changed()
+ }
}
/** §4.2 A: makes a computer this app manages part of the account; its cloud is turned on first. */
@@ -332,6 +367,11 @@ export class CloudModel extends Observable {
}
}
+/** What the account rules (`auto-claim`) read of a computer's host. */
+function candidate(store: BotStore): ClaimCandidate {
+ return { id: store.computer.id, online: store.connection.kind === 'online', cloud: store.cloud }
+}
+
/** This computer's name for the account's device list. */
async function deviceName() {
return window.codync.computerName || { darwin: 'Mac', linux: 'Linux', win32: 'Windows' }[window.codync.platform]
diff --git a/apps/desktop/src/renderer/views/ChatWindow.tsx b/apps/desktop/src/renderer/views/ChatWindow.tsx
index 177883ca..2bc74b11 100644
--- a/apps/desktop/src/renderer/views/ChatWindow.tsx
+++ b/apps/desktop/src/renderer/views/ChatWindow.tsx
@@ -37,6 +37,7 @@ import { StartupRecovery } from './StartupRecovery'
export { EmptyState } from './HostStateView'
import { RefreshIndicator } from './RefreshIndicator'
import { StarPrompt } from './StarPrompt'
+import { MoveComputerPrompt } from './MoveComputerPrompt'
import { OpenVoiceSettings } from './call/CallView'
import { AccountPanelLayer, ProfileAvatar } from './PanelMenus'
import { DesktopActionMenu, type ActionItem } from './DesktopActionMenu'
@@ -140,7 +141,7 @@ export function ChatWindow() {
/>
)}
{onboarded && accessSetup !== null && showsChat ? null : <div className="window-drag drag" />}
- {onboarded && accessSetup !== null ? <StarPrompt /> : null}
+ {onboarded && accessSetup !== null ? <><StarPrompt /><MoveComputerPrompt /></> : null}
<Sheet open={showAccess} onClose={() => setShowAccess(false)} width={660} height={Math.min(820, window.innerHeight - 80)}>
<ModalHeader icon="hand.raised" title={tr(`Computer access`)} />
<ComputerAccessView onContinue={(ready) => { finishAccess(ready, false); setShowAccess(false) }} />
diff --git a/apps/desktop/src/renderer/views/MoveComputerPrompt.tsx b/apps/desktop/src/renderer/views/MoveComputerPrompt.tsx
new file mode 100644
index 00000000..33af442f
--- /dev/null
+++ b/apps/desktop/src/renderer/views/MoveComputerPrompt.tsx
@@ -0,0 +1,30 @@
+import { Dialog } from '../components/Overlay'
+import { useModel } from '../lib/observable'
+import { useTr } from '../lib/use-language'
+import { useAccount } from '../store/account'
+import { useApp } from '../store/context'
+
+/** Signed in here with another account than the one this computer is in: move it over, or keep it there (`moveOffer`). */
+export function MoveComputerPrompt() {
+ const tr = useTr()
+ const app = useApp()
+ useAccount()
+ useModel(app.cloud)
+ useModel(app.local)
+ const offer = app.cloud.moveOffer
+ 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} ${tr('Devices that were approved through the account lose access. Devices paired with a QR code keep it.')} ${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 ? [
+ { title: 'Keep it there', action: () => app.cloud.keepInOtherAccount(offer.store) },
+ { title: 'Move here', action: () => void app.cloud.moveHere(offer.store) },
+ ] : []}
+ onClose={() => {}}
+ />
+ )
+}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
index 1bcdc48b..3e6e0486 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
@@ -1473,5 +1473,11 @@
"routines": "Routinen",
"memories": "Erinnerungen",
"workspace files": "Arbeitsbereich-Dateien",
- "Rate on Google Play": "Bei Google Play bewerten"
+ "Rate on Google Play": "Bei Google Play bewerten",
+ "Move this computer to your account?": "Diesen Computer in dein Konto verschieben?",
+ "It's in {name}'s account.": "Er ist im Konto von {name}.",
+ "It's in another account.": "Er ist in einem anderen Konto.",
+ "New devices ask for access with a 6-digit code.": "Neue Geräte fragen mit einem 6-stelligen Code nach Zugriff.",
+ "Keep it there": "Dort lassen",
+ "Move here": "Hierher verschieben"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
index d9d2351b..4ad8bfe2 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
@@ -1473,5 +1473,11 @@
"routines": "rutinas",
"memories": "recuerdos",
"workspace files": "archivos del espacio de trabajo",
- "Rate on Google Play": "Valorar en Google Play"
+ "Rate on Google Play": "Valorar en Google Play",
+ "Move this computer to your account?": "¿Mover esta computadora a tu cuenta?",
+ "It's in {name}'s account.": "Está en la cuenta de {name}.",
+ "It's in another account.": "Está en otra cuenta.",
+ "New devices ask for access with a 6-digit code.": "Los dispositivos nuevos piden acceso con un código de 6 dígitos.",
+ "Keep it there": "Dejarla ahí",
+ "Move here": "Mover aquí"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
index c5c10b3d..8d40baac 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
@@ -1473,5 +1473,11 @@
"routines": "routines",
"memories": "souvenirs",
"workspace files": "fichiers de l’espace de travail",
- "Rate on Google Play": "Noter sur Google Play"
+ "Rate on Google Play": "Noter sur Google Play",
+ "Move this computer to your account?": "Déplacer cet ordinateur vers votre compte ?",
+ "It's in {name}'s account.": "Il est dans le compte de {name}.",
+ "It's in another account.": "Il est dans un autre compte.",
+ "New devices ask for access with a 6-digit code.": "Les nouveaux appareils demandent l'accès avec un code à 6 chiffres.",
+ "Keep it there": "Le laisser là",
+ "Move here": "Déplacer ici"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
index ea0a5e87..5adef211 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
@@ -1473,5 +1473,11 @@
"routines": "ルーティン",
"memories": "メモリ",
"workspace files": "ワークスペースのファイル",
- "Rate on Google Play": "Google Play で評価"
+ "Rate on Google Play": "Google Play で評価",
+ "Move this computer to your account?": "このコンピュータをあなたのアカウントに移動しますか?",
+ "It's in {name}'s account.": "{name}のアカウントに入っています。",
+ "It's in another account.": "別のアカウントに入っています。",
+ "New devices ask for access with a 6-digit code.": "新しいデバイスは6桁のコードでアクセスをリクエストします。",
+ "Keep it there": "そのままにする",
+ "Move here": "ここに移動"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
index 2d7d0527..d23f5b25 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
@@ -1473,5 +1473,11 @@
"routines": "루틴",
"memories": "기억",
"workspace files": "작업 공간 파일",
- "Rate on Google Play": "Google Play에서 평가하기"
+ "Rate on Google Play": "Google Play에서 평가하기",
+ "Move this computer to your account?": "이 컴퓨터를 내 계정으로 옮길까요?",
+ "It's in {name}'s account.": "{name} 계정에 있습니다.",
+ "It's in another account.": "다른 계정에 있습니다.",
+ "New devices ask for access with a 6-digit code.": "새 기기는 6자리 코드로 접근을 요청합니다.",
+ "Keep it there": "그대로 두기",
+ "Move here": "여기로 옮기기"
}
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 18bc4531..4134a885 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
@@ -1473,5 +1473,11 @@
"routines": "个例行任务",
"memories": "条记忆",
"workspace files": "工作区文件",
- "Rate on Google Play": "在 Google Play 评分"
+ "Rate on Google Play": "在 Google Play 评分",
+ "Move this computer to your account?": "要把这台电脑移到你的账户吗?",
+ "It's in {name}'s account.": "它在 {name} 的账户里。",
+ "It's in another account.": "它在另一个账户里。",
+ "New devices ask for access with a 6-digit code.": "新设备要用 6 位验证码请求访问。",
+ "Keep it there": "留在原处",
+ "Move here": "移到这里"
}
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 88fece85..6edae300 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
@@ -1473,5 +1473,11 @@
"routines": "個例行任務",
"memories": "則記憶",
"workspace files": "工作區檔案",
- "Rate on Google Play": "在 Google Play 評分"
+ "Rate on Google Play": "在 Google Play 評分",
+ "Move this computer to your account?": "要把這臺電腦移到你的賬戶嗎?",
+ "It's in {name}'s account.": "它在 {name} 的賬戶裡。",
+ "It's in another account.": "它在另一個賬戶裡。",
+ "New devices ask for access with a 6-digit code.": "新裝置要用 6 位驗證碼請求訪問。",
+ "Keep it there": "留在原處",
+ "Move here": "移到這裡"
}
diff --git a/docs/guides/accounts-and-ssh.md b/docs/guides/accounts-and-ssh.md
index 2d5bd78f..65d7a135 100644
--- a/docs/guides/accounts-and-ssh.md
+++ b/docs/guides/accounts-and-ssh.md
@@ -222,7 +222,12 @@ and auto-claim never runs), *Add to account* (claim: `POST /v1/claims` → loopb
*Remove from account* (`unclaim`), a pairing QR, and, for this computer only, the computers it can use (its SSH computers, each with its own settings) and the devices that can use it, with revoke.
Signed in, this computer joins the account on its own once per host identity; an identity
that was already in the account and was removed (here or from a phone) is never re-added
-silently, only through *Add to account*. The section below, *Other computers in your account*,
+silently, only through *Add to account*. Signed in with a different account than the one this
+computer is in, the app asks once to move it (`mayOfferMove`): *Move here* leaves the old account
+(`unclaim`, which revokes that account's grants) and claims it for this one; *Keep it there* is
+remembered for this account (`keptOutOfAccount`). Out of an account, by any path, the host turns
+cloud assistants off and the 6-digit check back on (`cloud::pull`). Signing out never removes
+the computer from its account. The section below, *Other computers in your account*,
lists only the account's other computers. A device asking for access raises the menu bar dot
and opens the approval sheet with the 6-digit code; Approve stays disabled until the device
revealed its code.
diff --git a/host/src/remote/cloud.rs b/host/src/remote/cloud.rs
index f4042538..d31d3f97 100644
--- a/host/src/remote/cloud.rs
+++ b/host/src/remote/cloud.rs
@@ -338,10 +338,14 @@ pub async fn pull(hub: &Hub, base: &str) -> Result<()> {
s.owner = state.owner;
s.last_error = None;
});
- // Out of an account, cloud assistants go off: the account this computer joins next is asked again.
+ // Out of an account, cloud assistants go off and the 6-digit check comes back on: the account
+ // this computer joins next is asked again.
if !in_account && assistant::enabled(&hub.store) {
assistant::set_enabled(hub, false)?;
}
+ if !in_account && approval(&hub.store) == Approval::Auto {
+ set_approval(hub, Approval::Code)?;
+ }
sync_requests(hub, base, state.requests).await;
if approval(&hub.store) == Approval::Auto {
// The SAS exchange still runs (the device's commit must match); only the user's comparison is skipped.
@@ -768,7 +772,7 @@ mod tests {
set_approval(&hub, Approval::Auto).unwrap();
let (dk, nd): ([u8; 32], [u8; 32]) = (crypto::random(), crypto::random());
let request = |host_nonce: Option<String>, device_nonce: Option<[u8; 32]>| {
- json!({"owner": null, "grants": [], "requests": [{"requestId": "req_1", "deviceKey": b64(&dk),
+ json!({"owner": {"userId": "user_1"}, "grants": [], "requests": [{"requestId": "req_1", "deviceKey": b64(&dk),
"commit": b64(&crypto::sas_commit(&dk, &nd)), "hostNonce": host_nonce,
"deviceNonce": device_nonce.map(|n| b64(&n))}]})
};
@@ -793,16 +797,19 @@ mod tests {
}
#[tokio::test]
- async fn leaving_the_account_turns_cloud_assistants_off() {
+ async fn leaving_the_account_turns_cloud_assistants_off_and_the_check_on() {
let hub = temp_hub();
let fake = Arc::new(FakeCloud::default());
let base = fake_cloud(fake.clone()).await;
*fake.state.lock().unwrap() = json!({"owner": {"userId": "user_1"}, "grants": [], "requests": []});
pull(&hub, &base).await.unwrap();
assistant::set_enabled(&hub, true).unwrap();
+ set_approval(&hub, Approval::Auto).unwrap();
*fake.state.lock().unwrap() = json!({"owner": null, "grants": [], "requests": []});
pull(&hub, &base).await.unwrap();
assert!(!assistant::enabled(&hub.store) && !hub.cloud.status().assistants, "the next account is asked again");
+ assert_eq!(hub.cloud.status().approval, Approval::Code, "the next account's devices show a code");
+ assert_eq!(approval(&hub.store), Approval::Code);
}
#[tokio::test]
diff --git a/web/content/docs/remote-access.mdx b/web/content/docs/remote-access.mdx
index 3813e6eb..b1ed1e1e 100644
--- a/web/content/docs/remote-access.mdx
+++ b/web/content/docs/remote-access.mdx
@@ -40,7 +40,9 @@ You can sign in with Apple or Google on the iPhone and in the desktop app. Signi
On a computer without the desktop app, use `codync-host access` to list requests and `codync-host access approve <code>` to approve one.
-Comparing the code is what stops anyone who controls the Codync cloud from slipping in their own device. In **Settings → Computers**, **Skip the 6-digit check** lets devices signed in to your account in without it. Leave it off unless you accept the risk the app warns about: anyone who gets into your account, or anyone who compromises Codync's cloud, could then add a device with full control of the computer. Devices paired with a QR code aren't affected by this setting.
+Signing out of the desktop app keeps the computer in your account. If you then sign in with a different account, the app asks whether to move the computer there. Choose **Move here** and your phone, signed in to the new account, finds it under **Manage computers**. Devices approved through the old account lose access. Moving it turns **Skip the 6-digit check** off, so new devices ask with the 6-digit code; turn it back on in **Settings → Computers** if you want. Choose **Keep it there** to leave it where it is; you can still move it later with **Remove from account** and then **Add to account**.
+
+Comparing the code is what stops anyone who controls the Codync cloud from slipping in their own device. In **Settings → Computers**, **Skip the 6-digit check** lets devices signed in to your account in without it. Leave it off unless you accept the risk the app warns about: anyone who gets into your account, or anyone who compromises Codync's cloud, could then add a device with full control of the computer. It turns off whenever the computer leaves your account. Devices paired with a QR code aren't affected by this setting.
Devices approved through your account only work while the computer stays in touch with the Codync cloud. Devices paired with a QR code don't depend on it.