Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Group attached agents under owning sources

rcourtman5b79a80e1a82
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 4d7a1afcd4..58e2c53dd2 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -227,6 +227,7 @@ an add-only capacity posture.
9. Add or change profile management, the extracted agent profiles runtime owner, the infrastructure source-manager landing, the pure unified-agent inventory/install model, the connections-ledger workspace shell, the unified ConnectionEditor and its per-type credential slots, route model, shared install section owner, the shared direct-node/discovery infrastructure settings owners plus their model, shared frontend install-command assembly, Proxmox setup/install API transport, TrueNAS platform-connection management, VMware platform-connection management, the shared monitored-system admission preview shell for those platform connections, setup-completion install handoff transport, deploy-fallback manual install transport, and fleet-control presentation through `frontend-modern/src/api/agentProfiles.ts`, `frontend-modern/src/api/nodes.ts`, `frontend-modern/src/components/Settings/AgentProfilesPanel.tsx`, `frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts`, `frontend-modern/src/components/Settings/ConnectionsTable.tsx`, `frontend-modern/src/components/Settings/connectionsTableModel.ts`, `frontend-modern/src/components/Settings/useConnectionsLedger.ts`, `frontend-modern/src/components/Settings/useConnectionRowActions.ts`, `frontend-modern/src/components/Settings/ConnectionEditor/ConnectionEditor.tsx`, `frontend-modern/src/components/Settings/ConnectionEditor/AddressProbeStep.tsx`, `frontend-modern/src/components/Settings/ConnectionEditor/useConnectionEditor.ts`, `frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/NodeCredentialSlot.tsx`, `frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/TrueNASCredentialSlot.tsx`, `frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/VMwareCredentialSlot.tsx`, `frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx`, `frontend-modern/src/components/Settings/InfrastructureInstallerSection.tsx`, `frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx`, `frontend-modern/src/components/Settings/InfrastructureSourceManager.tsx`, `frontend-modern/src/components/Settings/infrastructureWorkspaceModel.ts`, `frontend-modern/src/components/Settings/MonitoredSystemAdmissionPreview.tsx`, `frontend-modern/src/components/Settings/platformConnectionsModel.ts`, `frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts`, `frontend-modern/src/components/Settings/useVMwareSettingsPanelState.ts`, `frontend-modern/src/components/Settings/proxmoxSettingsModel.ts`, `frontend-modern/src/components/Settings/ConfiguredNodeTables.tsx`, `frontend-modern/src/components/Settings/SettingsSectionNav.tsx`, `frontend-modern/src/components/Settings/infrastructureSettingsModel.ts`, `frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts`, `frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts`, `frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx`, `frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx`, `frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts`, `frontend-modern/src/components/Settings/nodeModalModel.ts`, `frontend-modern/src/components/Settings/useNodeModalState.ts`, `frontend-modern/src/components/SetupWizard/SetupCompletionPanel.tsx`, and `frontend-modern/src/utils/agentInstallCommand.ts`. Phase 9 retired the legacy reporting/inventory surface (InfrastructureOperationsController, InfrastructureInventorySection, InfrastructureActiveRowDetails, InfrastructureIgnoredRowDetails, InfrastructureStopMonitoringDialog, useInfrastructureReportingState) and the per-type shells (PlatformConnectionsWorkspace, ProxmoxSettingsPanel, ProxmoxDirectWorkspace, ProxmoxConfiguredNodesTable, ProxmoxDirectConnectionsCard, ProxmoxDiscoveryResultsCard, ProxmoxDeleteNodeDialog, ProxmoxNodeModalStack, NodeModal shell, TrueNASSettingsPanel, VMwareSettingsPanel, useProxmoxDirectWorkspaceState); lifecycle extensions must route through the unified aggregator ledger, source-manager cards, and ConnectionEditor credential slots rather than reintroducing those retired surfaces.
Those lifecycle-owned settings hooks may consume websocket state only through `frontend-modern/src/contexts/appRuntime.ts`; they must not import `frontend-modern/src/App.tsx` or recreate root-shell providers.
Discovery configuration is part of that same lifecycle-owned workspace boundary. `InfrastructureSourceManager.tsx` must open one canonical discovery editor through `InfrastructureDiscoverySettingsDialog.tsx`, `DiscoverySettingsForm.tsx`, and `discoverySettingsModel.ts`, while the System/Network shell stays limited to network-boundary controls instead of reintroducing a second editable discovery surface.
+ The same lifecycle-owned workspace boundary now also owns attached-agent composition. When a unified Pulse Agent augments a first-class platform source such as Proxmox VE, the source manager and edit dialog must present one primary platform row with explicit `API` plus `Pulse Agent` composition rather than duplicating that same machine as a second peer row under the generic Pulse Agent group. Standalone hosts with no owning platform source remain in the Pulse Agent group.
Public demo and other read-only settings posture must stay reporting-first
on that same lifecycle-owned workspace boundary: infrastructure workspace
routes may retain install and platform setup surfaces for manageable
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index f884e4e5b3..fd6b730ab4 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -414,7 +414,13 @@ the canonical monitored-system blocked payload.
must also validate user-supplied addresses before probing, reject metadata,
link-local, multicast, and unspecified destinations, and pin each outbound
dial to the first permitted resolved IP so DNS rebinding cannot swap the
- target between validation and connect time.
+ target between validation and connect time. That same `/api/connections`
+ payload now also owns the additive `systems[]` grouping contract for the
+ infrastructure settings source manager. Those grouped rows must stay
+ source-oriented and backend-authored: one primary source row may carry
+ attached collection methods such as a linked Pulse Agent, but attached
+ methods must not be emitted as duplicate peer rows when backend ownership
+ can prove they augment the same source.
## Forbidden Paths
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 972b8905c0..95da1a192d 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -253,6 +253,12 @@ work extends shared components instead of creating new local variants.
`InfrastructureWorkspace.tsx` and `ConnectionEditor.tsx` keep the add/edit
shell on `min-h-0` flex columns so long credential forms scroll inside the
modal body instead of trapping the lower fields below the fold.
+ The same shared shell boundary now also owns grouped source-row composition.
+ `useConnectionsLedger.ts`, `InfrastructureSourceManager.tsx`, and
+ `InfrastructureWorkspace.tsx` must render attached collection methods as
+ composition on the owning row, with explicit badges and edit-dialog detail,
+ instead of duplicating the same machine across multiple peer groups and
+ forcing operators to infer the relationship visually.
That same shared shell boundary now owns one canonical infrastructure
destination in the Settings sidebar. `InfrastructureWorkspace.tsx` owns the
source-manager landing inside that destination, while route-backed add flows
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 8c293ed28a..380bcbcf99 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -233,6 +233,13 @@ querying, and the operator-facing storage health presentation layer.
as a storage install prerequisite, provider-connection error, or
recovery-capability verdict.
21. Keep provider-backed recovery onboarding on the adjacent platform-connections contract. When `internal/api/` grows or changes TrueNAS connection CRUD, masked-secret preservation, saved-connection retest routes, edit-form saved-test payload overlays, or similar provider setup flows, storage and recovery may consume the resulting recovery points but must not absorb that connection-management ownership into storage/recovery-local handlers or page flows. That same adjacency also covers per-surface scope as it flows through the unified connections aggregator: when `internal/api/connections_aggregator.go` projects TrueNAS `MonitorDatasets`/`MonitorPools`/`MonitorReplication` flags into the aggregator's `scope` map, storage and recovery may observe that projection to explain dataset/pool/replication coverage to operators but must not reinterpret those flags as a recovery freshness verdict, restore-capability gate, or storage-local scope registry.
+ That same adjacent platform-connections boundary now also owns
+ source-oriented `systems[]` grouping on `/api/connections`. Storage and
+ recovery may observe grouped source composition to explain whether a
+ platform row is collecting additional host telemetry through Pulse Agent,
+ but they must not reinterpret attached agents as separate protected
+ systems, duplicate recovery inventory rows, or a storage-local ownership
+ taxonomy.
22. Keep backend-native platform actions on the adjacent AI/runtime and platform contracts. When `internal/api/` wires native TrueNAS app control for Assistant, storage and recovery may consume the refreshed recovery points afterward, but they must not grow a parallel recovery-local action transport or action-specific payload shape.
23. Keep backend-native platform diagnostics on the adjacent AI/runtime and platform contracts. When `internal/api/` wires native TrueNAS app log reads for Assistant, storage and recovery may use those diagnostics during investigation, but they must not grow a parallel recovery-local log transport or diagnostic payload shape.
24. Keep backend-native platform configuration reads on the adjacent AI/runtime and platform contracts. When `internal/api/` wires native TrueNAS app config for Assistant, storage and recovery may use that runtime shape during investigation, but they must not grow a parallel recovery-local config transport or provider-shaped configuration payload.
diff --git a/frontend-modern/src/api/__tests__/connections.test.ts b/frontend-modern/src/api/__tests__/connections.test.ts
index a6d1c225c7..50a194f738 100644
--- a/frontend-modern/src/api/__tests__/connections.test.ts
+++ b/frontend-modern/src/api/__tests__/connections.test.ts
@@ -13,7 +13,7 @@ describe('ConnectionsAPI', () => {
vi.clearAllMocks();
});
- it('list() calls GET /api/connections and returns the connections array', async () => {
+ it('list() calls GET /api/connections and returns the canonical ledger envelope', async () => {
const connections: Connection[] = [
{
id: 'pve-lab',
@@ -36,15 +36,15 @@ describe('ConnectionsAPI', () => {
const result = await ConnectionsAPI.list();
expect(mockedApiFetchJSON).toHaveBeenCalledWith('/api/connections');
- expect(result).toEqual(connections);
+ expect(result).toEqual({ connections, systems: [] });
});
- it('list() returns [] when the backend omits the connections field', async () => {
+ it('list() normalizes missing fields to empty collections', async () => {
mockedApiFetchJSON.mockResolvedValueOnce({} as { connections?: Connection[] });
const result = await ConnectionsAPI.list();
- expect(result).toEqual([]);
+ expect(result).toEqual({ connections: [], systems: [] });
});
it('probe() POSTs the address JSON and returns the candidates envelope', async () => {
diff --git a/frontend-modern/src/api/connections.ts b/frontend-modern/src/api/connections.ts
index 019b3df879..68d4c8f73a 100644
--- a/frontend-modern/src/api/connections.ts
+++ b/frontend-modern/src/api/connections.ts
@@ -48,8 +48,23 @@ export interface Connection {
capabilities: ConnectionCapabilities;
}
+export type ConnectionSystemComponentRole = 'primary' | 'attachment';
+
+export interface ConnectionSystemComponent {
+ connectionId: string;
+ type: ConnectionType;
+ role: ConnectionSystemComponentRole;
+}
+
+export interface ConnectionSystem {
+ id: string;
+ type: ConnectionType;
+ components: ConnectionSystemComponent[];
+}
+
export interface ConnectionsListResponse {
connections: Connection[];
+ systems?: ConnectionSystem[];
}
export interface ProbeRequest {
@@ -71,9 +86,12 @@ export interface ProbeResponse {
export class ConnectionsAPI {
private static readonly baseUrl = '/api/connections';
- static async list(): Promise<Connection[]> {
+ static async list(): Promise<ConnectionsListResponse> {
const response: ConnectionsListResponse = await apiFetchJSON(this.baseUrl);
- return response.connections ?? [];
+ return {
+ connections: response.connections ?? [],
+ systems: response.systems ?? [],
+ };
}
static async probe(address: string): Promise<ProbeResponse> {
diff --git a/frontend-modern/src/components/Settings/InfrastructureSourceManager.tsx b/frontend-modern/src/components/Settings/InfrastructureSourceManager.tsx
index 746de47d21..5cfffabf55 100644
--- a/frontend-modern/src/components/Settings/InfrastructureSourceManager.tsx
+++ b/frontend-modern/src/components/Settings/InfrastructureSourceManager.tsx
@@ -1,6 +1,5 @@
import { For, Show, createMemo, type Accessor, type Component } from 'solid-js';
import { Plus, RotateCw, Search, Server, SlidersHorizontal } from 'lucide-solid';
-import type { Connection } from '@/api/connections';
import SettingsPanel from '@/components/shared/SettingsPanel';
import {
Table,
@@ -28,7 +27,7 @@ interface InfrastructureSourceManagerProps {
onRunDiscovery?: () => void;
onDetectFromAddress?: () => void;
onOpenDiscoverySettings?: () => void;
- onOpenConnection?: (connection: Connection) => void;
+ onOpenConnection?: (row: InfrastructureSystemRow) => void;
onReviewDiscoveredSource?: (server: DiscoveredServer) => void;
}
@@ -111,7 +110,7 @@ export const InfrastructureSourceManager: Component<InfrastructureSourceManagerP
}
for (const row of props.rows()) {
- const productRows = next.get(row.connection.type as InfrastructureOnboardingConnectionType);
+ const productRows = next.get(row.ownerType as InfrastructureOnboardingConnectionType);
if (!productRows) continue;
productRows.push(row);
}
@@ -366,11 +365,24 @@ export const InfrastructureSourceManager: Component<InfrastructureSourceManagerP
<span class="absolute left-2 top-2.5 h-px w-3 bg-border" />
</span>
<div class="min-w-0">
- <div
- class="truncate text-[13px] text-base-content/80"
- title={row.name}
- >
- {row.name}
+ <div class="flex min-w-0 items-center gap-2">
+ <div
+ class="truncate text-[13px] text-base-content/80"
+ title={row.name}
+ >
+ {row.name}
+ </div>
+ <Show when={row.sourceBadges.length > 0}>
+ <div class="flex items-center gap-1 whitespace-nowrap">
+ <For each={row.sourceBadges}>
+ {(badge) => (
+ <span class="inline-flex items-center rounded-full border border-border bg-surface-alt px-1.5 py-0.5 text-[10px] font-medium text-muted">
+ {badge}
+ </span>
+ )}
+ </For>
+ </div>
+ </Show>
</div>
</div>
</div>
@@ -426,7 +438,7 @@ export const InfrastructureSourceManager: Component<InfrastructureSourceManagerP
>
<button
type="button"
- onClick={() => props.onOpenConnection?.(row.connection)}
+ onClick={() => props.onOpenConnection?.(row)}
class={inlineButtonClass}
>
Edit
diff --git a/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx b/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx
index 5336105745..a48dc00d12 100644
--- a/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx
+++ b/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx
@@ -19,6 +19,7 @@ import { InfrastructureDiscoverySettingsDialog } from './InfrastructureDiscovery
import { InfrastructureInstallerSection } from './InfrastructureInstallerSection';
import { InfrastructureSourceManager } from './InfrastructureSourceManager';
import { InfrastructureSourcePicker } from './InfrastructureSourcePicker';
+import { connectionLastActivityText, type InfrastructureSystemRow } from './connectionsTableModel';
import {
buildInfrastructureOnboardingPath,
buildInfrastructureWorkspacePath,
@@ -78,8 +79,9 @@ const describeManagedSourceType = (type: ConnectionType | null): string => {
type === 'pbs' ||
type === 'pmg'
) {
- return getInfrastructureOnboardingProductPresentation(type as InfrastructureOnboardingConnectionType)
- .label;
+ return getInfrastructureOnboardingProductPresentation(
+ type as InfrastructureOnboardingConnectionType,
+ ).label;
}
if (type === 'docker') return 'Docker';
if (type === 'kubernetes') return 'Kubernetes';
@@ -94,7 +96,7 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
const rowActions = useConnectionRowActions({ onMutated: () => ledger.reload() });
const [showAgentProfiles, setShowAgentProfiles] = createSignal(false);
- const [editingConnection, setEditingConnection] = createSignal<Connection | null>(null);
+ const [editingRow, setEditingRow] = createSignal<InfrastructureSystemRow | null>(null);
const [showDiscoverySettings, setShowDiscoverySettings] = createSignal(false);
const [selectedDiscoveredSource, setSelectedDiscoveredSource] =
createSignal<DiscoveredServer | null>(null);
@@ -113,6 +115,10 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
if (!step || step === 'pick' || step === 'detect') return null;
return ADD_STEP_TO_TYPE[step as ManagedAddTypeStep];
});
+ const editingConnection = createMemo<Connection | null>(() => editingRow()?.connection ?? null);
+ const attachedAgentConnections = createMemo(() =>
+ (editingRow()?.attachedConnections ?? []).filter((connection) => connection.type === 'agent'),
+ );
const findEditableNode = (connection: Connection): NodeConfigWithStatus | null => {
const accessor =
@@ -197,8 +203,11 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
if (connection) {
rowActions.cancelRemove(connection.id);
}
+ for (const attached of attachedAgentConnections()) {
+ rowActions.cancelRemove(attached.id);
+ }
resetInlineEditorState();
- setEditingConnection(null);
+ setEditingRow(null);
};
const handleAddSaved = () => {
@@ -479,6 +488,86 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
);
};
+ const renderAttachedAgentAugmentations = (connections: readonly Connection[]) => {
+ if (connections.length === 0) return null;
+
+ return (
+ <section class="space-y-4 rounded-xl border border-border bg-surface p-4">
+ <div class="space-y-1">
+ <div class="text-sm font-semibold text-base-content">Pulse Agent augmentation</div>
+ <p class="text-xs text-muted">
+ This source is also collecting local host telemetry through the Pulse Agent. You can
+ remove the agent attachment here without removing the primary platform connection.
+ </p>
+ </div>
+
+ <div class="space-y-3">
+ {connections.map((connection) => {
+ const removePending = () => rowActions.pendingAction(connection.id) === 'remove';
+ const removeConfirming = () => rowActions.confirmingRemove(connection.id);
+ const error = () => rowActions.actionError(connection.id);
+
+ return (
+ <div class="rounded-lg border border-border bg-surface-alt px-4 py-4">
+ <div class="flex flex-wrap items-start justify-between gap-4">
+ <div class="space-y-1">
+ <div class="text-sm font-medium text-base-content">{connection.name}</div>
+ <Show when={connection.address}>
+ <div class="break-words text-xs text-muted">{connection.address}</div>
+ </Show>
+ </div>
+ <div class="flex items-center gap-2">
+ <span class="inline-flex items-center rounded-full bg-green-100 px-2 py-0.5 text-[11px] font-medium text-green-800 dark:bg-green-900 dark:text-green-300">
+ {connection.state === 'active' ? 'Active' : connection.state}
+ </span>
+ <span class="text-xs text-muted">{connectionLastActivityText(connection)}</span>
+ </div>
+ </div>
+
+ <Show when={error()}>
+ {(message) => (
+ <div
+ role="alert"
+ class="mt-3 rounded-md border border-rose-300 bg-rose-50 px-3 py-2 text-xs text-rose-800 dark:border-rose-900 dark:bg-rose-950 dark:text-rose-200"
+ >
+ {message()}
+ </div>
+ )}
+ </Show>
+
+ <div class="mt-4 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end">
+ <button
+ type="button"
+ onClick={() => void handleCopy(agentUninstallCommands().linux)}
+ class={buttonClass}
+ >
+ Copy uninstall command
+ </button>
+ <button
+ type="button"
+ onClick={() => void rowActions.requestRemove(connection)}
+ disabled={removePending()}
+ class={
+ removeConfirming()
+ ? 'inline-flex min-h-10 sm:min-h-9 items-center justify-center rounded-md bg-rose-600 px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-rose-700 disabled:cursor-not-allowed disabled:opacity-60'
+ : 'inline-flex min-h-10 sm:min-h-9 items-center justify-center rounded-md border border-rose-300 px-3 py-2 text-sm font-medium text-rose-700 transition-colors hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-60 dark:border-rose-900 dark:text-rose-300 dark:hover:bg-rose-950'
+ }
+ >
+ {removePending()
+ ? 'Removing…'
+ : removeConfirming()
+ ? 'Click again to confirm'
+ : 'Remove Pulse Agent'}
+ </button>
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ </section>
+ );
+ };
+
const renderConnectionSlot = (context: {
mode: 'add' | 'edit';
type: ConnectionType;
@@ -664,11 +753,11 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
const connection = editingConnection();
if (!connection) return 'Update this source without leaving the infrastructure manager.';
const label = describeManagedSourceType(connection.type);
- return `${label}${connection.address ? ` · ${connection.address}` : ''}`;
+ const methods = attachedAgentConnections().length > 0 ? ' · API + Pulse Agent' : '';
+ return `${label}${connection.address ? ` · ${connection.address}` : ''}${methods}`;
});
- const isAgentDialog = () =>
- activeAddType() === 'agent' || editingConnection()?.type === 'agent';
+ const isAgentDialog = () => activeAddType() === 'agent' || editingConnection()?.type === 'agent';
return (
<div class="space-y-6">
@@ -691,13 +780,11 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
}
}
onDetectFromAddress={readOnly() ? undefined : () => openAddFlow('detect')}
- onOpenDiscoverySettings={
- readOnly()
- ? undefined
- : () => setShowDiscoverySettings(true)
+ onOpenDiscoverySettings={readOnly() ? undefined : () => setShowDiscoverySettings(true)}
+ onOpenConnection={readOnly() ? undefined : (row) => setEditingRow(row)}
+ onReviewDiscoveredSource={
+ readOnly() ? undefined : (server) => reviewDiscoveredSource(server)
}
- onOpenConnection={readOnly() ? undefined : (connection) => setEditingConnection(connection)}
- onReviewDiscoveredSource={readOnly() ? undefined : (server) => reviewDiscoveredSource(server)}
/>
<InfrastructureDiscoverySettingsDialog
@@ -823,16 +910,21 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
<Show
when={connection.type === 'agent'}
fallback={
- <ConnectionEditor
- mode="edit"
- initialType={connection.type}
- showSlotHeader={false}
- onClose={closeEditFlow}
- onSaved={handleEditSaved}
- renderCredentialSlot={({ type, onCancel, onSaved }) =>
- renderConnectionSlot({ mode: 'edit', type, onCancel, onSaved })
- }
- />
+ <div class="space-y-4">
+ <ConnectionEditor
+ mode="edit"
+ initialType={connection.type}
+ showSlotHeader={false}
+ onClose={closeEditFlow}
+ onSaved={handleEditSaved}
+ renderCredentialSlot={({ type, onCancel, onSaved }) =>
+ renderConnectionSlot({ mode: 'edit', type, onCancel, onSaved })
+ }
+ />
+ <Show when={attachedAgentConnections().length > 0}>
+ {renderAttachedAgentAugmentations(attachedAgentConnections())}
+ </Show>
+ </div>
}
>
{renderAgentConnectionDetails(connection)}
diff --git a/frontend-modern/src/components/Settings/__tests__/ConnectionsTable.test.tsx b/frontend-modern/src/components/Settings/__tests__/ConnectionsTable.test.tsx
index 185e2008e6..938683ac96 100644
--- a/frontend-modern/src/components/Settings/__tests__/ConnectionsTable.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/ConnectionsTable.test.tsx
@@ -26,10 +26,12 @@ const row = (overrides: Partial<InfrastructureSystemRow> = {}): InfrastructureSy
const connection = overrides.connection ?? connectionFixture();
return {
id: overrides.id ?? connection.id,
+ ownerType: overrides.ownerType ?? connection.type,
name: overrides.name ?? 'tower',
subtitle: undefined,
host: '10.0.0.1',
coverageLabels: ['Host telemetry'],
+ sourceBadges: [],
statusLabel: 'online',
statusClassName: 'bg-green-100 text-green-800',
lastActivityText: '5s ago',
@@ -39,6 +41,7 @@ const row = (overrides: Partial<InfrastructureSystemRow> = {}): InfrastructureSy
canPause: connection.capabilities.supportsPause,
canRemove: connection.type !== 'docker' && connection.type !== 'kubernetes',
isAgent: connection.type === 'agent',
+ attachedConnections: [],
connection,
...overrides,
};
@@ -61,7 +64,9 @@ describe('ConnectionsTable', () => {
render(() => <ConnectionsTable rows={() => []} />);
expect(screen.getByText('Start monitoring infrastructure')).toBeInTheDocument();
- expect(screen.getByText(/Supported today: TrueNAS SCALE/i)).toBeInTheDocument();
+ expect(
+ screen.getByText(/Source types available: VMware vCenter, TrueNAS SCALE/i),
+ ).toBeInTheDocument();
expect(screen.queryByRole('table')).toBeNull();
});
@@ -107,9 +112,7 @@ describe('ConnectionsTable', () => {
it('shows lastErrorMessage inline on the row when present', () => {
render(() => (
- <ConnectionsTable
- rows={() => [row({ lastErrorMessage: 'certificate expired' })]}
- />
+ <ConnectionsTable rows={() => [row({ lastErrorMessage: 'certificate expired' })]} />
));
expect(screen.getByText('certificate expired')).toBeInTheDocument();
@@ -118,9 +121,7 @@ describe('ConnectionsTable', () => {
it('renders Edit / Pause / Remove buttons when actions and onEdit are provided', () => {
const onEdit = vi.fn();
const actions = makeActions();
- render(() => (
- <ConnectionsTable rows={() => [row()]} actions={actions} onEdit={onEdit} />
- ));
+ render(() => <ConnectionsTable rows={() => [row()]} actions={actions} onEdit={onEdit} />);
expect(screen.getByRole('button', { name: 'Edit' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Pause' })).toBeInTheDocument();
@@ -148,11 +149,7 @@ describe('ConnectionsTable', () => {
const actions = makeActions({ togglePause });
const connection = connectionFixture();
render(() => (
- <ConnectionsTable
- rows={() => [row({ connection })]}
- actions={actions}
- onEdit={vi.fn()}
- />
+ <ConnectionsTable rows={() => [row({ connection })]} actions={actions} onEdit={vi.fn()} />
));
fireEvent.click(screen.getByRole('button', { name: 'Pause' }));
@@ -174,18 +171,14 @@ describe('ConnectionsTable', () => {
it('surfaces the row-specific actionError inside an alert', () => {
const actions = makeActions({ actionError: () => 'permission denied' });
- render(() => (
- <ConnectionsTable rows={() => [row()]} actions={actions} onEdit={vi.fn()} />
- ));
+ render(() => <ConnectionsTable rows={() => [row()]} actions={actions} onEdit={vi.fn()} />);
expect(screen.getByRole('alert')).toHaveTextContent('permission denied');
});
it('swaps the remove button into a confirming state when confirmingRemove is true', () => {
const actions = makeActions({ confirmingRemove: () => true });
- render(() => (
- <ConnectionsTable rows={() => [row()]} actions={actions} onEdit={vi.fn()} />
- ));
+ render(() => <ConnectionsTable rows={() => [row()]} actions={actions} onEdit={vi.fn()} />);
expect(screen.getByRole('button', { name: /Click again to confirm/i })).toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Remove' })).toBeNull();
@@ -207,7 +200,9 @@ describe('ConnectionsTable', () => {
));
expect(screen.getByText(/history is retained/i)).toBeInTheDocument();
- expect(screen.getByText(/Credentials on the platform itself are untouched/i)).toBeInTheDocument();
+ expect(
+ screen.getByText(/Credentials on the platform itself are untouched/i),
+ ).toBeInTheDocument();
// No uninstall block for Platform API rows — only agents get that courtesy.
expect(screen.queryByText(/--uninstall/)).toBeNull();
});
@@ -233,7 +228,8 @@ describe('ConnectionsTable', () => {
onEdit={vi.fn()}
agentUninstallCommands={{
linux: 'curl -fsSL http://pulse/install.sh | bash -s -- --uninstall',
- windows: '$env:PULSE_URL="http://pulse"; $env:PULSE_UNINSTALL="true"; iwr /install.ps1 | iex',
+ windows:
+ '$env:PULSE_URL="http://pulse"; $env:PULSE_UNINSTALL="true"; iwr /install.ps1 | iex',
}}
/>
));
@@ -242,9 +238,7 @@ describe('ConnectionsTable', () => {
expect(
screen.getByText(/curl -fsSL http:\/\/pulse\/install\.sh \| bash -s -- --uninstall/),
).toBeInTheDocument();
- expect(
- screen.getByText(/\$env:PULSE_UNINSTALL="true"/),
- ).toBeInTheDocument();
+ expect(screen.getByText(/\$env:PULSE_UNINSTALL="true"/)).toBeInTheDocument();
});
it('does not render action buttons when the row model forbids them', () => {
diff --git a/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx b/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
index 41296d9819..eb29736e5c 100644
--- a/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
@@ -1,6 +1,7 @@
import { cleanup, fireEvent, render, screen, waitFor, within } from '@solidjs/testing-library';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { Connection } from '@/api/connections';
+import type { InfrastructureSystemRow } from '../connectionsTableModel';
import { InfrastructureWorkspace } from '../InfrastructureWorkspace';
const routeState = vi.hoisted(() => ({
@@ -9,6 +10,7 @@ const routeState = vi.hoisted(() => ({
}));
const connectionState = vi.hoisted(() => ({
connections: [] as Connection[],
+ rows: null as InfrastructureSystemRow[] | null,
}));
const navigateSpy = vi.hoisted(() => vi.fn());
const presentationPolicyIsReadOnlyMock = vi.hoisted(() => vi.fn(() => false));
@@ -62,8 +64,10 @@ vi.mock('../useConnectionsLedger', () => ({
useConnectionsLedger: () => ({
connections: () => connectionState.connections,
rows: () =>
+ connectionState.rows ??
connectionState.connections.map((connection) => ({
id: connection.id,
+ ownerType: connection.type,
name: connection.name || connection.id,
subtitle:
connection.type === 'agent'
@@ -71,6 +75,7 @@ vi.mock('../useConnectionsLedger', () => ({
: `Platform API · ${connection.type === 'truenas' ? 'TrueNAS SCALE' : connection.type}`,
host: connection.address,
coverageLabels: ['VMs'],
+ sourceBadges: connection.type === 'agent' ? ['Pulse Agent'] : ['API'],
statusLabel: connection.state === 'paused' ? 'Paused' : 'Active',
statusClassName: 'bg-green-100 text-green-800',
lastActivityText: '1m ago',
@@ -80,6 +85,7 @@ vi.mock('../useConnectionsLedger', () => ({
canPause: connection.capabilities.supportsPause,
canRemove: connection.type !== 'docker' && connection.type !== 'kubernetes',
isAgent: connection.type === 'agent',
+ attachedConnections: [],
connection,
})),
findById: (id: string) =>
@@ -220,6 +226,7 @@ describe('InfrastructureWorkspace', () => {
routeState.pathname = '/settings/infrastructure';
routeState.search = '';
connectionState.connections = [connectionFixture()];
+ connectionState.rows = null;
});
afterEach(() => {
@@ -232,9 +239,7 @@ describe('InfrastructureWorkspace', () => {
it('renders the instance-first source manager as the only landing surface', async () => {
renderWorkspace();
- await waitFor(() =>
- expect(screen.getByText('Infrastructure sources')).toBeInTheDocument(),
- );
+ await waitFor(() => expect(screen.getByText('Infrastructure sources')).toBeInTheDocument());
expect(screen.getByRole('button', { name: /Run discovery/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /Discovery settings/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /Detect from address/i })).toBeInTheDocument();
@@ -262,9 +267,7 @@ describe('InfrastructureWorkspace', () => {
triggerDiscoveryScan,
});
- await waitFor(() =>
- expect(screen.getByText('discovered-pve.lab')).toBeInTheDocument(),
- );
+ await waitFor(() => expect(screen.getByText('discovered-pve.lab')).toBeInTheDocument());
expect(screen.getByText('Discovered')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: /Run discovery/i }));
@@ -323,7 +326,9 @@ describe('InfrastructureWorkspace', () => {
renderWorkspace();
await waitFor(() => expect(screen.getByRole('dialog')).toBeInTheDocument());
- fireEvent.click(within(screen.getByRole('dialog')).getByRole('button', { name: 'Detect from address' }));
+ fireEvent.click(
+ within(screen.getByRole('dialog')).getByRole('button', { name: 'Detect from address' }),
+ );
expect(navigateSpy).toHaveBeenCalledWith('/settings/infrastructure?add=detect', {
scroll: false,
@@ -335,7 +340,9 @@ describe('InfrastructureWorkspace', () => {
renderWorkspace();
await waitFor(() => expect(screen.getByRole('dialog')).toBeInTheDocument());
- fireEvent.click(within(screen.getByRole('dialog')).getByRole('button', { name: /TrueNAS SCALE/i }));
+ fireEvent.click(
+ within(screen.getByRole('dialog')).getByRole('button', { name: /TrueNAS SCALE/i }),
+ );
expect(navigateSpy).toHaveBeenCalledWith('/settings/infrastructure?add=truenas', {
scroll: false,
@@ -354,8 +361,12 @@ describe('InfrastructureWorkspace', () => {
),
).toBeInTheDocument();
expect(screen.getAllByText('Detect from address').length).toBeGreaterThan(0);
- expect(within(screen.getByRole('dialog')).getByRole('button', { name: /Back to source types/i })).toBeInTheDocument();
- expect(within(screen.getByRole('dialog')).getByRole('button', { name: /Probe address/i })).toBeInTheDocument();
+ expect(
+ within(screen.getByRole('dialog')).getByRole('button', { name: /Back to source types/i }),
+ ).toBeInTheDocument();
+ expect(
+ within(screen.getByRole('dialog')).getByRole('button', { name: /Probe address/i }),
+ ).toBeInTheDocument();
});
it('renders the route-backed agent dialog when the agent query is present', async () => {
@@ -382,7 +393,9 @@ describe('InfrastructureWorkspace', () => {
pveNodes: () => [{ name: 'zeus', host: 'https://10.0.0.1:8006' } as any],
});
- await waitFor(() => expect(screen.getByRole('button', { name: /^Edit$/i })).toBeInTheDocument());
+ await waitFor(() =>
+ expect(screen.getByRole('button', { name: /^Edit$/i })).toBeInTheDocument(),
+ );
fireEvent.click(screen.getByRole('button', { name: /^Edit$/i }));
await waitFor(() => expect(screen.getByRole('dialog')).toBeInTheDocument());
@@ -390,6 +403,57 @@ describe('InfrastructureWorkspace', () => {
expect(screen.getByTestId('proxmox-section')).toBeInTheDocument();
});
+ it('shows attached Pulse Agent augmentation details on a grouped platform source', async () => {
+ const primaryConnection = connectionFixture();
+ const attachedAgent = connectionFixture({
+ id: 'agent:zeus',
+ type: 'agent',
+ name: 'zeus-agent',
+ address: 'zeus.lab',
+ surfaces: ['host'],
+ scope: { host: true } as any,
+ lastSeen: new Date().toISOString(),
+ capabilities: { supportsPause: true, supportsScope: true, supportsTest: true },
+ });
+
+ connectionState.connections = [primaryConnection, attachedAgent];
+ connectionState.rows = [
+ {
+ id: primaryConnection.id,
+ ownerType: 'pve',
+ name: primaryConnection.name || primaryConnection.id,
+ subtitle: 'Platform API · pve',
+ host: primaryConnection.address,
+ coverageLabels: ['VMs', 'Host telemetry'],
+ sourceBadges: ['API', 'Pulse Agent'],
+ statusLabel: 'Active',
+ statusClassName: 'bg-green-100 text-green-800',
+ lastActivityText: '1m ago',
+ enabled: true,
+ canEdit: true,
+ canPause: true,
+ canRemove: true,
+ isAgent: false,
+ attachedConnections: [attachedAgent],
+ connection: primaryConnection,
+ },
+ ];
+
+ renderWorkspace({
+ pveNodes: () => [{ name: 'zeus', host: 'https://10.0.0.1:8006' } as any],
+ });
+
+ await waitFor(() =>
+ expect(screen.getByRole('button', { name: /^Edit$/i })).toBeInTheDocument(),
+ );
+ fireEvent.click(screen.getByRole('button', { name: /^Edit$/i }));
+
+ await waitFor(() => expect(screen.getByRole('dialog')).toBeInTheDocument());
+ expect(screen.getByText('Pulse Agent augmentation')).toBeInTheDocument();
+ expect(screen.getByText('zeus-agent')).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: /Copy uninstall command/i })).toBeInTheDocument();
+ });
+
it('hides the add flow and source-manager actions in read-only mode', () => {
presentationPolicyIsReadOnlyMock.mockReturnValue(true);
routeState.search = '?add=agent';
diff --git a/frontend-modern/src/components/Settings/connectionsTableModel.ts b/frontend-modern/src/components/Settings/connectionsTableModel.ts
index 96c93516bb..e9cb628e72 100644
--- a/frontend-modern/src/components/Settings/connectionsTableModel.ts
+++ b/frontend-modern/src/components/Settings/connectionsTableModel.ts
@@ -1,11 +1,29 @@
import type { Connection } from '@/api/connections';
+import type { ConnectionType } from '@/api/connections';
+
+export const connectionLastActivityText = (connection: Connection): string => {
+ if (!connection.lastSeen) return 'No activity yet';
+ const ts = Date.parse(connection.lastSeen);
+ if (Number.isNaN(ts)) return 'Unknown';
+ const diff = Math.max(0, Date.now() - ts);
+ const sec = Math.floor(diff / 1000);
+ if (sec < 60) return `${sec}s ago`;
+ const min = Math.floor(sec / 60);
+ if (min < 60) return `${min}m ago`;
+ const hr = Math.floor(min / 60);
+ if (hr < 24) return `${hr}h ago`;
+ const days = Math.floor(hr / 24);
+ return `${days}d ago`;
+};
export interface InfrastructureSystemRow {
id: string;
+ ownerType: ConnectionType;
name: string;
subtitle?: string;
host?: string;
coverageLabels: string[];
+ sourceBadges: string[];
statusLabel: string;
statusClassName: string;
lastActivityText: string;
@@ -15,5 +33,6 @@ export interface InfrastructureSystemRow {
canPause: boolean;
canRemove: boolean;
isAgent: boolean;
+ attachedConnections: Connection[];
connection: Connection;
}
diff --git a/frontend-modern/src/components/Settings/useConnectionsLedger.ts b/frontend-modern/src/components/Settings/useConnectionsLedger.ts
index ab133fcfd4..52dc51c4ef 100644
--- a/frontend-modern/src/components/Settings/useConnectionsLedger.ts
+++ b/frontend-modern/src/components/Settings/useConnectionsLedger.ts
@@ -3,9 +3,10 @@ import {
ConnectionsAPI,
type Connection,
type ConnectionState,
+ type ConnectionSystem,
type ConnectionType,
} from '@/api/connections';
-import type { InfrastructureSystemRow } from './connectionsTableModel';
+import { connectionLastActivityText, type InfrastructureSystemRow } from './connectionsTableModel';
const POLL_INTERVAL_MS = 15000;
@@ -61,7 +62,7 @@ const SURFACE_LABELS: Record<string, string> = {
queues: 'Queues',
quarantine: 'Quarantine',
domainStats: 'Domain stats',
- host: 'Host',
+ host: 'Host telemetry',
hosts: 'Hosts',
datasets: 'Datasets',
pools: 'Pools',
@@ -70,11 +71,6 @@ const SURFACE_LABELS: Record<string, string> = {
export const surfaceLabel = (key: string): string => SURFACE_LABELS[key] ?? key;
-// The ledger subtitle speaks the explainer's vocabulary so the user reads the
-// same "Platform API vs Pulse Unified Agent" split here that the explainer
-// card above just taught them. API-backed types get a "Platform API · {product}"
-// prefix; agent/docker/k8s rows use the product label alone (the product name
-// already carries the source — "Pulse Unified Agent" / "Docker" / "Kubernetes").
const PLATFORM_API_TYPES: ReadonlySet<ConnectionType> = new Set([
'pve',
'pbs',
@@ -83,29 +79,6 @@ const PLATFORM_API_TYPES: ReadonlySet<ConnectionType> = new Set([
'truenas',
]);
-const lastActivityText = (connection: Connection): string => {
- if (!connection.lastSeen) return 'No activity yet';
- const ts = Date.parse(connection.lastSeen);
- if (Number.isNaN(ts)) return 'Unknown';
- const diff = Math.max(0, Date.now() - ts);
- const sec = Math.floor(diff / 1000);
- if (sec < 60) return `${sec}s ago`;
- const min = Math.floor(sec / 60);
- if (min < 60) return `${min}m ago`;
- const hr = Math.floor(min / 60);
- if (hr < 24) return `${hr}h ago`;
- const days = Math.floor(hr / 24);
- return `${days}d ago`;
-};
-
-const subtitleFor = (connection: Connection): string | undefined => {
- if (connection.stateReason) return connection.stateReason;
- const productLabel = CONNECTION_TYPE_LABELS[connection.type] ?? connection.type;
- return PLATFORM_API_TYPES.has(connection.type)
- ? `Platform API · ${productLabel}`
- : productLabel;
-};
-
const EDITABLE_CONNECTION_TYPES: readonly ConnectionType[] = [
'pve',
'pbs',
@@ -114,37 +87,101 @@ const EDITABLE_CONNECTION_TYPES: readonly ConnectionType[] = [
'truenas',
];
-export const connectionToRow = (connection: Connection): InfrastructureSystemRow => {
- const presentation = STATE_PRESENTATION[connection.state] ?? STATE_PRESENTATION.pending;
- const activeScopeKeys = Object.keys(connection.scope ?? {}).filter(
- (key) => connection.scope?.[key],
- );
- const coverage =
- activeScopeKeys.length > 0
- ? activeScopeKeys.map(surfaceLabel)
- : connection.surfaces.map(surfaceLabel);
- const name = connection.name || connection.address || connection.id;
+const subtitleFor = (connection: Connection): string | undefined => {
+ if (connection.stateReason) return connection.stateReason;
+ const productLabel = CONNECTION_TYPE_LABELS[connection.type] ?? connection.type;
+ return PLATFORM_API_TYPES.has(connection.type) ? `Platform API · ${productLabel}` : productLabel;
+};
+
+const coverageLabelsFor = (connections: readonly Connection[]): string[] => {
+ const seen = new Set<string>();
+ for (const connection of connections) {
+ const activeScopeKeys = Object.keys(connection.scope ?? {}).filter(
+ (key) => connection.scope?.[key],
+ );
+ const coverage =
+ activeScopeKeys.length > 0
+ ? activeScopeKeys.map(surfaceLabel)
+ : connection.surfaces.map(surfaceLabel);
+ for (const label of coverage) {
+ seen.add(label);
+ }
+ }
+ return [...seen];
+};
+
+const sourceBadgesFor = (connections: readonly Connection[]): string[] => {
+ const badges: string[] = [];
+ if (connections.some((connection) => PLATFORM_API_TYPES.has(connection.type))) {
+ badges.push('API');
+ }
+ if (connections.some((connection) => connection.type === 'agent')) {
+ badges.push('Pulse Agent');
+ }
+ return badges;
+};
+
+const buildRow = (
+ ownerType: ConnectionType,
+ primaryConnection: Connection,
+ componentConnections: readonly Connection[],
+): InfrastructureSystemRow => {
+ const presentation = STATE_PRESENTATION[primaryConnection.state] ?? STATE_PRESENTATION.pending;
+ const name = primaryConnection.name || primaryConnection.address || primaryConnection.id;
const host =
- connection.address && connection.address !== name ? connection.address : undefined;
+ primaryConnection.address && primaryConnection.address !== name
+ ? primaryConnection.address
+ : undefined;
+ const attachedConnections = componentConnections.filter(
+ (connection) => connection.id !== primaryConnection.id,
+ );
+ const lastErrorMessage =
+ primaryConnection.lastError?.message ??
+ attachedConnections.find((connection) => connection.lastError?.message)?.lastError?.message;
+
return {
- id: connection.id,
+ id: primaryConnection.id,
+ ownerType,
name,
- subtitle: subtitleFor(connection),
+ subtitle: subtitleFor(primaryConnection),
host,
- coverageLabels: coverage,
+ coverageLabels: coverageLabelsFor(componentConnections),
+ sourceBadges: sourceBadgesFor(componentConnections),
statusLabel: presentation.label,
statusClassName: presentation.badgeClass,
- lastActivityText: lastActivityText(connection),
- lastErrorMessage: connection.lastError?.message,
- enabled: connection.enabled,
- canEdit: EDITABLE_CONNECTION_TYPES.includes(connection.type),
- canPause: connection.capabilities.supportsPause,
- canRemove: connection.type !== 'docker' && connection.type !== 'kubernetes',
- isAgent: connection.type === 'agent',
- connection,
+ lastActivityText: connectionLastActivityText(primaryConnection),
+ lastErrorMessage,
+ enabled: primaryConnection.enabled,
+ canEdit: EDITABLE_CONNECTION_TYPES.includes(primaryConnection.type),
+ canPause: primaryConnection.capabilities.supportsPause,
+ canRemove: primaryConnection.type !== 'docker' && primaryConnection.type !== 'kubernetes',
+ isAgent: primaryConnection.type === 'agent',
+ attachedConnections,
+ connection: primaryConnection,
};
};
+export const connectionToRow = (connection: Connection): InfrastructureSystemRow =>
+ buildRow(connection.type, connection, [connection]);
+
+const systemToRow = (
+ system: ConnectionSystem,
+ connectionsByID: Map<string, Connection>,
+): InfrastructureSystemRow | null => {
+ const primaryConnection = connectionsByID.get(system.id);
+ if (!primaryConnection) return null;
+
+ const componentConnections = system.components
+ .map((component) => connectionsByID.get(component.connectionId))
+ .filter((connection): connection is Connection => Boolean(connection));
+
+ if (componentConnections.length === 0) {
+ componentConnections.push(primaryConnection);
+ }
+
+ return buildRow(system.type, primaryConnection, componentConnections);
+};
+
export interface ConnectionsLedger {
connections: () => Connection[];
rows: () => InfrastructureSystemRow[];
@@ -154,10 +191,27 @@ export interface ConnectionsLedger {
error: () => unknown;
}
+interface ConnectionsLedgerSnapshot {
+ connections: Connection[];
+ systems: ConnectionSystem[];
+}
+
export const useConnectionsLedger = (): ConnectionsLedger => {
- const [resource, { refetch }] = createResource<Connection[]>(() => ConnectionsAPI.list(), {
- initialValue: [],
- });
+ const [resource, { refetch }] = createResource<ConnectionsLedgerSnapshot>(
+ async () => {
+ const response = await ConnectionsAPI.list();
+ return {
+ connections: response.connections ?? [],
+ systems: response.systems ?? [],
+ };
+ },
+ {
+ initialValue: {
+ connections: [],
+ systems: [],
+ },
+ },
+ );
createEffect(() => {
const handle = window.setInterval(() => {
@@ -166,8 +220,26 @@ export const useConnectionsLedger = (): ConnectionsLedger => {
onCleanup(() => window.clearInterval(handle));
});
- const connections = () => resource() ?? [];
- const rows = createMemo<InfrastructureSystemRow[]>(() => connections().map(connectionToRow));
+ const snapshot = () => resource() ?? { connections: [], systems: [] };
+ const connections = () => snapshot().connections ?? [];
+ const rows = createMemo<InfrastructureSystemRow[]>(() => {
+ const allConnections = connections();
+ const systems = snapshot().systems ?? [];
+ if (systems.length === 0) {
+ return allConnections.map(connectionToRow);
+ }
+
+ const byID = new Map(allConnections.map((connection) => [connection.id, connection]));
+ const groupedRows = systems
+ .map((system) => systemToRow(system, byID))
+ .filter((row): row is InfrastructureSystemRow => Boolean(row));
+
+ if (groupedRows.length === 0) {
+ return allConnections.map(connectionToRow);
+ }
+
+ return groupedRows;
+ });
const findById = (id: string) => connections().find((conn) => conn.id === id);
return {
diff --git a/internal/api/connections_grouping.go b/internal/api/connections_grouping.go
new file mode 100644
index 0000000000..272c691993
--- /dev/null
+++ b/internal/api/connections_grouping.go
@@ -0,0 +1,329 @@
+package api
+
+import (
+ "net"
+ "net/url"
+ "sort"
+ "strings"
+
+ "github.com/rcourtman/pulse-go-rewrite/internal/monitoring"
+ unified "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
+)
+
+type connectionSystemGroup struct {
+ id string
+ typ ConnectionType
+ name string
+ components map[string]ConnectionSystemComponent
+}
+
+func buildConnectionSystems(
+ connections []Connection,
+ monitor *monitoring.Monitor,
+) []ConnectionSystem {
+ if len(connections) == 0 {
+ return nil
+ }
+
+ connectionByID := make(map[string]Connection, len(connections))
+ for _, connection := range connections {
+ connectionByID[connection.ID] = connection
+ }
+
+ hostIndex := buildConnectionHostIndex(connections)
+ agentAttachments := resolveAgentAttachments(connectionByID, hostIndex, monitor)
+
+ groups := make(map[string]*connectionSystemGroup, len(connections))
+ ensureGroup := func(primary Connection) *connectionSystemGroup {
+ group := groups[primary.ID]
+ if group != nil {
+ return group
+ }
+ group = &connectionSystemGroup{
+ id: primary.ID,
+ typ: primary.Type,
+ name: strings.ToLower(primary.Name),
+ components: make(map[string]ConnectionSystemComponent, 2),
+ }
+ group.components[primary.ID] = ConnectionSystemComponent{
+ ConnectionID: primary.ID,
+ Type: primary.Type,
+ Role: ConnectionSystemComponentRolePrimary,
+ }
+ groups[primary.ID] = group
+ return group
+ }
+
+ for _, connection := range connections {
+ if connection.Type == ConnectionTypeAgent {
+ if primaryID, ok := agentAttachments[connection.ID]; ok && primaryID != "" {
+ primary, exists := connectionByID[primaryID]
+ if !exists {
+ continue
+ }
+ group := ensureGroup(primary)
+ group.components[connection.ID] = ConnectionSystemComponent{
+ ConnectionID: connection.ID,
+ Type: connection.Type,
+ Role: ConnectionSystemComponentRoleAttachment,
+ }
+ continue
+ }
+ }
+
+ ensureGroup(connection)
+ }
+
+ out := make([]ConnectionSystem, 0, len(groups))
+ for _, group := range groups {
+ components := make([]ConnectionSystemComponent, 0, len(group.components))
+ for _, component := range group.components {
+ components = append(components, component)
+ }
+ sort.Slice(components, func(i, j int) bool {
+ if components[i].Role != components[j].Role {
+ return connectionComponentRolePriority(components[i].Role) <
+ connectionComponentRolePriority(components[j].Role)
+ }
+ if components[i].Type != components[j].Type {
+ return connectionTypePriority(components[i].Type) < connectionTypePriority(components[j].Type)
+ }
+ return components[i].ConnectionID < components[j].ConnectionID
+ })
+ out = append(out, ConnectionSystem{
+ ID: group.id,
+ Type: group.typ,
+ Components: components,
+ })
+ }
+
+ sort.Slice(out, func(i, j int) bool {
+ if out[i].Type != out[j].Type {
+ return connectionTypePriority(out[i].Type) < connectionTypePriority(out[j].Type)
+ }
+ leftName := groups[out[i].ID].name
+ rightName := groups[out[j].ID].name
+ if leftName == rightName {
+ return out[i].ID < out[j].ID
+ }
+ return leftName < rightName
+ })
+
+ return out
+}
+
+func connectionComponentRolePriority(role ConnectionSystemComponentRole) int {
+ switch role {
+ case ConnectionSystemComponentRolePrimary:
+ return 0
+ case ConnectionSystemComponentRoleAttachment:
+ return 1
+ default:
+ return 100
+ }
+}
+
+func resolveAgentAttachments(
+ connectionByID map[string]Connection,
+ hostIndex connectionHostIndex,
+ monitor *monitoring.Monitor,
+) map[string]string {
+ attachments := make(map[string]string)
+ if monitor == nil {
+ return attachments
+ }
+
+ register := func(agentID, primaryID string, allowOverride bool) {
+ agentID = strings.TrimSpace(agentID)
+ primaryID = strings.TrimSpace(primaryID)
+ if agentID == "" || primaryID == "" || agentID == primaryID {
+ return
+ }
+ if _, ok := connectionByID[agentID]; !ok {
+ return
+ }
+ primary, ok := connectionByID[primaryID]
+ if !ok || primary.Type == ConnectionTypeAgent {
+ return
+ }
+
+ existing, exists := attachments[agentID]
+ if !exists || existing == "" {
+ attachments[agentID] = primaryID
+ return
+ }
+ if existing == primaryID {
+ return
+ }
+ if allowOverride {
+ attachments[agentID] = primaryID
+ return
+ }
+ attachments[agentID] = ""
+ }
+
+ for _, node := range monitor.NodesSnapshot() {
+ if strings.TrimSpace(node.LinkedAgentID) == "" || strings.TrimSpace(node.Instance) == "" {
+ continue
+ }
+ register("agent:"+strings.TrimSpace(node.LinkedAgentID), "pve:"+strings.TrimSpace(node.Instance), false)
+ }
+
+ resources, _ := monitor.UnifiedResourceSnapshot()
+ for _, resource := range resources {
+ if resource.Agent == nil {
+ continue
+ }
+ agentID := "agent:" + strings.TrimSpace(resource.Agent.AgentID)
+ if _, ok := connectionByID[agentID]; !ok {
+ continue
+ }
+ if _, exists := attachments[agentID]; exists {
+ continue
+ }
+ if primaryID := primaryConnectionIDForResource(resource, hostIndex); primaryID != "" {
+ register(agentID, primaryID, false)
+ }
+ }
+
+ for agentID, primaryID := range attachments {
+ if primaryID == "" {
+ delete(attachments, agentID)
+ }
+ }
+
+ return attachments
+}
+
+type connectionHostIndex struct {
+ byType map[ConnectionType]map[string][]string
+}
+
+func buildConnectionHostIndex(connections []Connection) connectionHostIndex {
+ index := connectionHostIndex{byType: make(map[ConnectionType]map[string][]string)}
+ for _, connection := range connections {
+ host := normalizedConnectionHost(connection)
+ if host == "" {
+ continue
+ }
+ typeBucket := index.byType[connection.Type]
+ if typeBucket == nil {
+ typeBucket = make(map[string][]string)
+ index.byType[connection.Type] = typeBucket
+ }
+ typeBucket[host] = append(typeBucket[host], connection.ID)
+ }
+ return index
+}
+
+func primaryConnectionIDForResource(
+ resource unified.Resource,
+ hostIndex connectionHostIndex,
+) string {
+ switch {
+ case resource.Proxmox != nil:
+ if instance := strings.TrimSpace(resource.Proxmox.Instance); instance != "" {
+ return "pve:" + instance
+ }
+ case resource.VMware != nil:
+ if connectionID := strings.TrimSpace(resource.VMware.ConnectionID); connectionID != "" {
+ return "vmware:" + connectionID
+ }
+ case resource.TrueNAS != nil:
+ for _, candidate := range []string{
+ strings.TrimSpace(resource.TrueNAS.Hostname),
+ canonicalResourceHostname(resource),
+ strings.TrimSpace(resource.Name),
+ } {
+ if matched := hostIndex.uniqueMatch(ConnectionTypeTrueNAS, candidate); matched != "" {
+ return matched
+ }
+ }
+ case resource.PBS != nil:
+ if instanceID := strings.TrimSpace(resource.PBS.InstanceID); instanceID != "" {
+ return "pbs:" + instanceID
+ }
+ case resource.PMG != nil:
+ if instanceID := strings.TrimSpace(resource.PMG.InstanceID); instanceID != "" {
+ return "pmg:" + instanceID
+ }
+ }
+
+ return ""
+}
+
+func (i connectionHostIndex) uniqueMatch(typ ConnectionType, raw string) string {
+ host := normalizeHost(raw)
+ if host == "" {
+ return ""
+ }
+ typeBucket := i.byType[typ]
+ if typeBucket == nil {
+ return ""
+ }
+ matches := typeBucket[host]
+ if len(matches) != 1 {
+ return ""
+ }
+ return matches[0]
+}
+
+func normalizedConnectionHost(connection Connection) string {
+ for _, candidate := range []string{connection.Address, connection.Name} {
+ if normalized := normalizeHost(candidate); normalized != "" {
+ return normalized
+ }
+ }
+ return ""
+}
+
+func normalizeHost(raw string) string {
+ value := strings.TrimSpace(raw)
+ if value == "" {
+ return ""
+ }
+
+ if parsedURL, err := url.Parse(value); err == nil && parsedURL.Host != "" {
+ value = parsedURL.Hostname()
+ } else if host, _, err := net.SplitHostPort(value); err == nil {
+ value = host
+ }
+
+ if parsedIP := net.ParseIP(value); parsedIP != nil {
+ return parsedIP.String()
+ }
+
+ value = strings.TrimSpace(strings.ToLower(value))
+ value = strings.TrimSuffix(value, ".")
+ return value
+}
+
+func canonicalResourceHostname(resource unified.Resource) string {
+ if resource.Canonical == nil {
+ return ""
+ }
+ return strings.TrimSpace(resource.Canonical.Hostname)
+}
+
+func connectionTypePriority(typ ConnectionType) int {
+ switch typ {
+ case ConnectionTypePVE:
+ return 0
+ case ConnectionTypeVMware:
+ return 1
+ case ConnectionTypeTrueNAS:
+ return 2
+ case ConnectionTypeDocker:
+ return 3
+ case ConnectionTypeAgent:
+ return 4
+ case ConnectionTypePBS:
+ return 10
+ case ConnectionTypePMG:
+ return 11
+ case ConnectionTypeKubernetes:
+ return 12
+ default:
+ return 100
+ }
+}
diff --git a/internal/api/connections_grouping_test.go b/internal/api/connections_grouping_test.go
new file mode 100644
index 0000000000..292e36fee3
--- /dev/null
+++ b/internal/api/connections_grouping_test.go
@@ -0,0 +1,101 @@
+package api
+
+import (
+ "testing"
+ "time"
+
+ "github.com/rcourtman/pulse-go-rewrite/internal/config"
+ "github.com/rcourtman/pulse-go-rewrite/internal/monitoring"
+ unified "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
+)
+
+func TestBuildConnectionSystems_AttachesMergedAgentToOwningProxmoxSource(t *testing.T) {
+ cfg := &config.Config{DataPath: t.TempDir()}
+ monitor, err := monitoring.New(cfg)
+ if err != nil {
+ t.Fatalf("monitoring.New: %v", err)
+ }
+ t.Cleanup(func() { monitor.Stop() })
+
+ now := time.Date(2026, 4, 22, 12, 0, 0, 0, time.UTC)
+ adapter := unified.NewMonitorAdapter(nil)
+ adapter.PopulateSupplementalRecords(unified.SourceProxmox, []unified.IngestRecord{
+ {
+ SourceID: "node-pi",
+ Resource: unified.Resource{
+ ID: "resource-node-pi",
+ Type: unified.ResourceTypeAgent,
+ Name: "pi",
+ Status: unified.StatusOnline,
+ LastSeen: now,
+ Sources: []unified.DataSource{unified.SourceProxmox, unified.SourceAgent},
+ Identity: unified.ResourceIdentity{
+ MachineID: "machine-pi",
+ Hostnames: []string{"pi"},
+ },
+ Proxmox: &unified.ProxmoxData{
+ Instance: "pi",
+ NodeName: "pi",
+ LinkedAgentID: "agent-pi",
+ },
+ Agent: &unified.AgentData{
+ AgentID: "agent-pi",
+ Hostname: "pi",
+ MachineID: "machine-pi",
+ LinkedNodeID: "node-pi",
+ },
+ },
+ },
+ })
+ setTestUnexportedField(t, monitor, "resourceStore", monitoring.ResourceStoreInterface(adapter))
+
+ connections := []Connection{
+ {
+ ID: "pve:pi",
+ Type: ConnectionTypePVE,
+ Name: "pi",
+ Address: "https://192.168.0.2:8006",
+ State: ConnectionStateActive,
+ Enabled: true,
+ Surfaces: []string{"vms", "containers", "storage", "backups"},
+ Scope: map[string]bool{"vms": true, "containers": true, "storage": true, "backups": true},
+ Source: ConnectionSourceAgent,
+ Capabilities: ConnectionCapabilities{SupportsPause: true, SupportsScope: true, SupportsTest: true},
+ },
+ {
+ ID: "agent:agent-pi",
+ Type: ConnectionTypeAgent,
+ Name: "pi",
+ Address: "pi",
+ State: ConnectionStateActive,
+ Enabled: true,
+ Surfaces: []string{"host"},
+ Scope: map[string]bool{"host": true},
+ LastSeen: &now,
+ Source: ConnectionSourceAgent,
+ Capabilities: ConnectionCapabilities{SupportsPause: false, SupportsScope: false, SupportsTest: false},
+ },
+ }
+
+ systems := buildConnectionSystems(connections, monitor)
+ if len(systems) != 1 {
+ t.Fatalf("expected 1 grouped system, got %d (%+v)", len(systems), systems)
+ }
+
+ system := systems[0]
+ if system.ID != "pve:pi" {
+ t.Fatalf("system id = %q, want %q", system.ID, "pve:pi")
+ }
+ if system.Type != ConnectionTypePVE {
+ t.Fatalf("system type = %q, want %q", system.Type, ConnectionTypePVE)
+ }
+ if len(system.Components) != 2 {
+ t.Fatalf("expected 2 system components, got %+v", system.Components)
+ }
+ if system.Components[0].ConnectionID != "pve:pi" || system.Components[0].Role != ConnectionSystemComponentRolePrimary {
+ t.Fatalf("unexpected primary component: %+v", system.Components[0])
+ }
+ if system.Components[1].ConnectionID != "agent:agent-pi" || system.Components[1].Role != ConnectionSystemComponentRoleAttachment {
+ t.Fatalf("unexpected attachment component: %+v", system.Components[1])
+ }
+}
diff --git a/internal/api/connections_handlers.go b/internal/api/connections_handlers.go
index ac65fcf921..fa82deafc3 100644
--- a/internal/api/connections_handlers.go
+++ b/internal/api/connections_handlers.go
@@ -73,8 +73,10 @@ func (h *ConnectionsHandlers) HandleList(w http.ResponseWriter, r *http.Request)
inputs.instanceHealth = map[string]monitoring.InstanceHealth{}
}
+ connections := buildConnections(inputs)
writeJSON(w, http.StatusOK, ConnectionsListResponse{
- Connections: buildConnections(inputs),
+ Connections: connections,
+ Systems: buildConnectionSystems(connections, monitor),
})
}
diff --git a/internal/api/connections_types.go b/internal/api/connections_types.go
index 0a79d0b156..6cc0b42c61 100644
--- a/internal/api/connections_types.go
+++ b/internal/api/connections_types.go
@@ -78,7 +78,33 @@ type Connection struct {
Capabilities ConnectionCapabilities `json:"capabilities"`
}
+type ConnectionSystemComponentRole string
+
+const (
+ ConnectionSystemComponentRolePrimary ConnectionSystemComponentRole = "primary"
+ ConnectionSystemComponentRoleAttachment ConnectionSystemComponentRole = "attachment"
+)
+
+// ConnectionSystemComponent identifies one underlying connection that
+// contributes to a grouped infrastructure source row in settings.
+type ConnectionSystemComponent struct {
+ ConnectionID string `json:"connectionId"`
+ Type ConnectionType `json:"type"`
+ Role ConnectionSystemComponentRole `json:"role"`
+}
+
+// ConnectionSystem is the source-oriented grouping contract for the settings
+// infrastructure manager. One row owns a primary connection and can carry
+// attached collection methods such as a unified agent augmenting a Proxmox
+// source.
+type ConnectionSystem struct {
+ ID string `json:"id"`
+ Type ConnectionType `json:"type"`
+ Components []ConnectionSystemComponent `json:"components"`
+}
+
// ConnectionsListResponse is the envelope for GET /api/connections.
type ConnectionsListResponse struct {
- Connections []Connection `json:"connections"`
+ Connections []Connection `json:"connections"`
+ Systems []ConnectionSystem `json:"systems,omitempty"`
}
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 2e45244a0a..e0c5be45e2 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -165,7 +165,7 @@ func TestContract_WebSocketTrustedProxyHostedOrigin(t *testing.T) {
}
func TestContract_AIRelayTargetHostnameEquivalence(t *testing.T) {
- server := agentexec.NewServer(func(string, string) bool { return true })
+ server := agentexec.NewServer(func(string, string, string) bool { return true })
ts := newIPv4HTTPServer(t, http.HandlerFunc(server.HandleWebSocket))
defer ts.Close()
@@ -11455,11 +11455,25 @@ func TestContract_ConnectionPayloadShapeStaysCanonical(t *testing.T) {
Source: ConnectionSourceManual,
Capabilities: ConnectionCapabilities{SupportsPause: true, SupportsScope: true, SupportsTest: true},
}
- body, err := json.Marshal(ConnectionsListResponse{Connections: []Connection{conn}})
+ system := ConnectionSystem{
+ ID: "pve-lab",
+ Type: ConnectionTypePVE,
+ Components: []ConnectionSystemComponent{
+ {
+ ConnectionID: "pve-lab",
+ Type: ConnectionTypePVE,
+ Role: ConnectionSystemComponentRolePrimary,
+ },
+ },
+ }
+ body, err := json.Marshal(ConnectionsListResponse{
+ Connections: []Connection{conn},
+ Systems: []ConnectionSystem{system},
+ })
if err != nil {
t.Fatalf("marshal Connection: %v", err)
}
- want := `{"connections":[{"id":"pve-lab","type":"pve","name":"lab","address":"https://pve.lab:8006","state":"active","enabled":true,"surfaces":["vms","containers"],"scope":{"containers":true,"vms":true},"lastSeen":"2026-04-19T10:00:00Z","source":"manual","capabilities":{"supportsPause":true,"supportsScope":true,"supportsTest":true}}]}`
+ want := `{"connections":[{"id":"pve-lab","type":"pve","name":"lab","address":"https://pve.lab:8006","state":"active","enabled":true,"surfaces":["vms","containers"],"scope":{"containers":true,"vms":true},"lastSeen":"2026-04-19T10:00:00Z","source":"manual","capabilities":{"supportsPause":true,"supportsScope":true,"supportsTest":true}}],"systems":[{"id":"pve-lab","type":"pve","components":[{"connectionId":"pve-lab","type":"pve","role":"primary"}]}]}`
assertJSONSnapshot(t, body, want)
}
@@ -11524,6 +11538,9 @@ func TestContract_ConnectionsListIncludesAgentHostsFromUnifiedReadState(t *testi
if len(resp.Connections) != 1 {
t.Fatalf("expected 1 connection from unified read-state, got %d", len(resp.Connections))
}
+ if len(resp.Systems) != 1 {
+ t.Fatalf("expected 1 grouped system from unified read-state, got %d", len(resp.Systems))
+ }
conn := resp.Connections[0]
if conn.ID != "agent:agent-1" {
@@ -11541,6 +11558,9 @@ func TestContract_ConnectionsListIncludesAgentHostsFromUnifiedReadState(t *testi
if conn.Source != ConnectionSourceAgent {
t.Fatalf("connection source = %q, want %q", conn.Source, ConnectionSourceAgent)
}
+ if resp.Systems[0].ID != "agent:agent-1" || resp.Systems[0].Type != ConnectionTypeAgent {
+ t.Fatalf("unexpected grouped system projection: %+v", resp.Systems[0])
+ }
}
// TestContract_ProbePayloadShapeStaysCanonical pins the POST