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 bounded Assistant tool output

rcourtmana94c5c4ace50
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 3ced7ef128..40e559774d 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -662,15 +662,15 @@ runtime cost control, and shared AI transport surfaces.
parseable, then replacing that copy with the governed command/query/resource
summary as soon as input arrives.
The referenced OpenCode source at fetched `origin/dev` commit
- `9ed17da55ab1f7360cc0e01075f763e27fa899e9` renders completed bash and
+ `4519a1da329c1a4fc384054e7203ba7d06928205` 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`
(`GenericTool`, lines 526-559; `Bash`, lines 701-731) to keep long output bounded.
- Pulse's completed tool rows must adapt that by keeping successful output
- behind Details and only previewing failed plain-text output when the preview
- is short enough to be actionable. Structured JSON, unavailable output,
- successful command output, and the full raw payload stay behind Details. The
- browser implementation owner is
+ Pulse's completed tool rows must adapt that by previewing short actionable
+ plain-text output for successful and failed tools while keeping long output
+ bounded behind Details. Structured JSON, unavailable output, truncated
+ successful output, and the full raw payload stay 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.
diff --git a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
index 75866ea30a..1018802efd 100644
--- a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
+++ b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
@@ -69,8 +69,6 @@ const trimPreviewLine = (line: string, maxLength: number) => {
};
const formatOutputPreview = (output: string, success: boolean) => {
- if (success) return '';
-
const normalized = stripAnsiControlCodes(output).replace(/\r\n/g, '\n').trim();
if (!hasReadableToolOutput(normalized)) return '';
if (looksLikeStructuredOutput(normalized)) return '';
@@ -87,6 +85,7 @@ const formatOutputPreview = (output: string, success: boolean) => {
const charsTruncated = lines
.slice(0, maxLines)
.some((line) => line.trimEnd().length > maxLineLength);
+ if (success && (linesTruncated || charsTruncated)) return '';
return linesTruncated || charsTruncated ? `${fullPreview}\n...` : fullPreview;
};
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 5be5eba66c..eb46b75eae 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx
@@ -278,11 +278,12 @@ describe('ToolExecutionBlock', () => {
// --- Output display ---
- it('keeps successful plain-text output in details instead of previewing it', () => {
+ 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 preview')).toHaveTextContent('hello world');
fireEvent.click(getToolDetailsTrigger());
- expect(screen.getByText('hello world')).toBeInTheDocument();
+ expect(screen.getByText('Output')).toBeInTheDocument();
+ expect(screen.getAllByText('hello world')).toHaveLength(2);
});
it('does not preview structured JSON output by default', () => {
@@ -339,7 +340,7 @@ describe('ToolExecutionBlock', () => {
));
expect(screen.getByText('Inspect devices on current resource')).toBeInTheDocument();
- expect(screen.queryByLabelText('Tool output preview')).not.toBeInTheDocument();
+ expect(screen.getByLabelText('Tool output preview')).toHaveTextContent('42');
});
it('hides output that is only whitespace', () => {
@@ -425,15 +426,15 @@ describe('ToolExecutionBlock', () => {
});
it('toggles raw details from the keyboard on the completed tool row', async () => {
- render(() => <ToolExecutionBlock tool={makeTool({ output: 'keyboard output' })} />);
+ render(() => <ToolExecutionBlock tool={makeTool({ output: '{"value":"keyboard output"}' })} />);
const trigger = getToolDetailsTrigger();
fireEvent.keyDown(trigger, { key: 'Enter' });
expect(trigger).toHaveAttribute('aria-expanded', 'true');
- expect(screen.getByText('keyboard output')).toBeInTheDocument();
+ expect(screen.getByText('{"value":"keyboard output"}')).toBeInTheDocument();
fireEvent.keyDown(trigger, { key: ' ' });
expect(trigger).toHaveAttribute('aria-expanded', 'false');
- expect(screen.queryByText('keyboard output')).not.toBeInTheDocument();
+ expect(screen.queryByText('{"value":"keyboard output"}')).not.toBeInTheDocument();
});
// --- Edge cases ---