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.

Preview Assistant completed tool output

rcourtman8c3a0e8dbc35
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 174508175c..c311a0a341 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -303,6 +303,10 @@ runtime cost control, and shared AI transport surfaces.
chronological tool rows. Pulse adapts this with a mutable footer status and
inline pending rows that show the current activity plus elapsed time while
keeping large command output collapsed.
+ Assistant experience parity claims against OpenCode must cite the inspected
+ OpenCode commit and source file/function anchor that defines the behavior
+ being adapted; observed UI behavior alone is not sufficient governance
+ evidence for future parity slices.
The referenced OpenCode source at commit
`f750deaa3e95098fdde5fb00305b273e43c5b2cd` mutates a single tool part from
`pending` input through `running` progress to completed/error in
@@ -358,7 +362,15 @@ runtime cost control, and shared AI transport surfaces.
should summarize the actual governed action (`search "prowlarr"`, `list
active alerts`, `topology summary`, `$ ls /dev | wc -l on current resource`)
instead of exposing only internal action names such as `QUERY search`,
- `exec`, or raw JSON; raw input and output stay available behind Details.
+ `exec`, or raw JSON; raw input and full output stay available behind
+ Details. The referenced OpenCode source at fetched `origin/dev` commit
+ `1399323b78a04229d9bfe00c7436d7f41770fda8` renders completed bash and
+ generic 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
+ showing 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.
The referenced OpenCode source at fetched `origin/dev` commit
`fa2b63f850fc0a23bec2bdff9e660450d3fe7913` also keeps assistant text,
reasoning, and tool invocation as typed message parts in
diff --git a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
index 0fcebc0984..a30a27a1fd 100644
--- a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
+++ b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
@@ -249,6 +249,36 @@ const hasReadableToolOutput = (output: string) => {
return trimmed.length > 0 && !trimmed.toLowerCase().includes('not available');
};
+const looksLikeStructuredJSON = (value: string) => {
+ const trimmed = value.trim();
+ if (!trimmed.startsWith('{') && !trimmed.startsWith('[')) return false;
+ if (trimmed.length > 5000) return true;
+ try {
+ JSON.parse(trimmed);
+ return true;
+ } catch {
+ return false;
+ }
+};
+
+const formatToolOutputPreview = (output: string) => {
+ const normalized = output.trim().replace(/\r\n/g, '\n');
+ if (!hasReadableToolOutput(normalized) || looksLikeStructuredJSON(normalized)) return '';
+
+ const lines = normalized.split('\n');
+ const maxLines = 3;
+ const maxChars = 240;
+ let preview = lines.slice(0, maxLines).join('\n').trimEnd();
+ let truncated = lines.length > maxLines;
+
+ if (preview.length > maxChars) {
+ preview = preview.slice(0, maxChars).trimEnd();
+ truncated = true;
+ }
+
+ return truncated ? `${preview}\n...` : preview;
+};
+
const toolValueText = (value: unknown) => {
if (typeof value === 'string') return value;
if (value === null || value === undefined) return '';
@@ -272,6 +302,7 @@ export const ToolExecutionBlock: Component<ToolExecutionBlockProps> = (props) =>
const hasInput = createMemo(() => inputText().trim().length > 0);
const hasOutput = createMemo(() => hasReadableToolOutput(outputText()));
const hasDetails = createMemo(() => hasInput() || hasOutput());
+ const outputPreview = createMemo(() => formatToolOutputPreview(outputText()));
const statusLabel = () => (props.tool.success ? 'completed' : 'failed');
@@ -313,6 +344,11 @@ export const ToolExecutionBlock: Component<ToolExecutionBlockProps> = (props) =>
</button>
</Show>
</div>
+ <Show when={outputPreview()}>
+ <pre class="ml-[calc(0.75rem+56px)] mt-0.5 max-h-20 overflow-hidden rounded bg-surface-alt px-2 py-1 text-[10px] leading-snug text-muted whitespace-pre-wrap break-words">
+ {outputPreview()}
+ </pre>
+ </Show>
<Show when={showDetails() && hasDetails()}>
<div class="ml-4 mt-1 mb-2 pl-2 border-l-2 border-border overflow-hidden">
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 bac44683c3..5ce5bb6550 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx
@@ -225,12 +225,43 @@ describe('ToolExecutionBlock', () => {
// --- Output display ---
- it('does not show output by default when non-empty', () => {
+ it('shows compact plain-text output by default when non-empty', () => {
render(() => <ToolExecutionBlock tool={makeTool({ output: 'hello world' })} />);
- expect(screen.queryByText('hello world')).not.toBeInTheDocument();
+ expect(screen.getByText('hello world')).toBeInTheDocument();
expect(screen.getByText('Details')).toBeInTheDocument();
});
+ it('does not preview structured JSON output by default', () => {
+ render(() => (
+ <ToolExecutionBlock
+ tool={makeTool({
+ name: 'pulse_query',
+ input: '{"action":"topology"}',
+ output: '{"summary":{"total_nodes":3}}',
+ })}
+ />
+ ));
+
+ expect(screen.queryByText(/total_nodes/)).not.toBeInTheDocument();
+ expect(screen.getByText('Details')).toBeInTheDocument();
+ });
+
+ it('collapses long plain-text output previews', () => {
+ const { container } = render(() => (
+ <ToolExecutionBlock
+ tool={makeTool({
+ output: ['line 1', 'line 2', 'line 3', 'line 4', 'line 5'].join('\n'),
+ })}
+ />
+ ));
+
+ const text = container.textContent || '';
+ expect(text).toContain('line 1');
+ expect(text).toContain('line 3');
+ expect(text).not.toContain('line 5');
+ expect(text).toContain('...');
+ });
+
it('hides output that is only whitespace', () => {
const { container } = render(() => (
<ToolExecutionBlock tool={makeTool({ output: ' \n\t ' })} />
@@ -261,7 +292,9 @@ describe('ToolExecutionBlock', () => {
it('shows raw input and output when details are opened', async () => {
const output = 'line1\nline2\nline3\nline4\nline5';
- render(() => <ToolExecutionBlock tool={makeTool({ input: '{"action":"list"}', output })} />);
+ const { container } = render(() => (
+ <ToolExecutionBlock tool={makeTool({ input: '{"action":"list"}', output })} />
+ ));
const btn = screen.getByText('Details');
fireEvent.click(btn);
@@ -269,11 +302,14 @@ describe('ToolExecutionBlock', () => {
expect(screen.getByText('Input')).toBeInTheDocument();
expect(screen.getByText('Output')).toBeInTheDocument();
expect(screen.getByText('{"action":"list"}')).toBeInTheDocument();
- expect(screen.getByText(/line1/).textContent).toContain('line5');
+ const rawDetails = Array.from(container.querySelectorAll('pre'))
+ .map((pre) => pre.textContent || '')
+ .join('\n');
+ expect(rawDetails).toContain('line5');
});
it('hides raw details when toggled closed', async () => {
- const output = 'line1\nline2\nline3\nline4\nline5';
+ const output = '{"value":"line1"}';
render(() => <ToolExecutionBlock tool={makeTool({ output })} />);
fireEvent.click(screen.getByText('Details'));
expect(screen.getByText('Hide details')).toBeInTheDocument();