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: pipe execution chat history sync and auto-save

Louis Beaumont4429547b3669
diff --git a/apps/screenpipe-app-tauri/components/hooks/use-chat-conversations.ts b/apps/screenpipe-app-tauri/components/hooks/use-chat-conversations.ts
index baf95decf..c8d6ea7c7 100644
--- a/apps/screenpipe-app-tauri/components/hooks/use-chat-conversations.ts
+++ b/apps/screenpipe-app-tauri/components/hooks/use-chat-conversations.ts
@@ -204,12 +204,16 @@ export function useChatConversations(opts: UseChatConversationsOpts) {
};
// ---- Auto-save conversation when a response completes (isLoading transitions from true to false) ----
- // Skip saving pipe watch conversations — they're transient, not user-initiated chats
+ // Skip saving live pipe watch conversations (transient, streaming from pipe_event).
+ // But DO save pipe execution conversations that the user has loaded and is chatting in
+ // (they have a conversationId and user-typed messages without pipe- IDs).
const prevIsLoadingRef = useRef(false);
useEffect(() => {
if (prevIsLoadingRef.current && !isLoading && messages.length > 0) {
- const isPipeWatch = messages.some((m) => m.id?.startsWith("pipe-"));
- if (!isPipeWatch) {
+ // Only skip if ALL messages are pipe-generated (live watch).
+ // If the user has typed follow-up messages, some won't have pipe- IDs → save.
+ const allPipe = messages.every((m) => m.id?.startsWith("pipe-"));
+ if (!allPipe) {
saveConversation(messages);
}
}
diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
index 607d19df7..3f0a595c3 100644
--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx
+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
@@ -2589,7 +2589,25 @@ export function StandaloneChat({ className }: { className?: string } = {}) {
if (!piSessionSyncedRef.current && messages.length > 0) {
const historyLines = messages
.slice(-40)
- .map(m => `${m.role}: ${m.content}`)
+ .map(m => {
+ let text = m.content || "";
+ // Include contentBlocks info (tool calls, results) for richer context
+ if (m.contentBlocks?.length) {
+ const blockTexts = m.contentBlocks.map((b: any) => {
+ if (b.type === "text" && b.text) return b.text;
+ if (b.type === "tool" && b.toolCall) {
+ const tc = b.toolCall;
+ let s = `[tool: ${tc.toolName}](${JSON.stringify(tc.args)})`;
+ if (tc.result) s += ` → ${tc.result.slice(0, 500)}`;
+ return s;
+ }
+ return "";
+ }).filter(Boolean).join("\n");
+ if (blockTexts && !text) text = blockTexts;
+ else if (blockTexts) text += "\n" + blockTexts;
+ }
+ return `${m.role}: ${text}`;
+ })
.join("\n");
promptMessage = `<conversation_history>\n${historyLines}\n</conversation_history>\n\n${userMessage}`;
piSessionSyncedRef.current = true;