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(chat): show loader after tool execution finishes (#7120)
Ezra Ellettef4f8f5767755
diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/chat-message-list.test.tsx b/apps/screenpipe-app-tauri/components/chat/standalone/chat-message-list.test.tsxindex 183ca5289..7a25f9096 100644--- a/apps/screenpipe-app-tauri/components/chat/standalone/chat-message-list.test.tsx+++ b/apps/screenpipe-app-tauri/components/chat/standalone/chat-message-list.test.tsx@@ -8,14 +8,6 @@ import { describe, expect, it, vi } from "vitest";import { ChatMessageList, type ChatMessageListProps } from "./chat-message-list";import type { Message } from "@/lib/chat/types";-vi.mock("@/components/chat/standalone/message-content", () => ({- MessageContent: ({ message, isGenerating }: { message: Message; isGenerating: boolean }) => (- <span data-testid={`message-content-${message.id}`} data-generating={String(isGenerating)}>- {message.content}- </span>- ),-}));-vi.mock("@/lib/stores/acp-boot-state", () => ({useAcpBootLabel: () => null,}));@@ -198,7 +190,7 @@ describe("ChatMessageList turn status ownership", () => {}],};- it("keeps the active tool group live through a silent post-tool gap", () => {+ it("shows the conversation loader through a silent post-tool gap until the turn ends", () => {const { rerender } = render(<ChatMessageList {...messageListProps({messages: [userMessage, completedToolMessage],isLoading: true,@@ -206,9 +198,9 @@ describe("ChatMessageList turn status ownership", () => {activeSourceFooterMessageId: completedToolMessage.id,})} />);- expect(screen.getByTestId(`message-content-${completedToolMessage.id}`))- .toHaveAttribute("data-generating", "true");- expect(screen.queryByTestId("chat-turn-status")).not.toBeInTheDocument();+ expect(screen.getByTestId("tool-activity-summary")).toBeInTheDocument();+ expect(screen.getByTestId("chat-turn-status")).toBeInTheDocument();+ expect(screen.getByTestId("chat-turn-scan-glyph")).toBeInTheDocument();const finalMessage: Message = {...completedToolMessage,@@ -225,11 +217,95 @@ describe("ChatMessageList turn status ownership", () => {activeSourceFooterMessageId: null,})} />);- expect(screen.getByTestId(`message-content-${finalMessage.id}`))- .toHaveAttribute("data-generating", "false");+ expect(screen.getByTestId("tool-activity-widget"))+ .toHaveAttribute("data-activity-state", "completed");+ expect(screen.queryByTestId("chat-turn-status")).not.toBeInTheDocument();expect(screen.getByText("diagnostic complete")).toBeInTheDocument();});+ it("lets a running tool own progress, then restores the loader when the tool finishes", () => {+ const runningMessage: Message = {+ ...completedToolMessage,+ contentBlocks: [{+ type: "tool",+ toolCall: { id: "read-1", toolName: "read", args: {}, isRunning: true },+ }],+ };+ const props = messageListProps({+ messages: [userMessage, runningMessage],+ isLoading: true,+ isStreaming: true,+ activeSourceFooterMessageId: runningMessage.id,+ });+ const { rerender } = render(<ChatMessageList {...props} />);++ expect(screen.getByTestId("tool-activity-running-indicator")).toBeInTheDocument();+ expect(screen.queryByTestId("chat-turn-status")).not.toBeInTheDocument();++ rerender(<ChatMessageList {...props} messages={[userMessage, completedToolMessage]} />);+ expect(screen.getByTestId("chat-turn-status")).toBeInTheDocument();++ rerender(<ChatMessageList {...props} />);+ expect(screen.queryByTestId("chat-turn-status")).not.toBeInTheDocument();+ expect(screen.getByTestId("tool-activity-running-indicator")).toBeInTheDocument();+ });++ it("shows the loader when the turn is streaming without the loading flag", () => {+ render(<ChatMessageList {...messageListProps({+ messages: [userMessage, completedToolMessage],+ isLoading: false,+ isStreaming: true,+ activeSourceFooterMessageId: completedToolMessage.id,+ })} />);++ expect(screen.getByTestId("chat-turn-status")).toBeInTheDocument();+ });++ it("does not let hidden MCP startup work suppress the loader", () => {+ const startupMessage: Message = {+ ...completedToolMessage,+ contentBlocks: [{+ type: "tool",+ toolCall: { id: "startup", toolName: "mcp__screenpipe__startup", args: {}, isRunning: true },+ }],+ };+ render(<ChatMessageList {...messageListProps({+ messages: [userMessage, startupMessage],+ isLoading: true,+ activeSourceFooterMessageId: startupMessage.id,+ })} />);++ expect(screen.queryByTestId("tool-activity-widget")).not.toBeInTheDocument();+ expect(screen.getByTestId("chat-turn-status")).toBeInTheDocument();+ });++ it("keeps the approval prompt as the status while the turn waits for the user", () => {+ const permissionMessage: Message = {+ id: "permission",+ role: "assistant",+ content: "",+ timestamp: Date.now(),+ contentBlocks: [{+ type: "agent_action",+ actionKind: "permission",+ requestId: "permission-1",+ sessionId: "session-1",+ title: "Run a local command",+ options: [{ optionId: "allow-once", name: "Allow once", kind: "allow_once" }],+ }],+ };+ render(<ChatMessageList {...messageListProps({+ messages: [userMessage, completedToolMessage, permissionMessage],+ isLoading: true,+ activeSourceFooterMessageId: completedToolMessage.id,+ })} />);++ expect(screen.getByRole("button", { name: "Allow once" })).toBeInTheDocument();+ expect(screen.getByTestId("tool-activity-widget"))+ .toHaveAttribute("data-activity-state", "waiting");+ expect(screen.queryByTestId("chat-turn-status")).not.toBeInTheDocument();+ });+it("shows the fallback when only historical tool work exists", () => {render(<ChatMessageList {...messageListProps({messages: [userMessage, completedToolMessage],@@ -238,8 +314,8 @@ describe("ChatMessageList turn status ownership", () => {activeSourceFooterMessageId: "new-turn-placeholder",})} />);- expect(screen.getByTestId(`message-content-${completedToolMessage.id}`))- .toHaveAttribute("data-generating", "false");+ expect(screen.getByTestId("tool-activity-widget"))+ .toHaveAttribute("data-activity-state", "completed");expect(screen.getByTestId("chat-turn-status")).toBeInTheDocument();});@@ -252,8 +328,8 @@ describe("ChatMessageList turn status ownership", () => {turnLiveness: { state: "offline" },})} />);- expect(screen.getByTestId(`message-content-${completedToolMessage.id}`))- .toHaveAttribute("data-generating", "false");+ expect(screen.getByTestId("tool-activity-widget"))+ .toHaveAttribute("data-activity-state", "completed");expect(screen.getByTestId("chat-turn-status")).toHaveAttribute("data-liveness", "offline");expect(screen.queryByTestId("chat-turn-scan-glyph")).not.toBeInTheDocument();diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/chat-message-list.tsx b/apps/screenpipe-app-tauri/components/chat/standalone/chat-message-list.tsxindex 205d4dd91..dfce87a1c 100644--- a/apps/screenpipe-app-tauri/components/chat/standalone/chat-message-list.tsx+++ b/apps/screenpipe-app-tauri/components/chat/standalone/chat-message-list.tsx@@ -27,12 +27,12 @@ import {getMessageIntentLabel,isNormalUserMessage,isSteeredAssistantMessage,- hasAssistantToolWorkBody,hasRenderableAssistantBody,isPendingAgentActionMessage,hasPendingPermissionRequest,} from "@/lib/chat/message-rendering";import { cn } from "@/lib/utils";+import { presentMcpStartup } from "@/lib/chat/tool-presentation";import { useAcpBootLabel } from "@/lib/stores/acp-boot-state";import type { ContentBlock, Message } from "@/lib/chat/types";import type { ConnectionListItem } from "@/lib/chat/connection-suggestions";@@ -221,9 +221,8 @@ export function ChatMessageList({activeAssistantIndex >= 0 &&hasPendingPermissionRequest(messages.slice(activeAssistantIndex));- // A steered child keeps its parent tool receipt live. This set also lets the- // generic status row ask whether a visible tool group truly owns liveness,- // instead of disappearing merely because some historical tool block exists.+ // A steered child keeps its parent tool receipt live. Include its running+ // tools when deciding whether tool activity owns the turn's progress display.const steerChildActiveParentIds = new Set<string>();if (turnActive && activeAssistantMessageId) {const activeIdx = visibleMessages.findIndex((message) => message.id === activeAssistantMessageId);@@ -239,11 +238,14 @@ export function ChatMessageList({}}}- const hasLiveToolStatusOwner = transformationActive && visibleMessages.some(+ const hasRunningToolStatusOwner = transformationActive && visibleMessages.some((message) =>message.role === "assistant" &&- hasAssistantToolWorkBody(message) &&- (message.id === activeAssistantMessageId || steerChildActiveParentIds.has(message.id)),+ (message.id === activeAssistantMessageId || steerChildActiveParentIds.has(message.id)) &&+ message.contentBlocks?.some((block) =>+ block.type === "tool" && block.toolCall.isRunning &&+ presentMcpStartup(block.toolCall) === null,+ ),);return (@@ -654,17 +656,16 @@ export function ChatMessageList({})()}</AnimatePresence><AnimatePresence>- {isLoading && (() => {+ {turnActive && (() => {const lastAssistant = [...messages].reverse().find((m) => m.role === "assistant");const blocks = lastAssistant?.contentBlocks;// A pending permission/sign-in card already states the turn is blocked// on the user ("needs your approval"); a generic status row below it// is both redundant and wrong (the agent is waiting, not working).if (lastAssistant && isPendingAgentActionMessage(lastAssistant)) return null;- // Suppress the fallback only when the active turn's visible tool- // group is actually rendering its live state. Historical tool blocks- // cannot erase the only indication that a newer turn is still active.- if (hasLiveToolStatusOwner) return null;+ // A completed tool receipt is not a loader. Keep the turn status+ // visible while the model continues after tool execution finishes.+ if (hasRunningToolStatusOwner || waitingForApproval) return null;// One row, one phase. The ACP boot label is a phase of this row// rather than a second loader mounted beside it: a cold npx fetch can