diff --git a/frontend-modern/src/components/Settings/__tests__/ConnectionsTable.test.tsx b/frontend-modern/src/components/Settings/__tests__/ConnectionsTable.test.tsx index c1edc6176..202d2f8c6 100644 --- a/frontend-modern/src/components/Settings/__tests__/ConnectionsTable.test.tsx +++ b/frontend-modern/src/components/Settings/__tests__/ConnectionsTable.test.tsx @@ -2,7 +2,8 @@ import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library'; import { afterEach, describe, expect, it, vi } from 'vitest'; import { ConnectionsTable } from '../ConnectionsTable'; import type { InfrastructureSystemRow } from '../connectionsTableModel'; -import type { Connection } from '@/api/connections'; +import { connectionAgentIdentitySummary } from '../connectionsTableModel'; +import type { Connection, ConnectionAgentIdentity } from '@/api/connections'; import type { ConnectionRowActions } from '../useConnectionRowActions'; const connectionFixture = (overrides: Partial = {}): Connection => ({ @@ -266,3 +267,50 @@ describe('ConnectionsTable', () => { expect(screen.queryByRole('button', { name: 'Remove' })).toBeNull(); }); }); + +describe('connectionAgentIdentitySummary', () => { + const withAgentIdentity = ( + agentIdentity: Partial | undefined, + ): Connection => + connectionFixture({ agentIdentity: agentIdentity as ConnectionAgentIdentity | undefined }); + + it('uses osName platform identity over the broader agent platform family', () => { + // Pi/delly/minipc shape: agent reports platform="debian"/"raspbian" because + // Proxmox VE is Debian-based, but osName carries the canonical identity. + // Display must surface the platform identity, not the OS family. + const summary = connectionAgentIdentitySummary( + withAgentIdentity({ + platform: 'debian', + osName: 'Proxmox VE', + osVersion: '9.1.9', + }), + ); + expect(summary).toBe('Proxmox VE 9.1.9'); + }); + + it('uses Unraid osName over Linux platform family', () => { + const summary = connectionAgentIdentitySummary( + withAgentIdentity({ + platform: 'linux', + osName: 'Unraid', + osVersion: '7.2.2', + }), + ); + expect(summary).toBe('Unraid 7.2.2'); + }); + + it('falls back to prettified platform when osName is missing', () => { + const summary = connectionAgentIdentitySummary( + withAgentIdentity({ + platform: 'linux', + osVersion: '6.1.0', + }), + ); + expect(summary).toBe('Linux 6.1.0'); + }); + + it('returns null when no agent identity is present', () => { + const summary = connectionAgentIdentitySummary(withAgentIdentity(undefined)); + expect(summary).toBeNull(); + }); +}); diff --git a/frontend-modern/src/components/Settings/connectionsTableModel.ts b/frontend-modern/src/components/Settings/connectionsTableModel.ts index aafd2670e..c62ee1d61 100644 --- a/frontend-modern/src/components/Settings/connectionsTableModel.ts +++ b/frontend-modern/src/components/Settings/connectionsTableModel.ts @@ -60,7 +60,12 @@ const connectionAgentHostProfileLabel = ( if (hostProfile) { return getAgentHostProfileFamily(hostProfile) ?? prettifyPlatform(hostProfile); } - return prettifyPlatform(identity?.platform ?? identity?.osName); + // Prefer osName over platform: osName carries the specific platform identity + // ("Proxmox VE", "Unraid", "TrueNAS SCALE") while platform is the broader OS + // family ("debian", "linux") that loses that identity on display. + const osName = identity?.osName?.trim(); + const platform = identity?.platform?.trim(); + return prettifyPlatform(osName || platform); }; const isIPv4Literal = (value: string): boolean => /^\d{1,3}(?:\.\d{1,3}){3}$/.test(value);