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
Preview Assistant tool output
rcourtman3bd1e7055765
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 5fdad8631a..ae748a7901 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -456,13 +456,17 @@ runtime cost control, and shared AI transport surfaces.instead of exposing only internal action names such as `QUERY search`,`exec`, or raw JSON; raw input and full output stay available behindDetails. The referenced OpenCode source at fetched `origin/dev` commit- `1399323b78a04229d9bfe00c7436d7f41770fda8` renders completed bash and+ `9ed17da55ab1f7360cc0e01075f763e27fa899e9` renders completed bash andgeneric tool output inside the tool block and uses `collapseToolOutput` in`packages/opencode/src/cli/cmd/tui/feature-plugins/system/session-v2.tsx`- to keep long output bounded. Pulse's completed tool rows must adapt that by+ (`GenericTool`, lines 526-559; `Bash`, lines 701-731) to keep long output bounded.+ Pulse's completed tool rows must adapt that byshowing a compact plain-text output preview when it is safe and useful,while keeping structured JSON, unavailable output, and the full raw payload- behind Details.+ behind Details. The browser implementation owner is+ `frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx`; completed+ `tool_end` events preserve streamed `raw_input` for the same readable command+ summary used while the tool is pending.The referenced OpenCode source at fetched `origin/dev` commit`fa2b63f850fc0a23bec2bdff9e660450d3fe7913` also keeps assistant text,reasoning, and tool invocation as typed message parts indiff --git a/frontend-modern/src/components/AI/Chat/MessageItem.tsx b/frontend-modern/src/components/AI/Chat/MessageItem.tsxindex 99a55f6131..1326f525e0 100644--- a/frontend-modern/src/components/AI/Chat/MessageItem.tsx+++ b/frontend-modern/src/components/AI/Chat/MessageItem.tsx@@ -377,6 +377,7 @@ export const MessageItem: Component<MessageItemProps> = (props) => {tool={{name: evt.tool?.name || 'unknown',input: evt.tool?.input || '{}',+ rawInput: evt.tool?.rawInput,output: evt.tool?.output || '',success: evt.tool?.success ?? true,}}diff --git a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsxindex 0fcebc0984..f8ce18d79f 100644--- a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx+++ b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx@@ -249,6 +249,51 @@ const hasReadableToolOutput = (output: string) => {return trimmed.length > 0 && !trimmed.toLowerCase().includes('not available');};+const stripAnsiControlCodes = (value: string) =>+ value.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, '');++const looksLikeStructuredOutput = (value: string) => {+ const trimmed = value.trim();+ if (!trimmed.startsWith('{') && !trimmed.startsWith('[')) return false;+ try {+ JSON.parse(trimmed);+ return true;+ } catch {+ return false;+ }+};++const hasBinaryControlCharacters = (value: string) =>+ /[\u0000-\u0008\u000B\u000C\u000E-\u001F]/.test(value);++const trimPreviewLine = (line: string, maxLength: number) => {+ const trimmed = line.trimEnd();+ if (trimmed.length <= maxLength) return trimmed;+ return `${trimmed.slice(0, maxLength).trimEnd()}...`;+};++const formatOutputPreview = (output: string) => {+ const normalized = stripAnsiControlCodes(output).replace(/\r\n/g, '\n').trim();+ if (!hasReadableToolOutput(normalized)) return '';+ if (looksLikeStructuredOutput(normalized)) return '';+ if (hasBinaryControlCharacters(normalized)) return '';++ const maxLines = 4;+ const maxLineLength = 120;+ const lines = normalized.split('\n');+ const previewLines = lines+ .slice(0, maxLines)+ .map((line) => trimPreviewLine(line, maxLineLength));+ const fullPreview = previewLines.join('\n').trim();+ if (!fullPreview) return '';++ const linesTruncated = lines.length > maxLines;+ const charsTruncated = lines+ .slice(0, maxLines)+ .some((line) => line.trimEnd().length > maxLineLength);+ return linesTruncated || charsTruncated ? `${fullPreview}\n...` : fullPreview;+};+const toolValueText = (value: unknown) => {if (typeof value === 'string') return value;if (value === null || value === undefined) return '';@@ -268,7 +313,10 @@ export const ToolExecutionBlock: Component<ToolExecutionBlockProps> = (props) =>const toolLabel = createMemo(() => getToolLabel(props.tool.name));const inputText = createMemo(() => toolValueText(props.tool.input));const outputText = createMemo(() => toolValueText(props.tool.output));- const inputSummary = createMemo(() => parseToolInputSummary(inputText(), props.tool.name));+ const inputSummary = createMemo(() =>+ parseToolInputSummary(inputText(), props.tool.name, props.tool.rawInput),+ );+ const outputPreview = createMemo(() => formatOutputPreview(outputText()));const hasInput = createMemo(() => inputText().trim().length > 0);const hasOutput = createMemo(() => hasReadableToolOutput(outputText()));const hasDetails = createMemo(() => hasInput() || hasOutput());@@ -314,6 +362,15 @@ export const ToolExecutionBlock: Component<ToolExecutionBlockProps> = (props) =></Show></div>+ <Show when={outputPreview()}>+ <pre+ class="ml-[calc(0.75rem+58px)] mr-2 mb-1 max-h-24 overflow-hidden whitespace-pre-wrap break-words rounded bg-surface-alt px-2 py-1 text-[10px] leading-relaxed text-base-content"+ aria-label="Tool output preview"+ >+ {outputPreview()}+ </pre>+ </Show>+<Show when={showDetails() && hasDetails()}><div class="ml-4 mt-1 mb-2 pl-2 border-l-2 border-border overflow-hidden"><Show when={hasInput()}>diff --git a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsxindex 58599b6c43..b5a346f3df 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx+++ b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx@@ -225,9 +225,9 @@ describe('ToolExecutionBlock', () => {// --- Output display ---- it('keeps plain-text output behind details by default', () => {+ it('previews plain-text output while keeping full details available', () => {render(() => <ToolExecutionBlock tool={makeTool({ output: 'hello world' })} />);- expect(screen.queryByText('hello world')).not.toBeInTheDocument();+ expect(screen.getByLabelText('Tool output preview')).toHaveTextContent('hello world');expect(screen.getByText('Details')).toBeInTheDocument();});@@ -246,7 +246,7 @@ describe('ToolExecutionBlock', () => {expect(screen.getByText('Details')).toBeInTheDocument();});- it('does not push long plain-text output into the transcript by default', () => {+ it('bounds long plain-text output previews without losing full details', () => {const { container } = render(() => (<ToolExecutionBlocktool={makeTool({@@ -256,12 +256,30 @@ describe('ToolExecutionBlock', () => {));const text = container.textContent || '';- expect(text).not.toContain('line 1');- expect(text).not.toContain('line 3');+ expect(screen.getByLabelText('Tool output preview').textContent).toBe(+ ['line 1', 'line 2', 'line 3', 'line 4', '...'].join('\n'),+ );expect(text).not.toContain('line 5');expect(screen.getByText('Details')).toBeInTheDocument();});+ it('uses raw streamed input to summarize sparse completed Pulse read tools', () => {+ render(() => (+ <ToolExecutionBlock+ tool={makeTool({+ name: 'pulse_read',+ input: '{}',+ rawInput:+ '{"action": "exec", "command": "ls /dev | wc -l", "target_host": "current_resource',+ output: '42',+ })}+ />+ ));++ expect(screen.getByText('$ ls /dev | wc -l on current resource')).toBeInTheDocument();+ expect(screen.getByLabelText('Tool output preview')).toHaveTextContent('42');+ });+it('hides output that is only whitespace', () => {const { container } = render(() => (<ToolExecutionBlock tool={makeTool({ output: ' \n\t ' })} />diff --git a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.tsindex 86723565e8..b2899d123d 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts+++ b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts@@ -1375,7 +1375,14 @@ describe('useChat', () => {fire({ type: 'tool_start', data: { id: 'tool-1', name: 'get_logs', input: '{}' } });fire({type: 'tool_end',- data: { id: 'tool-1', name: 'get_logs', input: '{}', output: 'log data', success: true },+ data: {+ id: 'tool-1',+ name: 'get_logs',+ input: '{}',+ raw_input: '{"action": "logs"',+ output: 'log data',+ success: true,+ },});const assistant = chat.messages().find((m) => m.role === 'assistant')!;@@ -1384,6 +1391,7 @@ describe('useChat', () => {expect(assistant.toolCalls![0]).toEqual({name: 'get_logs',input: '{}',+ rawInput: '{"action": "logs"',output: 'log data',success: true,});diff --git a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts b/frontend-modern/src/components/AI/Chat/hooks/useChat.tsindex 43ebc96bdf..bfb5ee0bb7 100644--- a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts+++ b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts@@ -875,6 +875,7 @@ export function useChat(options: UseChatOptions = {}) {const newToolCall: ToolExecution = {name: data.name || 'unknown',input: data.input || '{}',+ rawInput: data.raw_input,output: data.output || '',success: data.success ?? true,};diff --git a/frontend-modern/src/components/AI/Chat/types.ts b/frontend-modern/src/components/AI/Chat/types.tsindex d3593f350c..ef64ec15cc 100644--- a/frontend-modern/src/components/AI/Chat/types.ts+++ b/frontend-modern/src/components/AI/Chat/types.ts@@ -9,6 +9,7 @@ import type {export interface ToolExecution {name: string;input: string;+ rawInput?: string;output: string;success: boolean;}diff --git a/tests/integration/tests/76-assistant-tool-output-preview.spec.ts b/tests/integration/tests/76-assistant-tool-output-preview.spec.tsnew file mode 100644index 0000000000..3391e14a68--- /dev/null+++ b/tests/integration/tests/76-assistant-tool-output-preview.spec.ts@@ -0,0 +1,186 @@+import fs from 'node:fs';+import path from 'node:path';+import { fileURLToPath } from 'node:url';+import { test as base, expect, type Route } from '@playwright/test';+import { createAuthenticatedStorageState } from './helpers';++const __dirname = path.dirname(fileURLToPath(import.meta.url));++type WorkerFixtures = {+ authStorageStatePath: string;+};++const test = base.extend<{}, WorkerFixtures>({+ storageState: async ({ authStorageStatePath }, use) => {+ await use(authStorageStatePath);+ },+ authStorageStatePath: [+ async ({ browser }, use, workerInfo) => {+ const storageStatePath = path.resolve(+ __dirname,+ '..',+ '..',+ 'tmp',+ 'playwright-auth',+ `assistant-tool-output-preview-${workerInfo.project.name}.json`,+ );+ fs.mkdirSync(path.dirname(storageStatePath), { recursive: true });+ await createAuthenticatedStorageState(browser, storageStatePath);+ try {+ await use(storageStatePath);+ } finally {+ fs.rmSync(storageStatePath, { force: true });+ }+ },+ { scope: 'worker' },+ ],+});++test.describe('Assistant tool output preview', () => {+ test('renders bounded plain-text tool output in the drawer before raw details', async ({+ page,+ }) => {+ const sessionId = 'session-tool-output-preview';++ await page.route('**/api/truenas/connections', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify([]),+ });+ });++ await page.route('**/api/resources**', async (route) => {+ const requestUrl = new URL(route.request().url());+ if (requestUrl.pathname !== '/api/resources') {+ await route.continue();+ return;+ }++ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ data: [],+ meta: {+ page: 1,+ limit: 100,+ total: 0,+ totalPages: 1,+ },+ }),+ });+ });++ await page.route('**/api/ai/status', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({ running: true, engine: 'test' }),+ });+ });++ const fulfillAISettings = async (route: Route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ model: 'openrouter:deepseek/deepseek-chat',+ chat_model: '',+ control_level: 'read_only',+ discovery_enabled: true,+ }),+ });+ };+ await page.route('**/api/ai/settings', fulfillAISettings);+ await page.route('**/api/settings/ai', fulfillAISettings);++ await page.route('**/api/ai/models', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ models: [{ id: 'openrouter:deepseek/deepseek-chat', name: 'DeepSeek Chat' }],+ }),+ });+ });++ await page.route('**/api/ai/sessions', async (route) => {+ if (route.request().method() !== 'GET') {+ await route.continue();+ return;+ }++ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify([+ {+ id: sessionId,+ title: 'Tool output preview proof',+ created_at: '2026-06-06T09:00:00Z',+ updated_at: '2026-06-06T09:01:00Z',+ message_count: 2,+ },+ ]),+ });+ });++ await page.route('**/api/ai/sessions/*/messages', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify([+ {+ id: 'msg-user-tool-preview',+ role: 'user',+ content: 'Show the output from the read-only command.',+ timestamp: '2026-06-06T09:00:00Z',+ },+ {+ id: 'msg-assistant-tool-preview',+ role: 'assistant',+ content: 'I checked the target.',+ timestamp: '2026-06-06T09:01:00Z',+ tool_calls: [+ {+ name: 'pulse_read',+ input:+ '{"action":"exec","target_host":"current_resource","command":"printf preview-proof-0606"}',+ output:+ 'preview-proof-0606\nsecond-line\nthird-line\nfourth-line\nhidden-fifth-line',+ success: true,+ },+ ],+ },+ ]),+ });+ });++ await page.goto('/settings/infrastructure/platforms/truenas', {+ waitUntil: 'domcontentloaded',+ });+ await page.waitForURL(/\/settings\/infrastructure\/platforms\/truenas/, {+ timeout: 15_000,+ });++ await page.getByRole('button', { name: 'Expand Pulse Assistant' }).click();+ await expect(page.getByRole('heading', { name: 'Pulse Assistant', exact: true })).toBeVisible();++ await page.getByRole('button', { name: 'Resume Tool output preview proof' }).click();+ await expect(page.getByText('$ printf preview-proof-0606 on current resource')).toBeVisible();++ const preview = page.locator('pre[aria-label="Tool output preview"]');+ await expect(preview).toBeVisible();+ await expect(preview).toContainText('preview-proof-0606');+ await expect(preview).toContainText('second-line');+ await expect(preview).toContainText('fourth-line');+ await expect(preview).toContainText('...');+ await expect(preview).not.toContainText('hidden-fifth-line');+ await expect(page.getByText('hidden-fifth-line')).toHaveCount(0);++ await page.getByRole('button', { name: 'Details' }).click();+ await expect(page.getByText('hidden-fifth-line')).toBeVisible();+ await expect(page.getByText(/"target_host":"current_resource"/)).toBeVisible();+ });+});