Skip to content

The agent that grows with you

fix(desktop): show how far past the release an install is, not its commit

ethernet7038ba8f4686
diff --git a/apps/desktop/electron/gateway-version.test.ts b/apps/desktop/electron/gateway-version.test.ts
index 0435c9aefd9..bcd1cb6c97b 100644
--- a/apps/desktop/electron/gateway-version.test.ts
+++ b/apps/desktop/electron/gateway-version.test.ts
@@ -32,3 +32,9 @@ test('unavailable gateway version stays unknown instead of using another install
''
)
})
+
+test('the distance past the release tag wins over the bare release', async (): Promise<void> => {
+ const ahead: { version: string; displayVersion: string } = { version: '0.21.5', displayVersion: '0.21.5+1913' }
+ assert.equal(await resolveGatewayVersion(async () => ahead), '0.21.5+1913')
+ assert.equal(await resolveGatewayVersion(async () => ({ ...ahead, displayVersion: '' })), '0.21.5')
+})
diff --git a/apps/desktop/electron/gateway-version.ts b/apps/desktop/electron/gateway-version.ts
index 3d42468ba10..14f232d23ba 100644
--- a/apps/desktop/electron/gateway-version.ts
+++ b/apps/desktop/electron/gateway-version.ts
@@ -1,10 +1,18 @@
-/** The connected process owns its runtime version, not a checkout on disk. */
+/** The connected process owns its runtime version, not a checkout on disk.
+ * `displayVersion` carries the distance past the release tag (`0.21.5+1913`);
+ * a backend that predates it only reports the bare release. */
export async function resolveGatewayVersion(request: (path: string) => Promise<unknown>): Promise<string> {
try {
- const status = await request('/api/health')
+ const status: unknown = await request('/api/health')
- if (status && typeof status === 'object' && 'version' in status && typeof status.version === 'string') {
- return status.version
+ if (status && typeof status === 'object') {
+ if ('displayVersion' in status && typeof status.displayVersion === 'string' && status.displayVersion) {
+ return status.displayVersion
+ }
+
+ if ('version' in status && typeof status.version === 'string') {
+ return status.version
+ }
}
} catch {
// An offline gateway has no known running version.
diff --git a/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx b/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx
index 07d2aa0e646..009cb39c8b8 100644
--- a/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx
+++ b/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx
@@ -384,7 +384,6 @@ export function useStatusbarItems({
return {
className: status.hasUpdate ? 'text-primary hover:text-primary' : undefined,
- detail: status.detail,
hidden: status.unknown,
icon: applying ? <Loader2 className="size-3 animate-spin" /> : <Hash className="size-3" />,
id: 'version-client',
diff --git a/apps/desktop/src/components/update-status.tsx b/apps/desktop/src/components/update-status.tsx
index b4b3c79b07f..78fa6fe179a 100644
--- a/apps/desktop/src/components/update-status.tsx
+++ b/apps/desktop/src/components/update-status.tsx
@@ -8,6 +8,7 @@ import type { DesktopUpdateStatus, DesktopVersionInfo } from '@/global'
import { type Translations, useI18n } from '@/i18n'
import { AlertTriangle, CheckCircle2, ExternalLink, Loader2, RefreshCw } from '@/lib/icons'
import { cn } from '@/lib/utils'
+import { shortVersion } from '@/lib/version-label'
import {
$backendUpdateApply,
$backendUpdateChecking,
@@ -179,7 +180,7 @@ export function VersionHero({
<h2 className="text-lg font-semibold tracking-tight">{u.appName}</h2>
)}
<p className="mt-1 text-xs text-muted-foreground">
- {version?.appVersion ? u.version(version.appVersion) : u.versionUnavailable}
+ {version?.appVersion ? u.version(shortVersion(version.appVersion)) : u.versionUnavailable}
{version?.channel
? ` · ${Object.entries(u.channels).find(([name]: [string, string]): boolean => name === version.channel)?.[1] ?? version.channel}`
: ''}
diff --git a/apps/desktop/src/components/version-details.tsx b/apps/desktop/src/components/version-details.tsx
index 70d32023b44..4f2e896dce0 100644
--- a/apps/desktop/src/components/version-details.tsx
+++ b/apps/desktop/src/components/version-details.tsx
@@ -2,6 +2,7 @@ import type { DesktopVersionInfo, RuntimeSource } from '@/global'
import { useI18n } from '@/i18n'
import { distributionLabelKey } from '@/lib/distribution-label'
import { ExternalLink } from '@/lib/external-link'
+import { shortVersion } from '@/lib/version-label'
/**
* Human label for an external build's runtime source: the resolution rung
@@ -55,7 +56,7 @@ export function VersionDetails({ version }: { version: DesktopVersionInfo }) {
<div className="flex justify-between gap-4">
<dt className="text-muted-foreground">{u.versionDetailsVersion}</dt>
<dd>
- {version.appVersion ? `v${version.appVersion}` : u.versionUnavailable}
+ {version.appVersion ? `v${shortVersion(version.appVersion)}` : u.versionUnavailable}
{version.dirty && <span className="text-warning"> (!)</span>}
</dd>
</div>
diff --git a/apps/desktop/src/lib/version-label.test.ts b/apps/desktop/src/lib/version-label.test.ts
new file mode 100644
index 00000000000..6793a122e1e
--- /dev/null
+++ b/apps/desktop/src/lib/version-label.test.ts
@@ -0,0 +1,12 @@
+import { describe, expect, it } from 'vitest'
+
+import { shortVersion } from './version-label'
+
+describe('shortVersion', () => {
+ it('keeps the distance past the release and drops the commit', (): void => {
+ expect(shortVersion('0.21.5+1913.gf83a9e9')).toBe('0.21.5+1913')
+ expect(shortVersion('v0.21.5+1913.gf83a9e9.dirty')).toBe('0.21.5+1913')
+ expect(shortVersion('0.21.5+1913')).toBe('0.21.5+1913')
+ expect(shortVersion('0.21.5')).toBe('0.21.5')
+ })
+})
diff --git a/apps/desktop/src/lib/version-label.ts b/apps/desktop/src/lib/version-label.ts
new file mode 100644
index 00000000000..841c48bd5f3
--- /dev/null
+++ b/apps/desktop/src/lib/version-label.ts
@@ -0,0 +1,10 @@
+/**
+ * The one short form every surface names a version by: `<release>+<distance>`
+ * (`0.21.5+1913`), matching `hermes --version` minus its commit. The commit
+ * (`.g<sha>`, `.dirty`) is build metadata the expanded version details show in
+ * full; in a label it only adds noise. Callers own the `v` prefix, which the
+ * localized copy already carries.
+ */
+export function shortVersion(version: string): string {
+ return version.replace(/^v/, '').replace(/(\+\d+)\.g[0-9a-f]+(?:\.dirty)?$/i, '$1')
+}
diff --git a/apps/desktop/src/lib/version-status.test.ts b/apps/desktop/src/lib/version-status.test.ts
index 21b04d5ebef..ef91c561367 100644
--- a/apps/desktop/src/lib/version-status.test.ts
+++ b/apps/desktop/src/lib/version-status.test.ts
@@ -13,11 +13,11 @@ const backend = (over: Partial<Parameters<typeof resolveVersionStatus>[0]> = {})
resolveVersionStatus({ applying: false, copy, remote: true, restarting: false, target: 'backend', ...over })
describe('resolveVersionStatus', () => {
- it('labels a current local client with its version and sha detail', () => {
- const status = client({ sha: 'abc1234', version: '0.4.2' })
+ it('labels a current local client with its distance, keeping the commit for the tooltip', () => {
+ const status = client({ sha: 'abc1234', version: '0.4.2+1913.gabc1234' })
- expect(status.label).toBe('v0.4.2')
- expect(status.detail).toBe('abc1234')
+ expect(status.label).toBe('v0.4.2+1913')
+ expect(status.tooltip).toContain('abc1234')
expect(status.hasUpdate).toBe(false)
expect(status.unknown).toBe(false)
})
@@ -49,11 +49,10 @@ describe('resolveVersionStatus', () => {
expect(client().unknown).toBe(true)
})
- it('drops the diff and the sha detail while an apply is in flight', () => {
+ it('drops the diff while an apply is in flight', () => {
const applying = client({ applying: true, behind: 3, sha: 'abc1234', version: '0.4.2' })
expect(applying.label).toBe('v0.4.2 · update')
- expect(applying.detail).toBeUndefined()
expect(applying.hasUpdate).toBe(false)
expect(client({ applying: true, restarting: true, version: '0.4.2' }).label).toBe('v0.4.2 · restart')
@@ -63,7 +62,6 @@ describe('resolveVersionStatus', () => {
const status = backend({ sha: 'abc1234', version: '0.4.2' })
expect(status.label).toBe('backend v0.4.2')
- expect(status.detail).toBeUndefined()
expect(status.tooltip).toBe('Backend v0.4.2')
})
diff --git a/apps/desktop/src/lib/version-status.ts b/apps/desktop/src/lib/version-status.ts
index fb6d4e922bd..2fc615ae52f 100644
--- a/apps/desktop/src/lib/version-status.ts
+++ b/apps/desktop/src/lib/version-status.ts
@@ -9,6 +9,7 @@
*/
import type { UpdateTarget } from '@/lib/update-copy'
+import { shortVersion } from '@/lib/version-label'
export interface VersionStatusCopy {
backendLabel: (version: string) => string
@@ -57,8 +58,6 @@ export interface VersionStatusInput {
}
export interface VersionStatusResult {
- /** Secondary text beside the label — the commit sha, when it adds anything. */
- detail?: string
/** An update is waiting: callers tint the row with it. */
hasUpdate: boolean
label: string
@@ -80,8 +79,11 @@ export function resolveVersionStatus({
sha = null,
target,
updateAvailable,
- version = null
+ version: rawVersion = null
}: VersionStatusInput): VersionStatusResult {
+ // The label names the distance past the release; the commit stays in the
+ // tooltip and the expanded version details.
+ const version: null | string = rawVersion && shortVersion(rawVersion)
const client = target === 'client'
const busy = applying || restarting
// updateAvailable covers every "behind but uncountable" shape: shallow
@@ -122,7 +124,6 @@ export function resolveVersionStatus({
.join(' · ')
return {
- detail: client && version && sha && !busy && !remote ? sha : undefined,
hasUpdate: !busy && available,
label: busy ? `${base} · ${restarting ? copy.restart : copy.update}` : `${base}${hint}`,
tooltip: tooltip || undefined,
diff --git a/hermes_cli/version_info.py b/hermes_cli/version_info.py
index bd767787080..c31256c665f 100644
--- a/hermes_cli/version_info.py
+++ b/hermes_cli/version_info.py
@@ -34,6 +34,12 @@ class VersionInfo:
commit_date: int | None = None
distribution: Literal["docker", "nix", "desktop-app"] | None = None
+ @property
+ def display_version(self) -> str:
+ """``<base>+<distance>``: the short form surfaces label a version by.
+ The commit is shown beside it where there is room, never inside it."""
+ return _derived_version(self.base_version, self.distance)
+
def _derived_version(
base_version: str,
diff --git a/hermes_cli/web_routers/status.py b/hermes_cli/web_routers/status.py
index 0d612aee7c6..e191bee5162 100644
--- a/hermes_cli/web_routers/status.py
+++ b/hermes_cli/web_routers/status.py
@@ -116,7 +116,8 @@ async def get_ssh_ownership(request: Request):
@router.get("/api/health")
async def get_health():
"""Lightweight process liveness for desktop/backend readiness probes."""
- return {"ok": True, "version": get_version_info().base_version,
+ info = get_version_info()
+ return {"ok": True, "version": info.base_version, "displayVersion": info.display_version,
"auth_required": bool(getattr(app.state, "auth_required", False))}
diff --git a/tests/hermes_cli/test_version_info.py b/tests/hermes_cli/test_version_info.py
index 4f166f706ad..611fe54a278 100644
--- a/tests/hermes_cli/test_version_info.py
+++ b/tests/hermes_cli/test_version_info.py
@@ -23,6 +23,14 @@ def test_derived_version_shows_plus_question_for_dirty_unknown_distance():
assert _derived_version("0.19.0", 0, dirty=True) == "0.19.0"
+def test_display_version_names_the_distance_without_the_commit():
+ """Labels say how far past the release an install is; the commit is shown
+ beside them where there is room (`hermes --version` keeps `.g<sha>`)."""
+ ahead = VersionInfo("0.21.5", "0.21.5+1913.gf83a9e9", 1913, "f83a9e9" + "0" * 33, "main", "git")
+ assert ahead.display_version == "0.21.5+1913"
+ assert VersionInfo("0.21.5", "0.21.5", 0, None, None, "git").display_version == "0.21.5"
+
+
def test_stamp_version_info_reads_nix_stamp(tmp_path, monkeypatch):
stamp = {
"schemaVersion": 2,