The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): read the running version from the gateway
ethernet21986a89aa48
diff --git a/apps/desktop/electron/gateway-version.test.ts b/apps/desktop/electron/gateway-version.test.tsnew file mode 100644index 00000000000..b9860bb91dd--- /dev/null+++ b/apps/desktop/electron/gateway-version.test.ts@@ -0,0 +1,42 @@+import assert from 'node:assert/strict'+import { createServer } from 'node:http'++import { test } from 'vitest'++import { resolveGatewayVersion } from './gateway-version'++test('version follows the gateway response across runtime changes', async () => {+ let version = '1.2.3'++ const server = createServer((_request, response) => {+ response.setHeader('Content-Type', 'application/json')+ response.end(JSON.stringify({ ok: true, version }))+ })++ await new Promise<void>(resolve => server.listen(0, '127.0.0.1', resolve))+ const address = server.address()+ assert.ok(address && typeof address !== 'string')+ const baseUrl = `http://127.0.0.1:${address.port}`++ const request = async (endpoint: string): Promise<unknown> => {+ assert.equal(endpoint, '/api/health')++ return (await fetch(`${baseUrl}${endpoint}`)).json()+ }++ try {+ assert.equal(await resolveGatewayVersion(request), version)+ version = '4.5.6'+ assert.equal(await resolveGatewayVersion(request), version)+ } finally {+ await new Promise<void>((resolve, reject) => server.close(error => error ? reject(error) : resolve()))+ }+})++test('unavailable gateway version stays unknown instead of using another install', async () => {+ for (const response of [null, {}, { version: 42 }, { version: '' }]) {+ assert.equal(await resolveGatewayVersion(async () => response), '')+ }++ assert.equal(await resolveGatewayVersion(async () => { throw new Error('offline') }), '')+})diff --git a/apps/desktop/electron/gateway-version.ts b/apps/desktop/electron/gateway-version.tsnew file mode 100644index 00000000000..3d42468ba10--- /dev/null+++ b/apps/desktop/electron/gateway-version.ts@@ -0,0 +1,14 @@+/** The connected process owns its runtime version, not a checkout on disk. */+export async function resolveGatewayVersion(request: (path: string) => Promise<unknown>): Promise<string> {+ try {+ const status = await request('/api/health')++ if (status && typeof status === 'object' && 'version' in status && typeof status.version === 'string') {+ return status.version+ }+ } catch {+ // An offline gateway has no known running version.+ }++ return ''+}diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex a9b36d68504..f7f797b396e 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -205,6 +205,7 @@ import {writeBufferToFile} from './gateway-file-download'import { startGatewaysAfterUpdateAbort, stopGatewayBeforeUpdate } from './gateway-stop-before-update'+import { resolveGatewayVersion } from './gateway-version'import { probeGatewayWebSocket } from './gateway-ws-probe'import { registerGitIpc } from './git-ipc'import { readAndConsumeHandoffResult } from './handoff-result'@@ -1277,13 +1278,10 @@ if (IS_WINDOWS) {app.setAppUserModelId('com.nousresearch.hermes')}-// Seed the native About panel with the live Hermes version. This is refreshed-// on every open via the explicit "About" menu handler (refreshAboutPanel), so-// an in-place `hermes update` mid-session is reflected without an app restart;-// the seed here just covers the first open and any non-menu invocation path.+// The gateway version is unknown until the backend connects.app.setAboutPanelOptions({applicationName: APP_NAME,- applicationVersion: resolveHermesVersion(),+ applicationVersion: '',copyright: 'Copyright © 2026 Nous Research'})@@ -17236,29 +17234,8 @@ ipcMain.handle('hermes:updates:branch:set', async (_event, name) => {return { branch }})-// Resolve the canonical Hermes version (the one `release.py` bumps in-// hermes_cli/__init__.py + pyproject.toml) so the desktop About panel shows the-// real Hermes version instead of the Electron app's own package.json version,-// which historically drifted (stuck at 0.0.2). Falls back to app.getVersion()-// when the source tree can't be read (e.g. a packaged build without the repo).-function resolveHermesVersion() {- try {- const root = resolveUpdateRoot()- const initPath = path.join(root, 'hermes_cli', '__init__.py')-- if (fileExists(initPath)) {- const raw = fs.readFileSync(initPath, 'utf8')- const match = raw.match(/__version__\s*=\s*["']([^"']+)["']/)-- if (match) {- return match[1]- }- }- } catch {- // Fall through to the Electron app version below.- }-- return app.getVersion()+function resolveHermesVersion(scope: { connectionId?: string; profile?: string } = {}): Promise<string> {+ return resolveGatewayVersion(path => handleHermesApiRequest({ ...scope, path, timeoutMs: 5000 }))}// Renderer-bundle skew: `hermes update` moves the SOURCE TREE, but the UI@@ -17279,23 +17256,23 @@ async function detectRendererSkew() {// an app restart. macOS only — `showAboutPanel()` is a no-op elsewhere, and the// other platforms don't use this menu item.function showAboutPanelFresh() {- void detectRendererSkew().then(skew => {+ void Promise.all([detectRendererSkew(), resolveHermesVersion()]).then(([skew, version]) => {app.setAboutPanelOptions({applicationName: APP_NAME,applicationVersion: skew.outOfSync- ? `${resolveHermesVersion()} — app build out of date, update the desktop app`- : resolveHermesVersion(),+ ? `${version} — app build out of date, update the desktop app`+ : version,copyright: 'Copyright © 2026 Nous Research'})app.showAboutPanel()})}-ipcMain.handle('hermes:version', async () => {- const skew = await detectRendererSkew()+ipcMain.handle('hermes:version', async (_event, scope?: { connectionId?: string; profile?: string }) => {+ const [skew, version] = await Promise.all([detectRendererSkew(), resolveHermesVersion(scope)])return {- ...resolveHermesVersionInfo(),+ ...resolveHermesVersionInfo(version),electronVersion: process.versions.electron,nodeVersion: process.versions.node,platform: process.platform,@@ -17359,9 +17336,8 @@ function readLatestSyncReceipt(): Record<string, unknown> | null {ipcMain.handle('hermes:sync-status', () => readLatestSyncReceipt())-/** Build provenance read from the install stamp — the same facts the CLI- * reports. Falls back to the bare app version when there's no stamp. */-function resolveHermesVersionInfo() {+/** Runtime version comes from the gateway; build provenance stays with the app stamp. */+function resolveHermesVersionInfo(version: string) {// The baked build-time constant is typed more narrowly than a full stamp// loaded from disk; cast to the full shape so every provenance field is// readable on either source.@@ -17369,7 +17345,7 @@ function resolveHermesVersionInfo() {if (stamp) {return {- appVersion: resolveHermesVersion(),+ appVersion: version,baseVersion: stamp.baseVersion ?? undefined,distance: stamp.distance ?? undefined,commit: stamp.commit,@@ -17380,7 +17356,7 @@ function resolveHermesVersionInfo() {}}- return { appVersion: app.getVersion(), baseVersion: app.getVersion() }+ return { appVersion: version, baseVersion: app.getVersion() }}// Python's Path.resolve() equivalent for install-id derivation: realpath whendiff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.tsindex 32d17e48dee..3c11f223d0d 100644--- a/apps/desktop/electron/preload.ts+++ b/apps/desktop/electron/preload.ts@@ -497,7 +497,7 @@ contextBridge.exposeInMainWorld('hermesDesktop', {return () => ipcRenderer.removeListener('hermes:bootstrap:event', listener)},- getVersion: () => ipcRenderer.invoke('hermes:version'),+ getVersion: (scope?: { connectionId?: string; profile?: string }) => ipcRenderer.invoke('hermes:version', scope),getSyncStatus: () => ipcRenderer.invoke('hermes:sync-status'),relaunchApp: () => ipcRenderer.invoke('hermes:app:relaunch'),getRemoteDisplayReason: () => ipcRenderer.invoke('hermes:get-remote-display-reason'),diff --git a/apps/desktop/src/app/settings/about-settings.tsx b/apps/desktop/src/app/settings/about-settings.tsxindex 74a5aa64a74..f27c0be8f90 100644--- a/apps/desktop/src/app/settings/about-settings.tsx+++ b/apps/desktop/src/app/settings/about-settings.tsx@@ -29,7 +29,7 @@ export function AboutSettings() {if (remote) {void checkBackendUpdates()}- }, [remote])+ }, [connection, remote])return (<SettingsContent>diff --git a/apps/desktop/src/components/version-details.tsx b/apps/desktop/src/components/version-details.tsxindex 84c5c02ce9e..49b2de22fa9 100644--- a/apps/desktop/src/components/version-details.tsx+++ b/apps/desktop/src/components/version-details.tsx@@ -49,7 +49,7 @@ export function VersionDetails({ version }: { version: DesktopVersionInfo }) {<div className="flex justify-between gap-4"><dt className="text-muted-foreground">{u.versionDetailsVersion}</dt><dd>- v{version.appVersion}+ {version.appVersion ? `v${version.appVersion}` : u.versionUnavailable}{version.dirty && <span className="text-warning"> (!)</span>}</dd></div>diff --git a/apps/desktop/src/global.d.ts b/apps/desktop/src/global.d.tsindex 60a6c6238d3..17143e4fb8f 100644--- a/apps/desktop/src/global.d.ts+++ b/apps/desktop/src/global.d.ts@@ -521,7 +521,7 @@ declare global {repairBootstrap: () => Promise<{ ok: boolean; error?: string }>cancelBootstrap: () => Promise<{ ok: boolean; cancelled: boolean }>onBootstrapEvent: (callback: (payload: DesktopBootstrapEvent) => void) => () => void- getVersion: () => Promise<DesktopVersionInfo>+ getVersion: (scope?: { connectionId?: string; profile?: string }) => Promise<DesktopVersionInfo>/** The latest pm/venv/plugin-operation receipt (machine-readable):* bisect disables, failed rebuilds, update-check results. null when* no venv operation has run yet. */@@ -628,6 +628,7 @@ export interface DesktopSyncReceipt {}export interface DesktopVersionInfo {+ /** Running gateway version; empty when the gateway cannot report it. */appVersion: stringelectronVersion: stringnodeVersion: stringdiff --git a/apps/desktop/src/store/updates.test.ts b/apps/desktop/src/store/updates.test.tsindex 58397f5a067..bebcdfe7e4a 100644--- a/apps/desktop/src/store/updates.test.ts+++ b/apps/desktop/src/store/updates.test.ts@@ -1,6 +1,7 @@import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'-import type { DesktopUpdateStatus } from '@/global'+import { setApiRequestConnection, setApiRequestProfile } from '@/api/client'+import type { DesktopUpdateStatus, DesktopVersionInfo } from '@/global'import { en } from '@/i18n/en'const storage = new Map<string, string>()@@ -81,6 +82,8 @@ vi.mock('@/store/gateway-reconnect', () => ({}))const {+ refreshDesktopVersion,+ $desktopVersion,maybeNotifyUpdateAvailable,checkBackendUpdates,$backendUpdateStatus,@@ -134,6 +137,44 @@ const setRemote = (on: boolean) =>windowButtonPosition: null})+describe('gateway version refresh', () => {+ afterEach(() => {+ setApiRequestConnection(null)+ setApiRequestProfile(null)+ $desktopVersion.set(null)+ })++ it('requests the active gateway and does not publish a previous connection reply', async () => {+ setRemote(true)+ setApiRequestConnection('remote-box')+ setApiRequestProfile('work')++ const version: DesktopVersionInfo = {+ appVersion: '4.5.6', electronVersion: '40', nodeVersion: '26', platform: 'win32', hermesRoot: ''+ }++ const getVersion = vi.fn().mockResolvedValue(version)+ const previous = window.hermesDesktop+ window.hermesDesktop = { ...previous, getVersion }++ try {+ expect(await refreshDesktopVersion()).toEqual(version)+ expect(getVersion).toHaveBeenCalledWith({ connectionId: 'remote-box', profile: 'work' })+ expect($desktopVersion.get()?.appVersion).toBe('4.5.6')+ let finish!: (value: DesktopVersionInfo) => void+ getVersion.mockImplementationOnce(() => new Promise(resolve => { finish = resolve }))+ const pending = refreshDesktopVersion()+ setRemote(false)+ $desktopVersion.set(null)+ finish(version)+ expect(await pending).toBeNull()+ expect($desktopVersion.get()).toBeNull()+ } finally {+ window.hermesDesktop = previous+ }+ })+})+describe('maybeNotifyUpdateAvailable', () => {beforeEach(() => {storage.clear()diff --git a/apps/desktop/src/store/updates.ts b/apps/desktop/src/store/updates.tsindex 45204a6bea4..4edecad25ba 100644--- a/apps/desktop/src/store/updates.ts+++ b/apps/desktop/src/store/updates.ts@@ -5,6 +5,7 @@import { atom } from 'nanostores'+import { connectionScoped, profileScoped } from '@/api/client'import type {DesktopUpdateApplyOptions,DesktopUpdateApplyResult,@@ -352,11 +353,7 @@ export function requestActiveUpdate(): void {openUpdateOverlayFor(target)}-/** Re-read the running app's version from the Electron main process and- * publish it on `$desktopVersion`. Called when the About panel mounts, the- * update flow finishes, and the window regains focus, so the About text- * stays in sync with the just-installed binary instead of frozen at the- * value captured at first-load. */+/** Refresh the active gateway version and the desktop's build metadata. */export async function refreshDesktopVersion(): Promise<DesktopVersionInfo | null> {if (typeof window === 'undefined') {return null@@ -368,7 +365,10 @@ export async function refreshDesktopVersion(): Promise<DesktopVersionInfo | null// mid-reload, or the bridge not yet ready on first paint) would surface// as an unhandled promise rejection in the renderer. Swallow it.try {- const next = await window.hermesDesktop?.getVersion?.()+ const connection = $connection.get()+ const next = await window.hermesDesktop?.getVersion?.({ ...connectionScoped(), ...profileScoped() })++ if ($connection.get() !== connection) { return null }if (next) {$desktopVersion.set(next)