SPB Git

Repository Public

util.ts 1.1 KB 20 lines typescript

1import type { ClusterNode, Health } from '@cr/shared';23/** Stale telemetry is never presented as a live state. */4export const effectiveHealth = (n: Pick<ClusterNode, 'health' | 'stale' | 'metricsAt'>): Health => (n.stale ? 'UNKNOWN' : n.health);5export const memPct = (n: ClusterNode): number | null => (n.memUsedMb != null && n.memoryMb ? (n.memUsedMb / n.memoryMb) * 100 : null);67export type Tier = 'gateway' | 'studio' | 'mini' | 'laptop' | 'mobile' | 'other';8export const TIER_ORDER: readonly Tier[] = ['gateway', 'studio', 'mini', 'laptop', 'mobile', 'other'];9export const TIER_LABEL: Record<Tier, string> = { gateway: 'Gateways and servers', studio: 'Mac Studio', mini: 'Mac mini', laptop: 'Laptops', mobile: 'Mobile', other: 'Other' };10export function tierOf(n: ClusterNode): Tier {11  if (n.kind === 'server' || /gateway/i.test(n.role ?? '')) return 'gateway';12  if (n.kind === 'mobile') return 'mobile';13  if (n.kind !== 'mac') return 'other';14  const m = n.model ?? '';15  if (/studio|pro\b(?!.*book)/i.test(m) && !/book/i.test(m)) return 'studio';16  if (/mini/i.test(m)) return 'mini';17  if (/book/i.test(m)) return 'laptop';18  return 'other';19}20
Files main
Menu

Theme