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
Improve Assistant command tool presentation
rcourtman28bd52c214e9
diff --git a/frontend-modern/src/api/__tests__/aiChat.test.ts b/frontend-modern/src/api/__tests__/aiChat.test.tsindex de659a675a..3e5b141947 100644--- a/frontend-modern/src/api/__tests__/aiChat.test.ts+++ b/frontend-modern/src/api/__tests__/aiChat.test.ts@@ -556,6 +556,7 @@ describe('AIChatAPI', () => {it('exports fixture names and aliases for command discovery', () => {expect(AI_CHAT_DEV_STREAM_FIXTURE_NAMES).toContain('provider-retry');expect(AI_CHAT_DEV_STREAM_FIXTURE_NAMES).toContain('send-hold');+ expect(AI_CHAT_DEV_STREAM_FIXTURE_NAMES).toContain('command-tool');expect(AI_CHAT_DEV_STREAM_FIXTURE_NAMES).not.toContain('/fixture provider-retry');expect(AI_CHAT_DEV_STREAM_FIXTURE_ALIAS_NAMES).toEqual(['burst-tool', 'queued-follow-up']);});@@ -608,6 +609,63 @@ describe('AIChatAPI', () => {});});+ it('runs the command-tool dev stream fixture without opening a provider request', async () => {+ const onEvent = vi.fn();++ await AIChatAPI.chat(+ '/fixture command-tool',+ undefined,+ 'openrouter:deepseek/deepseek-chat',+ onEvent,+ );++ expect(apiFetchMock).not.toHaveBeenCalled();+ expect(onEvent.mock.calls.map(([event]) => event.type)).toEqual([+ 'session',+ 'workflow_state',+ 'tool_start',+ 'tool_progress',+ 'tool_end',+ 'content',+ 'done',+ ]);+ expect(onEvent.mock.calls[2][0]).toMatchObject({+ type: 'tool_start',+ data: {+ id: 'fixture-tool-command',+ name: 'pulse_run_command',+ input: '{}',+ raw_input: expect.stringContaining('systemctl restart nginx'),+ },+ });+ expect(onEvent.mock.calls[3][0]).toMatchObject({+ type: 'tool_progress',+ data: {+ id: 'fixture-tool-command',+ name: 'pulse_run_command',+ phase: 'running',+ message: 'Running command.',+ input: expect.stringContaining('systemctl restart nginx'),+ },+ });+ expect(onEvent.mock.calls[4][0]).toMatchObject({+ type: 'tool_end',+ data: {+ id: 'fixture-tool-command',+ name: 'pulse_run_command',+ output: 'queued',+ success: true,+ },+ });+ expect(onEvent.mock.calls[6][0]).toMatchObject({+ type: 'done',+ data: {+ session_id: 'dev-fixture-command-tool',+ model: 'openrouter:deepseek/deepseek-chat',+ },+ });+ });+it('runs the long-output dev stream fixture without opening a provider request', async () => {const onEvent = vi.fn();diff --git a/frontend-modern/src/api/aiChatDevStreamFixture.ts b/frontend-modern/src/api/aiChatDevStreamFixture.tsindex 9854111d67..b30f7a1161 100644--- a/frontend-modern/src/api/aiChatDevStreamFixture.ts+++ b/frontend-modern/src/api/aiChatDevStreamFixture.ts@@ -9,6 +9,7 @@ export const AI_CHAT_DEV_STREAM_FIXTURE_PROMPTS = ['/fixture context-group','/fixture status-boundary','/fixture pending-tool',+ '/fixture command-tool','/fixture long-output','/fixture provider-retry','/fixture stream-idle',@@ -622,6 +623,66 @@ const buildPendingToolFixtureEvents = (model?: string): AIChatStreamEvent[] => [},];+const buildCommandToolFixtureEvents = (model?: string): AIChatStreamEvent[] => [+ {+ type: 'session',+ data: { id: 'dev-fixture-command-tool' },+ },+ {+ type: 'workflow_state',+ data: {+ phase: 'request_start',+ message: 'Preparing Pulse context.',+ },+ },+ {+ type: 'tool_start',+ data: {+ id: 'fixture-tool-command',+ name: 'pulse_run_command',+ input: '{}',+ raw_input: 'pulse_run_command(target_host="tower", command="systemctl restart nginx',+ },+ },+ {+ type: 'tool_progress',+ data: {+ id: 'fixture-tool-command',+ name: 'pulse_run_command',+ phase: 'running',+ message: 'Running command.',+ input: '{"target_host":"tower","command":"systemctl restart nginx"}',+ raw_input: 'pulse_run_command(target_host="tower", command="systemctl restart nginx")',+ },+ },+ {+ type: 'tool_end',+ data: {+ id: 'fixture-tool-command',+ name: 'pulse_run_command',+ input: '{"target_host":"tower","command":"systemctl restart nginx"}',+ raw_input: 'pulse_run_command(target_host="tower", command="systemctl restart nginx")',+ output: 'queued',+ success: true,+ },+ },+ {+ type: 'content',+ data: {+ text: 'The command-tool fixture kept the governed command row readable with a separate command preview.',+ },+ },+ {+ type: 'done',+ data: {+ session_id: 'dev-fixture-command-tool',+ model: assistantFixtureModel(model),+ input_tokens: 71,+ output_tokens: 25,+ },+ },+];+const buildLongOutputFixtureEvents = (model?: string): AIChatStreamEvent[] => [{type: 'session',@@ -963,6 +1024,9 @@ const buildFixtureEvents = (prompt: string, model?: string): AIChatStreamEvent[]if (normalized === '/fixture pending-tool') {return buildPendingToolFixtureEvents(model);}+ if (normalized === '/fixture command-tool') {+ return buildCommandToolFixtureEvents(model);+ }if (normalized === '/fixture long-output') {return buildLongOutputFixtureEvents(model);}diff --git a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsxindex f97d200bdf..9a22a45535 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx@@ -907,7 +907,7 @@ describe('AIChat', () => {role: 'assistant',content: '',error:- 'Unknown Assistant fixture "/fixture typo-check". Available fixtures: devices, assistant-stream, send-hold, tool-burst, workflow-burst, context-group, status-boundary, pending-tool, long-output, provider-retry, stream-idle, queue-hold, queue-drain, compacted-artifact, skipped-tool.',+ 'Unknown Assistant fixture "/fixture typo-check". Available fixtures: devices, assistant-stream, send-hold, tool-burst, workflow-burst, context-group, status-boundary, pending-tool, command-tool, long-output, provider-retry, stream-idle, queue-hold, queue-drain, compacted-artifact, skipped-tool.',timestamp: new Date('2026-06-05T10:00:00Z'),model: 'openrouter:qwen/qwen3.7-plus',streamEvents: [diff --git a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsxindex ae85cccd4a..dc75777027 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx+++ b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx@@ -457,7 +457,13 @@ describe('ToolExecutionBlock', () => {expect(screen.getByText('logs jellyfin on jellyfin')).toBeInTheDocument();});- it('renders governed command input as the command being run', () => {+ it('renders governed command input as readable activity with a copyable command', async () => {+ const writeText = vi.fn().mockResolvedValue(undefined);+ Object.defineProperty(navigator, 'clipboard', {+ value: { writeText },+ configurable: true,+ });+render(() => (<ToolExecutionBlocktool={makeTool({@@ -468,7 +474,14 @@ describe('ToolExecutionBlock', () => {/>));- expect(screen.getByText('$ systemctl restart nginx on tower')).toBeInTheDocument();+ expect(screen.getByText('Run command on tower')).toBeInTheDocument();+ expect(screen.getByLabelText('Tool command')).toHaveTextContent('$ systemctl restart nginx');+ expect(screen.queryByText(/"target_host"/)).not.toBeInTheDocument();++ fireEvent.click(screen.getByRole('button', { name: 'Copy tool command' }));+ await waitFor(() => {+ expect(writeText).toHaveBeenCalledWith('systemctl restart nginx');+ });});it('uses structured raw input over backend command display strings', () => {@@ -483,7 +496,8 @@ describe('ToolExecutionBlock', () => {/>));- expect(screen.getByText('$ systemctl restart nginx on tower')).toBeInTheDocument();+ expect(screen.getByText('Run command on tower')).toBeInTheDocument();+ expect(screen.getByLabelText('Tool command')).toHaveTextContent('$ systemctl restart nginx');expect(screen.queryByText('Running: systemctl restart nginx')).not.toBeInTheDocument();});@@ -976,7 +990,8 @@ describe('PendingToolBlock', () => {/>));- expect(screen.getByText('$ systemctl restart nginx on tower')).toBeInTheDocument();+ expect(screen.getByText('Run command on tower')).toBeInTheDocument();+ expect(screen.getByLabelText('Tool command')).toHaveTextContent('$ systemctl restart nginx');expect(screen.queryByText('Running: systemctl restart nginx')).not.toBeInTheDocument();});diff --git a/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.tsindex 1727907445..56e648bc4a 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts+++ b/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts@@ -159,6 +159,32 @@ describe('getAssistantActiveTurnStatus', () => {});});+ it('surfaces pending governed command input in the active turn status', () => {+ const startedAt = Date.now() - 5_000;+ expect(+ getAssistantActiveTurnStatus(+ [+ assistantMessage({+ pendingTools: [+ {+ id: 'tool-1',+ name: 'pulse_run_command',+ input: '{"target_host":"tower","command":"systemctl restart nginx"}',+ status: 'running',+ startedAt,+ },+ ],+ }),+ ],+ true,+ ),+ ).toEqual({+ type: 'tool',+ text: 'Running $ systemctl restart nginx',+ startedAt,+ });+ });+it('redacts sensitive read-only command previews in the active turn status', () => {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.tsindex 22b53b4556..094772d7f5 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/transcriptExport.test.ts+++ b/frontend-modern/src/components/AI/Chat/__tests__/transcriptExport.test.ts@@ -155,6 +155,38 @@ describe('Assistant transcript export', () => {expect(transcript).not.toContain('pulse_read');});+ it('exports governed command activity with a separate command preview', () => {+ const transcript = formatAssistantTranscript({+ messages: [+ {+ id: 'assistant-1',+ role: 'assistant',+ content: '',+ timestamp,+ streamEvents: [+ {+ type: 'tool',+ tool: {+ name: 'pulse_run_command',+ input: JSON.stringify({+ command: 'systemctl restart nginx',+ target_host: 'tower',+ }),+ output: 'queued',+ success: true,+ },+ },+ ],+ },+ ],+ generatedAt: timestamp,+ });++ expect(transcript).toContain('[tool:cmd] Run command on tower');+ expect(transcript).toContain('$ systemctl restart nginx');+ expect(transcript).not.toContain('"target_host"');+ });+it('can include thinking and tool output when explicitly requested', () => {const messages: ChatMessage[] = [{diff --git a/frontend-modern/src/components/AI/Chat/toolPresentation.ts b/frontend-modern/src/components/AI/Chat/toolPresentation.tsindex 94a802c18f..b76a7a7a35 100644--- a/frontend-modern/src/components/AI/Chat/toolPresentation.ts+++ b/frontend-modern/src/components/AI/Chat/toolPresentation.ts@@ -179,22 +179,19 @@ const shellCommandIntentLabel = (command: string) => {return '';};-const isComplexShellCommand = (command: string) =>- command.length > 48 || /[;&|`<>]/.test(command) || /\$\(|\${/.test(command);-const formatCommandActivitySummary = (record: Record<string, unknown>, mode: 'read' | 'write') => {const command = normalizedShellCommand(stringField(record, ['command', 'cmd']));if (!command) return '';const target = targetSuffix(record);const intent = shellCommandIntentLabel(command);+ if (mode === 'write') {+ return `Run command${target}`;+ }if (mode === 'read' && intent) {return `${intent}${target}`;}- if (mode === 'read' && isComplexShellCommand(command)) {- return `Read with shell command${target}`;- }- return `$ ${inlineValue(command, 64)}${target}`;+ return `Run read-only command${target}`;};const parseFunctionStyleToolInput = (input: string, options?: { allowPartial?: boolean }) => {@@ -536,13 +533,15 @@ export const parseToolInputSummary = (input: string, toolName?: string, rawInput};const commandPreviewForRecord = (record: Record<string, unknown>, toolName?: string) => {- if (normalizedToolName(toolName) !== 'read') return '';+ const tool = normalizedToolName(toolName);+ if (tool !== 'read' && tool !== 'run_command' && tool !== 'control') return '';const command = stringField(record, ['command', 'cmd']);return command ? formatShellCommandPreview(command) : '';};const partialCommandPreview = (input: string | undefined, toolName?: string) => {- if (normalizedToolName(toolName) !== 'read') return '';+ const tool = normalizedToolName(toolName);+ if (tool !== 'read' && tool !== 'run_command' && tool !== 'control') return '';const command = extractPartialJSONStringField(input || '', ['command', 'cmd']);return command ? formatShellCommandPreview(command) : '';};