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

feat: Escape key aborts running agent in chat, closes window when idle

Louis Beaumont46e7830a4efd
diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
index 3f0a595c3..378ade2ea 100644
--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx
+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
@@ -1504,16 +1504,27 @@ export function StandaloneChat({ className }: { className?: string } = {}) {
setTimeout(() => inputRef.current?.focus(), 100);
}, []);
- // Escape key to close window
+ // Escape key: abort agent if running, otherwise close window
useEffect(() => {
- const handleEscape = (e: KeyboardEvent) => {
+ const handleEscape = async (e: KeyboardEvent) => {
if (e.key === "Escape" && !showMentionDropdown) {
- commands.closeWindow("Chat");
+ if (isLoading || isStreaming) {
+ // Stop the agent
+ try {
+ await commands.piAbort(PI_CHAT_SESSION);
+ } catch (err) {
+ console.warn("[Pi] Failed to abort on Escape:", err);
+ }
+ setIsLoading(false);
+ setIsStreaming(false);
+ } else {
+ commands.closeWindow("Chat");
+ }
}
};
window.addEventListener("keydown", handleEscape);
return () => window.removeEventListener("keydown", handleEscape);
- }, [showMentionDropdown]);
+ }, [showMentionDropdown, isLoading, isStreaming]);
// Smart auto-scroll: only scroll to bottom if user is near the bottom.
// If user scrolled up to read, don't interrupt them.