Skip to content

Commit 0cc4ee0

Browse files
committed
Fix update install state recovery
1 parent 2891581 commit 0cc4ee0

17 files changed

Lines changed: 79 additions & 17 deletions

File tree

‎apps/cli/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@craft-agent/cli",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"license": "Apache-2.0",
55
"description": "Terminal client for Craft Agent server",
66
"type": "module",

‎apps/electron/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@craft-agent/electron",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "Electron desktop app for Zo",
55
"main": "dist/main.cjs",
66
"private": true,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# v0.1.2 - Auto-update install hotfix
2+
3+
## Features
4+
5+
- None.
6+
7+
## Improvements
8+
9+
- None.
10+
11+
## Bug Fixes
12+
13+
- **Auto-update install recovery** - The installer now refreshes updater state from the validated pending download before failing. This fixes cases where an update was already downloaded, but clicking install showed "No update ready to install" after the in-memory updater state fell out of sync.
14+
15+
## Breaking Changes
16+
17+
- None.

‎apps/electron/src/main/auto-update.ts‎

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ function checkForExistingDownload(): { exists: boolean; version?: string } {
295295
const fileName = (info?.fileName || info?.path) as string | undefined
296296
if (fileName && fs.existsSync(path.join(cacheDir, fileName))) {
297297
mainLog.info(`[auto-update] Found existing download via update-info.json: ${fileName}`)
298-
return { exists: true, version: info?.version as string }
298+
return { exists: true, version: (info?.version as string | undefined) ?? inferVersionFromUpdateFileName(fileName) }
299299
}
300300
}
301301

@@ -309,7 +309,7 @@ function checkForExistingDownload(): { exists: boolean; version?: string } {
309309
)
310310
if (downloadFile) {
311311
mainLog.info(`[auto-update] Found existing download file: ${downloadFile}`)
312-
return { exists: true }
312+
return { exists: true, version: inferVersionFromUpdateFileName(downloadFile) }
313313
}
314314

315315
mainLog.info(`[auto-update] No existing download found in cache`)
@@ -320,6 +320,41 @@ function checkForExistingDownload(): { exists: boolean; version?: string } {
320320
}
321321
}
322322

323+
function inferVersionFromUpdateFileName(fileName: string): string | undefined {
324+
const match = fileName.match(/(?:^|[-_])(\d+\.\d+\.\d+)(?:[-_.]|$)/)
325+
return match?.[1]
326+
}
327+
328+
async function refreshReadyUpdateState(): Promise<boolean> {
329+
const internalState = checkElectronUpdaterState()
330+
if (internalState.ready) {
331+
updateInfo = {
332+
...updateInfo,
333+
available: true,
334+
latestVersion: internalState.version ?? updateInfo.latestVersion,
335+
downloadState: 'ready',
336+
downloadProgress: 100,
337+
}
338+
broadcastUpdateInfo()
339+
return true
340+
}
341+
342+
const existing = checkForExistingDownload()
343+
if (existing.exists) {
344+
updateInfo = {
345+
...updateInfo,
346+
available: true,
347+
latestVersion: existing.version ?? updateInfo.latestVersion,
348+
downloadState: 'ready',
349+
downloadProgress: 100,
350+
}
351+
broadcastUpdateInfo()
352+
return true
353+
}
354+
355+
return false
356+
}
357+
323358
/**
324359
* Check for available updates.
325360
* Returns the current UpdateInfo state after check completes.
@@ -382,6 +417,16 @@ export async function checkForUpdates(options: CheckOptions = {}): Promise<Updat
382417
* Then relaunches the app automatically.
383418
*/
384419
export async function installUpdate(): Promise<void> {
420+
if (updateInfo.downloadState !== 'ready') {
421+
mainLog.warn(`[auto-update] installUpdate called while state is ${updateInfo.downloadState}; refreshing update state`)
422+
423+
if (!await refreshReadyUpdateState()) {
424+
await checkForUpdates({ autoDownload: true })
425+
await new Promise(resolve => setTimeout(resolve, 500))
426+
await refreshReadyUpdateState()
427+
}
428+
}
429+
385430
if (updateInfo.downloadState !== 'ready') {
386431
throw new Error('No update ready to install')
387432
}

‎apps/viewer/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@craft-agent/viewer",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"license": "Apache-2.0",
55
"description": "Web viewer for Zo sessions - upload and share session transcripts",
66
"private": true,

‎apps/webui/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@craft-agent/webui",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"license": "Apache-2.0",
55
"private": true,
66
"type": "module",

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "craft-agent",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"license": "Apache-2.0",
55
"description": "Claude Code-like agent for Craft documents",
66
"type": "module",

‎packages/core/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@craft-agent/core",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"license": "Apache-2.0",
55
"description": "Core types, storage, and agent logic for Zo",
66
"type": "module",

‎packages/messaging-gateway/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@craft-agent/messaging-gateway",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"license": "Apache-2.0",
55
"description": "Messaging gateway for Craft Agent — Telegram & WhatsApp",
66
"type": "module",

‎packages/messaging-whatsapp-worker/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@craft-agent/messaging-whatsapp-worker",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"license": "Apache-2.0",
55
"description": "WhatsApp worker subprocess for Craft Agent (Baileys-based, unofficial API)",
66
"type": "module",

0 commit comments

Comments
 (0)