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
Centralize chat identifier normalization
rcourtman3a8026faaf51
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex ac9f1dad07..b2b3065484 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -356,3 +356,7 @@ AI chat tool-name labels, pending-tool headers, and assistant status copy nowalso route through the shared frontend identifier-label helper, so the chatsurfaces do not keep their own underscore-stripping behavior separate fromthe rest of the governed presentation helpers.+AI chat stream matching and mention dedupe now route through the shared+frontend chat identifier helper, so tool-name prefix stripping and mention-key+normalization stay aligned across the chat runtime instead of being redefined+inline in the stream processor or container component.diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex 84ae7d233c..ec97e80d9b 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -45,7 +45,8 @@ helpers.1. Add or change Patrol page orchestration through `frontend-modern/src/pages/AIIntelligence.tsx` and `frontend-modern/src/stores/aiIntelligence.ts`2. Add or change Patrol findings, approvals, investigation, or run-history presentation through `frontend-modern/src/components/AI/FindingsPanel.tsx` and `frontend-modern/src/components/patrol/`3. Keep Patrol and chat identifier-label presentation aligned through the shared `frontend-modern/src/utils/textPresentation.ts`-4. Keep Patrol transport and payload changes aligned through the governed AI runtime and API contract transport surfaces+4. Keep Patrol and chat stream-matching / mention dedupe aligned through the shared `frontend-modern/src/utils/chatIdentifiers.ts`+5. Keep Patrol transport and payload changes aligned through the governed AI runtime and API contract transport surfaces## Forbidden Pathsdiff --git a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts b/frontend-modern/src/components/AI/Chat/hooks/useChat.tsindex e5b461d6d5..9321a67782 100644--- a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts+++ b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts@@ -2,6 +2,7 @@ import { createSignal, onCleanup } from 'solid-js';import { AIChatAPI, type ChatMention, type StreamEvent } from '@/api/aiChat';import { notificationStore } from '@/stores/notifications';import { logger } from '@/utils/logger';+import { normalizeChatToolName } from '@/utils/chatIdentifiers';import type {ChatMessage,ToolExecution,@@ -224,14 +225,12 @@ export function useChat(options: UseChatOptions = {}) {const pendingTools = msg.pendingTools || [];const events = msg.streamEvents || [];- // Normalize tool name for matching - strip MCP server prefix (pulse_) which may be doubled- const normalizeToolName = (name: string) => (name || '').replace(/^(pulse_)+/, '');- const normalizedEndName = normalizeToolName(data.name || '');+ const normalizedEndName = normalizeChatToolName(data.name || '');// Find the matching pending tool (prefer tool ID, then fall back to name).const resolvedPendingIndex = data.id? pendingTools.findIndex((t) => t.id === data.id)- : pendingTools.findIndex((t) => normalizeToolName(t.name) === normalizedEndName);+ : pendingTools.findIndex((t) => normalizeChatToolName(t.name) === normalizedEndName);const updatedPending =resolvedPendingIndex >= 0? [@@ -255,7 +254,7 @@ export function useChat(options: UseChatOptions = {}) {evt.type === 'approval' &&(data.id? evt.approval?.toolId === data.id- : normalizeToolName(evt.approval?.toolName || '') === normalizedEndName),+ : normalizeChatToolName(evt.approval?.toolName || '') === normalizedEndName),);let updatedEvents: typeof events;@@ -266,7 +265,7 @@ export function useChat(options: UseChatOptions = {}) {evt.type === 'pending_tool' &&(data.id? evt.toolId === data.id- : normalizeToolName(evt.pendingTool?.name || '') === normalizedEndName)+ : normalizeChatToolName(evt.pendingTool?.name || '') === normalizedEndName)) {return false;}@@ -274,7 +273,7 @@ export function useChat(options: UseChatOptions = {}) {evt.type === 'approval' &&(data.id? evt.approval?.toolId === data.id- : normalizeToolName(evt.approval?.toolName || '') === normalizedEndName)+ : normalizeChatToolName(evt.approval?.toolName || '') === normalizedEndName)) {return false;}@@ -290,7 +289,7 @@ export function useChat(options: UseChatOptions = {}) {evt.type === 'pending_tool' &&(data.id? evt.toolId === data.id- : normalizeToolName(evt.pendingTool?.name || '') === normalizedEndName)+ : normalizeChatToolName(evt.pendingTool?.name || '') === normalizedEndName)) {updatedEvents[i] = { type: 'tool', tool: newToolCall };break;@@ -302,7 +301,7 @@ export function useChat(options: UseChatOptions = {}) {const updatedApprovals = (msg.pendingApprovals || []).filter((a) =>data.id? a.toolId !== data.id- : normalizeToolName(a.toolName || '') !== normalizedEndName,+ : normalizeChatToolName(a.toolName || '') !== normalizedEndName,);return {diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsxindex ba1fd6378e..74285a97ff 100644--- a/frontend-modern/src/components/AI/Chat/index.tsx+++ b/frontend-modern/src/components/AI/Chat/index.tsx@@ -27,6 +27,7 @@ import {getActionableAgentIdFromResource,hasAgentFacet as resourceHasAgentFacet,} from '@/utils/agentResources';+import { normalizeChatMentionKeyPart } from '@/utils/chatIdentifiers';import {getPreferredResourceDisplayName,getPreferredResourceHostname,@@ -323,10 +324,8 @@ export const AIChat: Component<AIChatProps> = (props) => {onCleanup(() => document.removeEventListener('click', handleClickOutside));});- const normalizeMentionKeyPart = (value?: string | null) => (value || '').trim().toLowerCase();-const mentionStatusRank = (status?: string) => {- switch (normalizeMentionKeyPart(status || '')) {+ switch (normalizeChatMentionKeyPart(status || '')) {case 'running':case 'online':return 3;@@ -352,7 +351,7 @@ export const AIChat: Component<AIChatProps> = (props) => {continue;}- const key = `${normalizeMentionKeyPart(resource.name)}:${resource.type}`;+ const key = `${normalizeChatMentionKeyPart(resource.name)}:${resource.type}`;const existing = byKey.get(key);if (!existing) {const index = out.length;diff --git a/frontend-modern/src/utils/__tests__/chatIdentifiers.test.ts b/frontend-modern/src/utils/__tests__/chatIdentifiers.test.tsnew file mode 100644index 0000000000..5f61d0cb32--- /dev/null+++ b/frontend-modern/src/utils/__tests__/chatIdentifiers.test.ts@@ -0,0 +1,18 @@+import { describe, expect, it } from 'vitest';++import { normalizeChatMentionKeyPart, normalizeChatToolName } from '@/utils/chatIdentifiers';++describe('chatIdentifiers', () => {+ it('normalizes mention key parts for dedupe and matching', () => {+ expect(normalizeChatMentionKeyPart(' Agent-01 ')).toBe('agent-01');+ expect(normalizeChatMentionKeyPart('')).toBe('');+ expect(normalizeChatMentionKeyPart(undefined)).toBe('');+ });++ it('strips repeated pulse_ prefixes from tool names', () => {+ expect(normalizeChatToolName('pulse_pulse_get_logs')).toBe('get_logs');+ expect(normalizeChatToolName('pulse_get_logs')).toBe('get_logs');+ expect(normalizeChatToolName('get_logs')).toBe('get_logs');+ expect(normalizeChatToolName(' pulse_get_logs ')).toBe('get_logs');+ });+});diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.tsindex 0f979f26e5..0c1e5cd132 100644--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts@@ -78,9 +78,11 @@ import textPresentationSource from '@/utils/textPresentation.ts?raw';import messageItemSource from '@/components/AI/Chat/MessageItem.tsx?raw';import toolExecutionBlockSource from '@/components/AI/Chat/ToolExecutionBlock.tsx?raw';import aiChatSource from '@/components/AI/Chat/index.tsx?raw';+import useChatSource from '@/components/AI/Chat/hooks/useChat.ts?raw';import patrolStatusBarSource from '@/components/patrol/PatrolStatusBar.tsx?raw';import patrolFormatSource from '@/utils/patrolFormat.ts?raw';import aiFindingPresentationSource from '@/utils/aiFindingPresentation.ts?raw';+import chatIdentifiersSource from '@/utils/chatIdentifiers.ts?raw';import diskListSource from '@/components/Storage/DiskList.tsx?raw';import useDiskListModelSource from '@/components/Storage/useDiskListModel.ts?raw';import diskDetailSource from '@/components/Storage/DiskDetail.tsx?raw';@@ -1932,6 +1934,12 @@ describe('frontend resource type boundaries', () => {expect(patrolRunPresentationSource).toContain('formatIdentifierLabel');expect(patrolRunPresentationSource).not.toContain("normalized.replace(/_/g, ' ')");expect(patrolRunPresentationSource).not.toContain("normalized ? normalized.replace(/_/g, ' ') : 'unknown'");+ expect(useChatSource).toContain('normalizeChatToolName');+ expect(useChatSource).not.toContain("replace(/^(pulse_)+/, '')");+ expect(aiChatSource).toContain('normalizeChatMentionKeyPart');+ expect(aiChatSource).not.toContain("const normalizeMentionKeyPart =");+ expect(chatIdentifiersSource).toContain('normalizeChatMentionKeyPart');+ expect(chatIdentifiersSource).toContain('normalizeChatToolName');expect(useUnifiedResourcesSource).not.toContain('normalizeResourcePolicyAISafeSummary(');expect(useUnifiedResourcesSource).not.toContain('normalizeResourcePolicy(');expect(useUnifiedResourcesSource).not.toContain('const resolvePolicySensitivity =');diff --git a/frontend-modern/src/utils/chatIdentifiers.ts b/frontend-modern/src/utils/chatIdentifiers.tsnew file mode 100644index 0000000000..9b84db1f86--- /dev/null+++ b/frontend-modern/src/utils/chatIdentifiers.ts@@ -0,0 +1,11 @@+export function normalizeChatMentionKeyPart(value?: string | null): string {+ return (value || '').trim().toLowerCase();+}++export function normalizeChatToolName(value?: string | null): string {+ let normalized = (value || '').trim();+ while (normalized.startsWith('pulse_')) {+ normalized = normalized.slice('pulse_'.length).trim();+ }+ return normalized;+}