Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Order Discovery tab facts by actionability before the cap
rcourtmanbbd9f9d0e51e
diff --git a/frontend-modern/src/components/Discovery/DiscoveryTab.tsx b/frontend-modern/src/components/Discovery/DiscoveryTab.tsxindex ad20728d21..9a26f106d4 100644--- a/frontend-modern/src/components/Discovery/DiscoveryTab.tsx+++ b/frontend-modern/src/components/Discovery/DiscoveryTab.tsx@@ -32,6 +32,7 @@ import {DISCOVERY_ANALYSIS_REASONING_LABEL,} from '@/utils/resourceAnalysisPresentation';import { useDiscoveryTabState } from './useDiscoveryTabState';+import { orderFactsByActionability } from './factOrdering';interface DiscoveryTabProps {resourceType: ResourceType;@@ -982,7 +983,7 @@ export const DiscoveryTab: Component<DiscoveryTabProps> = (props) => {<DiscoveryProvenanceMarker showLabel={false} /></div><div class="space-y-1.5">- <For each={d().facts.slice(0, 8)}>+ <For each={orderFactsByActionability(d().facts).slice(0, 8)}>{(fact) => (<div class="flex items-center justify-between gap-2 text-xs"><span class="min-w-0 text-muted truncate">{fact.key}</span>diff --git a/frontend-modern/src/components/Discovery/__tests__/factOrdering.test.ts b/frontend-modern/src/components/Discovery/__tests__/factOrdering.test.tsnew file mode 100644index 0000000000..a18e5b07f8--- /dev/null+++ b/frontend-modern/src/components/Discovery/__tests__/factOrdering.test.ts@@ -0,0 +1,49 @@+import { describe, it, expect } from 'vitest';+import { orderFactsByActionability } from '../factOrdering';+import type { DiscoveryFact } from '@/types/discovery';++const fact = (category: string, key: string): DiscoveryFact => ({+ category: category as DiscoveryFact['category'],+ key,+ value: key,+ source: 'test',+ confidence: 0.9,+ discovered_at: '2026-01-01T00:00:00Z',+});++describe('orderFactsByActionability', () => {+ it('orders the most actionable categories first', () => {+ const ordered = orderFactsByActionability([+ fact('version', 'v'),+ fact('storage', 's'),+ fact('service', 'restart'),+ fact('hardware', 'gpu'),+ ]);+ expect(ordered.map((f) => f.category)).toEqual(['service', 'hardware', 'version', 'storage']);+ });++ it('keeps a trailing service-control fact within the first 8 of many', () => {+ const facts: DiscoveryFact[] = [];+ for (let i = 0; i < 10; i += 1) facts.push(fact('version', `v${i}`));+ facts.push(fact('service', 'restart')); // 11th — dropped by a naive slice(0, 8)++ const top8 = orderFactsByActionability(facts).slice(0, 8);+ expect(top8.some((f) => f.key === 'restart')).toBe(true);+ });++ it('is stable within a category (preserves analyzer order)', () => {+ const ordered = orderFactsByActionability([+ fact('version', 'a'),+ fact('version', 'b'),+ fact('version', 'c'),+ ]);+ expect(ordered.map((f) => f.key)).toEqual(['a', 'b', 'c']);+ });++ it('does not mutate the input', () => {+ const input = [fact('version', 'v'), fact('service', 's')];+ const snapshot = input.map((f) => f.key);+ orderFactsByActionability(input);+ expect(input.map((f) => f.key)).toEqual(snapshot);+ });+});diff --git a/frontend-modern/src/components/Discovery/factOrdering.ts b/frontend-modern/src/components/Discovery/factOrdering.tsnew file mode 100644index 0000000000..7ac1d51945--- /dev/null+++ b/frontend-modern/src/components/Discovery/factOrdering.ts@@ -0,0 +1,30 @@+import type { DiscoveryFact } from '@/types/discovery';++// Mirror the backend context-pack ranking (servicediscovery filterImportantFacts):+// the human Discovery tab shows a capped subset of discovered facts, so the most+// actionable ones — how to restart (service), auth (security), what it depends+// on — must be ordered first and never dropped by the cap in favour of a purely+// informational fact (e.g. a version string).+const CATEGORY_RANK: Record<string, number> = {+ service: 0, // how to restart/reload — most actionable+ security: 1, // auth/access+ dependency: 2, // what it connects to+ hardware: 3, // GPU/TPU+ version: 4, // version info+ storage: 5, // backing dataset/disk+};++const rankOf = (category?: string): number =>+ category !== undefined && category in CATEGORY_RANK ? CATEGORY_RANK[category] : 6;++/**+ * Stable-sort facts by actionability (service > security > dependency > hardware+ * > version > storage > other), preserving the analyzer's within-category order.+ * Does not mutate the input.+ */+export function orderFactsByActionability(facts: DiscoveryFact[]): DiscoveryFact[] {+ return facts+ .map((fact, index) => ({ fact, index }))+ .sort((a, b) => rankOf(a.fact.category) - rankOf(b.fact.category) || a.index - b.index)+ .map((entry) => entry.fact);+}