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: WhatsApp gateway self-terminates when parent dies, timeline forward scroll & fresh end date

Louis Beaumontad1d00d8fbd1
diff --git a/apps/screenpipe-app-tauri/components/rewind/timeline.tsx b/apps/screenpipe-app-tauri/components/rewind/timeline.tsx
index 71c255f86..7b498436c 100644
--- a/apps/screenpipe-app-tauri/components/rewind/timeline.tsx
+++ b/apps/screenpipe-app-tauri/components/rewind/timeline.tsx
@@ -756,6 +756,19 @@ export default function Timeline({ embedded = false }: { embedded?: boolean }) {
getStartDateAndSet();
}, []);
+ // Keep the end date fresh so the timeline doesn't get stuck at an old boundary
+ useEffect(() => {
+ const updateEnd = () => {
+ setStartAndEndDates((prev) => ({
+ ...prev,
+ end: new Date(),
+ }));
+ };
+ // Update every minute
+ const interval = setInterval(updateEnd, 60_000);
+ return () => clearInterval(interval);
+ }, []);
+
const MAX_DATE_RETRIES = 7; // Don't walk back more than 7 days
useEffect(() => {
diff --git a/apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx b/apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx
index 818129a02..98ca69c14 100644
--- a/apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx
+++ b/apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx
@@ -4,7 +4,7 @@
import { StreamTimeSeriesResponse, TimeRange } from "@/components/rewind/timeline";
import { useTimelineSelection } from "@/lib/hooks/use-timeline-selection";
import { getStore, type ChatConversation } from "@/lib/hooks/use-settings";
-import { isAfter, subDays, format } from "date-fns";
+import { isAfter, subDays, addDays, startOfDay, format } from "date-fns";
import { motion } from "framer-motion";
import { ZoomIn, ZoomOut, Mic, Monitor, AppWindow, Globe, Hash, RotateCcw } from "lucide-react";
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
@@ -287,7 +287,9 @@ export const TimelineSlider = ({
}: TimelineSliderProps) => {
const containerRef = useRef<HTMLDivElement>(null);
const observerTargetRef = useRef<HTMLDivElement>(null);
+ const forwardObserverTargetRef = useRef<HTMLDivElement>(null);
const lastFetchRef = useRef<Date | null>(null);
+ const lastForwardFetchRef = useRef<Date | null>(null);
const [hoveredTimestamp, setHoveredTimestamp] = useState<string | null>(null);
const [hoveredRect, setHoveredRect] = useState<{ x: number; y: number } | null>(null);
@@ -753,6 +755,40 @@ export const TimelineSlider = ({
return () => observer.disconnect();
}, [fetchNextDayData, currentDate, startAndEndDates]);
+ // Forward observer: fetch newer day's data when scrolling left (toward newer frames)
+ useEffect(() => {
+ const forwardTarget = forwardObserverTargetRef.current;
+ if (!forwardTarget) return;
+
+ const forwardObserver = new IntersectionObserver(
+ (entries) => {
+ const entry = entries[0];
+ if (!entry.isIntersecting) return;
+
+ const nextDate = addDays(currentDate, 1);
+ const today = startOfDay(new Date());
+ const now = new Date();
+ const canFetch =
+ !lastForwardFetchRef.current ||
+ now.getTime() - lastForwardFetchRef.current.getTime() > 1000;
+
+ // Don't fetch beyond today
+ if (!isAfter(startOfDay(nextDate), today) && canFetch) {
+ lastForwardFetchRef.current = now;
+ fetchNextDayData(nextDate);
+ }
+ },
+ {
+ root: containerRef.current,
+ threshold: 1.0,
+ rootMargin: "0px 0px 0px 20%",
+ },
+ );
+
+ forwardObserver.observe(forwardTarget);
+ return () => forwardObserver.disconnect();
+ }, [fetchNextDayData, currentDate]);
+
useEffect(() => {
const container = containerRef.current;
if (!container || !frames[currentIndex]) return;
@@ -1207,6 +1243,7 @@ export const TimelineSlider = ({
onMouseUp={handleDragEnd}
onMouseLeave={handleDragEnd}
>
+ <div ref={forwardObserverTargetRef} className="h-full w-1" />
{appGroups.map((group, groupIndex) => {
const groupWidth = getGroupWidth(group);
const showLabel = groupWidth > 60; // Only show label if group is wide enough
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
index 9e738b882..5a4d361de 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -9173,7 +9173,7 @@ dependencies = [
[[package]]
name = "screenpipe-app"
-version = "2.2.98"
+version = "2.2.99"
dependencies = [
"anyhow",
"arboard",
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
index dc104e4d5..6d480e172 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "2.2.98"
+version = "2.2.99"
description = "24/7 memory for your desktop. 100% local."
authors = ["you"]
license = ""
diff --git a/crates/screenpipe-connect/src/whatsapp/gateway.mjs b/crates/screenpipe-connect/src/whatsapp/gateway.mjs
index 371705c7d..8de66b1f7 100644
--- a/crates/screenpipe-connect/src/whatsapp/gateway.mjs
+++ b/crates/screenpipe-connect/src/whatsapp/gateway.mjs
@@ -30,6 +30,30 @@ const SESSION_DIR = process.env.WHATSAPP_SESSION_DIR || join(homedir(), ".screen
const HTTP_PORT = parseInt(process.env.WHATSAPP_HTTP_PORT || "3035", 10);
mkdirSync(SESSION_DIR, { recursive: true });
+// Self-terminate when parent process dies.
+// Two mechanisms: (1) stdin EOF — fires when parent closes pipes (normal exit),
+// (2) PPID polling — catches SIGKILL/crash where pipes aren't cleaned up.
+process.stdin.resume();
+process.stdin.on("end", () => {
+ process.exit(0);
+});
+process.stdin.on("error", () => {
+ process.exit(0);
+});
+
+const parentPid = process.ppid;
+if (parentPid && parentPid !== 1) {
+ setInterval(() => {
+ try {
+ // signal 0 checks if process exists without sending a signal
+ process.kill(parentPid, 0);
+ } catch {
+ // parent is gone
+ process.exit(0);
+ }
+ }, 5000);
+}
+
let sock = null;
// In-memory contact store — populated from contacts.update events
const contactStore = {};