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 scheduling parsing and notification note opening reliability (#2866)

Ansh Grover6c6c1bda92ed
diff --git a/apps/screenpipe-app-tauri/app/notification-panel/page.tsx b/apps/screenpipe-app-tauri/app/notification-panel/page.tsx
index cf9397ef9..8573bef46 100644
--- a/apps/screenpipe-app-tauri/app/notification-panel/page.tsx
+++ b/apps/screenpipe-app-tauri/app/notification-panel/page.tsx
@@ -38,6 +38,37 @@ interface NotificationPayload {
pipe_name?: string;
}
+async function openNotificationLink(href: string) {
+ const raw = href.trim();
+ if (!raw) return;
+
+ let localPath: string | null = null;
+ if (raw.startsWith("~/")) {
+ const home = await import("@tauri-apps/api/path").then((m) => m.homeDir());
+ localPath = home + raw.slice(1);
+ } else if (raw.startsWith("/") && !raw.startsWith("//")) {
+ localPath = raw;
+ } else if (/^[A-Za-z]:[\\/]/.test(raw)) {
+ localPath = raw;
+ }
+
+ const { open } = await import("@tauri-apps/plugin-shell");
+ if (localPath && localPath.toLowerCase().endsWith(".md")) {
+ try {
+ await invoke("open_note_path", { path: localPath });
+ return;
+ } catch {
+ // Fallback to default file opener.
+ }
+ }
+ if (localPath) {
+ await invoke("open_note_path", { path: localPath });
+ return;
+ }
+
+ await open(raw);
+}
+
export default function NotificationPanelPage() {
const [payload, setPayload] = useState<NotificationPayload | null>(null);
const [visible, setVisible] = useState(false);
@@ -469,16 +500,7 @@ export default function NotificationPanelPage() {
e.preventDefault();
if (!href) return;
try {
- // file paths: expand ~ and open natively
- let url = href;
- if (url.startsWith("~/")) {
- const home = await import("@tauri-apps/api/path").then(m => m.homeDir());
- url = "file://" + home + url.slice(2);
- } else if (url.startsWith("/") && !url.startsWith("//")) {
- url = "file://" + url;
- }
- const { open } = await import("@tauri-apps/plugin-shell");
- await open(url);
+ await openNotificationLink(href);
} catch {
console.error("failed to open url externally:", href);
}
diff --git a/apps/screenpipe-app-tauri/components/notification-bell.tsx b/apps/screenpipe-app-tauri/components/notification-bell.tsx
index 59b569209..41d514431 100644
--- a/apps/screenpipe-app-tauri/components/notification-bell.tsx
+++ b/apps/screenpipe-app-tauri/components/notification-bell.tsx
@@ -9,6 +9,7 @@ import { Bell, ChevronRight, ChevronDown, MessageSquare, X } from "lucide-react"
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
import posthog from "posthog-js";
+import { invoke } from "@tauri-apps/api/core";
import {
Popover,
PopoverContent,
@@ -29,6 +30,40 @@ interface NotificationEntry {
const API_BASE = "http://localhost:11435";
+async function openNotificationLink(href: string) {
+ const raw = href.trim();
+ if (!raw) return;
+
+ let localPath: string | null = null;
+ if (raw.startsWith("~/")) {
+ const home = await import("@tauri-apps/api/path").then((m) => m.homeDir());
+ localPath = home + raw.slice(1);
+ } else if (raw.startsWith("/") && !raw.startsWith("//")) {
+ localPath = raw;
+ } else if (/^[A-Za-z]:[\\/]/.test(raw)) {
+ localPath = raw;
+ }
+
+ const { open } = await import("@tauri-apps/plugin-shell");
+
+ // Prefer opening markdown files in Obsidian if installed.
+ if (localPath && localPath.toLowerCase().endsWith(".md")) {
+ try {
+ await invoke("open_note_path", { path: localPath });
+ return;
+ } catch {
+ // Fallback to default system file opener below.
+ }
+ }
+
+ if (localPath) {
+ await invoke("open_note_path", { path: localPath });
+ return;
+ }
+
+ await open(raw);
+}
+
export function NotificationBell() {
const [history, setHistory] = useState<NotificationEntry[]>([]);
const [open, setOpen] = useState(false);
@@ -181,7 +216,31 @@ export function NotificationBell() {
</div>
{!isExpanded && entry.body && (
<div className="text-[10px] text-muted-foreground mt-0.5 line-clamp-2 pl-4 [&_p]:inline [&_strong]:text-foreground [&_a]:underline">
- <ReactMarkdown remarkPlugins={[remarkGfm]}>{entry.body}</ReactMarkdown>
+ <ReactMarkdown
+ remarkPlugins={[remarkGfm]}
+ components={{
+ a: ({ href, children }) => (
+ <a
+ onClick={async (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ if (!href) return;
+ try {
+ await openNotificationLink(href);
+ } catch (err) {
+ console.error("failed to open url:", href, err);
+ }
+ }}
+ style={{ cursor: "pointer", textDecoration: "underline" }}
+ className="text-foreground"
+ >
+ {children}
+ </a>
+ ),
+ }}
+ >
+ {entry.body}
+ </ReactMarkdown>
</div>
)}
</div>
@@ -213,19 +272,12 @@ export function NotificationBell() {
<a
onClick={async (e) => {
e.preventDefault();
+ e.stopPropagation();
if (!href) return;
try {
- let url = href;
- if (url.startsWith("~/")) {
- const home = await import("@tauri-apps/api/path").then(m => m.homeDir());
- url = "file://" + home + url.slice(2);
- } else if (url.startsWith("/") && !url.startsWith("//")) {
- url = "file://" + url;
- }
- const { open } = await import("@tauri-apps/plugin-shell");
- await open(url);
- } catch {
- console.error("failed to open url:", href);
+ await openNotificationLink(href);
+ } catch (err) {
+ console.error("failed to open url:", href, err);
}
}}
style={{ cursor: "pointer", textDecoration: "underline" }}
diff --git a/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx b/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx
index 955369dbb..097d31553 100644
--- a/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx
@@ -1105,11 +1105,23 @@ export function PipesSection() {
)
);
try {
- await fetch(`${apiBase}/pipes/${name}/enable`, {
+ const res = await fetch(`${apiBase}/pipes/${name}/enable`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ enabled }),
});
+ let data: { success?: boolean; error?: string } | null = null;
+ try {
+ data = await res.json();
+ } catch {
+ // Older servers may return empty body; treat non-2xx as failure below.
+ }
+ if (!res.ok || data?.error || data?.success === false) {
+ throw new Error(
+ data?.error ||
+ `failed to ${enabled ? "enable" : "disable"} pipe "${name}"`
+ );
+ }
} catch {
// Revert on failure
setPipes((prev) =>
@@ -1119,6 +1131,11 @@ export function PipesSection() {
: p
)
);
+ toast({
+ title: "pipe toggle failed",
+ description: `could not ${enabled ? "enable" : "disable"} "${name}"`,
+ variant: "destructive",
+ });
}
};
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
index 173df479a..85a41dd57 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
@@ -1764,6 +1764,53 @@ pub async fn copy_text_to_clipboard(text: String) -> Result<(), String> {
Ok(())
}
+/// Open a local markdown note in Obsidian (if available), then fallback to OS default app.
+#[tauri::command]
+#[specta::specta]
+pub async fn open_note_path(path: String) -> Result<(), String> {
+ #[cfg(target_os = "macos")]
+ {
+ use std::process::Command;
+ let obsidian_uri = format!("obsidian://open?path={}", urlencoding::encode(&path));
+ // Treat successful process launch as success. `open` can return
+ // non-zero even when LaunchServices still opens the target app.
+ if Command::new("open").arg(&obsidian_uri).spawn().is_ok()
+ || Command::new("open").arg(&path).spawn().is_ok()
+ {
+ Ok(())
+ } else {
+ Err(format!("failed to open note path: {}", path))
+ }
+ }
+ #[cfg(target_os = "windows")]
+ {
+ use std::process::Command;
+ let obsidian_uri = format!("obsidian://open?path={}", urlencoding::encode(&path));
+ if Command::new("cmd")
+ .args(["/C", "start", "", &obsidian_uri])
+ .spawn()
+ .is_ok()
+ || Command::new("cmd")
+ .args(["/C", "start", "", &path])
+ .spawn()
+ .is_ok()
+ {
+ Ok(())
+ } else {
+ Err(format!("failed to open note path: {}", path))
+ }
+ }
+ #[cfg(all(not(target_os = "macos"), not(target_os = "windows")))]
+ {
+ use std::process::Command;
+ if Command::new("xdg-open").arg(&path).spawn().is_ok() {
+ Ok(())
+ } else {
+ Err(format!("failed to open note path: {}", path))
+ }
+ }
+}
+
#[tauri::command]
#[specta::specta]
pub fn set_native_theme(app_handle: tauri::AppHandle, theme: String) -> Result<(), String> {
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rs
index 64dcd8bbe..e4ebae2d8 100755
--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs
@@ -856,6 +856,7 @@ async fn main() {
commands::copy_frame_to_clipboard,
commands::copy_deeplink_to_clipboard,
commands::copy_text_to_clipboard,
+ commands::open_note_path,
// Overlay commands (Windows)
commands::enable_overlay_click_through,
commands::disable_overlay_click_through,
diff --git a/crates/screenpipe-core/src/pipes/mod.rs b/crates/screenpipe-core/src/pipes/mod.rs
index cd7020dc6..49f84d6b2 100644
--- a/crates/screenpipe-core/src/pipes/mod.rs
+++ b/crates/screenpipe-core/src/pipes/mod.rs
@@ -3768,6 +3768,11 @@ pub fn parse_schedule(schedule: &str) -> Option<ParsedSchedule> {
86400,
)));
}
+ if s.eq_ignore_ascii_case("weekly") || s.eq_ignore_ascii_case("every week") {
+ return Some(ParsedSchedule::Interval(std::time::Duration::from_secs(
+ 7 * 86400,
+ )));
+ }
// Try human-readable interval first
if let Some(d) = parse_duration_str(s) {
return Some(ParsedSchedule::Interval(d));
@@ -3814,6 +3819,7 @@ fn parse_human_schedule(s: &str) -> Option<CronSchedule> {
// "monday", "tuesday", etc. → specific weekday
let cron_str = match prefix {
"day" => format!("0 0 {} * * * *", utc_hour),
+ "daily" => format!("0 0 {} * * * *", utc_hour),
"monday" | "mon" => format!("0 0 {} * * 1 *", utc_hour),
"tuesday" | "tue" => format!("0 0 {} * * 2 *", utc_hour),
"wednesday" | "wed" => format!("0 0 {} * * 3 *", utc_hour),
@@ -3839,6 +3845,12 @@ fn local_hour_to_utc(local_hour: u32) -> u32 {
/// Parse "9am", "12pm", "6pm", "14", "9" into a 24-hour number.
fn parse_time_str(s: &str) -> Option<u32> {
let s = s.trim().to_lowercase();
+ if let Some((hour, minute)) = parse_hour_minute(&s) {
+ if minute != 0 {
+ return None;
+ }
+ return Some(hour);
+ }
if let Some(h) = s.strip_suffix("am") {
let n: u32 = h.trim().parse().ok()?;
if n == 12 {
@@ -3867,6 +3879,68 @@ fn parse_time_str(s: &str) -> Option<u32> {
}
}
+fn parse_hour_minute(s: &str) -> Option<(u32, u32)> {
+ let normalized = s
+ .replace(" a.m.", "am")
+ .replace(" p.m.", "pm")
+ .replace(" a.m", "am")
+ .replace(" p.m", "pm")
+ .replace(" am", "am")
+ .replace(" pm", "pm")
+ .replace(' ', "");
+
+ let (clock, ampm) = if let Some(c) = normalized.strip_suffix("am") {
+ (c, Some("am"))
+ } else if let Some(c) = normalized.strip_suffix("pm") {
+ (c, Some("pm"))
+ } else {
+ (normalized.as_str(), None)
+ };
+
+ let (hour, minute) = if let Some((h, m)) = clock.split_once(':') {
+ let hour: u32 = h.parse().ok()?;
+ let minute: u32 = m.parse().ok()?;
+ (hour, minute)
+ } else {
+ let hour: u32 = clock.parse().ok()?;
+ (hour, 0)
+ };
+
+ if minute >= 60 {
+ return None;
+ }
+
+ let hour24 = match ampm {
+ Some("am") => {
+ if hour == 12 {
+ 0
+ } else if hour <= 12 {
+ hour
+ } else {
+ return None;
+ }
+ }
+ Some("pm") => {
+ if hour == 12 {
+ 12
+ } else if hour <= 12 {
+ hour + 12
+ } else {
+ return None;
+ }
+ }
+ _ => {
+ if hour < 24 {
+ hour
+ } else {
+ return None;
+ }
+ }
+ };
+
+ Some((hour24, minute))
+}
+
/// Check if a pipe should run now given its schedule and last run time.
fn should_run(schedule: &str, last_run: DateTime<Utc>) -> bool {
match parse_schedule(schedule) {
@@ -4425,6 +4499,13 @@ mod tests {
other.is_some()
),
}
+ match parse_schedule("daily at 9am") {
+ Some(ParsedSchedule::Cron(_)) => {}
+ other => panic!(
+ "expected cron for 'daily at 9am', got {:?}",
+ other.is_some()
+ ),
+ }
}
#[test]
@@ -4453,6 +4534,26 @@ mod tests {
assert_eq!(parse_time_str("6pm"), Some(18));
assert_eq!(parse_time_str("1pm"), Some(13));
assert_eq!(parse_time_str("14"), Some(14));
+ assert_eq!(parse_time_str("9:00am"), Some(9));
+ assert_eq!(parse_time_str("9:00 am"), Some(9));
+ assert_eq!(parse_time_str("09:00"), Some(9));
+ assert_eq!(parse_time_str("9:30am"), None);
+ }
+
+ #[test]
+ fn test_parse_schedule_weekly_aliases() {
+ match parse_schedule("weekly") {
+ Some(ParsedSchedule::Interval(d)) => {
+ assert_eq!(d, std::time::Duration::from_secs(7 * 86400));
+ }
+ _ => panic!("expected weekly interval"),
+ }
+ match parse_schedule("every week") {
+ Some(ParsedSchedule::Interval(d)) => {
+ assert_eq!(d, std::time::Duration::from_secs(7 * 86400));
+ }
+ _ => panic!("expected every week interval"),
+ }
}
#[test]