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.

Add Assistant tool detail copy actions

rcourtman3b6ab9861631
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index da1db9546b..dfcad4c8a0 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -174,10 +174,13 @@ runtime cost control, and shared AI transport surfaces.
suppressed: the referenced OpenCode source at fetched `origin/dev` commit
`1025540fcc2a69609a0131a7168300205656d728` keeps output visibility as an
explicit tool-view policy in `packages/opencode/src/cli/cmd/run/tool.ts`
- (`ToolView.output`, lines 40-44; tool display hooks, lines 117-123), so
- Pulse completed rows must expose compact output metadata for hidden long,
+ (`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 long,
structured, or binary outputs while keeping raw output behind the existing
- details disclosure.
+ details disclosure, and those raw input/output details must be copyable
+ from the disclosure without expanding the default transcript.
Live workflow activity is also active turn state, not disposable waiting
copy. The referenced OpenCode source at fetched `origin/dev` commit
`4519a1da329c1a4fc384054e7203ba7d06928205` defines model, shell, step,
diff --git a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
index 418466713c..6ca9e337f0 100644
--- a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
+++ b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
@@ -8,12 +8,15 @@ import {
For,
createUniqueId,
} from 'solid-js';
+import CheckIcon from 'lucide-solid/icons/check';
import CheckCircleIcon from 'lucide-solid/icons/check-circle';
import ChevronRightIcon from 'lucide-solid/icons/chevron-right';
import ClockIcon from 'lucide-solid/icons/clock';
+import CopyIcon from 'lucide-solid/icons/copy';
import LoaderCircleIcon from 'lucide-solid/icons/loader-circle';
import XCircleIcon from 'lucide-solid/icons/x-circle';
import type { ToolExecution, PendingTool } from './types';
+import { copyToClipboard } from '@/utils/clipboard';
import { getToolCallResultTextClass } from '@/utils/patrolRunPresentation';
import {
getToolLabel,
@@ -167,7 +170,9 @@ const ToolCommandPreview: Component<ToolCommandPreviewProps> = (props) => (
*/
export const ToolExecutionBlock: Component<ToolExecutionBlockProps> = (props) => {
const [showDetails, setShowDetails] = createSignal(false);
+ const [copiedDetail, setCopiedDetail] = createSignal<'input' | 'output' | null>(null);
const detailsId = createUniqueId();
+ let copiedResetTimer: number | undefined;
const toolLabel = createMemo(() => getToolLabel(props.tool.name));
const inputText = createMemo(() => toolValueText(props.tool.input));
@@ -208,6 +213,21 @@ export const ToolExecutionBlock: Component<ToolExecutionBlockProps> = (props) =>
event.preventDefault();
toggleDetails();
};
+ const copyDetail = async (kind: 'input' | 'output', value: string) => {
+ const text = value.trim();
+ if (!text) return;
+ const copied = await copyToClipboard(text);
+ if (!copied) return;
+ setCopiedDetail(kind);
+ if (copiedResetTimer) window.clearTimeout(copiedResetTimer);
+ copiedResetTimer = window.setTimeout(() => setCopiedDetail(null), 1500);
+ };
+ const detailCopyLabel = (kind: 'input' | 'output') =>
+ copiedDetail() === kind ? `Copied tool ${kind}` : `Copy tool ${kind}`;
+
+ onCleanup(() => {
+ if (copiedResetTimer) window.clearTimeout(copiedResetTimer);
+ });
return (
<div class="my-2 overflow-hidden rounded-md border border-border-subtle bg-surface text-[11px] shadow-sm">
@@ -299,16 +319,44 @@ export const ToolExecutionBlock: Component<ToolExecutionBlockProps> = (props) =>
<Show when={showDetails() && hasDetails()}>
<div id={detailsId} class="border-t border-border-subtle px-3 py-2">
<Show when={hasInput()}>
- <div class="mb-1 text-[9px] font-semibold uppercase tracking-wide text-muted">
- Input
+ <div class="mb-1 flex items-center justify-between gap-2">
+ <div class="text-[9px] font-semibold uppercase tracking-wide text-muted">Input</div>
+ <button
+ type="button"
+ class="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded border border-border-subtle bg-surface text-muted transition-colors hover:bg-surface-hover hover:text-base-content focus:outline-none focus:ring-2 focus:ring-blue-500/30"
+ onClick={() => void copyDetail('input', inputText())}
+ title={detailCopyLabel('input')}
+ aria-label={detailCopyLabel('input')}
+ >
+ <Show
+ when={copiedDetail() === 'input'}
+ fallback={<CopyIcon class="h-3 w-3" aria-hidden="true" />}
+ >
+ <CheckIcon class="h-3 w-3 text-emerald-600" aria-hidden="true" />
+ </Show>
+ </button>
</div>
<pre class="mb-2 max-h-36 overflow-auto rounded bg-surface-alt p-2 font-mono text-[10px] leading-5 text-muted whitespace-pre-wrap break-words">
{inputText().trim()}
</pre>
</Show>
<Show when={hasOutput()}>
- <div class="mb-1 text-[9px] font-semibold uppercase tracking-wide text-muted">
- Output
+ <div class="mb-1 flex items-center justify-between gap-2">
+ <div class="text-[9px] font-semibold uppercase tracking-wide text-muted">Output</div>
+ <button
+ type="button"
+ class="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded border border-border-subtle bg-surface text-muted transition-colors hover:bg-surface-hover hover:text-base-content focus:outline-none focus:ring-2 focus:ring-blue-500/30"
+ onClick={() => void copyDetail('output', outputText())}
+ title={detailCopyLabel('output')}
+ aria-label={detailCopyLabel('output')}
+ >
+ <Show
+ when={copiedDetail() === 'output'}
+ fallback={<CopyIcon class="h-3 w-3" aria-hidden="true" />}
+ >
+ <CheckIcon class="h-3 w-3 text-emerald-600" aria-hidden="true" />
+ </Show>
+ </button>
</div>
<pre class="max-h-72 overflow-auto rounded bg-surface-alt p-2 font-mono text-[10px] leading-5 text-muted whitespace-pre-wrap break-words">
{outputText().trim()}
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 9bb3aa639a..de9021f8b2 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx
@@ -1,5 +1,5 @@
-import { describe, expect, it } from 'vitest';
-import { cleanup, render, screen, fireEvent } from '@solidjs/testing-library';
+import { describe, expect, it, vi } from 'vitest';
+import { cleanup, render, screen, fireEvent, waitFor } from '@solidjs/testing-library';
import { afterEach } from 'vitest';
import {
ToolExecutionBlock,
@@ -454,6 +454,49 @@ describe('ToolExecutionBlock', () => {
expect(rawDetails).toContain('line5');
});
+ it('copies raw tool output from the details panel without closing it', async () => {
+ const writeText = vi.fn().mockResolvedValue(undefined);
+ Object.defineProperty(navigator, 'clipboard', {
+ value: { writeText },
+ configurable: true,
+ });
+ const output = ['line1', 'line2', 'line3', 'line4', 'line5'].join('\n');
+
+ render(() => <ToolExecutionBlock tool={makeTool({ input: '{"action":"list"}', output })} />);
+ const trigger = getToolDetailsTrigger();
+ fireEvent.click(trigger);
+ fireEvent.click(screen.getByRole('button', { name: 'Copy tool output' }));
+
+ await waitFor(() => {
+ expect(writeText).toHaveBeenCalledWith(output);
+ });
+ await waitFor(() => {
+ expect(screen.getByRole('button', { name: 'Copied tool output' })).toBeInTheDocument();
+ });
+ expect(trigger).toHaveAttribute('aria-expanded', 'true');
+ expect(screen.getByText('Output')).toBeInTheDocument();
+ });
+
+ it('copies raw tool input from the details panel', async () => {
+ const writeText = vi.fn().mockResolvedValue(undefined);
+ Object.defineProperty(navigator, 'clipboard', {
+ value: { writeText },
+ configurable: true,
+ });
+ const input = '{"action":"exec","command":"ls /dev | wc -l"}';
+
+ render(() => <ToolExecutionBlock tool={makeTool({ input, output: '42' })} />);
+ fireEvent.click(getToolDetailsTrigger());
+ fireEvent.click(screen.getByRole('button', { name: 'Copy tool input' }));
+
+ await waitFor(() => {
+ expect(writeText).toHaveBeenCalledWith(input);
+ });
+ await waitFor(() => {
+ expect(screen.getByRole('button', { name: 'Copied tool input' })).toBeInTheDocument();
+ });
+ });
+
it('keeps raw tool details readable without break-all formatting', async () => {
const output = 'alpha beta gamma delta epsilon';
const { container } = render(() => (