Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(updates): add progress/error/check IPC contract for update card

enes74f6d28b39f0
diff --git a/src/preload/index.ts b/src/preload/index.ts
index c1c936f2f..3f679dfdf 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -4,6 +4,7 @@ import type {
NodeTerminalApi,
PtyCreateOptions,
UpdateInfo,
+ UpdateProgress,
Workspace
} from '../shared/types'
@@ -88,6 +89,23 @@ const api: NodeTerminalApi = {
ipcRenderer.on(IPC.appUpdateDownloaded, handler)
return () => ipcRenderer.removeListener(IPC.appUpdateDownloaded, handler)
},
+ onProgress: (listener) => {
+ const handler = (_e: unknown, p: UpdateProgress) => listener(p)
+ ipcRenderer.on(IPC.appUpdateProgress, handler)
+ return () => ipcRenderer.removeListener(IPC.appUpdateProgress, handler)
+ },
+ onError: (listener) => {
+ const handler = (_e: unknown, message: string) => listener(message)
+ ipcRenderer.on(IPC.appUpdateError, handler)
+ return () => ipcRenderer.removeListener(IPC.appUpdateError, handler)
+ },
+ onNotAvailable: (listener) => {
+ const handler = () => listener()
+ ipcRenderer.on(IPC.appUpdateNotAvailable, handler)
+ return () => ipcRenderer.removeListener(IPC.appUpdateNotAvailable, handler)
+ },
+ check: () => ipcRenderer.send(IPC.appCheckForUpdates),
+ getVersion: () => ipcRenderer.invoke(IPC.appGetVersion),
restart: () => ipcRenderer.send(IPC.appRestartToUpdate)
},
announcements: {
diff --git a/src/shared/ipc.ts b/src/shared/ipc.ts
index cc7d30f65..ffaf1edc3 100644
--- a/src/shared/ipc.ts
+++ b/src/shared/ipc.ts
@@ -23,6 +23,11 @@ export const IPC = {
bridgeMessage: 'bridge:message',
appUpdateAvailable: 'app:update-available',
appUpdateDownloaded: 'app:update-downloaded',
+ appUpdateProgress: 'app:update-progress',
+ appUpdateError: 'app:update-error',
+ appUpdateNotAvailable: 'app:update-not-available',
+ appCheckForUpdates: 'app:check-for-updates',
+ appGetVersion: 'app:get-version',
appRestartToUpdate: 'app:restart-to-update',
announcementsFetch: 'announcements:fetch',
// Events broadcast from main to the renderer (sessionId is appended to the channel name).
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 94a42662b..c4d66abc4 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -282,11 +282,29 @@ export interface UpdateInfo {
notes?: string
}
+export interface UpdateProgress {
+ /** 0–100. */
+ percent: number
+ transferred: number
+ total: number
+ bytesPerSecond: number
+}
+
export interface UpdateApi {
/** A newer version was found and is downloading. Returns unsubscribe. */
onAvailable(listener: (info: UpdateInfo) => void): () => void
/** The update finished downloading and is ready to install. Returns unsubscribe. */
onDownloaded(listener: (info: UpdateInfo) => void): () => void
+ /** Download progress ticks while an update downloads. Returns unsubscribe. */
+ onProgress(listener: (p: UpdateProgress) => void): () => void
+ /** An updater error occurred (drives the card's error state). Returns unsubscribe. */
+ onError(listener: (message: string) => void): () => void
+ /** No newer version is available (also the dev no-op reply to check()). Returns unsubscribe. */
+ onNotAvailable(listener: () => void): () => void
+ /** Trigger a manual update check. */
+ check(): void
+ /** The running app version. */
+ getVersion(): Promise<string>
/** Quit and install the staged update. */
restart(): void
}