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.

Show Assistant tool command details

rcourtmane4e3b3a9efe6
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index d0825ecc29..d4bc0b56e3 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -671,6 +671,18 @@ runtime cost control, and shared AI transport surfaces.
decision) instead of exposing only internal action names such as `QUERY
search`, `exec`, provider function calls, or raw JSON; raw input and full
output stay available behind Details. The referenced OpenCode source at
+ fetched `origin/dev` commit
+ `06d7840d1d42c9815d2d2e45e7fa4090ca4e3577` renders Bash tool state through
+ `Bash` in
+ `packages/opencode/src/cli/cmd/tui/feature-plugins/system/session-v2.tsx`
+ (lines 701-735), where the pending row is replaced by the concrete command
+ and completed block output keeps `$ <command>` visible above bounded output.
+ Pulse adapts that for read-style infrastructure tools by keeping the
+ operator action label as the primary row and adding a sanitized `$ ...`
+ command preview below it when the tool input carries a shell command; raw
+ provider envelopes such as `pulse_read(...)`, raw JSON, and full command
+ output remain Details-only.
+ The referenced OpenCode source at
commit
`9ed17da55ab1f7360cc0e01075f763e27fa899e9` also renders pending tool rows
through `InlineTool` pending text in
diff --git a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
index 1018802efd..aee9133a67 100644
--- a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
+++ b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
@@ -18,6 +18,7 @@ import { getToolCallResultTextClass } from '@/utils/patrolRunPresentation';
import {
getToolLabel,
isPlaceholderToolInputSummary,
+ parseToolCommandPreview,
parseToolInputSummary,
pendingToolActionLabel,
pendingToolActionState,
@@ -32,6 +33,10 @@ interface ToolInputSummaryProps {
summary: string;
}
+interface ToolCommandPreviewProps {
+ preview: string;
+}
+
const hasReadableToolOutput = (output: string) => {
const trimmed = output.trim();
return trimmed.length > 0 && !trimmed.toLowerCase().includes('not available');
@@ -114,6 +119,16 @@ const ToolInputSummary: Component<ToolInputSummaryProps> = (props) => {
);
};
+const ToolCommandPreview: Component<ToolCommandPreviewProps> = (props) => (
+ <code
+ data-testid="tool-command-preview"
+ aria-label="Tool command"
+ class="mt-1 block whitespace-pre-wrap break-words font-mono text-[11px] leading-5 text-muted"
+ >
+ {props.preview}
+ </code>
+);
+
/**
* ToolExecutionBlock - Displays completed tool executions in a compact terminal-like style.
*/
@@ -127,6 +142,12 @@ export const ToolExecutionBlock: Component<ToolExecutionBlockProps> = (props) =>
const inputSummary = createMemo(() =>
parseToolInputSummary(inputText(), props.tool.name, props.tool.rawInput),
);
+ const commandPreview = createMemo(() => {
+ const preview = parseToolCommandPreview(inputText(), props.tool.name, props.tool.rawInput);
+ const summary = inputSummary().trim();
+ if (!preview || summary.startsWith('$ ') || preview === summary) return '';
+ return preview;
+ });
const outputPreview = createMemo(() => formatOutputPreview(outputText(), props.tool.success));
const hasInput = createMemo(() => inputText().trim().length > 0);
const hasOutput = createMemo(() => hasReadableToolOutput(outputText()));
@@ -202,6 +223,9 @@ export const ToolExecutionBlock: Component<ToolExecutionBlockProps> = (props) =>
</Show>
</div>
<ToolInputSummary summary={inputSummary()} />
+ <Show when={commandPreview()}>
+ <ToolCommandPreview preview={commandPreview()} />
+ </Show>
</div>
</div>
@@ -257,6 +281,12 @@ export const PendingToolBlock: Component<PendingToolBlockProps> = (props) => {
? pendingToolActionLabel(props.tool.name)
: summary;
});
+ const commandPreview = createMemo(() => {
+ const preview = parseToolCommandPreview(inputText(), props.tool.name, props.tool.rawInput);
+ const summary = inputSummary().trim();
+ if (!preview || summary.startsWith('$ ') || preview === summary) return '';
+ return preview;
+ });
const status = createMemo(() => props.tool.status || 'pending');
const [now, setNow] = createSignal(Date.now());
const statusLabel = createMemo(() => {
@@ -306,6 +336,9 @@ export const PendingToolBlock: Component<PendingToolBlockProps> = (props) => {
</Show>
</div>
<ToolInputSummary summary={inputSummary()} />
+ <Show when={commandPreview()}>
+ <ToolCommandPreview preview={commandPreview()} />
+ </Show>
</div>
</div>
<Show when={progressText()}>
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx
index eb46b75eae..a63d68662d 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx
@@ -194,6 +194,7 @@ describe('ToolExecutionBlock', () => {
));
expect(screen.getByText('Inspect devices on current resource')).toBeInTheDocument();
+ expect(screen.getByLabelText('Tool command')).toHaveTextContent('$ ls /dev | wc -l');
expect(screen.queryByText(/"target_host"/)).not.toBeInTheDocument();
});
@@ -229,9 +230,30 @@ describe('ToolExecutionBlock', () => {
));
expect(screen.getByText('Inspect devices on current resource')).toBeInTheDocument();
+ expect(screen.getByLabelText('Tool command')).toHaveTextContent('$ ls /dev | wc -l');
expect(screen.queryByText(/pulse_read\(/)).not.toBeInTheDocument();
});
+ it('redacts obvious secrets from completed read command previews', () => {
+ render(() => (
+ <ToolExecutionBlock
+ tool={makeTool({
+ name: 'pulse_read',
+ input:
+ '{"action":"exec","command":"curl -H \\"Authorization: Bearer secret-token\\" --password hunter2 https://example.local"}',
+ output: '200',
+ })}
+ />
+ ));
+
+ const preview = screen.getByLabelText('Tool command');
+ expect(preview).toHaveTextContent(
+ '$ curl -H "Authorization: Bearer [redacted-secret]" --password [redacted-secret] https://example.local',
+ );
+ expect(preview).not.toHaveTextContent('secret-token');
+ expect(preview).not.toHaveTextContent('hunter2');
+ });
+
it('renders Pulse read log input as a readable log action', () => {
render(() => (
<ToolExecutionBlock
@@ -340,6 +362,7 @@ describe('ToolExecutionBlock', () => {
));
expect(screen.getByText('Inspect devices on current resource')).toBeInTheDocument();
+ expect(screen.getByLabelText('Tool command')).toHaveTextContent('$ ls /dev | wc -l');
expect(screen.getByLabelText('Tool output preview')).toHaveTextContent('42');
});
@@ -574,6 +597,7 @@ describe('PendingToolBlock', () => {
));
expect(screen.getByText('Inspect devices on current resource')).toBeInTheDocument();
+ expect(screen.getByLabelText('Tool command')).toHaveTextContent('$ lsblk -o NAME,SIZE');
expect(screen.queryByText(/"command"/)).not.toBeInTheDocument();
});
@@ -608,6 +632,7 @@ describe('PendingToolBlock', () => {
));
expect(screen.getByText('Inspect devices on current resource')).toBeInTheDocument();
+ expect(screen.getByLabelText('Tool command')).toHaveTextContent('$ lsblk -o NAME,SIZE');
expect(screen.queryByText(/pulse_read\(/)).not.toBeInTheDocument();
});
@@ -624,6 +649,7 @@ describe('PendingToolBlock', () => {
));
expect(screen.getByText('Inspect devices on current resource')).toBeInTheDocument();
+ expect(screen.getByLabelText('Tool command')).toHaveTextContent('$ ls /dev | wc -l');
expect(screen.queryByText(/"target_host"/)).not.toBeInTheDocument();
});
@@ -639,6 +665,7 @@ describe('PendingToolBlock', () => {
));
expect(screen.getByText('Inspect devices')).toBeInTheDocument();
+ expect(screen.getByLabelText('Tool command')).toHaveTextContent('$ ls /dev |');
});
it('uses structured raw input over pending backend command display strings', () => {
diff --git a/frontend-modern/src/components/AI/Chat/toolPresentation.ts b/frontend-modern/src/components/AI/Chat/toolPresentation.ts
index 79a63db688..12e50f0ab3 100644
--- a/frontend-modern/src/components/AI/Chat/toolPresentation.ts
+++ b/frontend-modern/src/components/AI/Chat/toolPresentation.ts
@@ -110,6 +110,36 @@ const targetSuffix = (record: Record<string, unknown>) => {
const normalizedShellCommand = (command: string) => command.replace(/\s+/g, ' ').trim();
+const redactShellCommandPreview = (command: string) =>
+ command
+ .replace(/\bsk-[A-Za-z0-9_-]{8,}\b/g, '[redacted-secret]')
+ .replace(/(Authorization:\s*Bearer\s+)([^"'\s]+)/gi, '$1[redacted-secret]')
+ .replace(/(Bearer\s+)([A-Za-z0-9._~+/=-]{8,})/gi, '$1[redacted-secret]')
+ .replace(
+ /(--(?:api-?key|access-token|token|password|secret)(?:=|\s+))("[^"]*"|'[^']*'|[^\s]+)/gi,
+ '$1[redacted-secret]',
+ )
+ .replace(
+ /\b([A-Z0-9_]*(?:API_?KEY|ACCESS_?TOKEN|TOKEN|PASSWORD|SECRET)[A-Z0-9_]*=)("[^"]*"|'[^']*'|[^\s]+)/g,
+ '$1[redacted-secret]',
+ )
+ .replace(
+ /\b((?:api[_-]?key|apikey|access[_-]?token|token|password|secret)=)([^\s&]+)/gi,
+ '$1[redacted-secret]',
+ );
+
+const commandPreviewValue = (command: string, maxLength = 140) => {
+ const redacted = redactShellCommandPreview(normalizedShellCommand(command));
+ if (!redacted) return '';
+ if (redacted.length <= maxLength) return redacted;
+ return `${redacted.slice(0, maxLength).trimEnd()}...`;
+};
+
+const formatShellCommandPreview = (command: string) => {
+ const preview = commandPreviewValue(command);
+ return preview ? `$ ${preview}` : '';
+};
+
const shellCommandIntentLabel = (command: string) => {
const normalized = normalizedShellCommand(command).toLowerCase();
if (!normalized) return '';
@@ -246,6 +276,27 @@ const parseFunctionStyleToolInput = (input: string) => {
return { name: match[1], args };
};
+const parseStructuredInputRecord = (input: string) => {
+ const trimmed = input.trim();
+ if (!trimmed) return null;
+
+ try {
+ const parsed = JSON.parse(trimmed) as unknown;
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
+ return { record: parsed as Record<string, unknown> };
+ }
+ } catch {
+ // Keep trying provider-style function-call input below.
+ }
+
+ const functionCall = parseFunctionStyleToolInput(trimmed);
+ if (functionCall) {
+ return { name: functionCall.name, record: functionCall.args };
+ }
+
+ return null;
+};
+
const formatPartialRawInputSummary = (rawInput: string | undefined, toolName?: string) => {
if (!rawInput?.trim()) return '';
@@ -419,24 +470,9 @@ const formatStructuredInputSummary = (
};
const parseStructuredInputSummary = (input: string, toolName?: string, rawInput?: string) => {
- const trimmed = input.trim();
- if (!trimmed) return null;
-
- try {
- const parsed = JSON.parse(trimmed) as unknown;
- if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
- return formatStructuredInputSummary(parsed as Record<string, unknown>, toolName, rawInput);
- }
- } catch {
- // Keep trying provider-style function-call input below.
- }
-
- const functionCall = parseFunctionStyleToolInput(trimmed);
- if (functionCall) {
- return formatStructuredInputSummary(functionCall.args, functionCall.name, rawInput);
- }
-
- return null;
+ const parsed = parseStructuredInputRecord(input);
+ if (!parsed) return null;
+ return formatStructuredInputSummary(parsed.record, parsed.name || toolName, rawInput);
};
export const parseToolInputSummary = (input: string, toolName?: string, rawInput?: string) => {
@@ -458,6 +494,39 @@ export const parseToolInputSummary = (input: string, toolName?: string, rawInput
return formatIdentifierLabel(trimmed, { maxLength: 28 });
};
+const commandPreviewForRecord = (record: Record<string, unknown>, toolName?: string) => {
+ if (normalizedToolName(toolName) !== 'read') return '';
+ const command = stringField(record, ['command', 'cmd']);
+ return command ? formatShellCommandPreview(command) : '';
+};
+
+const partialCommandPreview = (input: string | undefined, toolName?: string) => {
+ if (normalizedToolName(toolName) !== 'read') return '';
+ const command = extractPartialJSONStringField(input || '', ['command', 'cmd']);
+ return command ? formatShellCommandPreview(command) : '';
+};
+
+const parseStructuredCommandPreview = (input: string, toolName?: string) => {
+ const parsed = parseStructuredInputRecord(input);
+ if (!parsed) return '';
+ return commandPreviewForRecord(parsed.record, parsed.name || toolName);
+};
+
+export const parseToolCommandPreview = (input: string, toolName?: string, rawInput?: string) => {
+ const trimmed = input.trim();
+ const directPreview = trimmed
+ ? parseStructuredCommandPreview(trimmed, toolName) || partialCommandPreview(trimmed, toolName)
+ : '';
+ if (directPreview) return directPreview;
+
+ const raw = rawInput?.trim();
+ if (raw && raw !== trimmed) {
+ return parseStructuredCommandPreview(raw, toolName) || partialCommandPreview(raw, toolName);
+ }
+
+ return '';
+};
+
export const toolValueText = (value: unknown) => {
if (typeof value === 'string') return value;
if (value === null || value === undefined) return '';