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.

Compact live Assistant tool activity

rcourtman586f80c8375c
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 05d3fb03bd..e67d407f5b 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -55,6 +55,21 @@ leave the transcript without exposing hidden provider/tool metadata.
## Extension Points
+Assistant frontend presentation changes under
+`frontend-modern/src/components/AI/Chat/` must keep live tool activity aligned
+with OpenCode's mutable tool-part pattern without losing Pulse's operator audit
+trail. The current OpenCode reference at fetched `origin/dev` commit
+`233427f08eb8b2a0627123816e807123fbbe5b26` keeps tool input/progress/result as
+a single mutable part in `packages/tui/src/context/sync-v2.tsx` lines 276-345,
+updates running tool metadata from the execution context in
+`packages/opencode/src/session/tools.ts` lines 53-66, and suppresses completed
+successful tool detail when `showDetails` is off in
+`packages/tui/src/routes/session/index.tsx` lines 1704-1779. Pulse adapts that
+by compacting only successful completed tool rows while the same Assistant turn
+is still streaming and newer concrete activity has arrived. Pending tools,
+skipped/canceled tools, failed tools, and completed-turn tool details must
+remain visible/inspectable.
+
1. Add or change chat runtime, Patrol orchestration, findings generation, or remediation behavior through `internal/ai/`
2. Add or change canonical AI provider config, provider-scoped model selection, or runtime auth/base-URL defaults through `internal/config/ai.go`.
Ollama request keep-alive is a provider runtime option owned by this path:
diff --git a/frontend-modern/src/components/AI/Chat/MessageItem.tsx b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
index 04575b564a..4428f52b91 100644
--- a/frontend-modern/src/components/AI/Chat/MessageItem.tsx
+++ b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
@@ -338,6 +338,16 @@ export const MessageItem: Component<MessageItemProps> = (props) => {
}
};
const hasRenderableStreamEvents = () => groupedEvents().some(isRenderableStreamEvent);
+ const hasLaterConcreteLiveActivity = (eventIndex: number) =>
+ props.message.isStreaming === true &&
+ groupedEvents()
+ .slice(eventIndex + 1)
+ .some((evt) => evt.type !== 'model_switch' && isConcreteStreamActivity(evt));
+ const shouldCompactCompletedToolEvent = (evt: StreamDisplayEvent, eventIndex: number) =>
+ evt.type === 'tool' &&
+ props.message.isStreaming === true &&
+ evt.tool?.success !== false &&
+ hasLaterConcreteLiveActivity(eventIndex);
const isLeadingThinkingEvent = (index: number) =>
groupedEvents()
.slice(0, index)
@@ -652,6 +662,7 @@ export const MessageItem: Component<MessageItemProps> = (props) => {
completedAt={evt?.updatedAt}
live={props.message.isStreaming}
settleUntil={evt?.settleUntil}
+ compact={shouldCompactCompletedToolEvent(evt, index())}
tool={{
name: tool().name || 'unknown',
input: tool().input || '{}',
diff --git a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
index d3589c43d2..9df93a9920 100644
--- a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
+++ b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx
@@ -35,6 +35,7 @@ interface ToolExecutionBlockProps {
completedAt?: number;
live?: boolean;
settleUntil?: number;
+ compact?: boolean;
}
interface ToolInputSummaryProps {
@@ -356,7 +357,7 @@ export const ToolExecutionBlock: Component<ToolExecutionBlockProps> = (props) =>
const hasOutput = createMemo(() => hasReadableToolOutput(outputText()));
const hasDetails = createMemo(() => hasInput() || hasOutput());
createEffect(() => {
- if (!props.tool.success) {
+ if (props.compact || !props.tool.success) {
setSettlingFastCompletion(false);
return;
}
@@ -406,6 +407,40 @@ export const ToolExecutionBlock: Component<ToolExecutionBlockProps> = (props) =>
};
return (
+ <Show
+ when={!props.compact}
+ fallback={
+ <div
+ class="my-1 inline-flex max-w-full items-start gap-2 rounded-md border border-border-subtle bg-surface-alt px-2.5 py-1.5 text-[11px] text-muted"
+ role="status"
+ aria-label="Assistant completed tool activity"
+ title={inputSummary()}
+ >
+ <CheckCircleIcon
+ class="mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-300"
+ aria-label="completed"
+ />
+ <span class="shrink-0 font-mono text-[9px] font-semibold uppercase tracking-wider">
+ {toolLabel()}
+ </span>
+ <span class="min-w-0 truncate text-base-content">{inputSummary()}</span>
+ <Show when={durationLabel()}>
+ <span class="shrink-0 text-[10px]" aria-label={`Tool duration ${durationLabel()}`}>
+ {durationLabel()}
+ </span>
+ </Show>
+ <Show when={hiddenOutputSummary()}>
+ <span
+ class="shrink-0 rounded border border-border-subtle bg-surface px-1.5 py-0.5 text-[9px] font-medium"
+ title="Open the completed turn to inspect tool output"
+ aria-label={`Tool output available: ${hiddenOutputSummary()}`}
+ >
+ {hiddenOutputBadgeLabel()}
+ </span>
+ </Show>
+ </div>
+ }
+ >
<div
class="my-2 overflow-hidden rounded-md border border-border-subtle bg-surface text-[11px] shadow-sm"
role={settlingFastCompletion() ? 'status' : undefined}
@@ -514,6 +549,7 @@ export const ToolExecutionBlock: Component<ToolExecutionBlockProps> = (props) =>
/>
</Show>
</div>
+ </Show>
);
};
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
index d64d31e2c9..5d1cfaf94e 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
@@ -42,6 +42,7 @@ vi.mock('../ToolExecutionBlock', () => ({
startedAt?: number;
completedAt?: number;
settleUntil?: number;
+ compact?: boolean;
}) => (
<div
data-testid="tool-execution-block"
@@ -49,6 +50,7 @@ vi.mock('../ToolExecutionBlock', () => ({
data-started-at={props.startedAt}
data-completed-at={props.completedAt}
data-settle-until={props.settleUntil}
+ data-compact={props.compact ? 'true' : 'false'}
>
{props.tool.output}
</div>
@@ -1199,6 +1201,102 @@ describe('MessageItem', () => {
expect(block).toHaveAttribute('data-completed-at', '4200');
});
+ it('compacts superseded successful tool rows while the turn is still streaming', () => {
+ const events: StreamDisplayEvent[] = [
+ {
+ type: 'tool',
+ tool: {
+ name: 'pulse_read',
+ input: '{"command":"ls /dev | wc -l"}',
+ output: '4358',
+ success: true,
+ },
+ },
+ {
+ type: 'pending_tool',
+ pendingTool: {
+ id: 'tool-2',
+ name: 'pulse_get_metrics_history',
+ input: '{"resource_id":"vm-101"}',
+ status: 'running',
+ },
+ },
+ ];
+
+ render(() => (
+ <MessageItem
+ message={makeMessage({
+ role: 'assistant',
+ isStreaming: true,
+ streamEvents: events,
+ })}
+ {...makeHandlers()}
+ />
+ ));
+
+ expect(screen.getByTestId('tool-execution-block')).toHaveAttribute('data-compact', 'true');
+ expect(screen.getByTestId('pending-tool-block')).toHaveAttribute(
+ 'data-tool-name',
+ 'pulse_get_metrics_history',
+ );
+ });
+
+ it('keeps completed-turn successful tool rows expanded for later inspection', () => {
+ const events: StreamDisplayEvent[] = [
+ {
+ type: 'tool',
+ tool: {
+ name: 'pulse_read',
+ input: '{"command":"ls /dev | wc -l"}',
+ output: '4358',
+ success: true,
+ },
+ },
+ { type: 'content', content: 'Done.' },
+ ];
+
+ render(() => (
+ <MessageItem
+ message={makeMessage({
+ role: 'assistant',
+ isStreaming: false,
+ streamEvents: events,
+ })}
+ {...makeHandlers()}
+ />
+ ));
+
+ expect(screen.getByTestId('tool-execution-block')).toHaveAttribute('data-compact', 'false');
+ });
+
+ it('does not compact failed tool rows while newer stream activity continues', () => {
+ const events: StreamDisplayEvent[] = [
+ {
+ type: 'tool',
+ tool: {
+ name: 'pulse_read',
+ input: '{"command":"cat /root/secret"}',
+ output: 'permission denied',
+ success: false,
+ },
+ },
+ { type: 'content', content: 'I could not read that path.' },
+ ];
+
+ render(() => (
+ <MessageItem
+ message={makeMessage({
+ role: 'assistant',
+ isStreaming: true,
+ streamEvents: events,
+ })}
+ {...makeHandlers()}
+ />
+ ));
+
+ expect(screen.getByTestId('tool-execution-block')).toHaveAttribute('data-compact', 'false');
+ });
+
it('renders canceled tool activity as a skipped transcript row', () => {
const events: StreamDisplayEvent[] = [
{
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 3f504e9fd4..3638a90bce 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx
@@ -175,6 +175,26 @@ describe('ToolExecutionBlock', () => {
expect(screen.getByLabelText('Tool duration <1s')).toHaveTextContent('<1s');
});
+ it('renders compact completed activity without the running settle state', () => {
+ render(() => (
+ <ToolExecutionBlock
+ tool={makeTool({ output: 'up 42 days' })}
+ startedAt={1_000}
+ completedAt={1_040}
+ live
+ compact
+ />
+ ));
+
+ const row = screen.getByRole('status', { name: 'Assistant completed tool activity' });
+ expect(row).toHaveTextContent('cmd');
+ expect(row).toHaveTextContent('uptime');
+ expect(row).toHaveTextContent('<1s');
+ expect(screen.getByLabelText('completed')).toBeInTheDocument();
+ expect(screen.queryByLabelText('Assistant tool running')).not.toBeInTheDocument();
+ expect(screen.queryByText('running')).not.toBeInTheDocument();
+ });
+
it('does not defer failed fast completions behind a running state', () => {
render(() => (
<ToolExecutionBlock