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.

Normalize Assistant workflow status labels

rcourtman6e46dcbab0cb
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 38131260ea..502c188a1c 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -221,6 +221,10 @@ runtime cost control, and shared AI transport surfaces.
evidence arrives, that confirmed route replaces the provisional local
selected-model row rather than stacking multiple "Using ..." rows. Once a
durable boundary exists, later route events are preserved chronologically.
+ Rendered workflow-status rows, active-turn footer text, and transcript
+ export status lines must normalize internal tool identifiers such as
+ `pulse_query`, `pulse_read`, and `pulse_exec` into operator-facing activity
+ labels, while preserving the raw typed event payload for Details/debug paths.
Placeholder `request_start` workflow statuses remain fallback activity only:
once selected-model, provider, tool, thinking, approval, question, or content
activity is visible, the placeholder must not outrank it in the footer or
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
index 7a00ec9649..57d178a9e3 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
@@ -4672,7 +4672,10 @@ describe('AIChat', () => {
]);
renderChat();
expect(screen.getByLabelText('Assistant active turn status')).toHaveTextContent(
- 'Planning governed action and safety checks before execution. · exec',
+ 'Planning governed action and safety checks before execution. · command',
+ );
+ expect(screen.getByLabelText('Assistant active turn status')).not.toHaveTextContent(
+ 'pulse_exec',
);
expect(screen.queryByText('Generating response...')).not.toBeInTheDocument();
});
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
index c65bc41727..f0cc9d97f0 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
@@ -600,11 +600,43 @@ describe('MessageItem', () => {
));
expect(
- screen.getByText('Planning governed action and safety checks before execution. · exec'),
+ screen.getByText('Planning governed action and safety checks before execution. · command'),
).toBeInTheDocument();
expect(screen.queryByText('Thinking...')).not.toBeInTheDocument();
});
+ it('renders workflow progress without internal tool identifiers', () => {
+ render(() => (
+ <MessageItem
+ message={makeMessage({
+ role: 'assistant',
+ content: '',
+ isStreaming: true,
+ pendingTools: [],
+ streamEvents: [
+ {
+ type: 'workflow_status',
+ workflowStatus: {
+ phase: 'context',
+ message: 'Reading current Pulse inventory with pulse_query.',
+ tool: 'pulse_query',
+ },
+ },
+ ],
+ workflowStatus: {
+ phase: 'context',
+ message: 'Reading current Pulse inventory with pulse_query.',
+ tool: 'pulse_query',
+ },
+ })}
+ {...makeHandlers()}
+ />
+ ));
+
+ expect(screen.getByText('Reading current Pulse inventory.')).toBeInTheDocument();
+ expect(screen.queryByText(/pulse_query/)).not.toBeInTheDocument();
+ });
+
it('shows live workflow progress as a transcript activity row', () => {
render(() => (
<MessageItem
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts
index c0fd0b3d73..15673bcbcc 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts
+++ b/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
-import { getAssistantActiveTurnStatus } from '../activeTurnStatus';
+import { formatAssistantWorkflowStatus, getAssistantActiveTurnStatus } from '../activeTurnStatus';
import type { ChatMessage } from '../types';
const assistantMessage = (overrides: Partial<ChatMessage> = {}): ChatMessage => ({
@@ -362,10 +362,28 @@ describe('getAssistantActiveTurnStatus', () => {
),
).toEqual({
type: 'tool',
- text: 'Preparing governed tools · exec',
+ text: 'Preparing governed tools · command',
});
});
+ it('normalizes internal workflow tool identifiers before display', () => {
+ expect(
+ formatAssistantWorkflowStatus({
+ phase: 'context',
+ message: 'Reading current Pulse inventory with pulse_query.',
+ tool: 'pulse_query',
+ }),
+ ).toBe('Reading current Pulse inventory.');
+
+ expect(
+ formatAssistantWorkflowStatus({
+ phase: 'preflight',
+ message: 'Preparing governed tools',
+ tool: 'pulse_exec',
+ }),
+ ).toBe('Preparing governed tools · command');
+ });
+
it('lets a newer provider switch replace stale waiting progress', () => {
expect(
getAssistantActiveTurnStatus(
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/transcriptExport.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/transcriptExport.test.ts
index 22fcf2b472..834b472e4f 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/transcriptExport.test.ts
+++ b/frontend-modern/src/components/AI/Chat/__tests__/transcriptExport.test.ts
@@ -37,8 +37,9 @@ describe('Assistant transcript export', () => {
{
type: 'workflow_status',
workflowStatus: {
- message: 'Checking device nodes',
- phase: 'tool',
+ message: 'Reading current Pulse inventory with pulse_query.',
+ phase: 'context',
+ tool: 'pulse_query',
},
},
{
@@ -76,7 +77,8 @@ describe('Assistant transcript export', () => {
expect(transcript).toContain('how many devices in this');
expect(transcript).toContain('## Pulse Assistant');
expect(transcript).toContain('Model: DeepSeek via OpenRouter');
- expect(transcript).toContain('[status] Checking device nodes');
+ expect(transcript).toContain('[status] Reading current Pulse inventory.');
+ expect(transcript).not.toContain('pulse_query');
expect(transcript).toContain('[tool:read]');
expect(transcript).toContain('Inspect devices on current resource');
expect(transcript).not.toContain('ls /dev | wc -l');
diff --git a/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts b/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts
index 241c14884b..50302b2ed2 100644
--- a/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts
+++ b/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts
@@ -25,6 +25,95 @@ interface AssistantActiveTurnStatusCandidate extends AssistantActiveTurnStatus {
const formatToolName = (name?: string) =>
formatIdentifierLabel(name, { stripPrefix: 'pulse_', fallback: 'tool', maxLength: 36 });
+const WORKFLOW_TOOL_LABELS: Record<string, string> = {
+ alerts: 'alerts',
+ control: 'command',
+ exec: 'command',
+ fetch_url: 'fetch',
+ get_active_alerts: 'alerts',
+ get_baselines: 'baselines',
+ get_disk_health: 'disk health',
+ get_infrastructure_state: 'infrastructure',
+ get_metrics_history: 'metrics',
+ get_patterns: 'patterns',
+ get_resource_details: 'resource',
+ get_storage: 'storage',
+ get_storage_config: 'storage config',
+ pulse_alerts: 'alerts',
+ pulse_control: 'command',
+ pulse_exec: 'command',
+ pulse_fetch_url: 'fetch',
+ pulse_get_active_alerts: 'alerts',
+ pulse_get_baselines: 'baselines',
+ pulse_get_disk_health: 'disk health',
+ pulse_get_infrastructure_state: 'infrastructure',
+ pulse_get_metrics_history: 'metrics',
+ pulse_get_patterns: 'patterns',
+ pulse_get_resource_details: 'resource',
+ pulse_get_storage: 'storage',
+ pulse_get_storage_config: 'storage config',
+ pulse_query: 'inventory',
+ pulse_read: 'read',
+ pulse_run_command: 'command',
+ query: 'inventory',
+ read: 'read',
+ run_command: 'command',
+};
+
+const normalizedWorkflowToolName = (name?: string) => name?.trim().toLowerCase() || '';
+
+const formatWorkflowToolName = (name?: string) => {
+ const normalized = normalizedWorkflowToolName(name);
+ return (
+ WORKFLOW_TOOL_LABELS[normalized] ||
+ formatIdentifierLabel(name, { stripPrefix: 'pulse_', fallback: 'tool', maxLength: 36 })
+ );
+};
+
+const internalWorkflowToolIdentifiers = (tool?: string) => {
+ const identifiers = new Set<string>();
+ const normalized = normalizedWorkflowToolName(tool);
+ if (normalized) {
+ identifiers.add(normalized);
+ if (normalized.startsWith('pulse_')) {
+ identifiers.add(normalized.slice('pulse_'.length));
+ }
+ }
+
+ for (const key of Object.keys(WORKFLOW_TOOL_LABELS)) {
+ if (key.startsWith('pulse_') || key.includes('_')) {
+ identifiers.add(key);
+ }
+ }
+
+ return Array.from(identifiers).sort((a, b) => b.length - a.length);
+};
+
+const sanitizeWorkflowStatusMessage = (message: string, tool?: string) => {
+ const toolLabel = formatWorkflowToolName(tool);
+ let sanitized = message.trim();
+
+ for (const identifier of internalWorkflowToolIdentifiers(tool)) {
+ const escaped = escapeRegExp(identifier);
+ sanitized = sanitized.replace(
+ new RegExp(`\\s+(?:with|using|via)\\s+(?:the\\s+)?${escaped}\\.?$`, 'i'),
+ (match) => (match.trim().endsWith('.') ? '.' : ''),
+ );
+ }
+
+ for (const identifier of internalWorkflowToolIdentifiers(tool)) {
+ const label = WORKFLOW_TOOL_LABELS[identifier] || toolLabel;
+ if (!label) continue;
+ const escaped = escapeRegExp(identifier);
+ sanitized = sanitized.replace(new RegExp(`\\b${escaped}\\b`, 'gi'), label);
+ }
+
+ return sanitized
+ .replace(/\s+\./g, '.')
+ .replace(/\s{2,}/g, ' ')
+ .trim();
+};
+
const escapeRegExp = (value: string) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const messageContainsToolLabel = (message: string, label: string) => {
@@ -74,14 +163,17 @@ export const formatAssistantWorkflowStatus = (status?: WorkflowStatus, now?: num
if (!message) return '';
const tool = status?.tool?.trim();
- const toolLabel = tool ? formatToolName(tool) : '';
+ const visibleMessage = sanitizeWorkflowStatusMessage(message, tool);
+ const toolLabel = tool ? formatWorkflowToolName(tool) : '';
const toolSuffix =
- toolLabel && !message.includes(tool || '') && !messageContainsToolLabel(message, toolLabel)
+ toolLabel &&
+ !visibleMessage.includes(tool || '') &&
+ !messageContainsToolLabel(visibleMessage, toolLabel)
? ` · ${toolLabel}`
: '';
const retrySuffix = formatRetryStatusSuffix(status, now);
- return `${message}${toolSuffix}${retrySuffix}`;
+ return `${visibleMessage}${toolSuffix}${retrySuffix}`;
};
const formatPendingToolStatus = (tool?: PendingTool): string => {