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): keep dev builds and Linux hosts out of app updates

leepokai1d0250281252
diff --git a/apps/desktop/src/main/account.ts b/apps/desktop/src/main/account.ts
index f3ae2e7e..fb58bd2d 100644
--- a/apps/desktop/src/main/account.ts
+++ b/apps/desktop/src/main/account.ts
@@ -20,9 +20,9 @@ interface Config {
cloudURL: string | null
}
-/** `CODYNC_CLERK_PUBLISHABLE_KEY` / `CODYNC_CLOUD_URL`, else the build's account config. */
-function loadConfig(): Config {
- let file: Partial<Config> = {}
+/** The build's account config (`tools/account-config.mjs`). */
+function configFile(): Partial<Config> & { environment?: string } {
+ let file: Partial<Config> & { environment?: string } = {}
const candidates = [
app.isPackaged ? join(process.resourcesPath, 'account-config.json') : null,
join(__dirname, '../../resources/account-config.json'),
@@ -30,11 +30,20 @@ function loadConfig(): Config {
for (const path of candidates) {
if (path && existsSync(path)) {
try {
- file = JSON.parse(readFileSync(path, 'utf8')) as Partial<Config>
+ file = JSON.parse(readFileSync(path, 'utf8')) as typeof file
break
} catch {}
}
}
+ return file
+}
+
+/** Release builds are made for `main`; a `dev` build never replaces itself with one. */
+export const isMainEnvironment = () => configFile().environment === 'main'
+
+/** `CODYNC_CLERK_PUBLISHABLE_KEY` / `CODYNC_CLOUD_URL`, else the build's account config. */
+function loadConfig(): Config {
+ const file = configFile()
const key = (process.env.CODYNC_CLERK_PUBLISHABLE_KEY ?? file.clerkPublishableKey ?? '').trim()
const cloud = (process.env.CODYNC_CLOUD_URL ?? file.cloudURL ?? '').trim()
return {
diff --git a/apps/desktop/src/main/host-controller.ts b/apps/desktop/src/main/host-controller.ts
index d1fd89d1..b877dafc 100644
--- a/apps/desktop/src/main/host-controller.ts
+++ b/apps/desktop/src/main/host-controller.ts
@@ -167,9 +167,13 @@ export class HostController extends EventEmitter {
this.setState({ kind: 'notInstalled' })
}
- /** Stops the service before the app replaces itself; `resumeAfterCancelledUpdate` undoes it. */
+ /**
+ * Stops the service before the app replaces itself; `resumeAfterCancelledUpdate` undoes it.
+ * macOS only: there the host runs from inside the app. Linux uses the installed host, which an
+ * app update leaves alone.
+ */
async prepareForUpdate() {
- if (devPort !== null) return
+ if (devPort !== null || !isMac) return
if (this.installing) throw new Error('The host is being installed. Try again when it finishes.')
this.preparingForUpdate = true
if (existsSync(serviceFile)) prefs.set('hostRestartAfterAppUpdate', true)
diff --git a/apps/desktop/src/main/updates.ts b/apps/desktop/src/main/updates.ts
index d817d494..80520058 100644
--- a/apps/desktop/src/main/updates.ts
+++ b/apps/desktop/src/main/updates.ts
@@ -3,19 +3,23 @@ import { app, BrowserWindow, ipcMain, powerMonitor } from 'electron'
import electronUpdater, { type UpdateInfo } from 'electron-updater'
import { isBelow, parseVersion } from '../shared/compat'
import type { UpdateState } from '../shared/ipc'
+import { isMainEnvironment } from './account'
import { prefs, type HostController } from './host-controller'
const { autoUpdater } = electronUpdater
/**
- * The app's own updates (electron-updater, GitHub releases; release builds only). Codync
+ * The app's own updates (electron-updater, GitHub releases; packaged `main` builds only, so a
+ * local `dev` build never replaces itself with a release). Codync
* coordinates its background services before the installer replaces the app: the host is
* stopped first, and a restart marker makes the next launch reinstall it from the new bundle.
*/
+const enabled = app.isPackaged && isMainEnvironment()
+
export class Updates extends EventEmitter {
state: UpdateState = {
- supported: app.isPackaged,
- canCheck: app.isPackaged,
+ supported: enabled,
+ canCheck: enabled,
checking: false,
availableVersion: null,
staged: false,
@@ -44,7 +48,7 @@ export class Updates extends EventEmitter {
this.on('change', () => {
for (const w of windows()) w.webContents.send('updates:change', this.state)
})
- if (!app.isPackaged) return
+ if (!enabled) return
autoUpdater.autoDownload = false
autoUpdater.autoInstallOnAppQuit = true
@@ -57,7 +61,12 @@ export class Updates extends EventEmitter {
else this.installWhenIdle()
})
autoUpdater.on('error', (error) => {
- this.checked({ error: this.userInitiated ? error.message : null })
+ // An install that failed after the host was stopped puts the host back.
+ if (this.prepared) {
+ this.prepared = false
+ this.host.resumeAfterCancelledUpdate()
+ }
+ this.checked({ error: this.userInitiated || this.state.staged ? error.message : null })
this.userInitiated = false
})
@@ -103,7 +112,7 @@ export class Updates extends EventEmitter {
}
check() {
- if (!app.isPackaged) return
+ if (!enabled) return
if (this.state.staged) return void this.install()
this.userInitiated = true
this.set({ error: null })
diff --git a/apps/desktop/tools/account-config.mjs b/apps/desktop/tools/account-config.mjs
index 84992e1d..001c5d29 100644
--- a/apps/desktop/tools/account-config.mjs
+++ b/apps/desktop/tools/account-config.mjs
@@ -11,6 +11,6 @@ const plist = readFileSync(join(root, '../shared/Config', `${env}.plist`), 'utf8
const value = (key) => new RegExp(`<key>${key}</key>\\s*<string>([^<]*)</string>`).exec(plist)?.[1] ?? null
writeFileSync(
join(root, 'resources/account-config.json'),
- `${JSON.stringify({ clerkPublishableKey: value('clerkPublishableKey'), cloudURL: value('cloudURL') }, null, 2)}\n`,
+ `${JSON.stringify({ environment: env, clerkPublishableKey: value('clerkPublishableKey'), cloudURL: value('cloudURL') }, null, 2)}\n`,
)
console.log(`account config: ${env}`)
diff --git a/docs/guides/updates.md b/docs/guides/updates.md
index bcb875c6..b0a08b4b 100644
--- a/docs/guides/updates.md
+++ b/docs/guides/updates.md
@@ -9,7 +9,8 @@ Release builds update through electron-updater from GitHub releases
(`apps/desktop/src/main/updates.ts`). Open **Settings → Updates** in the menu bar
to check for a release, enable scheduled checks, or opt into automatic downloads
and installation. The chat window's Settings has the same **Check for updates**
-action on its Updates page. Development builds (`npm run dev`) don't update.
+action on its Updates page. Only packaged `main` builds update: `npm run dev` and builds made
+with `tools/account-config.mjs dev` never replace themselves with a release.
The app checks daily (hourly while a release waits for the iPhone app, below).
Automatic installation waits until no Codync window is focused, there has been no
@@ -18,8 +19,10 @@ A staged update also installs when quitting. Manual installation can interrupt w
A release whose `latest-mac.yml` names a `minApp` newer than the App Store's iPhone
app waits while an iPhone is paired with this host.
-Before replacement, Codync unregisters its screen helper and stops the host
-(`codync-host stop`). If that fails, installation pauses with a retry action. A
+Before replacement on macOS, Codync unregisters its screen helper and stops the host
+(`codync-host stop`), which runs from inside the app; on Linux the installed host keeps
+running. If stopping fails, installation pauses with a retry action, and an install that
+fails afterwards starts the host again. A
persistent restart marker makes the next app launch reinstall the host service from
the new bundle; remote screen registration is restored when the host reports that
it is enabled. Ordinary Quit keeps the host running when no update is staged.