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 safe Assistant tool output snippets

rcourtman33701fe274ee
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index b71eb1c02a..0a3385abbd 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -270,13 +270,12 @@ remain visible/inspectable.
(`ToolView.output`, lines 40-44; tool display hooks, lines 117-123), and
commits allowed tool output into scrollback in
`packages/opencode/src/cli/cmd/run/session-data.ts` (lines 960-964). Pulse
- completed rows must expose compact output metadata for hidden successful
- outputs while keeping raw output behind the existing details disclosure, and
- those raw input/output details must be copyable from the disclosure without
- expanding the default transcript. Failed tool output may stay visible as a
- bounded inline preview because it is the operator-facing failure reason;
- successful command output belongs in details unless the Assistant answer
- explicitly summarizes it as normal response text.
+ completed rows must expose safe bounded plain-text output previews when they
+ can be rendered without turning the transcript into a raw terminal dump,
+ while keeping the full raw output behind the existing details disclosure.
+ Structured, binary, unavailable, or otherwise noisy output may collapse to
+ compact output metadata. Raw input/output details must remain copyable from
+ the disclosure without expanding the default transcript.
Completed Assistant context summaries must use the same operator-facing
tool-input presentation as the visible tool rows, not raw internal tool
identifiers. A completed `pulse_read` device inspection should therefore
@@ -696,11 +695,10 @@ remain visible/inspectable.
output unless `showGenericToolOutput` is enabled, and bounds output-heavy
blocks with `packages/opencode/src/cli/cmd/tui/util/collapse-tool-output.ts`.
Pulse adapts that by keeping the completed tool action visible in the
- transcript, keeping successful raw output behind Details, and surfacing only
- short failed plain-text output as a preview when it is actionable. Structured
- JSON, unavailable output, successful command output, and the full raw payload
- stay behind Details. This preserves evidence for inspection without letting
- command output compete with the Assistant answer flow.
+ transcript, rendering only short safe plain-text output previews inline, and
+ keeping structured JSON, unavailable output, noisy output, and the full raw
+ payload behind Details. This preserves evidence for inspection without
+ letting command output compete with the Assistant answer flow.
The row itself owns the details trigger, not a tiny adjacent text action:
completed tool rows with inspectable input or output must expose
`aria-expanded`, keyboard activation, and a chevron affordance on the row
diff --git a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
index 9df93a9920..2e297c1e3b 100644
--- a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
+++ b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
@@ -343,10 +343,7 @@ export const ToolExecutionBlock: Component<ToolExecutionBlockProps> = (props) =>
if (!preview || summary.startsWith('$ ') || preview === summary) return '';
return preview;
});
- const shouldPreviewOutput = createMemo(() => props.tool.success === false);
- const outputPreview = createMemo(() =>
- shouldPreviewOutput() ? formatOutputPreview(outputText()) : '',
- );
+ const outputPreview = createMemo(() => formatOutputPreview(outputText()));
const hiddenOutputSummary = createMemo(() =>
outputPreview() ? '' : formatHiddenOutputSummary(outputText()),
);
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 3638a90bce..1b9cea1bb8 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx
@@ -307,6 +307,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');
expect(screen.queryByText(/"target_host"/)).not.toBeInTheDocument();
});
@@ -471,15 +472,13 @@ describe('ToolExecutionBlock', () => {
// --- Output display ---
- it('keeps successful short plain-text output behind details', () => {
+ it('previews successful short plain-text output while keeping full details available', () => {
render(() => <ToolExecutionBlock tool={makeTool({ output: 'hello world' })} />);
- expect(screen.queryByLabelText('Tool output preview')).not.toBeInTheDocument();
- expect(screen.getByLabelText('Tool output available: 11 chars output')).toHaveTextContent(
- 'output available',
- );
+ expect(screen.getByLabelText('Tool output preview')).toHaveTextContent('hello world');
+ expect(screen.queryByText('11 chars output')).not.toBeInTheDocument();
fireEvent.click(getToolDetailsTrigger());
expect(screen.getByText('Output')).toBeInTheDocument();
- expect(screen.getByText('hello world')).toBeInTheDocument();
+ expect(screen.getAllByText('hello world')).toHaveLength(2);
});
it('does not preview structured JSON output by default', () => {
@@ -500,7 +499,7 @@ describe('ToolExecutionBlock', () => {
expect(getToolDetailsTrigger()).toBeInTheDocument();
});
- it('keeps successful long plain-text output behind details', () => {
+ it('previews successful plain-text output with a bounded visible snippet', () => {
const { container } = render(() => (
<ToolExecutionBlock
tool={makeTool({
@@ -510,22 +509,20 @@ describe('ToolExecutionBlock', () => {
));
const text = container.textContent || '';
- expect(screen.queryByLabelText('Tool output preview')).not.toBeInTheDocument();
- expect(text).not.toContain('line 5');
- expect(screen.getByLabelText('Tool output available: 5 lines output')).toHaveTextContent(
- 'output available',
+ expect(screen.getByLabelText('Tool output preview')).toHaveTextContent(
+ 'line 1 line 2 line 3 line 4 ...',
);
+ expect(text).not.toContain('line 5');
expect(screen.queryByText('5 lines output')).not.toBeInTheDocument();
expect(getToolDetailsTrigger()).toBeInTheDocument();
});
- it('hides long successful single-line output without showing raw output counts', () => {
+ it('previews long successful single-line output without showing raw output counts', () => {
render(() => <ToolExecutionBlock tool={makeTool({ output: 'x'.repeat(160) })} />);
- expect(screen.queryByLabelText('Tool output preview')).not.toBeInTheDocument();
- expect(screen.getByLabelText('Tool output available: 160 chars output')).toHaveTextContent(
- 'output available',
- );
+ const preview = screen.getByLabelText('Tool output preview');
+ expect(preview).toHaveTextContent(/\.\.\.$/);
+ expect(preview.textContent || '').not.toHaveLength(160);
expect(screen.queryByText('160 chars output')).not.toBeInTheDocument();
});
@@ -553,10 +550,7 @@ describe('ToolExecutionBlock', () => {
expect(screen.getByText('Inspect devices on current resource')).toBeInTheDocument();
expect(screen.getByLabelText('Tool command')).toHaveTextContent('$ ls /dev | wc -l');
- expect(screen.queryByLabelText('Tool output preview')).not.toBeInTheDocument();
- expect(screen.getByLabelText('Tool output available: 2 chars output')).toHaveTextContent(
- 'output available',
- );
+ expect(screen.getByLabelText('Tool output preview')).toHaveTextContent('42');
});
it('hides output that is only whitespace', () => {