mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-22 03:04:03 +00:00
Surface platform identity for agent-only Proxmox VE hosts
Standalone hosts on the Infrastructure surface were rendering Proxmox
VE nodes as their broader OS family. Pi/delly/minipc all showed
"debian 9.1.9" instead of "Proxmox VE 9.1.9" because
connectionAgentHostProfileLabel preferred agent.platform over
agent.osName when no explicit hostProfile was reported. The agent
correctly carries the platform identity in osName but the broader
family ("debian", "raspbian") was winning the display.
Reverse the preference so osName takes priority, falling back to the
prettified platform family only when osName is absent. The canonical
badge presentation already handled this correctly for the resource
list; this change brings the connection-table summary into agreement.
Add unit coverage for the Proxmox VE, Unraid, fallback, and absent
identity cases inside ConnectionsTable.test.tsx.
This commit is contained in:
@@ -2,7 +2,8 @@ import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
|
|||||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||||
import { ConnectionsTable } from '../ConnectionsTable';
|
import { ConnectionsTable } from '../ConnectionsTable';
|
||||||
import type { InfrastructureSystemRow } from '../connectionsTableModel';
|
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';
|
import type { ConnectionRowActions } from '../useConnectionRowActions';
|
||||||
|
|
||||||
const connectionFixture = (overrides: Partial<Connection> = {}): Connection => ({
|
const connectionFixture = (overrides: Partial<Connection> = {}): Connection => ({
|
||||||
@@ -266,3 +267,50 @@ describe('ConnectionsTable', () => {
|
|||||||
expect(screen.queryByRole('button', { name: 'Remove' })).toBeNull();
|
expect(screen.queryByRole('button', { name: 'Remove' })).toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('connectionAgentIdentitySummary', () => {
|
||||||
|
const withAgentIdentity = (
|
||||||
|
agentIdentity: Partial<ConnectionAgentIdentity> | 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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -60,7 +60,12 @@ const connectionAgentHostProfileLabel = (
|
|||||||
if (hostProfile) {
|
if (hostProfile) {
|
||||||
return getAgentHostProfileFamily(hostProfile) ?? prettifyPlatform(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);
|
const isIPv4Literal = (value: string): boolean => /^\d{1,3}(?:\.\d{1,3}){3}$/.test(value);
|
||||||
|
|||||||
Reference in New Issue
Block a user