import { Link } from '@tanstack/react-router' import { useQuery } from '@tanstack/react-query' import { useTranslation } from 'react-i18next' import { updatesQueryOptions } from '../../queries/updates' import { displayVersion } from '../../lib/updateBehind' import { TONE, type Tone } from '@/components/kit/tone' import { cn } from '@/lib/utils' import type { ShellStatus } from '@/lib/shellStatus' import { useShellStatus } from './useShellStatus' const STATUS_TONE: Record = { healthy: 'success', update: 'warning', degraded: 'warning', incident: 'danger', busy: 'info', unknown: 'neutral', } export function SidebarVersionLinkView({ current, latest, updateAvailable, status, }: { current: string | undefined latest: string | null | undefined updateAvailable: boolean status?: ShellStatus }) { const { t } = useTranslation() const label = current ? `${t('shell.account.controlPlane')} ${displayVersion(current)}` : t('shell.account.controlPlane') // The update is its own marker; the status dot stays a health signal. const health = status === 'update' ? 'healthy' : status const healthLabel = health ? t(`shell.logoStatus.${health}`) : null const hint = updateAvailable && latest ? t('shell.account.updateAvailable', { version: displayVersion(latest) }) : null const full = [label, healthLabel, hint].filter(Boolean).join('. ') return ( {health ? (