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: AI inbox

Louis Beaumont01de2e93f897
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index b1baba122..3d4596df8 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -1,6 +1,6 @@
---
name: bug report
-about: create a report to help us improve
+about: report a bug in screenpipe
title: "[bug] "
labels: bug
assignees: ''
@@ -8,28 +8,19 @@ assignees: ''
---
**describe the bug**
-a clear and concise description of what the bug is.
+brief description of the bug.
**to reproduce**
-steps to reproduce the behavior:
-1. go to '...'
-2. click on '....'
-3. scroll down to '....'
-4. see error
+1.
+2.
+3.
**expected behavior**
-a clear and concise description of what you expected to happen.
+what should happen?
-**screenshots**
-if applicable, add screenshots to help explain your problem.
-
-**system information:**
- - os: [e.g. macos, windows, linux]
- - os version: [e.g. 10.15.7, 20h2, ubuntu 20.04]
- - application version: [e.g. 1.2.3]
+**system info**
+- os: [e.g. macos 10.15.7, windows 10, ubuntu 20.04]
+- screenpipe version: [e.g. 1.2.3]
**additional context**
-add any other context about the problem here. for example:
-- hardware specifications
-- relevant software versions
-- error logs or console output (in app right click -> "inspect" -> "console")
+add any other context, screenshots, or error logs here.
diff --git a/.github/ISSUE_TEMPLATE/documentation.md b/.github/ISSUE_TEMPLATE/documentation.md
new file mode 100644
index 000000000..db4341600
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/documentation.md
@@ -0,0 +1,17 @@
+---
+name: documentation
+about: report issues with or suggest improvements to documentation
+title: "[docs] "
+labels: documentation
+assignees: ''
+
+---
+
+**describe the issue or improvement**
+explain what's missing, unclear, or needs improvement in the docs.
+
+**suggested changes**
+if you have specific suggestions, please outline them here.
+
+**additional context**
+add any other context about the documentation issue here.
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 000000000..b9644c464
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,21 @@
+---
+name: feature request
+about: suggest an idea for screenpipe
+title: "[feature] "
+labels: enhancement
+assignees: ''
+
+---
+
+**describe the feature**
+brief description of the feature you'd like.
+
+**why is this needed?**
+explain the use case or problem this solves.
+
+**alternatives considered**
+any alternative solutions or features you've thought about?
+
+**additional context**
+add any other context or screenshots about the feature request here.
+
diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md
new file mode 100644
index 000000000..be84db7b1
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/question.md
@@ -0,0 +1,14 @@
+---
+name: question
+about: ask a question about screenpipe
+title: "[question] "
+labels: question
+assignees: ''
+
+---
+
+**your question**
+ask your question here. be as specific as possible.
+
+**context**
+add any relevant context that might help us answer your question.
\ No newline at end of file
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index 5ae421d52..fc2ad6f86 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -13,34 +13,25 @@ brief description of the changes in this pr.
related issue: #
## type of change
-- [ ] bug fix (non-breaking change which fixes an issue)
-- [ ] new feature (non-breaking change which adds functionality)
-- [ ] breaking change (fix or feature that would cause existing functionality to not work as expected)
-- [ ] this change requires a documentation update
+- [ ] bug fix
+- [ ] new feature
+- [ ] breaking change
+- [ ] documentation update
## how to test
-describe how to test your changes. include steps like:
-
-1. checkout this branch
-2. run `npm install` (or equivalent)
-3. start the app with `npm start`
-4. navigate to '...'
-5. click on '...'
-6. observe '...'
-
-## screenshots (if applicable)
-add screenshots to help explain your changes.
+1.
+2.
+3.
## checklist
-- [ ] i read rust & programming best practices
-- [ ] my code follows the style guidelines of this project
-- [ ] i have performed a self-review of my own code
-- [ ] i have made corresponding changes to the documentation
+- [ ] i have read the [CONTRIBUTING.md](../CONTRIBUTING.md) file
+- [ ] i have added the custom cursor AI prompt to my settings as mentioned in CONTRIBUTING.md and used to write this PR
+- [ ] my code follows the project's style guidelines
+- [ ] i have performed a self-review of my code
+- [ ] i have updated the documentation if necessary
- [ ] my changes generate no new warnings
- [ ] i have added tests that prove my fix is effective or that my feature works
-- [ ] new and existing unit tests pass locally with my changes
-- [ ] any dependent changes have been merged and published in downstream modules
-- [ ] other operating systems are not broken
+- [ ] all tests pass locally with my changes
## additional notes
-any other information that you want to share that is relevant to the pr. this could include benchmarks, areas that you want reviewers to pay extra attention to, or notes about the implementation.
\ No newline at end of file
+any other relevant information about the pr.
diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.yml
index bff2a0bd1..ff694de81 100644
--- a/.github/workflows/release-app.yml
+++ b/.github/workflows/release-app.yml
@@ -134,6 +134,11 @@ jobs:
iwr -useb get.scoop.sh | iex
}
+ - name: Setup tmate session # HACK
+ if: matrix.platform == 'windows-latest'
+ uses: mxschmitt/action-tmate@v3
+
+
- name: Run pre_build.js
shell: bash
env:
@@ -165,8 +170,7 @@ jobs:
fi
cargo build --release ${{ matrix.args }}
- # - name: Setup tmate session
- # uses: mxschmitt/action-tmate@v3
+
# Run pre build again to copy the CLI into app
- name: Run pre_build.js on ${{ matrix.platform }}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 0cdaf4441..08796b93c 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -59,6 +59,9 @@ I use cursor with this prompt to help me with the code:
```
Rules:
+- Coding: louis is working on screenpipe most of the time, it's an open source app, lib, and CLI, that record screens & mics 24/7, extract OCR & STT, save to local db, connect to AI, do magic, it's written in Rust + Tauri and we write plugins (pipes) in TS + Deno. the Rust CLI is embedded as a sidecar in Tauri. it works on macos, windows, linux
+- Coding: always keep my style black and white, with some nerdy style and fonts pixelated / scientific style
+- Coding: do not remove @ts-ignore except if i explicitly ask you
- Coding: always use lower case for logging stuff or UI
- Coding: Rust: always use anyhow error, tokio instead of std stuff, avoid mutex if you can, prefer channels, write code easy to read for humans, fast for machines
- Coding: when i ask to give me the full code it means FULL, no fucking // rest of the code comments GIVE ME THE FULL CODE
@@ -71,12 +74,14 @@ Rules:
### Principles
-- **User fanatic: focus on building what people want and making users happy.**
+- **User fanatic: focus on building what people want and bring maximum value.**
- Concurrency: channels > mutexes/locks
-- Simplicity: avoid premature optimization. less is more. optimise for less code, less files, less dependencies, less complexity.
+- Simplicity: avoid premature optimization. write code that is easy for humans to read, fast for machines to execute. less is more. optimise for less code, less files, less dependencies, less complexity.
+- Production: we're building real products, not python toy that grow to 150k stars and die prematurely and never leave localhost, thank you.
- Focus: avoid feature creep. focus on the core functionality and build upon it. focus on the user and their needs.
- Use numbers: if you can't measure it, you can't improve it.
- Avoid OOP: prefer functional programming.
+- Positive-sum: we're all going to win, it is a multiplayer, positive sum game. (that escalated quickly)
### Issue and Pull Request Labels
diff --git a/content/docs/pages/docs/plugins.mdx b/content/docs/pages/docs/plugins.mdx
index 3498e8b2f..57b616982 100644
--- a/content/docs/pages/docs/plugins.mdx
+++ b/content/docs/pages/docs/plugins.mdx
@@ -114,11 +114,12 @@ we would be happy to help you make money!
- pipes have access to a special API that allows you to interact with your computer or special features like sending notifications, sending emails, etc.
- check this [file](https://github.com/mediar-ai/screenpipe/blob/main/screenpipe-core/src/deno/runtime.js) for more details.
- in general we recommend using local LLMs like ollama as the data can be large and sensitive.
+- deno caches dependencies and sometimes need to clear/reload cache
### known limitations
- you can only use JS/TS to build your pipes.
-- we did not figure out yet a way to use dependencies but some manage to do so, this is because pipes run in Deno runtime which is special.
- you usually need to run the pipe in an infinite loop for example if it's something that process your data continuously, of course if this is for example an agent that summarize your day one shot it does not have to be infinite loop.
+
</MotionDiv>
\ No newline at end of file
diff --git a/examples/typescript/pipe-llama32-comment-linear-while-you-work/pipe.ts b/examples/typescript/pipe-llama32-comment-linear-while-you-work/pipe.ts
index d7bd54c79..971c0020d 100644
--- a/examples/typescript/pipe-llama32-comment-linear-while-you-work/pipe.ts
+++ b/examples/typescript/pipe-llama32-comment-linear-while-you-work/pipe.ts
@@ -1,9 +1,4 @@
-import {
- queryScreenpipe,
- loadPipeConfig,
- ContentItem,
- sendDesktopNotification,
-} from "screenpipe";
+import { ContentItem, pipe } from "screenpipe";
import { z } from "zod";
import { generateObject } from "ai";
@@ -135,6 +130,20 @@ async function addCommentToLinear(
body: commentWithMention,
});
console.log("comment added to linear successfully");
+
+ // Send inbox message
+ const issue = await client.issue(comment.taskId as string);
+ const inboxMessage = {
+ title: `Comment added to: ${issue.title}`,
+ body: `
+### New comment on Linear issue
+
+${comment.body}
+
+[View issue in Linear](${issue.url})
+ `,
+ };
+ await pipe.inbox.send(inboxMessage);
} catch (error) {
console.error("linear api error:", error);
throw new Error("failed to add comment to linear");
@@ -161,7 +170,7 @@ async function searchLinearTasks(
async function streamCommentsToLinear(): Promise<void> {
console.log("starting comments stream to linear");
- const config = await loadPipeConfig();
+ const config = await pipe.loadPipeConfig();
console.log("loaded config:", JSON.stringify(config, null, 2));
const interval = config.interval * 1000;
@@ -172,6 +181,12 @@ async function streamCommentsToLinear(): Promise<void> {
const windowName = config.windowName;
const contentType = config.contentType;
+ // announce pipe in the inbox
+ await pipe.inbox.send({
+ title: "linear comment pipeline started",
+ body: `commenting on linear tasks every ${interval / 1000} seconds`,
+ });
+
while (true) {
await new Promise((resolve) => setTimeout(resolve, interval));
@@ -179,7 +194,7 @@ async function streamCommentsToLinear(): Promise<void> {
const now = new Date();
const intervalAgo = new Date(now.getTime() - interval);
- const screenData = await queryScreenpipe({
+ const screenData = await pipe.queryScreenpipe({
startTime: intervalAgo.toISOString(),
endTime: now.toISOString(),
limit: config.pageSize,
@@ -221,7 +236,7 @@ async function streamCommentsToLinear(): Promise<void> {
await addCommentToLinear(comment, apiKey);
// randomly send a notification
- await sendDesktopNotification({
+ await pipe.sendDesktopNotification({
title: "linear comment pipeline update",
body: `comment added to task ${comment.taskId}`,
});
diff --git a/screenpipe-app-tauri/components/header.tsx b/screenpipe-app-tauri/components/header.tsx
index 653234304..082b02cf0 100644
--- a/screenpipe-app-tauri/components/header.tsx
+++ b/screenpipe-app-tauri/components/header.tsx
@@ -19,8 +19,10 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
-import { MessageSquare, Heart, Menu } from "lucide-react";
+import { MessageSquare, Heart, Menu, Bell } from "lucide-react";
import { open } from "@tauri-apps/plugin-shell";
+import { InboxMessages, Message } from "@/components/inbox-messages";
+import { useState, useRef, useEffect } from "react";
function IconNewChat() {
return (
@@ -32,7 +34,7 @@ function IconNewChat() {
xmlns="http://www.w3.org/2000/svg"
>
<path
- d="M12.1464 1.14645C12.3417 0.951184 12.6583 0.951184 12.8535 1.14645L14.8535 3.14645C15.0488 3.34171 15.0488 3.65829 14.8535 3.85355L10.9109 7.79618C10.8349 7.87218 10.7471 7.93543 10.651 7.9835L6.72359 9.94721C6.53109 10.0435 6.29861 10.0057 6.14643 9.85355C5.99425 9.70137 5.95652 9.46889 6.05277 9.27639L8.01648 5.34897C8.06455 5.25283 8.1278 5.16507 8.2038 5.08907L12.1464 1.14645ZM12.5 2.20711L8.91091 5.79618L7.87266 7.87267L8.12731 8.12732L10.2038 7.08907L13.7929 3.5L12.5 2.20711ZM9.99998 2L8.99998 3H4.9C4.47171 3 4.18056 3.00039 3.95552 3.01877C3.73631 3.03668 3.62421 3.06915 3.54601 3.10899C3.35785 3.20487 3.20487 3.35785 3.10899 3.54601C3.06915 3.62421 3.03669 3.73631 3.01878 3.95552C3.00039 4.18056 3 4.47171 3 4.9V11.1C3 11.5283 3.00039 11.8194 3.01878 12.0445C3.03669 12.2637 3.06915 12.3758 3.10899 12.454C3.20487 12.6422 3.35785 12.7951 3.54601 12.891C3.62421 12.9309 3.73631 12.9633 3.95552 12.9812C4.18056 12.9996 4.47171 13 4.9 13H11.1C11.5283 13 11.8194 12.9996 12.0445 12.9812C12.2637 12.9633 12.3758 12.9309 12.454 12.891C12.6422 12.7951 12.7951 12.6422 12.891 12.454C12.9309 12.3758 12.9633 12.2637 12.9812 12.0445C12.9996 11.8194 13 11.5283 13 11.1V6.99998L14 5.99998V11.1V11.1207C14 11.5231 14 11.8553 13.9779 12.1259C13.9549 12.407 13.9057 12.6653 13.782 12.908C13.5903 13.2843 13.2843 13.5903 12.908 13.782C12.6653 13.9057 12.407 13.9549 12.1259 13.9779C11.8553 14 11.5231 14 11.1207 14H11.1H4.9H4.87934C4.47686 14 4.14468 14 3.87409 13.9779C3.59304 13.9549 3.33469 13.9057 3.09202 13.782C2.7157 13.5903 2.40973 13.2843 2.21799 12.908C2.09434 12.6653 2.04506 12.407 2.0221 12.1259C1.99999 11.8553 1.99999 11.5231 2 11.1207V11.1206V11.1V4.9V4.87935V4.87932V4.87931C1.99999 4.47685 1.99999 4.14468 2.0221 3.87409C2.04506 3.59304 2.09434 3.33469 2.21799 3.09202C2.40973 2.71569 2.7157 2.40973 3.09202 2.21799C3.33469 2.09434 3.59304 2.04506 3.87409 2.0221C4.14468 1.99999 4.47685 1.99999 4.87932 2H4.87935H4.9H9.99998Z"
+ d="M12.1464 1.14645C12.3417 0.951184 12.6583 0.951184 12.8535 1.14645L14.8535 3.14645C15.0488 3.34171 15.0488 3.65829 14.8535 3.85355L10.9109 7.79618C10.8349 7.87218 10.7471 7.93543 10.651 7.9835L6.72359 9.94721C6.53109 10.0435 6.29861 10.0057 6.14643 9.85355C5.99425 9.70137 5.95652 9.46889 6.05277 9.27639L8.01648 5.34897C8.06455 5.25283 8.1278 5.16507 8.2038 5.08907L12.1464 1.14645ZM12.5 2.20711L8.91091 5.79618L7.87266 7.87267L8.12731 8.12732L10.2038 7.08907L13.7929 3.5L12.5 2.20711ZM9.99998 2L8.99998 3H4.9C4.47171 3 4.18056 3.00039 3.95552 3.01877C3.73631 3.03668 3.62421 3.06915 3.54601 3.10899C3.35785 3.20487 3.20487 3.35785 3.10899 3.54601C3.06915 3.62421 3.03669 3.73631 3.01878 3.95552C3.00039 4.18056 3 4.47171 3 4.9V11.1C3 11.5283 3.00039 11.8194 3.01878 12.0445C3.03669 12.2637 3.06915 12.3758 3.10899 12.454C3.20487 12.6422 3.35785 12.7951 3.54601 12.891C3.62421 12.9309 3.73631 12.9633 3.95552 12.9812C4.18056 12.9996 4.47171 13 4.9 13H11.1C11.5283 13 11.8194 12.9996 12.0445 12.9812C12.2637 12.9633 12.3758 12.9309 12.454 12.891C12.6422 12.7951 12.7951 12.6422 12.891 12.454C12.9309 12.3758 12.9633 12.2637 12.9812 12.0445C12.9996 11.8194 13 11.5283 13 11.1V6.99998L14 5.99998V11.1V11.1207C14 11.5231 14 11.8553 13.9779 12.1259C13.9549 12.407 13.9057 12.6653 13.782 12.908C13.5903 13.2843 13.2843 13.5903 12.908 13.782C12.6653 13.9057 12.407 13.9549 12.1259 13.9779C11.8553 14 11.5231 14 11.1207 14H11.1H4.9H4.87934C4.47686 14 4.14468 14 3.87409 13.9779C3.59304 13.9549 3.33469 13.9057 3.09202 13.782C2.7157 13.5903 2.40973 13.2843 2.21799 12.908C2.09434 12.6653 2.04506 12.407 2.0221 12.1259C1.99999 11.8553 1.99999 11.5231 2 11.1207V11.1206V11.1V4.9V4.87935V4.87931C1.99999 4.47685 1.99999 4.14468 2.0221 3.87409C2.04506 3.59304 2.09434 3.33469 2.21799 3.09202C2.40973 2.71569 2.7157 2.40973 3.09202 2.21799C3.33469 2.09434 3.59304 2.04506 3.87409 2.0221C4.14468 1.99999 4.47685 1.99999 4.87932 2H4.87935H4.9H9.99998Z"
fill="currentColor"
fillRule="evenodd"
clipRule="evenodd"
@@ -41,6 +43,19 @@ function IconNewChat() {
);
}
export default function Header() {
+ const [showInbox, setShowInbox] = useState(false);
+ const [messages, setMessages] = useState<Message[]>([]);
+
+ const handleMessageRead = (id: string) => {
+ setMessages(
+ messages.map((msg) => (msg.id === id ? { ...msg, read: true } : msg))
+ );
+ };
+
+ const handleMessageDelete = (id: string) => {
+ setMessages(messages.filter((msg) => msg.id !== id));
+ };
+
return (
<div>
<div className="absolute left-8 top-4">
@@ -80,28 +95,18 @@ export default function Header() {
</div>
<div className="flex space-x-4 absolute top-4 right-4">
<HealthStatus className="mt-3" />
- <Settings />
<MeetingHistory />
<PipeDialog />
- {/* <LogViewer /> */}
- {/* <PrettyLink href="https://github.com/mediar-ai/screenpipe/tree/main/examples/ts">
- <span className="mr-2">Examples</span>
- <svg
- xmlns="http://www.w3.org/2000/svg"
- width="16"
- height="16"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- strokeWidth="2"
- strokeLinecap="round"
- strokeLinejoin="round"
- >
- <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" />
- <polyline points="15 3 21 3 21 9" />
- <line x1="10" y1="14" x2="21" y2="3" />
- </svg>
- </PrettyLink> */}
+ <Settings />
+
+ <Button
+ variant="ghost"
+ size="icon"
+ onClick={() => setShowInbox(!showInbox)}
+ >
+ <Bell className="h-[1.2rem] w-[1.2rem]" />
+ <span className="sr-only">notifications</span>
+ </Button>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="icon">
@@ -113,7 +118,7 @@ export default function Header() {
<DropdownMenuItem
onClick={() =>
open(
- "mailto:[email protected]?subject=Screenpipe%20Feedback&body=Please%20enter%20your%20feedback%20here...%0A%0A...%20or%20let's%20chat?%0Ahttps://cal.com/louis030195/screenpipe",
+ "mailto:[email protected]?subject=Screenpipe%20Feedback&body=Please%20enter%20your%20feedback%20here...%0A%0A...%20or%20let's%20chat?%0Ahttps://cal.com/louis030195/screenpipe"
)
}
>
@@ -123,7 +128,7 @@ export default function Header() {
<DropdownMenuItem
onClick={() =>
open(
- "https://twitter.com/intent/tweet?text=here's%20how%20i%20use%20@screen_pipe%20...%20%5Bscreenshot%5D%20an%20awesome%20tool%20for%20...",
+ "https://twitter.com/intent/tweet?text=here's%20how%20i%20use%20@screen_pipe%20...%20%5Bscreenshot%5D%20an%20awesome%20tool%20for%20..."
)
}
>
@@ -133,6 +138,16 @@ export default function Header() {
</DropdownMenuContent>
</DropdownMenu>
</div>
+ {showInbox && (
+ <div className="absolute right-4 top-16 z-50 bg-white shadow-lg rounded-lg">
+ <InboxMessages
+ messages={messages}
+ onMessageRead={handleMessageRead}
+ onMessageDelete={handleMessageDelete}
+ onClose={() => setShowInbox(false)}
+ />
+ </div>
+ )}
</div>
);
}
diff --git a/screenpipe-app-tauri/components/inbox-messages.tsx b/screenpipe-app-tauri/components/inbox-messages.tsx
new file mode 100644
index 000000000..b5ac88439
--- /dev/null
+++ b/screenpipe-app-tauri/components/inbox-messages.tsx
@@ -0,0 +1,359 @@
+import React, { useEffect, useState, useRef } from "react";
+import { ScrollArea } from "@/components/ui/scroll-area";
+import { Button } from "@/components/ui/button";
+import {
+ X,
+ ChevronDown,
+ ChevronUp,
+ Bot,
+ Maximize2,
+ CheckSquare,
+} from "lucide-react";
+import {
+ Card,
+ CardContent,
+ CardFooter,
+ CardHeader,
+} from "@/components/ui/card";
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+ DialogClose,
+} from "@/components/ui/dialog";
+import { listen } from "@tauri-apps/api/event";
+import { MemoizedReactMarkdown } from "./markdown";
+import remarkGfm from "remark-gfm";
+import remarkMath from "remark-math";
+import localforage from "localforage";
+import { format } from "date-fns";
+
+export interface Message {
+ id: string;
+ title: string;
+ body: string;
+ date: string;
+ read: boolean;
+}
+
+interface InboxMessagesProps {
+ messages: Message[];
+ onMessageRead: (id: string) => void;
+ onMessageDelete: (id: string) => void;
+ onClose: () => void;
+}
+
+export function InboxMessages({
+ messages: initialMessages,
+ onMessageRead,
+ onMessageDelete,
+ onClose,
+}: InboxMessagesProps) {
+ const [messages, setMessages] = useState<Message[]>([]);
+ const [expandedMessages, setExpandedMessages] = useState<Set<string>>(
+ new Set()
+ );
+ const [dialogMessage, setDialogMessage] = useState<Message | null>(null);
+ const [dialogOpen, setDialogOpen] = useState(false);
+ const inboxRef = useRef<HTMLDivElement>(null);
+
+ useEffect(() => {
+ const loadMessages = async () => {
+ const savedMessages = await localforage.getItem<Message[]>(
+ "inboxMessages"
+ );
+ if (savedMessages) {
+ setMessages(savedMessages);
+ } else {
+ setMessages(initialMessages);
+ }
+ };
+
+ loadMessages();
+
+ const unlisten = listen<Message>(
+ "inbox-message-received",
+ async (event) => {
+ console.log("inbox-message-received", event);
+ const newMessage: Message = {
+ id: Date.now().toString(),
+ title: event.payload.title,
+ body: event.payload.body,
+ date: new Date().toISOString(),
+ read: false,
+ };
+ const updatedMessages = [newMessage, ...messages];
+ setMessages(updatedMessages);
+ await localforage.setItem("inboxMessages", updatedMessages);
+ }
+ );
+
+ return () => {
+ unlisten.then((unlistenFn) => unlistenFn());
+ };
+ }, [initialMessages, messages]);
+
+ const handleMarkAllAsRead = async () => {
+ const updatedMessages = messages.map((msg) => ({ ...msg, read: true }));
+ setMessages([]); // Clear all messages from the display
+ await localforage.setItem("inboxMessages", updatedMessages);
+ updatedMessages.forEach((msg) => {
+ onMessageRead(msg.id);
+ onMessageDelete(msg.id); // Add this to remove messages from parent state
+ });
+ };
+
+ const handleMessageAction = async (id: string) => {
+ const updatedMessages = messages.filter((msg) => msg.id !== id);
+ setMessages(updatedMessages);
+ await localforage.setItem("inboxMessages", updatedMessages);
+ onMessageRead(id);
+ onMessageDelete(id);
+ };
+
+ const toggleMessageExpansion = (id: string) => {
+ setExpandedMessages((prev) => {
+ const newSet = new Set(prev);
+ if (newSet.has(id)) {
+ newSet.delete(id);
+ } else {
+ newSet.add(id);
+ }
+ return newSet;
+ });
+ };
+
+ const truncateContent = (content: string | undefined, maxLength: number) => {
+ if (!content) return "";
+ if (content.length <= maxLength) return content;
+ return content.slice(0, maxLength) + "...";
+ };
+
+ const formatDate = (dateString: string) => {
+ const date = new Date(dateString);
+ return format(date, "MMM d, yyyy 'at' h:mm a");
+ };
+
+ const handleMessageRead = async (id: string) => {
+ const updatedMessages = messages.map((msg) =>
+ msg.id === id ? { ...msg, read: true } : msg
+ );
+ setMessages(updatedMessages);
+ await localforage.setItem("inboxMessages", updatedMessages);
+ onMessageRead(id);
+ };
+
+ const openDialog = (message: Message) => {
+ setDialogMessage(message);
+ setDialogOpen(true);
+ if (!message.read) {
+ handleMessageRead(message.id);
+ }
+ };
+
+ const closeDialog = () => {
+ setDialogOpen(false);
+ };
+
+ const handleDeleteAndClose = async () => {
+ if (dialogMessage) {
+ await handleMessageAction(dialogMessage.id);
+ closeDialog();
+ }
+ };
+
+ useEffect(() => {
+ function handleClickOutside(event: MouseEvent) {
+ if (
+ inboxRef.current &&
+ !inboxRef.current.contains(event.target as Node)
+ ) {
+ if (!dialogOpen) {
+ onClose(); // Close the entire inbox component
+ }
+ }
+ }
+
+ document.addEventListener("mousedown", handleClickOutside);
+ return () => {
+ document.removeEventListener("mousedown", handleClickOutside);
+ };
+ }, [dialogOpen, onClose]);
+
+ return (
+ <div ref={inboxRef}>
+ <ScrollArea className="w-full max-w-[46vw] overflow-y-auto max-h-[80vh]">
+ <Card className="w-full">
+ <CardHeader className="flex flex-row items-center justify-between">
+ <h2 className="text-lg font-semibold">inbox messages</h2>
+ {messages.filter((msg) => !msg.read).length > 0 && (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={handleMarkAllAsRead}
+ className="text-xs"
+ >
+ <CheckSquare className="mr-1 h-4 w-4" />
+ mark all as read
+ </Button>
+ )}
+ </CardHeader>
+ <CardContent className="min-h-[200px] w-[45vw]">
+ {messages.filter((msg) => !msg.read).length === 0 ? (
+ <div className="flex h-full w-full items-center justify-center text-sm text-gray-500">
+ no new messages
+ </div>
+ ) : (
+ messages
+ .filter((msg) => !msg.read)
+ .map((message) => (
+ <Card
+ key={message.id}
+ className={`mb-4 w-full ${
+ message.read ? "bg-secondary/50" : "bg-background"
+ }`}
+ >
+ <CardHeader className="flex flex-row items-center justify-between py-2">
+ <div className="flex items-center space-x-2 flex-1 mr-2 max-w-[70%]">
+ <Bot className="h-4 w-4 flex-shrink-0 text-muted-foreground" />
+ <h3
+ className="text-sm font-semibold truncate"
+ title={message.title}
+ >
+ {message.title}
+ </h3>
+ </div>
+ <span className="text-xs text-muted-foreground whitespace-nowrap">
+ {formatDate(message.date)}
+ </span>
+ </CardHeader>
+ <CardContent className="py-2">
+ <div className="w-full overflow-hidden">
+ <MemoizedReactMarkdown
+ className="prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 w-[35vw] text-sm"
+ remarkPlugins={[remarkGfm, remarkMath]}
+ components={{
+ p: ({ children }) => (
+ <p className="mb-2 last:mb-0">{children}</p>
+ ),
+ a: ({ node, href, children, ...props }) => (
+ <a
+ href={href}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="break-all"
+ {...props}
+ >
+ {children}
+ </a>
+ ),
+ }}
+ >
+ {expandedMessages.has(message.id)
+ ? message.body || ""
+ : truncateContent(message.body, 150)}
+ </MemoizedReactMarkdown>
+ </div>
+ {message.body && message.body.length > 150 && (
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => toggleMessageExpansion(message.id)}
+ className="text-xs mt-2"
+ >
+ {expandedMessages.has(message.id) ? (
+ <>
+ <ChevronUp className="mr-1 h-4 w-4" />
+ show less
+ </>
+ ) : (
+ <>
+ <ChevronDown className="mr-1 h-4 w-4" />
+ show more
+ </>
+ )}
+ </Button>
+ )}
+ </CardContent>
+ <CardFooter className="flex justify-end space-x-2 py-2">
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => handleMessageAction(message.id)}
+ className="text-xs"
+ >
+ <X className="mr-1 h-4 w-4" />
+ dismiss
+ </Button>
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => openDialog(message)}
+ className="text-xs"
+ >
+ <Maximize2 className="mr-1 h-4 w-4" />
+ expand
+ </Button>
+ </CardFooter>
+ </Card>
+ ))
+ )}
+ </CardContent>
+ </Card>
+ <Dialog
+ open={dialogOpen}
+ onOpenChange={(open) => {
+ if (!open) {
+ closeDialog();
+ }
+ }}
+ >
+ <DialogContent
+ className="max-w-3xl max-h-[80vh] overflow-y-auto"
+ onPointerDownOutside={(e) => e.preventDefault()}
+ onInteractOutside={(e) => e.preventDefault()}
+ >
+ <DialogHeader>
+ <DialogTitle>{dialogMessage?.title}</DialogTitle>
+ </DialogHeader>
+ <div className="mt-4">
+ <MemoizedReactMarkdown
+ className="prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0"
+ remarkPlugins={[remarkGfm, remarkMath]}
+ components={{
+ p: ({ children }) => (
+ <p className="mb-2 last:mb-0">{children}</p>
+ ),
+ a: ({ node, href, children, ...props }) => (
+ <a
+ href={href}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="break-all"
+ {...props}
+ >
+ {children}
+ </a>
+ ),
+ }}
+ >
+ {dialogMessage?.body || ""}
+ </MemoizedReactMarkdown>
+ </div>
+ <div className="flex justify-end space-x-2 mt-4">
+ <DialogClose asChild>
+ <Button variant="outline" onClick={closeDialog}>
+ close
+ </Button>
+ </DialogClose>
+ <Button variant="default" onClick={handleDeleteAndClose}>
+ dismiss
+ </Button>
+ </div>
+ </DialogContent>
+ </Dialog>
+ </ScrollArea>
+ </div>
+ );
+}
diff --git a/screenpipe-app-tauri/components/pipe-config-form.tsx b/screenpipe-app-tauri/components/pipe-config-form.tsx
index b9af1de5e..b2a396c7d 100644
--- a/screenpipe-app-tauri/components/pipe-config-form.tsx
+++ b/screenpipe-app-tauri/components/pipe-config-form.tsx
@@ -135,6 +135,8 @@ export const PipeConfigForm: React.FC<PipeConfigFormProps> = ({
onChange={(e) =>
handleInputChange(field.name, parseFloat(e.target.value) || 0)
}
+ onWheel={(e) => e.preventDefault()} // prevent scrolling down breaking stuff
+ step="any"
autoCorrect="off"
spellCheck="false"
/>
diff --git a/screenpipe-app-tauri/components/screenpipe-status.tsx b/screenpipe-app-tauri/components/screenpipe-status.tsx
index a26a39efd..f697c1177 100644
--- a/screenpipe-app-tauri/components/screenpipe-status.tsx
+++ b/screenpipe-app-tauri/components/screenpipe-status.tsx
@@ -416,7 +416,14 @@ const HealthStatus = ({ className }: { className?: string }) => {
return "bg-red-500";
};
- if (!health) return null;
+ if (!health) {
+ return (
+ <Badge variant="outline" className="cursor-pointer bg-transparent text-foreground hover:bg-accent hover:text-accent-foreground">
+ <Activity className="mr-2 h-4 w-4" />
+ status <span className="ml-1 w-2 h-2 rounded-full bg-yellow-500 inline-block animate-pulse" />
+ </Badge>
+ );
+ }
const formatTimestamp = (timestamp: string | null) => {
return timestamp ? new Date(timestamp).toLocaleString() : "n/a";
@@ -582,4 +589,4 @@ const HealthStatus = ({ className }: { className?: string }) => {
);
};
-export default HealthStatus;
+export default HealthStatus;
\ No newline at end of file
diff --git a/screenpipe-app-tauri/components/settings.tsx b/screenpipe-app-tauri/components/settings.tsx
index f59654a8b..480fe1051 100644
--- a/screenpipe-app-tauri/components/settings.tsx
+++ b/screenpipe-app-tauri/components/settings.tsx
@@ -89,9 +89,9 @@ export function Settings({ className }: { className?: string }) {
}}
>
<DialogTrigger asChild>
- <Button variant="ghost" className={className}>
- <Settings2 className="mr-2 h-4 w-4" />
- settings
+ <Button variant="ghost" size="icon" className={className}>
+ <Settings2 className="h-5 w-5" />
+ <span className="sr-only">settings</span>
</Button>
</DialogTrigger>
<DialogContent className="max-w-[80vw] w-full max-h-[80vh] h-full overflow-y-auto">
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.toml
index 2ae6884d6..9585aaad5 100644
--- a/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "0.3.3"
+version = "0.3.4"
description = ""
authors = ["you"]
license = ""
diff --git a/screenpipe-app-tauri/src-tauri/src/main.rs b/screenpipe-app-tauri/src-tauri/src/main.rs
index b02b389f3..2de06dae0 100755
--- a/screenpipe-app-tauri/src-tauri/src/main.rs
+++ b/screenpipe-app-tauri/src-tauri/src/main.rs
@@ -234,6 +234,8 @@ async fn main() {
tokio::task::block_in_place(move || {
Handle::current().block_on(async move {
+ // i think it shouldn't kill if we're in dev mode (on macos, windows need to kill)
+ // bad UX: i use CLI and it kills my CLI because i updated app
if let Err(err) = sidecar::kill_all_sreenpipes(
app_handle.state::<SidecarState>(),
app_handle.clone(),
diff --git a/screenpipe-app-tauri/src-tauri/src/server.rs b/screenpipe-app-tauri/src-tauri/src/server.rs
index ccf40ae0a..724600384 100644
--- a/screenpipe-app-tauri/src-tauri/src/server.rs
+++ b/screenpipe-app-tauri/src-tauri/src/server.rs
@@ -39,6 +39,21 @@ struct ApiResponse {
message: String,
}
+#[derive(Serialize, Deserialize, Debug)]
+struct InboxMessagePayload {
+ title: String,
+ body: String,
+ #[serde(rename = "type")]
+ message_type: String,
+ actions: Option<Vec<InboxMessageAction>>,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+struct InboxMessageAction {
+ label: String,
+ action: String,
+}
+
pub async fn run_server(app_handle: tauri::AppHandle, port: u16) {
let state = ServerState { app_handle };
@@ -50,6 +65,7 @@ pub async fn run_server(app_handle: tauri::AppHandle, port: u16) {
let app = Router::new()
.route("/notify", axum::routing::post(send_notification))
+ .route("/inbox", axum::routing::post(send_inbox_message))
.route("/log", axum::routing::post(log_message))
.layer(cors)
.layer(
@@ -89,6 +105,29 @@ async fn send_notification(
}
}
+async fn send_inbox_message(
+ State(state): State<ServerState>,
+ Json(payload): Json<InboxMessagePayload>,
+) -> Result<Json<ApiResponse>, (StatusCode, String)> {
+ info!("received inbox message request: {:?}", payload);
+ match state.app_handle.emit("inbox-message-received", &payload) {
+ Ok(e) => {
+ info!("inbox message sent: {:?}", e);
+ Ok(Json(ApiResponse {
+ success: true,
+ message: "inbox message sent successfully".to_string(),
+ }))
+ }
+ Err(e) => {
+ error!("failed to send inbox message: {}", e);
+ Err((
+ StatusCode::INTERNAL_SERVER_ERROR,
+ format!("failed to send inbox message: {}", e),
+ ))
+ }
+ }
+}
+
async fn log_message(
State(state): State<ServerState>,
Json(log_entry): Json<LogEntry>,
diff --git a/screenpipe-app-tauri/src-tauri/src/updates.rs b/screenpipe-app-tauri/src-tauri/src/updates.rs
index 8ff604071..059a899c6 100644
--- a/screenpipe-app-tauri/src-tauri/src/updates.rs
+++ b/screenpipe-app-tauri/src-tauri/src/updates.rs
@@ -7,6 +7,10 @@ use tauri::{Manager, Wry};
use tauri_plugin_updater::UpdaterExt;
use tokio::sync::Mutex;
use tokio::time::interval;
+use tauri_plugin_dialog::DialogExt;
+use tauri_plugin_dialog::MessageDialogButtons;
+use crate::SidecarState;
+use crate::kill_all_sreenpipes;
pub struct UpdatesManager {
interval: Duration,
@@ -36,6 +40,7 @@ impl UpdatesManager {
self.update_menu_item
.set_text("downloading latest version of screenpipe")?;
+
if let Some(tray) = self.app.tray_by_id("screenpipe_main") {
let path = self.app.path().resolve(
"assets/update-logo-black.png",
@@ -54,6 +59,29 @@ impl UpdatesManager {
self.update_menu_item.set_enabled(true)?;
self.update_menu_item.set_text("update now")?;
+
+ let answer = self.app.dialog()
+ .message("update available")
+ .title("screenpipe update")
+ .buttons(MessageDialogButtons::OkCancelCustom("update now".to_string(), "later".to_string()))
+ .blocking_show();
+ if answer {
+ // Proceed with the update
+
+ // i think it shouldn't kill if we're in dev mode (on macos, windows need to kill)
+ // bad UX: i use CLI and it kills my CLI because i updated app
+
+ if let Err(err) = kill_all_sreenpipes(
+ self.app.state::<SidecarState>(),
+ self.app.clone(),
+ )
+ .await
+ {
+ error!("Failed to kill sidecar: {}", err);
+ }
+ self.update_screenpipe();
+ }
+
return Result::Ok(true);
}