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

fix(chat): abort pi process on close so deleted chat stays deleted

Louis Beaumontfff3b2a2cc79
diff --git a/apps/screenpipe-app-tauri/components/chat-sidebar.tsx b/apps/screenpipe-app-tauri/components/chat-sidebar.tsx
index c710e38a4..849025609 100644
--- a/apps/screenpipe-app-tauri/components/chat-sidebar.tsx
+++ b/apps/screenpipe-app-tauri/components/chat-sidebar.tsx
@@ -45,6 +45,7 @@ import {
} from "@/lib/stores/chat-store";
import { updateConversationFlags } from "@/lib/chat-storage";
import { pipeSessionId } from "@/lib/events/types";
+import { commands } from "@/lib/utils/tauri";
interface ChatSidebarProps {
className?: string;
@@ -152,6 +153,10 @@ export function ChatSidebar({ className }: ChatSidebarProps) {
const handleClose = async (e: React.MouseEvent, id: string) => {
e.stopPropagation();
+ // Abort the Pi process first. Otherwise a still-streaming Pi keeps
+ // emitting events for `id`, and pi-event-router's lazy-create branch
+ // resurrects the row in the sidebar a beat after the user closed it.
+ commands.piAbort(id).catch(() => {});
actions.drop(id);
// If the user closed the chat they were viewing, tell standalone-chat
// to clear the panel. Otherwise the panel would keep showing a