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): match the Mac app's reset and update gate

leepokai6b1ed6835ba5
diff --git a/apps/desktop/src/main/host-controller.ts b/apps/desktop/src/main/host-controller.ts
index 412178d2..27a72719 100644
--- a/apps/desktop/src/main/host-controller.ts
+++ b/apps/desktop/src/main/host-controller.ts
@@ -140,6 +140,20 @@ export class HostController extends EventEmitter {
void this.install()
}
+ /** One loopback API call from the main process; throws when the host isn't running. */
+ async call<T>(method: string, params: object = {}, timeoutMs = 5000): Promise<T> {
+ const local = this.local
+ if (!local) throw new Error('The host isn’t running')
+ const res = await fetch(`${local.baseURL}/api/${method}`, {
+ method: 'POST',
+ headers: { Authorization: `Bearer ${local.token}`, 'Content-Type': 'application/json' },
+ body: JSON.stringify(params),
+ signal: AbortSignal.timeout(timeoutMs),
+ })
+ if (!res.ok) throw new Error(`${method}: HTTP ${res.status}`)
+ return (await res.json()) as T
+ }
+
async uninstall() {
const bin = this.binary
if (!bin) return
diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts
index cb6f30cd..d9d402e3 100644
--- a/apps/desktop/src/main/index.ts
+++ b/apps/desktop/src/main/index.ts
@@ -170,6 +170,11 @@ function registerIPC(tray: Tray) {
return app.getLoginItemSettings().openAtLogin
})
ipcMain.handle('app:resetAllData', async () => {
+ // Tell paired devices first: connected ones see "No access" at once, and the account drops
+ // this computer instead of keeping an unreachable older copy of it.
+ await host.call('unclaim', {}, 30_000).catch(() => {})
+ const devices = await host.call<{ devices: { key: string }[] }>('devices').catch(() => ({ devices: [] }))
+ for (const device of devices.devices) await host.call('revokeDevice', { key: device.key }).catch(() => {})
await account.signOutAll()
await host.uninstall()
const { rm } = await import('node:fs/promises')
diff --git a/apps/desktop/src/main/updates.ts b/apps/desktop/src/main/updates.ts
index bafb9bab..d817d494 100644
--- a/apps/desktop/src/main/updates.ts
+++ b/apps/desktop/src/main/updates.ts
@@ -112,7 +112,8 @@ export class Updates extends EventEmitter {
/**
* A release that needs a newer iPhone app than the App Store has (still in review) waits,
- * so paired iPhones aren't asked for an update they can't get yet.
+ * so paired iPhones aren't asked for an update they can't get yet. Without an answer from
+ * the App Store, background checks wait and a check the person started goes ahead.
*/
private async available(info: UpdateInfo) {
const required = (info as UpdateInfo & { minApp?: string }).minApp
@@ -121,7 +122,7 @@ export class Updates extends EventEmitter {
const [hostMinApp, iphones] = await this.localHostFacts()
this.appStoreVersion = (await appStoreVersion()) ?? this.appStoreVersion
const storeHas = this.appStoreVersion && parseVersion(this.appStoreVersion) && !isBelow(this.appStoreVersion, required)
- if (isBelow(hostMinApp ?? '0', required) && iphones !== false && !storeHas && !(this.appStoreVersion === null && !this.userInitiated)) {
+ if (isBelow(hostMinApp ?? '0', required) && iphones !== false && !storeHas && !(this.appStoreVersion === null && this.userInitiated)) {
waiting = required
}
}
@@ -136,19 +137,11 @@ export class Updates extends EventEmitter {
/** The local host's `minApp` and whether an iPhone is paired with it. */
private async localHostFacts(): Promise<[string | null, boolean | null]> {
- const local = this.host.local
- if (!local) return [null, null]
- const call = async <T>(method: string) => {
- const res = await fetch(`${local.baseURL}/api/${method}`, {
- method: 'POST',
- headers: { Authorization: `Bearer ${local.token}`, 'Content-Type': 'application/json' },
- body: '{}',
- signal: AbortSignal.timeout(5000),
- })
- return (await res.json()) as T
- }
try {
- const [hello, devices] = await Promise.all([call<{ minApp?: string }>('hello'), call<{ devices: { platform?: string }[] }>('devices')])
+ const [hello, devices] = await Promise.all([
+ this.host.call<{ minApp?: string }>('hello'),
+ this.host.call<{ devices: { platform?: string }[] }>('devices'),
+ ])
return [hello.minApp ?? null, devices.devices.some((d) => d.platform === 'ios')]
} catch {
return [null, null]
diff --git a/apps/desktop/src/renderer/views/UpdateNeededCard.tsx b/apps/desktop/src/renderer/views/UpdateNeededCard.tsx
index 97214cba..e08ea0aa 100644
--- a/apps/desktop/src/renderer/views/UpdateNeededCard.tsx
+++ b/apps/desktop/src/renderer/views/UpdateNeededCard.tsx
@@ -16,7 +16,7 @@ export const updateNeededText = {
}
const how =
os === 'macos' ? 'Open Codync on that Mac and choose Check for Updates.'
- : os === 'linux' ? 'Run codync-host update there, or use Check for updates in its Codync app.'
+ : os === 'linux' ? 'Run codync-host update there.'
: 'Update Codync on that computer.'
const needs = `${host} runs Codync ${m.version}; this app needs ${m.minimum} or newer.`
return instructions ? `${needs} ${how}` : needs
@@ -32,11 +32,12 @@ export function UpdateNeededCard() {
const store = useStore()
const mismatch = store.mismatch
if (!mismatch) return null
- // This app updates itself; this computer's own host is put back on the app's bundled copy.
+ // This app updates itself; on macOS this computer's own host is put back on the app's bundled
+ // copy. Linux has no bundled host, so the card says how to update it instead.
const action: [string, () => void] | null =
mismatch.kind === 'updateApp'
? ['Update Codync', () => window.codync.updates.check()]
- : store === app.local && !app.host.dev
+ : store === app.local && !app.host.dev && window.codync.platform === 'darwin'
? [`Update ${store.hostName}`, () => window.codync.host.restart()]
: null
return (
diff --git a/apps/ios/Kit/Sources/CodyncUI/UpdateNeededCard.swift b/apps/ios/Kit/Sources/CodyncUI/UpdateNeededCard.swift
index bed030e4..742510b5 100644
--- a/apps/ios/Kit/Sources/CodyncUI/UpdateNeededCard.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/UpdateNeededCard.swift
@@ -114,7 +114,7 @@ public enum UpdateNeededText {
case let .updateHost(version, minimum):
let how = switch os {
case "macos": "Open Codync on that Mac and choose Check for Updates."
- case "linux": "Run codync-host update there, or use Check for updates in its Codync app."
+ case "linux": "Run codync-host update there."
default: "Update Codync on that computer."
}
let needs = "\(host) runs Codync \(version); this app needs \(minimum) or newer."