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: obsidian pipe cron

Louis Beaumontf44b8fab2285
diff --git a/pipes/obsidian/pipe.json b/pipes/obsidian/pipe.json
index c778eb2c9..6819831a1 100644
--- a/pipes/obsidian/pipe.json
+++ b/pipes/obsidian/pipe.json
@@ -2,7 +2,7 @@
"crons": [
{
"path": "/api/log",
- "schedule": "* * * * * *"
+ "schedule": "0 */5 * * * *"
}
]
}
diff --git a/pipes/obsidian/src/app/api/settings/route.ts b/pipes/obsidian/src/app/api/settings/route.ts
index 2979b86b3..6c560ff47 100644
--- a/pipes/obsidian/src/app/api/settings/route.ts
+++ b/pipes/obsidian/src/app/api/settings/route.ts
@@ -2,10 +2,59 @@
import { pipe } from "@screenpipe/js/node";
import { NextResponse } from "next/server";
import type { Settings } from "@screenpipe/js";
+import { promises as fs } from "fs";
+import path from "path";
// Force Node.js runtime
export const runtime = "nodejs"; // Add this line
export const dynamic = "force-dynamic";
+async function updateCronSchedule(intervalMinutes: number) {
+ try {
+ // Get the .screenpipe base directory from the environment or use a default
+ const screenpipeDir = process.env.SCREENPIPE_DIR || process.cwd();
+ const pipeConfigPath = path.join(
+ screenpipeDir,
+ "pipes",
+ "obsidian",
+ "pipe.json"
+ );
+
+ console.log(`updating cron schedule at: ${pipeConfigPath}`);
+
+ let config: any = {};
+
+ try {
+ const content = await fs.readFile(pipeConfigPath, "utf8");
+ config = JSON.parse(content);
+ } catch (err) {
+ console.log(
+ `no existing config found, creating new one at ${pipeConfigPath}`
+ );
+ config = { crons: [] };
+ }
+
+ // Update or add the cron schedule
+ config.crons = [
+ {
+ path: "/api/log",
+ schedule: `0 */${intervalMinutes} * * * *`,
+ },
+ ];
+
+ // Preserve other existing properties
+ config.enabled = config.enabled ?? true;
+ config.is_nextjs = config.is_nextjs ?? true;
+
+ await fs.writeFile(pipeConfigPath, JSON.stringify(config, null, 2));
+ console.log(
+ `updated cron schedule to run every ${intervalMinutes} minutes`
+ );
+ } catch (err) {
+ console.error("failed to update cron schedule:", err);
+ throw err;
+ }
+}
+
export async function GET() {
const defaultSettings: Settings = {
openaiApiKey: "",
@@ -55,6 +104,14 @@ export async function PUT(request: Request) {
const body = await request.json();
const { key, value, isPartialUpdate, reset, namespace } = body;
+ // Handle obsidian namespace updates
+ if (namespace === "obsidian" && isPartialUpdate && value.interval) {
+ // Convert interval from milliseconds to minutes, ensure it's at least 1
+ const intervalMinutes = Math.max(1, Math.floor(value.interval / 60000));
+ await updateCronSchedule(intervalMinutes);
+ console.log(`setting interval to ${intervalMinutes} minutes`);
+ }
+
if (reset) {
if (namespace) {
if (key) {
diff --git a/screenpipe-app-tauri/components/recording-settings.tsx b/screenpipe-app-tauri/components/recording-settings.tsx
index 7ce0b85a6..dc862b759 100644
--- a/screenpipe-app-tauri/components/recording-settings.tsx
+++ b/screenpipe-app-tauri/components/recording-settings.tsx
@@ -1005,7 +1005,7 @@ export function RecordingSettings() {
htmlFor="deepgramApiKey"
className="flex items-center space-x-2"
>
- <Key className="pl-2 h-4 w-4" />
+ <Key className="h-4 w-4" />
api key
</Label>
<div className="flex-grow relative">