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

feat: replace OS notifications with in-app notification panel for /notify API

Louis Beaumont34937b2dc8eb
diff --git a/apps/screenpipe-app-tauri/app/notification-panel/page.tsx b/apps/screenpipe-app-tauri/app/notification-panel/page.tsx
index cfcbaf02b..fa984526a 100644
--- a/apps/screenpipe-app-tauri/app/notification-panel/page.tsx
+++ b/apps/screenpipe-app-tauri/app/notification-panel/page.tsx
@@ -8,6 +8,7 @@ import { useEffect, useState, useCallback, useRef } from "react";
import { listen, emit } from "@tauri-apps/api/event";
import { invoke } from "@tauri-apps/api/core";
import posthog from "posthog-js";
+import ReactMarkdown from "react-markdown";
interface NotificationAction {
label: string;
@@ -164,6 +165,20 @@ export default function NotificationPanelPage() {
transform: translateX(0);
}
}
+ .notif-md p { margin: 0 0 4px 0; }
+ .notif-md p:last-child { margin: 0; }
+ .notif-md strong { color: rgba(0, 0, 0, 0.9); }
+ .notif-md a { color: rgba(0, 0, 0, 0.7); text-decoration: underline; }
+ .notif-md code {
+ background: rgba(0, 0, 0, 0.06);
+ padding: 1px 4px;
+ font-size: 10px;
+ }
+ .notif-md ul, .notif-md ol {
+ margin: 2px 0;
+ padding-left: 16px;
+ }
+ .notif-md li { margin: 1px 0; }
`}</style>
{/* Header */}
@@ -210,7 +225,7 @@ export default function NotificationPanelPage() {
</div>
{/* Body */}
- <div style={{ padding: "8px 14px", flex: 1 }}>
+ <div style={{ padding: "8px 14px", flex: 1, overflow: "auto" }}>
<div
style={{
fontSize: "12px",
@@ -222,73 +237,77 @@ export default function NotificationPanelPage() {
{payload.title}
</div>
<div
+ className="notif-md"
style={{
fontSize: "11px",
lineHeight: "1.4",
color: "rgba(0, 0, 0, 0.5)",
}}
>
- {payload.body}
+ <ReactMarkdown>{payload.body}</ReactMarkdown>
</div>
</div>
{/* Actions */}
- <div
- style={{
- display: "flex",
- alignItems: "center",
- padding: "0 14px 10px 14px",
- gap: "8px",
- }}
- >
- {payload.actions.map((action) => (
- <button
- key={action.action}
- onClick={() => handleAction(action.action)}
+ {payload.actions.length > 0 && (
+ <div
+ style={{
+ display: "flex",
+ alignItems: "center",
+ padding: "0 14px 10px 14px",
+ gap: "8px",
+ flexWrap: "wrap",
+ }}
+ >
+ {payload.actions.map((action) => (
+ <button
+ key={action.action}
+ onClick={() => handleAction(action.action)}
+ style={{
+ background: action.primary
+ ? "rgba(0, 0, 0, 0.06)"
+ : "none",
+ border: "1px solid rgba(0, 0, 0, 0.12)",
+ color: "rgba(0, 0, 0, 0.75)",
+ cursor: "pointer",
+ padding: "4px 10px",
+ fontSize: "10px",
+ fontFamily: '"IBM Plex Mono", monospace',
+ fontWeight: 500,
+ letterSpacing: "0.03em",
+ }}
+ onMouseEnter={(e) =>
+ (e.currentTarget.style.background = "rgba(0, 0, 0, 0.08)")
+ }
+ onMouseLeave={(e) =>
+ (e.currentTarget.style.background = action.primary
+ ? "rgba(0, 0, 0, 0.06)"
+ : "none")
+ }
+ >
+ {action.label}
+ </button>
+ ))}
+ <span
+ onClick={() => hide(false)}
style={{
- background: action.primary
- ? "rgba(0, 0, 0, 0.06)"
- : "none",
- border: "1px solid rgba(0, 0, 0, 0.12)",
- color: "rgba(0, 0, 0, 0.75)",
- cursor: "pointer",
- padding: "4px 10px",
+ marginLeft: "auto",
fontSize: "10px",
+ color: "rgba(0, 0, 0, 0.3)",
+ cursor: "pointer",
fontFamily: '"IBM Plex Mono", monospace',
- fontWeight: 500,
- letterSpacing: "0.03em",
}}
onMouseEnter={(e) =>
- (e.currentTarget.style.background = "rgba(0, 0, 0, 0.08)")
+ (e.currentTarget.style.color = "rgba(0, 0, 0, 0.6)")
}
onMouseLeave={(e) =>
- (e.currentTarget.style.background = action.primary
- ? "rgba(0, 0, 0, 0.06)"
- : "none")
+ (e.currentTarget.style.color = "rgba(0, 0, 0, 0.3)")
}
>
- {action.label}
- </button>
- ))}
- <span
- onClick={() => hide(false)}
- style={{
- marginLeft: "auto",
- fontSize: "10px",
- color: "rgba(0, 0, 0, 0.3)",
- cursor: "pointer",
- fontFamily: '"IBM Plex Mono", monospace',
- }}
- onMouseEnter={(e) =>
- (e.currentTarget.style.color = "rgba(0, 0, 0, 0.6)")
- }
- onMouseLeave={(e) =>
- (e.currentTarget.style.color = "rgba(0, 0, 0, 0.3)")
- }
- >
- dismiss →
- </span>
- </div>
+ dismiss →
+ </span>
+ </div>
+ )}
{/* Progress bar */}
<div
diff --git a/apps/screenpipe-app-tauri/components/notification-handler.tsx b/apps/screenpipe-app-tauri/components/notification-handler.tsx
index 0631d6d46..4d3ea241b 100644
--- a/apps/screenpipe-app-tauri/components/notification-handler.tsx
+++ b/apps/screenpipe-app-tauri/components/notification-handler.tsx
@@ -53,9 +53,20 @@ const NotificationHandler: React.FC = () => {
console.log(
`notification requested ${event.payload.title} ${event.payload.body}`
);
- sendNotification({
+ // Use in-app notification panel instead of OS notifications
+ showNotificationPanel({
+ id: `legacy-${Date.now()}`,
+ type: "general",
title: event.payload.title,
body: event.payload.body,
+ actions: [],
+ autoDismissMs: 20000,
+ }).catch(() => {
+ // Fallback to OS notification if panel fails
+ sendNotification({
+ title: event.payload.title,
+ body: event.payload.body,
+ });
});
});
};
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/server.rs b/apps/screenpipe-app-tauri/src-tauri/src/server.rs
index fe76070b9..4442b1401 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/server.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/server.rs
@@ -49,6 +49,16 @@ pub struct ServerState {
struct NotificationPayload {
title: String,
body: String,
+ /// unique id (auto-generated if omitted)
+ id: Option<String>,
+ /// notification type/category
+ #[serde(rename = "type")]
+ notification_type: Option<String>,
+ /// auto-dismiss after N ms (default 20000)
+ #[serde(rename = "autoDismissMs")]
+ auto_dismiss_ms: Option<u64>,
+ /// timeout in ms (alias for autoDismissMs)
+ timeout: Option<u64>,
}
#[derive(Serialize)]
@@ -375,19 +385,38 @@ async fn send_notification(
Json(payload): Json<NotificationPayload>,
) -> Result<Json<ApiResponse>, (StatusCode, String)> {
info!("Received notification request: {:?}", payload);
- match state.app_handle.emit("notification-requested", &payload) {
- Ok(e) => {
- info!("Notification sent: {:?}", e);
+
+ // Build the panel payload matching what the frontend expects
+ let panel_id = payload.id.unwrap_or_else(|| uuid::Uuid::new_v4().to_string());
+ let dismiss_ms = payload.auto_dismiss_ms
+ .or(payload.timeout)
+ .unwrap_or(20000);
+
+ let panel_payload = serde_json::json!({
+ "id": panel_id,
+ "type": payload.notification_type.unwrap_or_else(|| "pipe".to_string()),
+ "title": payload.title,
+ "body": payload.body,
+ "actions": [],
+ "autoDismissMs": dismiss_ms,
+ });
+
+ let panel_json = panel_payload.to_string();
+
+ // Use the show_notification_panel command directly
+ match crate::commands::show_notification_panel(state.app_handle.clone(), panel_json).await {
+ Ok(()) => {
+ info!("Notification panel shown");
Ok(Json(ApiResponse {
success: true,
message: "Notification sent successfully".to_string(),
}))
}
Err(e) => {
- error!("Failed to send notification: {}", e);
+ error!("Failed to show notification panel: {}", e);
Err((
StatusCode::INTERNAL_SERVER_ERROR,
- format!("Failed to send notification: {}", e),
+ format!("Failed to show notification: {}", e),
))
}
}
@@ -730,20 +759,19 @@ pub fn spawn_server(app_handle: tauri::AppHandle, port: u16) -> mpsc::Sender<()>
/*
+# Simple notification (just title + body)
curl -X POST http://localhost:11435/notify \
-H "Content-Type: application/json" \
- -d '{"title": "Test Notification", "body": "This is a test notification body"}'
-
- curl -X POST http://localhost:11435/notify \
- -H "Content-Type: application/json" \
- -d '{"title": "Special Characters: !@#$%^&*()", "body": "Testing with émojis 😀🎉"}'
+ -d '{"title": "Test", "body": "This is a test notification"}'
- curl -X POST http://localhost:11435/notify \
+# Markdown body
+curl -X POST http://localhost:11435/notify \
-H "Content-Type: application/json" \
- -d '{"title": "Long Notification", "body": "This is a much longer notification body to test how the system handles larger amounts of text. It might wrap or be truncated depending on the system'\''s limitations."}'
+ -d '{"title": "Meeting Summary", "body": "**Q3 Planning**\n- Budget approved\n- Launch date: *Oct 15*\n- [Notes](https://example.com)"}'
- curl -X POST http://localhost:11435/notify \
+# Custom auto-dismiss (5 seconds)
+curl -X POST http://localhost:11435/notify \
-H "Content-Type: application/json" \
- -d '{"title": "Malformed JSON", "body": "This JSON is malformed}'
+ -d '{"title": "Saved", "body": "Note saved to Obsidian", "timeout": 5000}'
*/