Skip to content

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

Improve chat activity summaries and disclosure (#7296)

Louis Beaumont042cd396a676
diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/message-content.streaming.test.tsx b/apps/screenpipe-app-tauri/components/chat/standalone/message-content.streaming.test.tsx
index 25a1c21f6..aeff69cde 100644
--- a/apps/screenpipe-app-tauri/components/chat/standalone/message-content.streaming.test.tsx
+++ b/apps/screenpipe-app-tauri/components/chat/standalone/message-content.streaming.test.tsx
@@ -75,6 +75,10 @@ describe("MessageContent streaming Markdown", () => {
expect(screen.getByTestId("streaming-markdown-tail")).toHaveTextContent(
"still streaming",
);
+ // Once the model is writing the next paragraph, the earlier read must
+ // remain completed instead of borrowing the whole turn's busy state.
+ expect(screen.getByTestId("tool-activity-widget")).toHaveAttribute("data-activity-state", "completed");
+ expect(screen.getByTestId("tool-activity-summary")).toHaveTextContent("Read source.ts");
expect(
screen.getByRole("heading", { name: "live result" }),
).toBeInTheDocument();
diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/message-content.tsx b/apps/screenpipe-app-tauri/components/chat/standalone/message-content.tsx
index e2520acc9..4714afeb2 100644
--- a/apps/screenpipe-app-tauri/components/chat/standalone/message-content.tsx
+++ b/apps/screenpipe-app-tauri/components/chat/standalone/message-content.tsx
@@ -41,6 +41,8 @@ import {
firstExternalWebTarget,
presentToolActivity,
presentToolActivityStatus,
+ summarizeToolActivities,
+ toolActivityFileName,
presentMcpStartup,
mcpScreenpipeCommand,
type WebTargetPresentation,
@@ -1305,15 +1307,6 @@ function formatRunningWorkDuration(label: string, startedAtMs: number): string {
return durationMs >= 1000 ? `${label} · ${formatDurationParts(durationMs)}` : label;
}
-function completedWorkSummaryFromRunning(runningSummary: string): string {
- const separator = " · ";
- const separatorIndex = runningSummary.lastIndexOf(separator);
- if (separatorIndex >= 0) {
- return `Done in ${runningSummary.slice(separatorIndex + separator.length)}`;
- }
- return "done";
-}
-
function friendlyCompletedSummary(summary?: string): string | undefined {
if (!summary) return undefined;
if (summary === "Worked") return "done";
@@ -1392,8 +1385,6 @@ function ToolActivityGroup({
const [manualExpand, setManualExpand] = useState<boolean | null>(null);
const [runningSummary, setRunningSummary] = useState("Working");
- const [completedLiveSummary, setCompletedLiveSummary] = useState<string | null>(null);
- const wasWorkingRef = useRef(false);
const reduceMotion = useReducedMotion();
const hasRunningTool = toolCalls.some((tc) => tc.isRunning);
@@ -1410,20 +1401,12 @@ function ToolActivityGroup({
const runningLabel = waitingForApproval
? "Waiting for your approval"
: presentToolActivityStatus(toolCalls, isGenerating);
- const justCompletedSummary = !isWorking && wasWorkingRef.current
- ? completedWorkSummaryFromRunning(runningSummary)
- : null;
- const summary = allDone
- ? (
- preferSummaryOverride && summaryOverride
- ? friendlyCompletedSummary(summaryOverride)
- : justCompletedSummary ||
- completedLiveSummary ||
- (completedDurationMs
- ? `done in ${formatDurationParts(completedDurationMs)}`
- : (friendlyCompletedSummary(summaryOverride) || "done"))
- )
- : "";
+ const summary = preferSummaryOverride && summaryOverride
+ ? friendlyCompletedSummary(summaryOverride)
+ : summarizeToolActivities(toolCalls);
+ const durationLabel = completedDurationMs
+ ? formatDurationParts(completedDurationMs)
+ : summaryOverride?.startsWith("Worked for ") ? summaryOverride.slice("Worked for ".length) : undefined;
const summaryToolCall = [...toolCalls].reverse().find((toolCall) => toolCall.isRunning)
?? toolCalls[toolCalls.length - 1];
const summaryIcon = waitingForApproval
@@ -1464,18 +1447,6 @@ function ToolActivityGroup({
return () => window.clearInterval(id);
}, [isWorking, runningLabel, startedAtMs, hasRunningTool, toolCalls]);
- useEffect(() => {
- if (isWorking) {
- wasWorkingRef.current = true;
- setCompletedLiveSummary(null);
- return;
- }
- if (wasWorkingRef.current) {
- setCompletedLiveSummary(completedWorkSummaryFromRunning(runningSummary));
- wasWorkingRef.current = false;
- }
- }, [isWorking, runningSummary]);
-
// 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.
@@ -1494,10 +1465,7 @@ function ToolActivityGroup({
return (
<div
- className={cn(
- "w-full min-w-0 self-stretch",
- !hideSummary && "border border-border/70 bg-card/30",
- )}
+ className="w-full min-w-0 self-stretch py-1"
data-testid="tool-activity-widget"
data-activity-state={widgetState}
>
@@ -1509,18 +1477,18 @@ function ToolActivityGroup({
summary + any failure count once idle. */}
<button
onClick={() => setManualExpand(isExpanded ? false : true)}
- className="group flex w-full min-w-0 cursor-pointer items-center gap-2 px-2 py-1.5 text-left transition-colors duration-150 hover:bg-foreground/[0.035] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-signal disabled:cursor-default disabled:opacity-70 motion-reduce:transition-none"
+ className="group flex max-w-full min-w-0 cursor-pointer items-center gap-2 rounded-sm py-1 text-left transition-colors duration-150 hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-signal focus-visible:ring-offset-2 disabled:cursor-default disabled:opacity-70 motion-reduce:transition-none"
data-testid="tool-activity-summary"
aria-expanded={isExpanded}
disabled={forceCollapsed || hasInteractiveTool}
>
- <ActivityIcon
+ {(isWorking || (hasError && !recoveredWithAnswer)) && <ActivityIcon
kind={summaryIcon}
state={widgetState}
testId={isWorking ? "tool-activity-running-indicator" : undefined}
- />
+ />}
<span
- className="truncate text-xs font-mono text-foreground/55 transition-colors duration-150 group-hover:text-foreground/80 motion-reduce:transition-none"
+ className="min-w-0 text-sm leading-5 text-muted-foreground [overflow-wrap:anywhere] transition-colors duration-150 group-hover:text-foreground motion-reduce:transition-none"
aria-live="polite"
>
{isWorking ? (
@@ -1535,6 +1503,7 @@ function ToolActivityGroup({
) : (
<>
<WorkSummaryText text={summary || `${total} steps`} animateRunningDuration={false} />
+ {durationLabel && !preferSummaryOverride && <span className="ml-2 text-xs tabular-nums text-muted-foreground/70">{durationLabel}</span>}
{hasError && !recoveredWithAnswer && (
<span className="ml-1.5 text-destructive">· {toolCalls.filter(tc => tc.isError).length} failed</span>
)}
@@ -1547,6 +1516,11 @@ function ToolActivityGroup({
<ChevronRight className="h-3.5 w-3.5 flex-shrink-0 text-foreground/30 group-hover:text-foreground/60 transition-colors duration-150" />
))}
</button>
+ {hasRunningTool && summaryToolCall && toolActivityFileName(summaryToolCall) && (
+ <p className="mt-0.5 pl-6 font-mono text-xs text-muted-foreground [overflow-wrap:anywhere]" data-testid="tool-activity-current-target">
+ {toolActivityFileName(summaryToolCall)}
+ </p>
+ )}
</div>
)}
@@ -1562,7 +1536,7 @@ function ToolActivityGroup({
<div
className={cn(
"pt-1",
- hideSummary ? "pl-1" : "border-t border-border/60 px-2 pb-1 pt-2",
+ hideSummary ? "pl-1" : "border-l border-border/60 ml-1 pl-2 pb-1 pt-2",
)}
data-testid="tool-activity-list"
>
@@ -1969,7 +1943,7 @@ export function MessageContent({
key={`tools-${group.key}`}
toolCalls={group.toolCalls}
defaultExpanded={false}
- isGenerating={isGenerating && !message.workDurationMs}
+ isGenerating={isGenerating && groupIndex === displayGroups.length - 1 && !message.workDurationMs}
waitingForApproval={waitingForApproval}
preferSummaryOverride={Boolean(workSummaryOverride)}
summaryOverride={workSummaryOverride || (message.workDurationMs ? formatWorkDuration(message.workDurationMs) : undefined)}
@@ -1992,7 +1966,7 @@ export function MessageContent({
key={`work-${group.key}`}
toolCalls={group.toolCalls}
defaultExpanded={false}
- isGenerating={isGenerating && !message.workDurationMs}
+ isGenerating={isGenerating && groupIndex === displayGroups.length - 1 && !message.workDurationMs}
waitingForApproval={waitingForApproval}
preferSummaryOverride={Boolean(workSummaryOverride)}
summaryOverride={workSummaryOverride || formatWorkDuration(durationMs)}
diff --git a/apps/screenpipe-app-tauri/e2e/COVERAGE.md b/apps/screenpipe-app-tauri/e2e/COVERAGE.md
index 20fff9e59..18d266150 100644
--- a/apps/screenpipe-app-tauri/e2e/COVERAGE.md
+++ b/apps/screenpipe-app-tauri/e2e/COVERAGE.md
@@ -162,7 +162,7 @@ pass/fail/skip counts.
| chat-stuck-queue-guard.spec.ts | windows, macos, linux | chat-ai | chat | high | partial | synthetic | 1 | A turn that ends while the panel does not own the session on the agent-event bus must still release the composer dispatch guards and must not duplicate the user message; regression for the stuck 'analyzing…' chat whose later messages all piled into QUEUED. |
| chat-subagent-async-completion.spec.ts | windows, macos, linux | chat-ai, real-ui-e2e, tauri-command | chat, chat-streaming, async-subagents | high | strong | real-user-flow | 1 | Verifies an asynchronous subagent completion appears as a distinct second assistant turn after the original answer settles, without another user prompt. |
| chat-switch-context-loss.spec.ts | windows, macos, linux | chat-ai | chat, chat-context | medium | partial | synthetic | 1 | Switching conversations during streaming must not corrupt state. |
-| chat-tool-activity.spec.ts | windows, macos, linux | chat-ai, real-ui-e2e | chat, chat-answer-rendering, chat-commentary, chat-long-tool-liveness, chat-tools, mcp-startup-filtering, pi-tool-activity, progressive-disclosure | high | strong | mixed | 9 | Mixed Python, JavaScript, Screenpipe API, file, test, recovered-error, and optional live Pi tool flows stay collapsed by default, expose only friendly activity on first expansion, and keep completed tools active while the shared Pi turn is still streaming. Commentary remains visible in transcript order around live and completed tool groups; settled final answers remain distinct from progress, so unrecovered failure, user-stop, and app-interruption states stay truthful. Synthetic MCP startup events stay out of the transcript so the answer remains primary, connection diagnostics never leak into chat, and startup failures never inflate the command rail's failure count. |
+| chat-tool-activity.spec.ts | windows, macos, linux | chat-ai, real-ui-e2e | chat, chat-answer-rendering, chat-commentary, chat-long-tool-liveness, chat-tools, mcp-startup-filtering, pi-tool-activity, progressive-disclosure | high | strong | mixed | 9 | Mixed Python, JavaScript, Screenpipe API, file, test, recovered-error, and optional live Pi tool flows stay collapsed by default, expose only friendly activity on first expansion, and keep the trailing tool group active while the shared Pi turn is still streaming. Completed groups retain action and file summaries with secondary duration; earlier groups settle when later prose streams. Commentary remains visible in transcript order around live and completed tool groups; settled final answers remain distinct from progress, so unrecovered failure, user-stop, and app-interruption states stay truthful. Synthetic MCP startup events stay out of the transcript so the answer remains primary, connection diagnostics never leak into chat, and startup failures never inflate the command rail's failure count. |
| chat-turn-liveness.spec.ts | windows, macos, linux | chat-ai, real-ui-e2e | chat, chat-streaming, offline-recovery | high | strong | real-user-flow | 1 | The real desktop chat turns off its active phosphor signal and explains that a message is saved when WebView connectivity drops, restores active state on reconnect, and exposes a silent harness after the bounded no-event deadline. |
| chat-window.spec.ts | windows, macos, linux | chat-ai, window-lifecycle, real-ui-e2e | chat, window-lifecycle | high | strong | real-user-flow | 2 | Opens Chat and focuses the composer for typing. A chat saved from the floating window syncs into Home's Recents without becoming a second Home working tab. |
| chat-within-session-context-loss.spec.ts | macos | chat-ai | chat, chat-context | medium | conditional | synthetic | 5 | macOS-only within-chat context retention regression. |
diff --git a/apps/screenpipe-app-tauri/e2e/coverage-map.json b/apps/screenpipe-app-tauri/e2e/coverage-map.json
index f9e225f25..073aff6ca 100644
--- a/apps/screenpipe-app-tauri/e2e/coverage-map.json
+++ b/apps/screenpipe-app-tauri/e2e/coverage-map.json
@@ -1563,7 +1563,7 @@
"criticality": "high",
"confidence": "strong",
"ux": "mixed",
- "notes": "Mixed Python, JavaScript, Screenpipe API, file, test, recovered-error, and optional live Pi tool flows stay collapsed by default, expose only friendly activity on first expansion, and keep completed tools active while the shared Pi turn is still streaming. Commentary remains visible in transcript order around live and completed tool groups; settled final answers remain distinct from progress, so unrecovered failure, user-stop, and app-interruption states stay truthful. Synthetic MCP startup events stay out of the transcript so the answer remains primary, connection diagnostics never leak into chat, and startup failures never inflate the command rail's failure count."
+ "notes": "Mixed Python, JavaScript, Screenpipe API, file, test, recovered-error, and optional live Pi tool flows stay collapsed by default, expose only friendly activity on first expansion, and keep the trailing tool group active while the shared Pi turn is still streaming. Completed groups retain action and file summaries with secondary duration; earlier groups settle when later prose streams. Commentary remains visible in transcript order around live and completed tool groups; settled final answers remain distinct from progress, so unrecovered failure, user-stop, and app-interruption states stay truthful. Synthetic MCP startup events stay out of the transcript so the answer remains primary, connection diagnostics never leak into chat, and startup failures never inflate the command rail's failure count."
},
{
"spec": "chat-window.spec.ts",
diff --git a/apps/screenpipe-app-tauri/e2e/specs/chat-tool-activity.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/chat-tool-activity.spec.ts
index 1a3bcf7a1..53b1d398f 100644
--- a/apps/screenpipe-app-tauri/e2e/specs/chat-tool-activity.spec.ts
+++ b/apps/screenpipe-app-tauri/e2e/specs/chat-tool-activity.spec.ts
@@ -345,12 +345,13 @@ describe("Chat tool activity progressive disclosure", function () {
const summaries = Array.from(
document.querySelectorAll('[data-testid="tool-activity-summary"]'),
);
- return summaries.at(-1)?.textContent?.includes("done in 31s") ?? false;
+ const text = summaries.at(-1)?.textContent ?? "";
+ return text.includes("Analyzed information") && text.includes("31s");
})) as boolean,
{
timeout: t(8_000),
interval: 100,
- timeoutMsg: "completed activity never collapsed into a duration receipt",
+ timeoutMsg: "completed activity never showed its action and duration receipt",
},
);
const summary = await lastSummary();
diff --git a/apps/screenpipe-app-tauri/lib/chat/__tests__/activity-summary.test.ts b/apps/screenpipe-app-tauri/lib/chat/__tests__/activity-summary.test.ts
new file mode 100644
index 000000000..4edbad35e
--- /dev/null
+++ b/apps/screenpipe-app-tauri/lib/chat/__tests__/activity-summary.test.ts
@@ -0,0 +1,30 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+import { describe, expect, it } from "vitest";
+import { summarizeToolActivities, toolActivityFileName } from "../tool-presentation";
+describe("completed activity summaries", () => {
+ it("describes mixed work and keeps parent paths and raw commands out of the summary", () => {
+ const summary = summarizeToolActivities([
+ { toolName: "query_recordings", args: { q: "handoff" } },
+ { toolName: "read", args: { path: "/private/work/checklist.md" } },
+ { toolName: "edit", args: { path: "/private/work/checklist.md" } },
+ ]);
+ expect(summary).toBe("Searched recordings · Read checklist.md · Updated checklist.md");
+ expect(summary).not.toContain("/private");
+ });
+ it("counts distinct paths and repeated queries without dropping any activity", () => {
+ expect(summarizeToolActivities([
+ { toolName: "read", args: { path: "/a/notes.md" } },
+ { toolName: "read", args: { path: "/b/notes.md" } },
+ { toolName: "read", args: { path: "/a/notes.md" } },
+ { toolName: "query_recordings" }, { toolName: "query_recordings" },
+ ])).toBe("Read 2 files · Searched recordings ×2");
+ expect(toolActivityFileName({ toolName: "read", args: { filePath: "C:\\work\\notes.md" } })).toBe("notes.md");
+ });
+ it("never describes failed or running writes as completed", () => {
+ const failure = { toolName: "edit", args: { path: "/a/notes.md" }, isError: true };
+ expect(summarizeToolActivities([failure])).toBe("Activity failed");
+ expect(summarizeToolActivities([{ ...failure, isError: false, isRunning: true }])).toBe("Working");
+ expect(summarizeToolActivities([{ toolName: "read", args: { path: "README.md" } }, failure])).toBe("Read README.md");
+ });
+});
diff --git a/apps/screenpipe-app-tauri/lib/chat/tool-presentation.ts b/apps/screenpipe-app-tauri/lib/chat/tool-presentation.ts
index eec5ac3fa..4254e3416 100644
--- a/apps/screenpipe-app-tauri/lib/chat/tool-presentation.ts
+++ b/apps/screenpipe-app-tauri/lib/chat/tool-presentation.ts
@@ -1092,3 +1092,40 @@ export function presentToolActivityStatus(
return isGenerating ? "Preparing your answer" : "Working on your request";
}
+
+/** A short file target, without exposing its parent directories in the transcript. */
+export function toolActivityFileName(tool: PresentableToolCall): string | undefined {
+ if (tool.subagent) return;
+ const name = tool.toolName.toLowerCase();
+ if (!["read", "read_file", "open_file", "edit", "write", "write_file", "apply_patch"].includes(name) && !["read", "edit"].includes(tool.kind ?? "")) return;
+ const args = tool.args ?? {};
+ const path = args.path ?? args.filePath ?? args.file_path ?? args.file ?? args.abs_path;
+ if (typeof path !== "string") return;
+ return path.split(/[\\/]/).filter(Boolean).at(-1);
+}
+
+/** Keep completed work descriptive. Counts describe calls, never successful writes inferred from elapsed time. */
+export function summarizeToolActivities(tools: PresentableToolCall[]): string {
+ const done = tools.filter(tool => !tool.isRunning && !tool.isError);
+ if (done.length === 0) return tools.some(tool => tool.isError) ? "Activity failed" : "Working";
+ const groups = new Map<string, { label: string; count: number; files: Set<string> }>();
+ for (const tool of done) {
+ const presentation = presentToolActivity(tool);
+ const file = toolActivityFileName(tool);
+ const key = `${presentation.icon}:${presentation.completedLabel}`;
+ const group = groups.get(key) ?? { label: presentation.completedLabel, count: 0, files: new Set<string>() };
+ group.count++;
+ // Count full paths, since distinct folders can contain the same filename.
+ if (file) group.files.add(String(tool.args?.path ?? tool.args?.filePath ?? tool.args?.file_path ?? tool.args?.file ?? tool.args?.abs_path));
+ groups.set(key, group);
+ }
+ const summaries = [...groups.values()].map(group => {
+ if (["Reviewed a file", "Updated files"].includes(group.label) && group.files.size) {
+ const verb = group.label === "Reviewed a file" ? "Read" : "Updated";
+ if (group.files.size === 1) return `${verb} ${[...group.files][0].split(/[\\/]/).at(-1)}`;
+ return `${verb} ${group.files.size} files`;
+ }
+ return group.count > 1 ? `${group.label} ×${group.count}` : group.label;
+ });
+ return summaries.join(" · ");
+}