YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: preserve ACP tool metadata in chat
Louis Beaumont7b0e80820c02
diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/hooks/use-pi-foreground-events.ts b/apps/screenpipe-app-tauri/components/chat/standalone/hooks/use-pi-foreground-events.tsindex e8c1766c1..49b0930e4 100644--- a/apps/screenpipe-app-tauri/components/chat/standalone/hooks/use-pi-foreground-events.ts+++ b/apps/screenpipe-app-tauri/components/chat/standalone/hooks/use-pi-foreground-events.ts@@ -491,6 +491,7 @@ export function usePiForegroundEvents({if (piMessageIdRef.current) {const msgId = piMessageIdRef.current;const parentToolCallId = stringValue(data.parentToolCallId);+ const agentId = stringValue(data.agentId);const toolKind = stringValue(data.kind);const toolCall: ToolCall = {id: stringValue(data.toolCallId, Date.now().toString()),@@ -498,6 +499,7 @@ export function usePiForegroundEvents({args: isRecord(data.args) ? data.args : {},isRunning: true,startedAtMs: Date.now(),+ ...(agentId ? { agentId } : {}),...(toolKind ? { kind: toolKind } : {}),...(parentToolCallId ? { parentToolCallId } : {}),...(data.subagent === true ? { subagent: true } : {}),@@ -543,6 +545,11 @@ export function usePiForegroundEvents({if (data.retry !== undefined) block.toolCall.retry = data.retry;const title = stringValue(data.title);if (title) block.toolCall.toolName = title;+ const agentId = stringValue(data.agentId);+ if (agentId) block.toolCall.agentId = agentId;+ const kind = stringValue(data.kind);+ if (kind) block.toolCall.kind = kind;+ if (isRecord(data.args)) block.toolCall.args = data.args;const outputDelta = stringValue(data.outputDelta);if (outputDelta) {const combined = `${block.toolCall.progress ?? ""}${outputDelta}`;@@ -566,6 +573,13 @@ export function usePiForegroundEvents({// Update the tool block in-placefor (const block of piContentBlocksRef.current) {if (block.type === "tool" && block.toolCall.id === toolCallId) {+ const toolName = stringValue(data.toolName);+ if (toolName) block.toolCall.toolName = toolName;+ const agentId = stringValue(data.agentId);+ if (agentId) block.toolCall.agentId = agentId;+ const kind = stringValue(data.kind);+ if (kind) block.toolCall.kind = kind;+ if (isRecord(data.args)) block.toolCall.args = data.args;block.toolCall.isRunning = false;block.toolCall.result = truncated;block.toolCall.isError = data.isError === true;diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/message-content.tsx b/apps/screenpipe-app-tauri/components/chat/standalone/message-content.tsxindex 926cc3204..9df19b887 100644--- a/apps/screenpipe-app-tauri/components/chat/standalone/message-content.tsx+++ b/apps/screenpipe-app-tauri/components/chat/standalone/message-content.tsx@@ -1368,11 +1368,16 @@ function ToolActivityGroup({// Tool activity is progressively disclosed: one friendly status is visible// by default, and the user can expand a high-level activity list. Interactive// tools stay open because hiding a question would block the conversation.+ const e2eForceExpanded =+ process.env.NEXT_PUBLIC_SCREENPIPE_E2E === "true" &&+ typeof window !== "undefined" &&+ (window as typeof window & { __e2eExpandToolActivity?: boolean })+ .__e2eExpandToolActivity === true;const isExpanded = forceCollapsed? false: hideSummary? true- : hasInteractiveTool+ : hasInteractiveTool || e2eForceExpanded? true: manualExpand !== null ? manualExpand : defaultExpanded;@@ -1438,10 +1443,10 @@ function ToolActivityGroup({<AnimatePresence>{isExpanded && (<motion.div- initial={{ height: 0, opacity: 0 }}+ initial={e2eForceExpanded ? false : { height: 0, opacity: 0 }}animate={{ height: "auto", opacity: 1 }}exit={{ height: 0, opacity: 0 }}- transition={{ duration: reduceMotion ? 0 : 0.15 }}+ transition={{ duration: reduceMotion || e2eForceExpanded ? 0 : 0.15 }}className="overflow-hidden"><div@@ -1484,9 +1489,12 @@ function ToolActivityGroup({return (<motion.divkey={toolCallRenderKey(tc, i)}- initial={reduceMotion ? false : { opacity: 0, x: -8 }}+ initial={reduceMotion || e2eForceExpanded ? false : { opacity: 0, x: -8 }}animate={{ opacity: 1, x: 0 }}- transition={{ duration: reduceMotion ? 0 : 0.15, delay: reduceMotion ? 0 : i * 0.03 }}+ transition={{+ duration: reduceMotion || e2eForceExpanded ? 0 : 0.15,+ delay: reduceMotion || e2eForceExpanded ? 0 : i * 0.03,+ }}><ToolCallRailItemtoolCall={tc}diff --git a/apps/screenpipe-app-tauri/e2e/COVERAGE.md b/apps/screenpipe-app-tauri/e2e/COVERAGE.mdindex 3da4eb16b..7f2e12fe1 100644--- a/apps/screenpipe-app-tauri/e2e/COVERAGE.md+++ b/apps/screenpipe-app-tauri/e2e/COVERAGE.md@@ -7,8 +7,8 @@ and layer declared in the manifest, weighted by confidence and criticality.- Manifest: `e2e/coverage-map.json`- Specs directory: `e2e/specs`- Mapped specs: 120-- Declared test blocks: 351-- Weighted coverage points: 275.5+- Declared test blocks: 352+- Weighted coverage points: 276.2Confidence weights: strong=1.0, partial=0.7, conditional=0.4, smoke=0.3.Criticality weights: high=1.0, medium=0.7, low=0.4.@@ -19,9 +19,9 @@ can execute more runtime cases than this number shows.| Platform | Specs | Declared tests | Weighted points | Layers | Features | Critical score || --- | --- | --- | --- | --- | --- | --- |-| windows | 91 | 301 | 245.9 | 15 | 98 | 92% |-| macos | 116 | 313 | 245.3 | 17 | 105 | 90% |-| linux | 80 | 259 | 215.3 | 14 | 95 | 88% |+| windows | 91 | 302 | 246.6 | 15 | 99 | 92% |+| macos | 116 | 314 | 246.0 | 17 | 106 | 90% |+| linux | 80 | 260 | 216.0 | 14 | 96 | 88% |## Runtime Results@@ -37,18 +37,18 @@ pass/fail/skip counts.| auth | - | 1 specs / 1 tests / 1.0 pts | - || billing | 4 specs / 6 tests / 5.7 pts | 4 specs / 6 tests / 5.7 pts | 4 specs / 6 tests / 5.7 pts || capture-ocr | 2 specs / 16 tests / 6.4 pts | 8 specs / 12 tests / 4.8 pts | 1 specs / 3 tests / 1.2 pts |-| chat-ai | 26 specs / 57 tests / 43.1 pts | 38 specs / 79 tests / 57.2 pts | 25 specs / 56 tests / 42.6 pts |+| chat-ai | 26 specs / 58 tests / 43.8 pts | 38 specs / 80 tests / 57.9 pts | 25 specs / 57 tests / 43.3 pts || entitlement | - | 1 specs / 1 tests / 1.0 pts | - || local-api | 25 specs / 114 tests / 95.0 pts | 33 specs / 104 tests / 87.5 pts | 20 specs / 82 tests / 73.2 pts || notifications | 4 specs / 26 tests / 17.3 pts | 3 specs / 5 tests / 3.4 pts | 2 specs / 4 tests / 3.1 pts || onboarding | 9 specs / 37 tests / 32.8 pts | 11 specs / 39 tests / 34.2 pts | 9 specs / 37 tests / 32.8 pts |-| os-integration | 7 specs / 30 tests / 25.5 pts | 14 specs / 27 tests / 16.0 pts | 2 specs / 13 tests / 9.4 pts |+| os-integration | 7 specs / 31 tests / 26.2 pts | 14 specs / 28 tests / 16.7 pts | 2 specs / 14 tests / 10.1 pts || performance | 2 specs / 44 tests / 44.0 pts | 4 specs / 34 tests / 30.5 pts | 1 specs / 29 tests / 29.0 pts || pipes | 6 specs / 19 tests / 19.0 pts | 8 specs / 25 tests / 25.0 pts | 6 specs / 19 tests / 19.0 pts || real-ui-e2e | 65 specs / 202 tests / 166.5 pts | 79 specs / 210 tests / 172.4 pts | 60 specs / 178 tests / 152.6 pts || settings | 14 specs / 40 tests / 37.0 pts | 16 specs / 34 tests / 29.7 pts | 13 specs / 31 tests / 28.0 pts || storage-privacy | 9 specs / 42 tests / 33.3 pts | 9 specs / 27 tests / 26.1 pts | 6 specs / 20 tests / 19.1 pts |-| tauri-command | 19 specs / 52 tests / 40.1 pts | 27 specs / 64 tests / 48.3 pts | 18 specs / 53 tests / 40.9 pts |+| tauri-command | 19 specs / 53 tests / 40.8 pts | 27 specs / 65 tests / 49.0 pts | 18 specs / 54 tests / 41.6 pts || window-lifecycle | 19 specs / 66 tests / 55.0 pts | 19 specs / 46 tests / 32.4 pts | 13 specs / 39 tests / 29.9 pts |## Critical Feature Matrix@@ -100,7 +100,7 @@ pass/fail/skip counts.| Spec | Platforms | Layers | Features | Criticality | Confidence | UX | Tests | Notes || --- | --- | --- | --- | --- | --- | --- | --- | --- |-| acp-backend.spec.ts | windows, macos, linux | chat-ai, tauri-command, os-integration | chat, acp-backend, agent-streaming, agent-permissions, agent-cancellation, agent-terminal, mcp-registration, process-supervision | high | partial | mixed | 12 | Official Rust ACP SDK runtime and inline UI E2E with a deterministic stdio agent: initialization, session close, streaming, background permissions, cancellation, localized auth/cancel, malformed stdout, exact adapter/descendant reaping, terminal lifecycle/output draining, and a real authenticated local API MCP health call. Curated third-party adapters remain manual smoke coverage. |+| acp-backend.spec.ts | windows, macos, linux | chat-ai, tauri-command, os-integration | chat, acp-backend, agent-streaming, agent-permissions, agent-cancellation, agent-terminal, agent-tool-metadata, mcp-registration, process-supervision | high | partial | mixed | 13 | Official Rust ACP SDK runtime and inline UI E2E with a deterministic stdio agent: initialization, session close, streaming, background permissions, cancellation, localized auth/cancel, malformed stdout, exact adapter/descendant reaping, terminal lifecycle/output draining, late tool metadata/error propagation with a provider fallback, and a real authenticated local API MCP health call. Curated third-party adapters remain manual smoke coverage. || acp-onboarding-ux.spec.ts | windows, macos, linux | chat-ai, real-ui-e2e, tauri-command | chat, acp-backend, acp-onboarding, acp-auth | high | partial | real-user-flow | 2 | Selecting an ACP agent connects it with nothing sent (sign-in surfaces before the first send, not after a cold install), and the settings picker states who owns sign-in/models/API keys next to the agent list. || api-key-cold-spawn.spec.ts | windows, macos, linux | local-api, tauri-command | local-api-auth, app-launch | medium | partial | command | 3 | Cold-spawn local API config regression coverage. || api-search-stress.spec.ts | windows, macos, linux | local-api, performance | local-api-auth, local-api-search, health, audio-device-health, local-api-load | high | strong | api | 29 | Broad readonly API, auth, search, and load coverage. |diff --git a/apps/screenpipe-app-tauri/e2e/coverage-map.json b/apps/screenpipe-app-tauri/e2e/coverage-map.jsonindex 43e64f587..9ac47def1 100644--- a/apps/screenpipe-app-tauri/e2e/coverage-map.json+++ b/apps/screenpipe-app-tauri/e2e/coverage-map.json@@ -336,13 +336,14 @@"agent-permissions","agent-cancellation","agent-terminal",+ "agent-tool-metadata","mcp-registration","process-supervision"],"criticality": "high","confidence": "partial","ux": "mixed",- "notes": "Official Rust ACP SDK runtime and inline UI E2E with a deterministic stdio agent: initialization, session close, streaming, background permissions, cancellation, localized auth/cancel, malformed stdout, exact adapter/descendant reaping, terminal lifecycle/output draining, and a real authenticated local API MCP health call. Curated third-party adapters remain manual smoke coverage."+ "notes": "Official Rust ACP SDK runtime and inline UI E2E with a deterministic stdio agent: initialization, session close, streaming, background permissions, cancellation, localized auth/cancel, malformed stdout, exact adapter/descendant reaping, terminal lifecycle/output draining, late tool metadata/error propagation with a provider fallback, and a real authenticated local API MCP health call. Curated third-party adapters remain manual smoke coverage."},{"spec": "acp-onboarding-ux.spec.ts",diff --git a/apps/screenpipe-app-tauri/e2e/fixtures/mock-acp-agent.ts b/apps/screenpipe-app-tauri/e2e/fixtures/mock-acp-agent.tsindex e78fdf4dd..7d63620b6 100644--- a/apps/screenpipe-app-tauri/e2e/fixtures/mock-acp-agent.ts+++ b/apps/screenpipe-app-tauri/e2e/fixtures/mock-acp-agent.ts@@ -17,7 +17,7 @@ type JsonRpcMessage = {error?: unknown;};-type Scenario = "normal" | "malformed" | "exit" | "auth" | "mcp" | "tree" | "terminal" | "subagent" | "resume";+type Scenario = "normal" | "malformed" | "exit" | "auth" | "mcp" | "tree" | "terminal" | "subagent" | "metadata" | "resume";const scenarioArg = process.argv.find((arg) => arg.startsWith("--scenario="));const scenario = (scenarioArg?.slice("--scenario=".length) ?? "normal") as Scenario;@@ -306,6 +306,45 @@ function emitPromptPrelude(): void {});}+function emitMetadataRefinementFlow(requestId: JsonRpcId): void {+ update({+ sessionUpdate: "tool_call",+ toolCallId: "mock-refined",+ title: "MCP: tool",+ status: "in_progress",+ rawInput: {},+ });+ update({+ sessionUpdate: "tool_call_update",+ toolCallId: "mock-refined",+ title: "mcp__screenpipe__search-content",+ kind: "search",+ status: "completed",+ rawInput: { query: "late ACP metadata" },+ rawOutput: { error: "Tool execution error" },+ });+ update({+ sessionUpdate: "tool_call",+ toolCallId: "mock-provider-fallback",+ title: "MCP: tool",+ status: "in_progress",+ rawInput: {},+ });+ update({+ sessionUpdate: "tool_call_update",+ toolCallId: "mock-provider-fallback",+ status: "completed",+ rawOutput: { success: true },+ });+ update({+ sessionUpdate: "agent_message_chunk",+ content: { type: "text", text: "Metadata refinement turn complete." },+ messageId: "mock-metadata-final",+ });+ respond(requestId, { stopReason: "end_turn" });+ activePromptRequestId = undefined;+}+/** Deterministic subagent turn matching the claude-agent-acp and codex-acp* wire formats: a parent Task tool call, a flat child stamped with* _meta.claudeCode.parentToolUseId, heartbeat and streamed-output@@ -612,6 +651,10 @@ async function handleRequest(message: JsonRpcMessage): Promise<void> {emitSubagentFlow(message.id);return;}+ if (scenario === "metadata") {+ emitMetadataRefinementFlow(message.id);+ return;+ }if (!activePromptIsCancellation) beginPermissionFlow();return;}diff --git a/apps/screenpipe-app-tauri/e2e/specs/acp-backend.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/acp-backend.spec.tsindex 45b3e8dca..4e8093712 100644--- a/apps/screenpipe-app-tauri/e2e/specs/acp-backend.spec.ts+++ b/apps/screenpipe-app-tauri/e2e/specs/acp-backend.spec.ts@@ -10,6 +10,7 @@ import { fileURLToPath } from "node:url";import { openHomeWindow, waitForAppReady, t } from "../helpers/test-utils.js";import { invokeOrThrow } from "../helpers/tauri.js";+import { saveScreenshot } from "../helpers/screenshot-utils.js";type AgentEnvelope = {source?: string;@@ -42,7 +43,7 @@ type ProcessMarker = {descendantPid?: number;};-type AcpScenario = "normal" | "malformed" | "exit" | "auth" | "mcp" | "tree" | "terminal" | "subagent" | "resume";+type AcpScenario = "normal" | "malformed" | "exit" | "auth" | "mcp" | "tree" | "terminal" | "subagent" | "metadata" | "resume";const fixturePath = fileURLToPath(new URL("../fixtures/mock-acp-agent.ts", import.meta.url));let normalSession = "";@@ -55,6 +56,7 @@ let treeSession = "";let mcpSession = "";let terminalSession = "";let subagentSession = "";+let metadataSession = "";let resumeSession = "";let orphanedPresetSession = "";let treeMarkerPrefix = "";@@ -71,6 +73,7 @@ function resetRunIdentifiers(): void {mcpSession = randomUUID();terminalSession = randomUUID();subagentSession = randomUUID();+ metadataSession = randomUUID();resumeSession = randomUUID();orphanedPresetSession = randomUUID();treeMarkerPrefix = path.join(os.tmpdir(), `screenpipe-acp-process-${treeSession}`);@@ -85,7 +88,7 @@ function acpProviderConfig(return {backend: "acp",acpAgent: {- id: "custom",+ id: scenario === "metadata" ? "pi-acp" : "custom",command: process.execPath,args: [fixturePath, `--scenario=${scenario}`],env,@@ -304,7 +307,7 @@ async function answerAgentAction(async function startAcp(sessionId: string,- scenario: "normal" | "malformed" | "mcp" | "tree" | "terminal" | "subagent" | "resume",+ scenario: "normal" | "malformed" | "mcp" | "tree" | "terminal" | "subagent" | "metadata" | "resume",env: Record<string, string> = {},userToken: string | null = null,resumeSessionId: string | null = null,@@ -552,6 +555,7 @@ describe("ACP backend", function () {await invokeOrThrow("pi_stop", { sessionId: treeSession }).catch(() => undefined);await invokeOrThrow("pi_stop", { sessionId: mcpSession }).catch(() => undefined);await invokeOrThrow("pi_stop", { sessionId: terminalSession }).catch(() => undefined);+ await invokeOrThrow("pi_stop", { sessionId: metadataSession }).catch(() => undefined);rmSync(processMarkerPath("adapter"), { force: true });rmSync(processMarkerPath("descendant"), { force: true });});@@ -913,6 +917,63 @@ describe("ACP backend", function () {await stopAndAssertGone(subagentSession);});+ it("preserves terminal ACP metadata and renders traceable tool activity", async () => {+ await startAcp(metadataSession, "metadata");+ await foregroundChat(metadataSession);+ await browser.execute(() => {+ (window as any).__e2eExpandToolActivity = true;+ });+ await beginPrompt(metadataSession, "refine late tool metadata");+ const prompt = await waitForPromptDone();+ expect(prompt.error).toBeUndefined();+ await browser.waitUntil(+ async () => (await capturedEvents(metadataSession)).some(+ (envelope) => envelope.event?.type === "agent_end",+ ),+ {+ timeout: t(10_000),+ interval: 100,+ timeoutMsg: "metadata refinement turn did not complete",+ },+ );++ const widgets = await $$('[data-testid="tool-activity-widget"]');+ expect(widgets.length).toBeGreaterThan(0);+ const widget = widgets[widgets.length - 1];+ const list = await widget.$('[data-testid="tool-activity-list"]');+ await list.waitForExist({ timeout: t(10_000) });+ const rows = await widget.$$('[data-testid="tool-activity-item"]');+ expect(rows).toHaveLength(2);+ const listText = await list.getText();+ expect(listText).toContain("Searched your history");+ expect(listText).toContain("Used a Pi tool");+ expect(listText).not.toContain("Completed a background step");++ await rows[0].click();+ await browser.waitUntil(async () => (await widget.getText()).includes("late ACP metadata"), {+ timeout: t(5_000),+ interval: 100,+ timeoutMsg: "refined ACP arguments were not disclosed in the tool row",+ });+ const variant = process.env.SCREENPIPE_PR_PROOF_VARIANT ?? "after";+ const screenshot = await saveScreenshot(`acp-tool-metadata-${variant}`);+ expect(existsSync(screenshot)).toBe(true);++ const terminal = (await capturedEvents(metadataSession)).find(+ (envelope) =>+ envelope.event?.type === "tool_execution_end" &&+ envelope.event?.toolCallId === "mock-refined",+ )?.event;+ expect(terminal).toMatchObject({+ toolName: "mcp__screenpipe__search-content",+ agentId: "pi-acp",+ kind: "search",+ args: { query: "late ACP metadata" },+ isError: true,+ });+ await stopAndAssertGone(metadataSession);+ });+it("reattaches to a prior session via session/resume when one is provided", async () => {await startAcp(resumeSession, "resume", {}, null, "mock-acp-session");const events = await capturedEvents(resumeSession);diff --git a/apps/screenpipe-app-tauri/lib/__tests__/pi-event-router.test.ts b/apps/screenpipe-app-tauri/lib/__tests__/pi-event-router.test.tsindex fea0b0457..9590804db 100644--- a/apps/screenpipe-app-tauri/lib/__tests__/pi-event-router.test.ts+++ b/apps/screenpipe-app-tauri/lib/__tests__/pi-event-router.test.ts@@ -953,6 +953,48 @@ describe("pi-event-router: subagent tool progress", () => {).toolCall;expect(cmd.progress.length).toBe(4000);});++ it("keeps late ACP metadata on a completed background tool", async () => {+ seed("A");+ useChatStore.setState({ currentId: "B" });+ await handlePiEvent(+ piEvt("A", { type: "message_start", message: { role: "assistant" } }),+ );+ await handlePiEvent(+ piEvt("A", {+ type: "tool_execution_start",+ toolCallId: "late-metadata",+ toolName: "MCP: tool",+ agentId: "cursor",+ args: {},+ } as unknown as AgentInnerEvent),+ );+ await handlePiEvent(+ piEvt("A", {+ type: "tool_execution_end",+ toolCallId: "late-metadata",+ toolName: "mcp__screenpipe__search-content",+ agentId: "cursor",+ kind: "search",+ args: { query: "late ACP metadata" },+ result: { content: [{ type: "text", text: '{"error":"Tool execution error"}' }] },+ isError: true,+ } as unknown as AgentInnerEvent),+ );++ const session = useChatStore.getState().sessions.A;+ const tool = (session.contentBlocks as any[]).find(+ (block) => block.type === "tool" && block.toolCall.id === "late-metadata",+ ).toolCall;+ expect(tool).toMatchObject({+ toolName: "mcp__screenpipe__search-content",+ agentId: "cursor",+ kind: "search",+ args: { query: "late ACP metadata" },+ isRunning: false,+ isError: true,+ });+ });});describe("pi-event-router: honest interruption on quit/crash", () => {diff --git a/apps/screenpipe-app-tauri/lib/chat/__tests__/tool-presentation.test.ts b/apps/screenpipe-app-tauri/lib/chat/__tests__/tool-presentation.test.tsindex dbe466ea2..8a65ea897 100644--- a/apps/screenpipe-app-tauri/lib/chat/__tests__/tool-presentation.test.ts+++ b/apps/screenpipe-app-tauri/lib/chat/__tests__/tool-presentation.test.ts@@ -469,6 +469,21 @@ describe("presentToolActivity — ACP tool calls", () => {"Completed a background step",);});++ it("identifies the provider when ACP supplies no meaningful tool metadata", () => {+ expect(+ presentToolActivity({ toolName: "MCP: tool", agentId: "cursor", args: {} }),+ ).toMatchObject({+ runningLabel: "Using a Cursor tool",+ completedLabel: "Used a Cursor tool",+ });+ expect(+ presentToolActivity({ toolName: "MCP: tool", agentId: "pi-acp", args: {} }).completedLabel,+ ).toBe("Used a Pi tool");+ expect(+ presentToolActivity({ toolName: "MCP: tool", agentId: "custom", args: {} }).completedLabel,+ ).toBe("Used an ACP tool");+ });});describe("MCP server startup diagnostics", () => {diff --git a/apps/screenpipe-app-tauri/lib/chat/tool-presentation.ts b/apps/screenpipe-app-tauri/lib/chat/tool-presentation.tsindex 5d9b4ff11..7e4fee519 100644--- a/apps/screenpipe-app-tauri/lib/chat/tool-presentation.ts+++ b/apps/screenpipe-app-tauri/lib/chat/tool-presentation.ts@@ -469,6 +469,7 @@ export interface PresentableToolCall {kind?: string;isRunning?: boolean;isError?: boolean;+ agentId?: string;// Set when this call is a subagent launch (Claude's Task/Agent tool). It is a// container for the nested transcript, so it is labeled as a subagent run// rather than by its `think` kind, which reads as "Thought it through".@@ -509,6 +510,19 @@ const GENERIC_ACTIVITY: ToolActivityPresentation = {icon: "work",};+function providerToolActivity(agentId?: string): ToolActivityPresentation | null {+ if (!agentId) return null;+ const provider = ({+ "cursor": "Cursor",+ "claude-acp": "Claude",+ "codex-acp": "Codex",+ "pi-acp": "Pi",+ "github-copilot-cli": "GitHub Copilot",+ } as Record<string, string>)[agentId.toLowerCase()] ?? "ACP";+ const article = provider === "ACP" ? "an" : "a";+ return activity(`Using ${article} ${provider} tool`, `Used ${article} ${provider} tool`, "work");+}+function activity(runningLabel: string,completedLabel: string,@@ -1038,7 +1052,7 @@ export function presentToolActivity(toolCall: PresentableToolCall): ToolActivityreturn activity(humanized, humanized, "work");}}- return GENERIC_ACTIVITY;+ return providerToolActivity(toolCall.agentId) ?? GENERIC_ACTIVITY;}/**diff --git a/apps/screenpipe-app-tauri/lib/chat/types.ts b/apps/screenpipe-app-tauri/lib/chat/types.tsindex 566d4ee8e..f77028f79 100644--- a/apps/screenpipe-app-tauri/lib/chat/types.ts+++ b/apps/screenpipe-app-tauri/lib/chat/types.ts@@ -59,6 +59,9 @@ export type ChatAttachment = {export interface ToolCall {id: string;toolName: string;+ /** ACP adapter id that produced this call. Used only for a safe provider+ * fallback when the adapter never supplies a meaningful tool title. */+ agentId?: string;/** ACP tool-call kind (read/edit/execute/fetch/search/think/…) when the agent* provides one; drives a sensible activity label for native ACP tools. */kind?: string;diff --git a/apps/screenpipe-app-tauri/lib/stores/pi-event-router.ts b/apps/screenpipe-app-tauri/lib/stores/pi-event-router.tsindex 81d2ce708..8f1e7a037 100644--- a/apps/screenpipe-app-tauri/lib/stores/pi-event-router.ts+++ b/apps/screenpipe-app-tauri/lib/stores/pi-event-router.ts@@ -756,15 +756,20 @@ function applyEventToSessionContent(sid: string, payload: PiInnerEvent) {if (!cur?.streamingMessageId) return;const msgId = cur.streamingMessageId;const parentToolCallId = (payload as any).parentToolCallId;+ const agentId = (payload as any).agentId;+ const toolKind = (payload as any).kind;const tool = {id: (payload as any).toolCallId || `${Date.now()}`,toolName: (payload as any).toolName || "unknown",args: (payload as any).args || {},isRunning: true,startedAtMs: Date.now(),+ ...(typeof agentId === "string" && agentId ? { agentId } : {}),+ ...(typeof toolKind === "string" && toolKind ? { kind: toolKind } : {}),...(typeof parentToolCallId === "string" && parentToolCallId? { parentToolCallId }: {}),+ ...((payload as any).subagent === true ? { subagent: true } : {}),};const blocks = [...((cur.contentBlocks as any[]) ?? []), { type: "tool", toolCall: tool }];store.actions.setStreaming(sid, { contentBlocks: blocks });@@ -817,6 +822,9 @@ function applyEventToSessionContent(sid: string, payload: PiInnerEvent) {if (typeof p.subagentType === "string") next.subagentType = p.subagentType;if (p.retry !== undefined) next.retry = p.retry;if (typeof p.title === "string" && p.title) next.toolName = p.title;+ if (typeof p.agentId === "string" && p.agentId) next.agentId = p.agentId;+ if (typeof p.kind === "string" && p.kind) next.kind = p.kind;+ if (p.args && typeof p.args === "object" && !Array.isArray(p.args)) next.args = p.args;if (typeof p.outputDelta === "string" && p.outputDelta) {const combined = `${next.progress ?? ""}${p.outputDelta}`;next.progress = combined.length > 4000 ? combined.slice(-4000) : combined;@@ -850,6 +858,12 @@ function applyEventToSessionContent(sid: string, payload: PiInnerEvent) {...b,toolCall: {...b.toolCall,+ ...((payload as any).toolName ? { toolName: (payload as any).toolName } : {}),+ ...((payload as any).agentId ? { agentId: (payload as any).agentId } : {}),+ ...((payload as any).kind ? { kind: (payload as any).kind } : {}),+ ...((payload as any).args && typeof (payload as any).args === "object"+ ? { args: (payload as any).args }+ : {}),isRunning: false,result: truncated,isError: (payload as any).isError,diff --git a/crates/screenpipe-core/src/agents/acp/runtime.rs b/crates/screenpipe-core/src/agents/acp/runtime.rsindex f5fafcc32..e8170cb90 100644--- a/crates/screenpipe-core/src/agents/acp/runtime.rs+++ b/crates/screenpipe-core/src/agents/acp/runtime.rs@@ -1783,7 +1783,10 @@ impl RuntimeState {self.output.send(json!({"type": "tool_execution_end","toolCallId": tool_call_id,+ "agentId": self.agent_id,"toolName": tool_name(&tool),+ "kind": tool_kind(&tool),+ "args": tool_args(&tool),"result": result,"isError": is_error}));@@ -1917,6 +1920,7 @@ impl RuntimeState {let mut start = json!({"type": "tool_execution_start","toolCallId": id,+ "agentId": self.agent_id,"toolName": tool_name(&update),// The ACP category (read/edit/execute/fetch/search/...) lets// the desktop label native agent tools whose human title@@ -1936,7 +1940,7 @@ impl RuntimeState {self.output.send(start);if update_status_finished(&update) {self.observe_provider_schedule(&update);- finish_tool(&self.output, &id, &update);+ finish_tool(&self.output, &self.agent_id, &id, &update);turn.active_tools.remove(&id);}}@@ -1963,6 +1967,7 @@ impl RuntimeState {let mut start = json!({"type": "tool_execution_start","toolCallId": id,+ "agentId": self.agent_id,"toolName": tool_name(&merged),"kind": tool_kind(&merged),"args": tool_args(&merged),@@ -1975,12 +1980,13 @@ impl RuntimeState {}if update_status_finished(&merged) {self.observe_provider_schedule(&merged);- finish_tool(&self.output, &id, &merged);+ finish_tool(&self.output, &self.agent_id, &id, &merged);turn.active_tools.remove(&id);} else if let Some(progress) = tool_progress(&update) {let mut event = json!({"type": "tool_execution_progress","toolCallId": id,+ "agentId": self.agent_id,});// Carry the parent so a subagent heartbeat nests under its// Task row even when linkage only appears on updates.@@ -2308,6 +2314,12 @@ fn tool_progress(update: &Value) -> Option<Value> {{fields.insert("title".into(), json!(title));}+ if let Some(kind) = tool_kind(update) {+ fields.insert("kind".into(), json!(kind));+ }+ if let Some(args) = tool_args_if_present(update) {+ fields.insert("args".into(), args);+ }if fields.is_empty() {None} else {@@ -2391,12 +2403,16 @@ fn tool_kind(update: &Value) -> Option<String> {// adapters omit it and carry the invocation under `input`/`arguments`. Falling// back keeps the desktop tool card (and its citations) from rendering empty.fn tool_args(update: &Value) -> Value {+ tool_args_if_present(update).unwrap_or_else(|| json!({}))+}++fn tool_args_if_present(update: &Value) -> Option<Value> {for key in ["rawInput", "input", "arguments"] {if let Some(object) = update.get(key).filter(|value| value.is_object()) {- return object.clone();+ return Some(object.clone());}}- json!({})+ None}fn update_status_finished(update: &Value) -> bool {@@ -2415,8 +2431,44 @@ fn tool_result_text(update: &Value) -> String {.unwrap_or_default()}-fn finish_tool(output: &ParentOutput, id: &str, update: &Value) {- let is_error = update.get("status").and_then(Value::as_str) == Some("failed");+fn tool_result_is_error(update: &Value) -> bool {+ if update.get("status").and_then(Value::as_str) == Some("failed") {+ return true;+ }++ fn explicit_error(value: &Value) -> bool {+ let parsed;+ let value = if let Some(text) = value.as_str() {+ parsed = match serde_json::from_str::<Value>(text.trim()) {+ Ok(value) => value,+ Err(_) => return false,+ };+ &parsed+ } else {+ value+ };+ let Some(object) = value.as_object() else {+ return false;+ };+ if object.get("success").and_then(Value::as_bool) == Some(true) {+ return false;+ }+ match object.get("error") {+ Some(Value::Null | Value::Bool(false)) | None => false,+ Some(Value::String(message)) => !message.trim().is_empty(),+ Some(_) => true,+ }+ }++ update.get("rawOutput").is_some_and(explicit_error)+ || update+ .get("content")+ .and_then(|content| content_text(Some(content)))+ .is_some_and(|text| explicit_error(&Value::String(text)))+}++fn finish_tool(output: &ParentOutput, agent_id: &str, id: &str, update: &Value) {+ let is_error = tool_result_is_error(update);let mut result = tool_result_text(update);if result.trim().is_empty() {// Some adapters report completion with neither content nor rawOutput; a@@ -2429,7 +2481,10 @@ fn finish_tool(output: &ParentOutput, id: &str, update: &Value) {output.send(json!({"type": "tool_execution_end","toolCallId": id,+ "agentId": agent_id,"toolName": tool_name(update),+ "kind": tool_kind(update),+ "args": tool_args(update),// The desktop event router reads the raw-Pi result shape// ({content: [{text}]}), not a bare string."result": { "content": [{ "type": "text", "text": result }] },@@ -5533,6 +5588,17 @@ mod tests {.expect("output progress");assert_eq!(progress["outputDelta"], json!("compiling...\n"));+ // Late ACP metadata must be visible to the desktop before completion.+ let progress = tool_progress(&json!({+ "title": "mcp__screenpipe__search-content",+ "kind": "search",+ "rawInput": { "query": "late metadata" }+ }))+ .expect("metadata progress");+ assert_eq!(progress["title"], json!("mcp__screenpipe__search-content"));+ assert_eq!(progress["kind"], json!("search"));+ assert_eq!(progress["args"], json!({ "query": "late metadata" }));+// A bare status merge carries nothing renderable.assert_eq!(tool_progress(&json!({ "status": "in_progress" })), None);}@@ -5682,6 +5748,50 @@ mod tests {assert_eq!(events_of_type(&events, "tool_execution_end").len(), 1);}+ #[test]+ fn terminal_tool_update_keeps_metadata_and_error_payload() {+ let output = ParentOutput::buffer();+ let state = test_state(&output);+ state.handle_update(json!({+ "sessionUpdate": "tool_call",+ "toolCallId": "late-tool",+ "title": "MCP: tool",+ "status": "in_progress",+ "rawInput": {}+ }));+ output.drain();++ state.handle_update(json!({+ "sessionUpdate": "tool_call_update",+ "toolCallId": "late-tool",+ "title": "mcp__screenpipe__search-content",+ "kind": "search",+ "status": "completed",+ "rawInput": { "query": "late ACP metadata" },+ "rawOutput": { "error": "Tool execution error" }+ }));+ let events = output.drain();+ let ends = events_of_type(&events, "tool_execution_end");+ assert_eq!(ends.len(), 1);+ assert_eq!(ends[0]["agentId"], json!("test-agent"));+ assert_eq!(+ ends[0]["toolName"],+ json!("mcp__screenpipe__search-content")+ );+ assert_eq!(ends[0]["kind"], json!("search"));+ assert_eq!(ends[0]["args"], json!({ "query": "late ACP metadata" }));+ assert_eq!(ends[0]["isError"], json!(true));++ assert!(!tool_result_is_error(&json!({+ "status": "completed",+ "rawOutput": { "success": true, "error": "diagnostic field" }+ })));+ assert!(!tool_result_is_error(&json!({+ "status": "completed",+ "rawOutput": { "error": null }+ })));+ }+#[test]fn advertises_and_detects_the_subagent_transcript_capability() {let meta = subagent_transcript_capability();diff --git a/docs/pr-assets/acp-tool-metadata/after.png b/docs/pr-assets/acp-tool-metadata/after.pngnew file mode 100644index 000000000..74ba48d9bBinary files /dev/null and b/docs/pr-assets/acp-tool-metadata/after.png differdiff --git a/docs/pr-assets/acp-tool-metadata/before.png b/docs/pr-assets/acp-tool-metadata/before.pngnew file mode 100644index 000000000..ed43ef496Binary files /dev/null and b/docs/pr-assets/acp-tool-metadata/before.png differ