Skip to content

Commit 748b6be

Browse files
committed
fix: compare daemon version against app version
1 parent 48e93ef commit 748b6be

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

packages/web-core/src/components/dashboard/DashboardVersionBanner.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ import { getMachineDisplayName } from '../../utils/daemon-utils'
44

55
interface DashboardVersionBannerProps {
66
daemons: DaemonData[]
7+
targetVersion?: string | null
78
upgradingDaemons: Record<string, 'upgrading' | 'done' | 'error'>
89
onUpgrade: (daemonId: string) => void
910
onDismiss: () => void
1011
}
1112

1213
export default function DashboardVersionBanner({
1314
daemons,
15+
targetVersion,
1416
upgradingDaemons,
1517
onUpgrade,
1618
onDismiss,
1719
}: DashboardVersionBannerProps) {
1820
if (daemons.length === 0) return null
1921

20-
const latest = daemons[0] as any
21-
2222
return (
2323
<div
2424
className="flex items-center gap-2.5 px-4 py-2 border-b text-xs text-text-secondary shrink-0 flex-wrap"
@@ -27,11 +27,12 @@ export default function DashboardVersionBanner({
2727
<span className="text-sm shrink-0 mt-0.5" style={{ color: 'var(--status-warning)' }}><IconRefresh size={14} /></span>
2828
<span className="flex-1 flex items-center gap-2 flex-wrap min-w-0">
2929
<span>
30-
Update available: <strong>v{latest.version}</strong><strong>v{latest.serverVersion}</strong>
30+
Update available{targetVersion ? <>: <strong>v{targetVersion}</strong></> : null}
3131
</span>
3232
{daemons.map((daemon: any) => {
3333
const name = getMachineDisplayName(daemon, { fallbackId: daemon.id })
3434
const state = upgradingDaemons[daemon.id]
35+
const currentVersion = daemon.version || daemon.daemonVersion || 'unknown'
3536

3637
return (
3738
<span
@@ -40,7 +41,7 @@ export default function DashboardVersionBanner({
4041
style={{ background: 'color-mix(in srgb, var(--status-warning) 8%, transparent)', border: '1px solid color-mix(in srgb, var(--status-warning) 15%, transparent)' }}
4142
>
4243
<span className="font-medium text-text-primary">{name}</span>
43-
<span className="text-[10px] text-text-muted">v{daemon.version}</span>
44+
<span className="text-[10px] text-text-muted">v{currentVersion}</span>
4445
{state === 'upgrading' ? (
4546
<span className="text-[10px] animate-pulse" style={{ color: 'var(--status-warning)' }}>upgrading…</span>
4647
) : state === 'done' ? (

packages/web-core/src/hooks/useDashboardVersionBanner.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useCallback, useMemo, useState } from 'react'
22
import type { DaemonData } from '../types'
33

4+
declare const __APP_VERSION__: string
5+
46
interface UseDashboardVersionBannerOptions {
57
ides: DaemonData[]
68
sendDaemonCommand: (id: string, type: string, data: Record<string, unknown>) => Promise<any>
@@ -10,9 +12,15 @@ export function useDashboardVersionBanner({
1012
ides,
1113
sendDaemonCommand,
1214
}: UseDashboardVersionBannerOptions) {
15+
const appVersion = typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : null
1316
const versionMismatchDaemons = useMemo(
14-
() => ides.filter((daemon: any) => daemon.type === 'adhdev-daemon' && daemon.versionMismatch),
15-
[ides],
17+
() => ides.filter((daemon: any) => {
18+
if (daemon.type !== 'adhdev-daemon') return false
19+
const daemonVersion = daemon.version || daemon.daemonVersion || null
20+
if (!daemonVersion || !appVersion) return false
21+
return daemonVersion !== appVersion
22+
}),
23+
[appVersion, ides],
1624
)
1725
const [versionBannerDismissed, setVersionBannerDismissed] = useState(false)
1826
const [upgradingDaemons, setUpgradingDaemons] = useState<Record<string, 'upgrading' | 'done' | 'error'>>({})
@@ -33,6 +41,7 @@ export function useDashboardVersionBanner({
3341

3442
return {
3543
versionMismatchDaemons,
44+
appVersion,
3645
versionBannerDismissed,
3746
setVersionBannerDismissed,
3847
upgradingDaemons,

packages/web-core/src/pages/Dashboard.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ export default function Dashboard() {
216216

217217
const {
218218
versionMismatchDaemons,
219+
appVersion,
219220
versionBannerDismissed,
220221
setVersionBannerDismissed,
221222
upgradingDaemons,
@@ -233,6 +234,7 @@ export default function Dashboard() {
233234
{!versionBannerDismissed && (
234235
<DashboardVersionBanner
235236
daemons={versionMismatchDaemons}
237+
targetVersion={appVersion}
236238
upgradingDaemons={upgradingDaemons}
237239
onUpgrade={handleBannerUpgrade}
238240
onDismiss={() => setVersionBannerDismissed(true)}

0 commit comments

Comments
 (0)