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.

fix(ai): deduplicate PVE node and host agent in AI mention autocomplete (#1252)

rcourtman3efb3fc1da37
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/mentionResources.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/mentionResources.test.ts
index 8f5074fd52..cebb4dfb28 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/mentionResources.test.ts
+++ b/frontend-modern/src/components/AI/Chat/__tests__/mentionResources.test.ts
@@ -42,6 +42,77 @@ describe('mentionResources', () => {
expect(hosts[0].status).toBe('online');
});
+ it('deduplicates PVE node and linked host agent via linkedHostAgentId (#1252)', () => {
+ // Both sides of the link exist — node has linkedHostAgentId, host has linkedNodeId
+ const state = {
+ nodes: [
+ {
+ id: 'pve-instance-1-pve01',
+ instance: 'pve-instance-1',
+ name: 'pve01',
+ status: 'online',
+ clusterName: undefined,
+ linkedHostAgentId: 'host-agent-1',
+ },
+ ],
+ vms: [],
+ containers: [],
+ dockerHosts: [],
+ hosts: [
+ {
+ id: 'host-agent-1',
+ hostname: 'pve01',
+ displayName: 'pve01',
+ status: 'online',
+ lastSeen: Date.now(),
+ linkedNodeId: 'pve-instance-1-pve01',
+ memory: { total: 16, used: 8, free: 8, usage: 50 },
+ },
+ ],
+ } as unknown as State;
+
+ const resources = buildMentionResources(state);
+ // Should be 1 entry, not 2 (node + host agent)
+ const nodeOrHost = resources.filter((r) => r.type === 'node' || r.type === 'host');
+ expect(nodeOrHost).toHaveLength(1);
+ expect(nodeOrHost[0].name).toBe('pve01');
+ });
+
+ it('deduplicates via host linkedNodeId even when node has no linkedHostAgentId (#1252)', () => {
+ // Only the host-side link exists — tests the node-backend-id alias path
+ const state = {
+ nodes: [
+ {
+ id: 'pve-instance-1-pve01',
+ instance: 'pve-instance-1',
+ name: 'pve01',
+ status: 'online',
+ clusterName: undefined,
+ // no linkedHostAgentId — only host side has the link
+ },
+ ],
+ vms: [],
+ containers: [],
+ dockerHosts: [],
+ hosts: [
+ {
+ id: 'host-agent-1',
+ hostname: 'pve01',
+ displayName: 'pve01',
+ status: 'online',
+ lastSeen: Date.now(),
+ linkedNodeId: 'pve-instance-1-pve01',
+ memory: { total: 16, used: 8, free: 8, usage: 50 },
+ },
+ ],
+ } as unknown as State;
+
+ const resources = buildMentionResources(state);
+ const nodeOrHost = resources.filter((r) => r.type === 'node' || r.type === 'host');
+ expect(nodeOrHost).toHaveLength(1);
+ expect(nodeOrHost[0].name).toBe('pve01');
+ });
+
it('deduplicates cluster node mentions from multiple instances and keeps the healthiest status', () => {
const state = {
nodes: [
diff --git a/frontend-modern/src/components/AI/Chat/mentionResources.ts b/frontend-modern/src/components/AI/Chat/mentionResources.ts
index cd6053c470..c4f0a7f063 100644
--- a/frontend-modern/src/components/AI/Chat/mentionResources.ts
+++ b/frontend-modern/src/components/AI/Chat/mentionResources.ts
@@ -192,6 +192,17 @@ export function buildMentionResources(state: MentionStateSubset): MentionResourc
}
for (const node of state.nodes || []) {
+ const aliases = [
+ `node-id:${node.instance}:${node.name}`,
+ nodeAlias(node.instance, node.clusterName, node.name),
+ // Register backend node ID so host agents with linkedNodeId can merge (#1252)
+ `node-backend-id:${node.id}`,
+ ];
+ // If this node has a linked host agent, add the agent's alias so they merge
+ // instead of appearing as separate entries (#1252)
+ if (node.linkedHostAgentId) {
+ aliases.push(`agent-host-id:${node.linkedHostAgentId}`);
+ }
upsertMentionResource(
byKey,
aliasToKey,
@@ -201,15 +212,22 @@ export function buildMentionResources(state: MentionStateSubset): MentionResourc
type: 'node',
status: node.status,
},
- [
- `node-id:${node.instance}:${node.name}`,
- nodeAlias(node.instance, node.clusterName, node.name),
- ],
+ aliases,
);
}
for (const host of state.hosts || []) {
const hostName = host.displayName || host.hostname || host.id;
+ const aliases = [
+ `agent-host-id:${host.id}`,
+ `host-name:${hostName}`,
+ `host-hostname:${host.hostname}`,
+ ];
+ // If this host agent is linked to a PVE node, add the node's backend ID alias so they merge (#1252).
+ // linkedNodeId is the node's backend ID (format: "instance-nodeName").
+ if (host.linkedNodeId) {
+ aliases.push(`node-backend-id:${host.linkedNodeId}`);
+ }
upsertMentionResource(
byKey,
aliasToKey,
@@ -219,11 +237,7 @@ export function buildMentionResources(state: MentionStateSubset): MentionResourc
type: 'host',
status: host.status,
},
- [
- `agent-host-id:${host.id}`,
- `host-name:${hostName}`,
- `host-hostname:${host.hostname}`,
- ],
+ aliases,
);
}