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: reddit auto post pipe (#1165)
tribhuwanf6a05d0d396f
diff --git a/pipes/reddit-auto-posts/app/api/pipeline/route.ts b/pipes/reddit-auto-posts/app/api/pipeline/route.tsindex 3bdae4f3b..e5136ddb8 100644--- a/pipes/reddit-auto-posts/app/api/pipeline/route.ts+++ b/pipes/reddit-auto-posts/app/api/pipeline/route.ts@@ -1,4 +1,5 @@"use server";+// requestion on this route will send mail (use it only in cron)import fs from "node:fs";import path from "node:path";import { DailyLog } from "@/lib/types";@@ -83,11 +84,12 @@ export async function GET() {try {fs.mkdirSync(logsDir);} catch (_error) {- console.warn("failed to create logs directory, probably already exists:", logsDir);+ console.warn("creating logs directory, probably already exists:", logsDir);}const fileContent = fs.readFileSync(pipeConfigPath, 'utf-8');const configData = JSON.parse(fileContent);+if (emailEnabled && !configData?.welcomeEmailSent) {const welcomeEmail = `Welcome to the daily reddit questions pipeline!@@ -117,66 +119,10 @@ export async function GET() {{ status: 500 });}- }+ };const now = new Date();const startTime = new Date(now.getTime() - interval);-- const screenData = await retry(() => pipe.queryScreenpipe({- startTime: startTime.toISOString(),- endTime: now.toISOString(),- windowName: windowName,- limit: pageSize,- contentType: contentType,- }));-- let logEntry: DailyLog | undefined;- if (screenData && screenData.data && screenData.data.length > 0) {- if (aiProvider === "screenpipe-cloud" && !userToken) {- return NextResponse.json(- { error: `seems like you don't have screenpipe-cloud access :(` },- { status: 500 }- );- }- logEntry = await generateDailyLog(- screenData.data,- dailylogPrompt,- aiProvider,- aiModel,- aiUrl,- openaiApiKey,- userToken as string,- );- await saveDailyLog(logEntry);- } else {- return NextResponse.json(- { message: "no screenpipe data is found, is screenpipe running?" },- { status: 200 }- );- }-- let lastEmailSent = new Date(0);- let shouldSendSummary = false;-- if (summaryFrequency === "daily") {- const [emailHour, emailMinute] = emailTime.split(":").map(Number);- const emailTimeToday = new Date(- now.getFullYear(),- now.getMonth(),- now.getDate(),- emailHour,- emailMinute- );- shouldSendSummary =- now >= emailTimeToday &&- now.getTime() - lastEmailSent.getTime() > 24 * 60 * 60 * 1000;- } else if (summaryFrequency.startsWith("hourly:")) {- const hours = parseInt(summaryFrequency.split(":")[1], 10);- shouldSendSummary =- now.getTime() - lastEmailSent.getTime() >= hours * 60 * 60 * 1000;- }-- if (shouldSendSummary) {const screenData = await retry(() => pipe.queryScreenpipe({startTime: startTime.toISOString(),endTime: now.toISOString(),@@ -192,6 +138,19 @@ export async function GET() {{ status: 500 });}++ let logEntry: DailyLog | undefined;+ logEntry = await generateDailyLog(+ screenData.data,+ dailylogPrompt,+ aiProvider,+ aiModel,+ aiUrl,+ openaiApiKey,+ userToken as string,+ );+ await saveDailyLog(logEntry);+const redditQuestions = await generateRedditQuestions(screenData.data,customPrompt,@@ -250,23 +209,16 @@ export async function GET() {{ status: 500 });}- lastEmailSent = now;return NextResponse.json({ message: "pipe executed successfully", suggestedQuestions: redditQuestions },{ status: 200 });} else {return NextResponse.json(- { message: "no screenpipe data is found, is screenpipe running?" },+ { message: "query is empty please wait & and try again!" },{ status: 200 });- }- } else {- return NextResponse.json(- { message: "pipe executed successfully, but its not that time to send questions!" },- { status: 200 }- );- }+ };} catch (error) {console.error("error in GET handler:", error);return NextResponse.json(diff --git a/pipes/reddit-auto-posts/app/api/test-pipeline/route.ts b/pipes/reddit-auto-posts/app/api/test-pipeline/route.tsnew file mode 100644index 000000000..98cc8d3f8--- /dev/null+++ b/pipes/reddit-auto-posts/app/api/test-pipeline/route.ts@@ -0,0 +1,155 @@+"use server";+// this route is only for getting reddit post reccomendation, explicitly by clickin the+// `generate button` it won't send any mails+import fs from "node:fs";+import path from "node:path";+import { NextResponse } from "next/server";+import { pipe } from "@screenpipe/js";+import sendEmail from "@/lib/actions/send-email";+import generateRedditQuestions from "@/lib/actions/generate-reddit-question";++async function retry(fn: any, retries = 3, delay = 5000) {+ for (let i = 0; i < retries; i++) {+ try {+ const result = await fn();+ if (result){+ return result;+ }+ } catch (error) {+ console.log(`Screenpipe query failed, retry, attempt: ${i + 1}`)+ if (i === retries - 1) throw error;+ await new Promise(res => setTimeout(res, delay));+ }+ }+}++export async function GET() {+ try {+ console.log("starting daily log pipeline");+ const settingsManager = pipe.settings;+ const redditSettings = await pipe.settings.getNamespaceSettings("reddit-auto-posts");++ if (!settingsManager) {+ return NextResponse.json(+ { error: `no setting manager found` },+ { status: 500 }+ );+ }++ const rawSettings = await settingsManager.getAll();+ const aiModel = rawSettings?.aiModel;+ const aiUrl = rawSettings?.aiUrl;+ const openaiApiKey = rawSettings?.openaiApiKey;+ const aiProvider = rawSettings?.aiProviderType;+ const userToken = rawSettings?.user?.token;++ const interval = redditSettings?.interval * 1000 || 60000;+ const emailAddress = redditSettings?.emailAddress;+ const emailPassword = redditSettings?.emailPassword;+ const customPrompt = redditSettings?.customPrompt!;+ const windowName = redditSettings?.windowName || "";+ const pageSize = redditSettings?.pageSize;+ const contentType = redditSettings?.contentType || "ocr";+ const emailEnabled = !!(emailAddress && emailPassword);+ const screenpipeDir = process.env.SCREENPIPE_DIR || process.cwd();+ const logsDir = path.join(screenpipeDir, "pipes", "reddit-auto-posts", "logs");++ try {+ fs.mkdirSync(logsDir);+ } catch (_error) {+ console.warn("creating logs directory, probably already exists:", logsDir);+ }++ const now = new Date();+ const startTime = new Date(now.getTime() - interval);+ const screenData = await retry(() => pipe.queryScreenpipe({+ startTime: startTime.toISOString(),+ endTime: now.toISOString(),+ windowName: windowName,+ limit: pageSize,+ contentType: contentType,+ }));++ if (screenData && screenData.data && screenData.data.length > 0) {+ if (aiProvider === "screenpipe-cloud" && !userToken) {+ return NextResponse.json(+ { error: `seems like you don't have screenpipe-cloud access :(` },+ { status: 500 }+ );+ }+ const redditQuestions = await generateRedditQuestions(+ screenData.data,+ customPrompt,+ aiProvider,+ aiModel,+ aiUrl,+ openaiApiKey,+ userToken as string,+ );+ console.log("reddit questions:", redditQuestions);++ if (emailEnabled && redditQuestions) {+ try {+ await sendEmail(+ emailAddress!,+ emailPassword!,+ "reddit questions",+ redditQuestions+ );+ } catch(error) {+ return NextResponse.json(+ { error: `error in sending mail ${error}` },+ { status: 500 }+ );+ }+ } else {+ console.log("Failed to get reddit questions!!")+ }++ if (redditQuestions) {+ try {+ console.log("Sending screenpipe inbox notification");+ await pipe.inbox.send({+ title: "reddit questions",+ body: redditQuestions,+ });+ } catch(error) {+ return NextResponse.json(+ { error: `error in sending inbox notification ${error}` },+ { status: 500 }+ );+ }+ } else {+ console.log("Failed to get reddit questions!!")+ }++ try {+ console.log("Sending desktop notification");+ await pipe.sendDesktopNotification({+ badge: "reddit questions",+ body: "just sent you some reddit questions",+ });+ } catch (error) {+ return NextResponse.json(+ { error: `error in sending desktop notification ${error}` },+ { status: 500 }+ );+ }+ return NextResponse.json(+ { message: "pipe executed successfully", suggestedQuestions: redditQuestions },+ { status: 200 }+ );+ } else {+ return NextResponse.json(+ { message: "query is empty please wait & and try again!" },+ { status: 200 }+ );+ };+ } catch (error) {+ console.error("error in GET handler:", error);+ return NextResponse.json(+ { error: `${error}` },+ { status: 400 }+ );+ }+}diff --git a/pipes/reddit-auto-posts/app/page.tsx b/pipes/reddit-auto-posts/app/page.tsxindex 9cf621b54..96eff5c9b 100644--- a/pipes/reddit-auto-posts/app/page.tsx+++ b/pipes/reddit-auto-posts/app/page.tsx@@ -4,7 +4,7 @@ import Pipe from "@/components/pipe"export default function Home() {return (- <main className="min-h-[1250px]">+ <main className="min-h-[1300px]"><Header /><Pipe /></main>diff --git a/pipes/reddit-auto-posts/bun.lockb b/pipes/reddit-auto-posts/bun.lockbindex 0865aae80..cd37e0f4c 100644Binary files a/pipes/reddit-auto-posts/bun.lockb and b/pipes/reddit-auto-posts/bun.lockb differdiff --git a/pipes/reddit-auto-posts/components/header.tsx b/pipes/reddit-auto-posts/components/header.tsxindex f91c7734c..1a18c414f 100644--- a/pipes/reddit-auto-posts/components/header.tsx+++ b/pipes/reddit-auto-posts/components/header.tsx@@ -1,17 +1,36 @@"use client"+import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"+import { useSettings } from "@/lib/hooks/use-settings";+import { Terminal } from "lucide-react";export default function Header() {++ const { settings } = useSettings();+ const aiDisabled = settings.aiProviderType === "screenpipe-cloud" && !settings.user.token;+return (- <div className="flex flex-col justify-center items-center mt-8">- <img- className="w-24 h-24"- src="/128x128.png"- alt="screenpipe-logo"- />- <h1 className="font-bold text-center text-2xl">screenpipe</h1>- <h1 className='font-medium text-lg text-center mt-1'>- get reddit posts recommendation using your screenpipe data- </h1>+ <div className="flex flex-col justify-center items-center mt-2">+ {aiDisabled &&(+ <Alert className="w-[70%] shadow-sm">+ <Terminal className="h-4 w-4" />+ <AlertTitle>heads up!</AlertTitle>+ <AlertDescription className="text-muted-foreground">+ your ai provider is set to 'screenpipe-cloud' and you don't have logged in <br/>+ please login to use this pipe, go to app > settings > login+ </AlertDescription>+ </Alert>+ )}+ <div className="flex flex-col justify-center items-center">+ <img+ className="w-24 h-24"+ src="/128x128.png"+ alt="screenpipe-logo"+ />+ <h1 className="font-bold text-center text-2xl">screenpipe</h1>+ <h1 className='font-medium text-lg text-center mt-1'>+ get reddit posts recommendation using your screenpipe data+ </h1>+ </div></div>);}diff --git a/pipes/reddit-auto-posts/components/pipe.tsx b/pipes/reddit-auto-posts/components/pipe.tsxindex 9b6ba1d2c..340e2a966 100644--- a/pipes/reddit-auto-posts/components/pipe.tsx+++ b/pipes/reddit-auto-posts/components/pipe.tsx@@ -7,11 +7,18 @@ import { Label } from "@/components/ui/label";import { FileCheck, Laptop } from "lucide-react";import { useToast } from "@/lib/use-toast";import updatePipeConfig from "@/lib/actions/update-pipe-config";+import { useHealthCheck } from "@/lib/hooks/use-health";import { MemoizedReactMarkdown } from "./markdown";import { SqlAutocompleteInput } from "./sql-autocomplete-input";import { Eye, EyeOff } from "lucide-react";import remarkGfm from "remark-gfm";import remarkMath from "remark-math";+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "@/components/ui/tooltip";import {Select,SelectContent,@@ -23,13 +30,15 @@ import {const Pipe: React.FC = () => {const { settings, updateSettings } = useSettings();+ const { isServerDown } = useHealthCheck();const { toast } = useToast();const [showKey, setShowKey] = useState(false);- const [loading, setLoading] = useState(false);+ const [loading, setLoading] = useState<boolean>();const [lastLog, setLastLog] = useState<any>(null);- const [appName, setAppName] = useState("");+ const [windowName, setWindowName] = useState("");const [contentType, setContentType] = useState("");+ const aiDisabled = settings.aiProviderType === "screenpipe-cloud" && !settings.user.token;const defaultDailylogPrompt =`- Analyze user activities and summarize them into a structured daily log.@@ -49,7 +58,7 @@ const Pipe: React.FC = () => {const testPipe = async () => {setLoading(true);try {- const res = await fetch("/api/pipeline");+ const res = await fetch("/api/test-pipeline");if (res.status === 500 || res.status === 400) {toast({title: "failed to intialize daily log",@@ -75,17 +84,6 @@ const Pipe: React.FC = () => {}};- const getNextCronTime = (lastIntervalChangeTime: string, interval: number) => {- const lastChangeDate = new Date(lastIntervalChangeTime) || new Date().toISOString();- const now = new Date();- let nextCronTime = new Date(lastChangeDate.getTime());- nextCronTime.setMinutes(nextCronTime.getMinutes() + interval);- while (nextCronTime < now) {- nextCronTime.setMinutes(nextCronTime.getMinutes() + interval);- }- return nextCronTime.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });- };-const isMacOS = () => {return navigator.platform.toUpperCase().indexOf('MAC') >= 0;};@@ -103,7 +101,7 @@ const Pipe: React.FC = () => {emailTime: (formData).get("emailTime") as string,customPrompt: formData.get("customPrompt") as string,dailylogPrompt: formData.get("dailylogPrompt") as string,- windowName: formData.get("windowName") as string,+ windowName: formData.get("windowName") as string || windowName,contentType: contentType as string,lastIntervalChangeTime: new Date().toISOString()}@@ -140,10 +138,6 @@ const Pipe: React.FC = () => {className="flex-1"/></div>- <div className="text-sm text-muted-foreground">- next cron will run at: {getNextCronTime(settings.customSettings?.["reddit-auto-posts"]?.lastIntervalChangeTime,- settings.customSettings?.["reddit-auto-posts"]?.interval / 60)}- </div></div><div className="space-y-3"><Label htmlFor="pageSize">page size </Label>@@ -164,12 +158,12 @@ const Pipe: React.FC = () => {id="summaryFrequency"name="summaryFrequency"defaultValue={settings.customSettings?.["reddit-auto-posts"]?.summaryFrequency || "daily"}- placeholder="frequency of summary emails: 'daily' for once a day at emailTime, or 'hourly:X' for every X hours (e.g., 'hourly:4' for every 4 hours)"+ placeholder="frequency of summary emails: 'daily' for once a day at email time, or 'hourly:X' for every X hours (e.g., 'hourly:4' for every 4 hours)"/></div><div className="space-y-2"><Label htmlFor="emailTime">email time </Label>- <span className="text-[13px] text-muted-foreground"> time to send daily summary email (used only if summaryFrequency is 'daily')</span>+ <span className="text-[13px] text-muted-foreground"> time to send daily summary email (used only if summary frequency is 'daily')</span><Inputid="emailTime"name="emailTime"@@ -248,7 +242,7 @@ const Pipe: React.FC = () => {type="window"icon={<Laptop className="h-4 w-4" />}defaultValue={settings.customSettings?.["reddit-auto-posts"]?.windowName}- onChange={setAppName}+ onChange={(v) => setWindowName(v)}placeholder="window name to filter the screen data"className="flex-grow"/>@@ -278,16 +272,34 @@ const Pipe: React.FC = () => {save settings</Button></form>- <div className="space-y-4 w-full flex flex-col">- <Button- onClick={testPipe}- variant="outline"- disabled={loading}- className="w-full"- >- {loading ? "generating..." : "generate reddit questions"}- </Button>-+ <div className="space-y-4 pb-[30px] w-full flex flex-col">+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <span>+ <Button+ onClick={testPipe}+ className="w-full border-[1.4px] shadow-sm"+ variant={"outline"}+ disabled={loading || aiDisabled || isServerDown}+ >+ {loading ? "generating..." : "generate reddit questions"}+ </Button>+ </span>+ </TooltipTrigger>+ {(aiDisabled || isServerDown) && (+ <TooltipContent>+ <p>{`${(aiDisabled && isServerDown) ?+ "you don't have access of screenpipe-cloud and screenpipe is down!"+ : isServerDown ? "screenpipe is not running..."+ : aiDisabled ? "you don't have access to screenpipe-cloud :( please consider login"+ : ""+ }+ `}</p>+ </TooltipContent>+ )}+ </Tooltip>+ </TooltipProvider>{lastLog && (<div className="p-4 border rounded-lg space-y-2 font-mono text-sm"><MemoizedReactMarkdowndiff --git a/pipes/reddit-auto-posts/components/ui/alert.tsx b/pipes/reddit-auto-posts/components/ui/alert.tsxnew file mode 100644index 000000000..41fa7e056--- /dev/null+++ b/pipes/reddit-auto-posts/components/ui/alert.tsx@@ -0,0 +1,59 @@+import * as React from "react"+import { cva, type VariantProps } from "class-variance-authority"++import { cn } from "@/lib/utils"++const alertVariants = cva(+ "relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",+ {+ variants: {+ variant: {+ default: "bg-background text-foreground",+ destructive:+ "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",+ },+ },+ defaultVariants: {+ variant: "default",+ },+ }+)++const Alert = React.forwardRef<+ HTMLDivElement,+ React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>+>(({ className, variant, ...props }, ref) => (+ <div+ ref={ref}+ role="alert"+ className={cn(alertVariants({ variant }), className)}+ {...props}+ />+))+Alert.displayName = "Alert"++const AlertTitle = React.forwardRef<+ HTMLParagraphElement,+ React.HTMLAttributes<HTMLHeadingElement>+>(({ className, ...props }, ref) => (+ <h5+ ref={ref}+ className={cn("mb-1 font-medium leading-none tracking-tight", className)}+ {...props}+ />+))+AlertTitle.displayName = "AlertTitle"++const AlertDescription = React.forwardRef<+ HTMLParagraphElement,+ React.HTMLAttributes<HTMLParagraphElement>+>(({ className, ...props }, ref) => (+ <div+ ref={ref}+ className={cn("text-sm [&_p]:leading-relaxed", className)}+ {...props}+ />+))+AlertDescription.displayName = "AlertDescription"++export { Alert, AlertTitle, AlertDescription }diff --git a/pipes/reddit-auto-posts/lib/actions/update-pipe-config.ts b/pipes/reddit-auto-posts/lib/actions/update-pipe-config.tsindex c33f0a375..9c2fbe5db 100644--- a/pipes/reddit-auto-posts/lib/actions/update-pipe-config.ts+++ b/pipes/reddit-auto-posts/lib/actions/update-pipe-config.ts@@ -10,6 +10,7 @@ export default async function updatePipeConfig(throw new Error("Reddit settings not found");}+ let cronSchedule = "";const screenpipeDir = process.env.SCREENPIPE_DIR || process.cwd();const pipeConfigPath = path.join(screenpipeDir,@@ -18,6 +19,14 @@ export default async function updatePipeConfig("pipe.json");+ if (redditSettings.summaryFrequency === "daily") {+ const [emailHour, emailMinute] = redditSettings.emailTime.split(":").map(Number);+ cronSchedule = `0 ${emailMinute} ${emailHour} * * *`;+ } else if (redditSettings.summaryFrequency.startsWith("hourly:")) {+ const hours = parseInt(redditSettings.summaryFrequency.split(":")[1], 10);+ cronSchedule = `0 0 */${hours} * * *`;+ }+try {const fileContent = await fs.readFile(pipeConfigPath, 'utf-8');const configData = JSON.parse(fileContent);@@ -25,7 +34,7 @@ export default async function updatePipeConfig(configData.crons = [{path: "/api/pipeline",- schedule: `0 */${redditSettings?.interval / 60} * * * *`,+ schedule: cronSchedule,},];diff --git a/pipes/reddit-auto-posts/lib/hooks/use-health.tsx b/pipes/reddit-auto-posts/lib/hooks/use-health.tsxnew file mode 100644index 000000000..d22796faf--- /dev/null+++ b/pipes/reddit-auto-posts/lib/hooks/use-health.tsx@@ -0,0 +1,122 @@+import { useState, useEffect, useCallback, useRef } from "react";++import { debounce } from "lodash";+++interface HealthCheckResponse {+ status: string;+ status_code: number;+ last_frame_timestamp: string | null;+ last_audio_timestamp: string | null;+ last_ui_timestamp: string | null;+ frame_status: string;+ audio_status: string;+ ui_status: string;+ message: string;+}++function isHealthChanged(+ oldHealth: HealthCheckResponse | null,+ newHealth: HealthCheckResponse+): boolean {+ if (!oldHealth) return true;+ return (+ oldHealth.status !== newHealth.status ||+ oldHealth.status_code !== newHealth.status_code ||+ oldHealth.last_frame_timestamp !== newHealth.last_frame_timestamp ||+ oldHealth.last_audio_timestamp !== newHealth.last_audio_timestamp ||+ oldHealth.last_ui_timestamp !== newHealth.last_ui_timestamp ||+ oldHealth.frame_status !== newHealth.frame_status ||+ oldHealth.audio_status !== newHealth.audio_status ||+ oldHealth.ui_status !== newHealth.ui_status ||+ oldHealth.message !== newHealth.message+ );+}++interface HealthCheckHook {+ health: HealthCheckResponse | null;+ isServerDown: boolean;+ isLoading: boolean;+ fetchHealth: () => Promise<void>;+ debouncedFetchHealth: () => Promise<void>;+}++export function useHealthCheck() {+ const [health, setHealth] = useState<HealthCheckResponse | null>(null);+ const [isServerDown, setIsServerDown] = useState(false);+ const [isLoading, setIsLoading] = useState(false);+ const healthRef = useRef(health);++ const fetchHealth = useCallback(async () => {++ try {+ setIsLoading(true);+ const response = await fetch("http://localhost:3030/health", {+ cache: "no-store",+ headers: {+ "Cache-Control": "no-cache",+ Pragma: "no-cache",+ },+ });++ if (!response.ok) {+ setIsServerDown(true);+ throw new Error(`HTTP error! status: ${response.status}`);+ }++ const data: HealthCheckResponse = await response.json();++ if (isHealthChanged(healthRef.current, data)) {+ setHealth(data);+ healthRef.current = data;+ }++ setIsServerDown(false);+ } catch (error) {+ if (error instanceof Error) {+ setIsServerDown(true);+ return;+ }++ if (!isServerDown) {+ setIsServerDown(true);+ const errorHealth: HealthCheckResponse = {+ last_frame_timestamp: null,+ last_audio_timestamp: null,+ last_ui_timestamp: null,+ frame_status: "error",+ audio_status: "error",+ ui_status: "error",+ status: "error",+ status_code: 500,+ message: "Failed to fetch health status. Server might be down.",+ };+ setHealth(errorHealth);+ healthRef.current = errorHealth;+ }+ } finally {+ setIsLoading(false);+ }+ }, [isServerDown, setIsLoading]);++ const debouncedFetchHealth = useCallback(debounce(fetchHealth, 200), [+ fetchHealth,+ ]);++ useEffect(() => {+ fetchHealth();+ const interval = setInterval(fetchHealth, 2000);++ return () => {+ clearInterval(interval);+ };+ }, [fetchHealth]);++ return {+ health,+ isServerDown,+ isLoading,+ fetchHealth,+ debouncedFetchHealth,+ } as HealthCheckHook;+}diff --git a/pipes/reddit-auto-posts/package.json b/pipes/reddit-auto-posts/package.jsonindex e1948e79e..804b3f696 100644--- a/pipes/reddit-auto-posts/package.json+++ b/pipes/reddit-auto-posts/package.json@@ -13,6 +13,7 @@"@radix-ui/react-select": "^2.1.1","@radix-ui/react-toast": "^1.2.1","@radix-ui/react-tooltip": "^1.1.6",+ "@types/lodash": "^4.17.13","@screenpipe/js": "1.0.0","@screenpipe/browser": "0.1.12","@types/nodemailer": "^6.4.17",diff --git a/pipes/reddit-auto-posts/pipe.json b/pipes/reddit-auto-posts/pipe.jsonindex df2cbbc68..0ebbdc886 100644--- a/pipes/reddit-auto-posts/pipe.json+++ b/pipes/reddit-auto-posts/pipe.json@@ -2,7 +2,7 @@"crons": [{"path": "/api/pipeline",- "schedule": "0 */1 * * * *"+ "schedule": "0 0 11 * * *"}]}diff --git a/screenpipe-core/src/pipes.rs b/screenpipe-core/src/pipes.rsindex 845e0928d..1c7880ca5 100644--- a/screenpipe-core/src/pipes.rs+++ b/screenpipe-core/src/pipes.rs@@ -963,10 +963,10 @@ mod pipes {}};- let now = chrono::Utc::now();+ let now = chrono::Local::now();let next = if let Some(last) = last_run {// Get next occurrence after the last execution- let last_chrono = chrono::DateTime::<chrono::Utc>::from(last);+ let last_chrono = chrono::DateTime::<chrono::Local>::from(last);schedule.after(&last_chrono).next()} else {schedule.after(&now).next()@@ -980,11 +980,15 @@ mod pipes {}};+ if next <= now {+ info!("next execution time is before or equal to the current time, recalculating...");+ continue;+ }let duration = match (next - now).to_std() {Ok(duration) => duration,Err(e) => {error!("invalid duration: {}", e);- tokio::time::Duration::from_secs(60) // fallback to 1 minute+ continue; // falling back to minute is messing with cron schedule}};