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

refactor(release): remove OpenAI changelog, Claude Code generates it instead

Louis Beaumont45d5ca03a8ee
diff --git a/.claude/skills/release/SKILL.md b/.claude/skills/release/SKILL.md
index 8bd3cc744..015908db4 100644
--- a/.claude/skills/release/SKILL.md
+++ b/.claude/skills/release/SKILL.md
@@ -1,7 +1,7 @@
---
name: release
-description: "Release the screenpipe monorepo. Bumps versions, triggers GitHub Actions for app, CLI, MCP, and JS packages."
-allowed-tools: Bash, Read, Edit, Grep
+description: "Release the screenpipe monorepo. Bumps versions, generates changelog, triggers GitHub Actions for app, CLI, MCP, and JS packages."
+allowed-tools: Bash, Read, Edit, Grep, Write
---
# Screenpipe Monorepo Release Skill
@@ -26,27 +26,64 @@ Automate releasing all components of the screenpipe monorepo.
echo "=== App ===" && grep '^version' screenpipe-app-tauri/src-tauri/Cargo.toml | head -1
echo "=== CLI ===" && grep '^version' Cargo.toml | head -1
echo "=== MCP ===" && grep '"version"' screenpipe-integrations/screenpipe-mcp/package.json | head -1
-echo "=== JS Browser ===" && grep '"version"' screenpipe-js/browser-sdk/package.json | head -1
-echo "=== JS Node ===" && grep '"version"' screenpipe-js/node-sdk/package.json | head -1
-echo "=== JS CLI ===" && grep '"version"' screenpipe-js/cli/package.json | head -1
```
-### 2. Bump Version
-Use Edit tool to update version in the appropriate file.
+### 2. Generate Changelog
+
+Get commits since last release and generate a user-friendly changelog:
-### 3. Commit & Push
+```bash
+# Get last release tag
+LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
+
+# Get commits since last release (or last 50 if no tag)
+if [ -n "$LAST_TAG" ]; then
+ git log $LAST_TAG..HEAD --oneline --no-merges
+else
+ git log -50 --oneline --no-merges
+fi
+```
+
+Then create changelog at `content/changelogs/vX.Y.Z.md` with format:
+
+```markdown
+## New Features
+- Feature description (from commit context)
+
+## Improvements
+- Improvement description
+
+## Bug Fixes
+- Fix description
+
+#### **Full Changelog:** [abc123..def456](https://github.com/mediar-ai/screenpipe/compare/abc123..def456)
+```
+
+Guidelines:
+- Only include changes that bring clear **customer value**
+- Skip: CI changes, refactors, dependency bumps, merge commits
+- Be concise but descriptive
+- Group related changes together
+
+Also copy to `screenpipe-app-tauri/public/CHANGELOG.md` for in-app display.
+
+### 3. Bump Version
+
+Edit `screenpipe-app-tauri/src-tauri/Cargo.toml` to update version.
+
+### 4. Commit & Push
```bash
git add -A && git commit -m "Bump app to vX.Y.Z" && git pull --rebase && git push
```
-### 4. Trigger Release (Draft Only)
+### 5. Trigger Release (Draft Only)
```bash
gh workflow run release-app.yml
```
**Important**: `workflow_dispatch` creates a **draft only** - does NOT auto-publish. This allows manual testing before publishing.
-### 5. Monitor Build Status
+### 6. Monitor Build Status
```bash
# Get latest run ID
gh run list --workflow=release-app.yml --limit=1
@@ -55,41 +92,29 @@ gh run list --workflow=release-app.yml --limit=1
gh run view <RUN_ID> --json status,conclusion,jobs --jq '{status: .status, conclusion: .conclusion, jobs: [.jobs[] | {name: (.name | split(",")[0]), status: .status, conclusion: .conclusion}]}'
```
-### 6. Test the Draft Release
+### 7. Test the Draft Release
- Download from CrabNebula Cloud: https://web.crabnebula.cloud/mediar/screenpipe/releases
- Test on macOS and Windows
- Verify updater artifacts exist (.tar.gz, .sig files)
-### 7. Publish Release
+### 8. Publish Release
After testing, publish manually via CrabNebula Cloud dashboard, OR commit with magic words:
```bash
git commit --allow-empty -m "release-app-publish" && git push
```
-## Changelog Generation
-
-Changelogs are **automatically generated** during the release workflow using OpenAI GPT-4o-mini:
-
-1. Gets commits between last published release and current
-2. Sends to OpenAI to categorize into: New Features, Improvements, Fixes
-3. Saves to `content/changelogs/vX.Y.Z.md`
-4. Copies to `screenpipe-app-tauri/public/CHANGELOG.md`
-
-Script: `.github/scripts/generate_changelog_md.sh`
-
## Quick Release (App Only)
```bash
-# 1. Bump version
-# Edit screenpipe-app-tauri/src-tauri/Cargo.toml
-
-# 2. Commit and push
+# 1. Generate changelog (Claude does this)
+# 2. Bump version in Cargo.toml
+# 3. Commit and push
git add -A && git commit -m "Bump app to vX.Y.Z" && git push
-# 3. Trigger release (draft)
+# 4. Trigger release (draft)
gh workflow run release-app.yml
-# 4. Monitor
+# 5. Monitor
sleep 5 && gh run list --workflow=release-app.yml --limit=1
```
diff --git a/.github/scripts/generate_changelog_md.sh b/.github/scripts/generate_changelog_md.sh
deleted file mode 100755
index 06a80f2c9..000000000
--- a/.github/scripts/generate_changelog_md.sh
+++ /dev/null
@@ -1,110 +0,0 @@
-CURRENT_RELEASE=$1
-
-CHANGELOG_PUBLIC_PATH=screenpipe-app-tauri/public/CHANGELOG.md
-
-LAST_CHANGELOG=$(awk '{printf "%s\\n", $0}' content/changelogs/v0.1.98.md | sed 's/"/\\"/g')
-
-# The if else is necessary to ensure it works both locally and on cloud
-
-# Download cn binary from https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/cn_linux
-# only download it if it doesn't exist
-if ! command -v cn &> /dev/null; then
- echo "Downloading Crab Nebula binary"
- curl -L -o cn https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/cn_linux
- chmod +x cn
- CN_CMD=./cn
-else
- CN_CMD=cn
-fi
-
-LAST_RELEASE=$($CN_CMD release list mediar/screenpipe --api-key $CN_API_KEY --format json | jq '.[0] | select(.status == "Published")')
-COMMIT_DATE_LAST_RELEASE=$(echo $LAST_RELEASE | jq '.createdAt')
-
-# Format date for git (remove quotes if present)
-COMMIT_DATE_LAST_RELEASE=$(echo "$COMMIT_DATE_LAST_RELEASE" | tr -d '"')
-
-COMMIT_LAST_RELEASE=$(git log -1 --until="$COMMIT_DATE_LAST_RELEASE" --format="%H")
-
-COMMIT_CURRENT_RELEASE=$(git log -1 --format="%H")
-COMMIT_CURRENT_RELEASE=${2:-$COMMIT_CURRENT_RELEASE}
-
-if [ "$COMMIT_LAST_RELEASE" == "" ]; then
- echo "Failed to get the commit hash for the last release"
- echo "CHANGELOG_GENERATED=0" >> $GITHUB_ENV
- exit 1
-fi
-
-if [ "$COMMIT_CURRENT_RELEASE" == "" ]; then
- echo "Failed to get the commit hash for the current release"
- echo "CHANGELOG_GENERATED=0" >> $GITHUB_ENV
- exit 1
-fi
-
-# If both are equal, then there's nothing to add to the changelog
-if [ "$COMMIT_LAST_RELEASE" == "$COMMIT_CURRENT_RELEASE" ]; then
- echo "No new commits to add to the changelog"
- echo "CHANGELOG_GENERATED=0" >> $GITHUB_ENV
- exit 0
-fi
-
-COMMITS=$(git log --oneline $COMMIT_LAST_RELEASE..$COMMIT_CURRENT_RELEASE --oneline | tr '\n' ', ' | sed 's/"/\\"/g')
-
-# Debug: Print the commits being sent
-echo "DEBUG: Commits being sent to OpenAI:"
-echo "$COMMITS"
-echo "---"
-
-CONTENT=$(
- curl https://api.openai.com/v1/chat/completions \
- -H "Content-Type: application/json" \
- -H "Authorization: Bearer $OPENAI_API_KEY" \
- -d "{
- \"model\": \"gpt-4o-mini\",
- \"messages\": [
- {
- \"role\": \"system\",
- \"content\": \"You are a helpful assistant.\nThe user is using a product called "screenpipe" which records his screen and mics 24/7. The user ask you questions and you use his screenpipe recordings to answer him.\nYou will generate a changelog for the new screenpipe update based on a list of commits.\nHere are a some guidelines for your responses:\n- only adds to the changelog what brings clear customer value\n- categorize the changes into 'New Features', 'Improvements' and 'Fixes'. Anything not matching these guidelines should not be included on your response\n- Deploys, merges, and software maintenance tasks which does not bring clear value to the end-user should not be included.\n\nUse the following changelog file as an example: $LAST_CHANGELOG\"
- },
- {
- \"role\": \"user\",
- \"content\": \"Here are my commits: $COMMITS\"
- }
- ]
- }"
-)
-
-# Debug: Print the raw response from OpenAI
-echo "DEBUG: Raw OpenAI response:"
-echo "$CONTENT"
-echo "---"
-
-CONTENT=$(jq '.choices[0].message.content' <<< $CONTENT)
-
-# exit if the content is null
-if [ "$CONTENT" == "null" ]; then
- echo "Failed to generate changelog content."
- echo "CHANGELOG_GENERATED=0" >> $GITHUB_ENV
- exit 1
-fi
-
-# Create directory content/changelogs if it doesn't exist
-mkdir -p content/changelogs
-
-# Create a new file with the current release as the name
-echo -e ${CONTENT//\"/} > content/changelogs/$CURRENT_RELEASE.md
-SHORT_COMMIT_LAST_RELEASE=$(echo $COMMIT_LAST_RELEASE | cut -c 1-5)
-SHORT_COMMIT_CURRENT_RELEASE=$(echo $COMMIT_CURRENT_RELEASE | cut -c 1-5)
-
-# Add the full changelog on the end of the file
-echo """
-#### **Full Changelog:** [$SHORT_COMMIT_LAST_RELEASE..$SHORT_COMMIT_CURRENT_RELEASE](https://github.com/mediar-ai/screenpipe/compare/$SHORT_COMMIT_LAST_RELEASE..$SHORT_COMMIT_CURRENT_RELEASE)
-""" >> content/changelogs/$CURRENT_RELEASE.md
-
-# Copy the new changelog to the main changelog file
-cp content/changelogs/$CURRENT_RELEASE.md $CHANGELOG_PUBLIC_PATH
-
-# Output the current release version to be used in the workflow
-echo "CURRENT_RELEASE=$CURRENT_RELEASE" >> $GITHUB_ENV
-
-# Set the flag to indicate that the changelog was generated
-echo "CHANGELOG_GENERATED=1" >> $GITHUB_ENV
diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.yml
index 123dcf705..788fb81ca 100644
--- a/.github/workflows/release-app.yml
+++ b/.github/workflows/release-app.yml
@@ -57,48 +57,8 @@ jobs:
echo "should_test=${{ github.event.inputs.needs_testing }}" >> $GITHUB_OUTPUT
fi
- generate_changelog:
- needs: check_commit
- if: github.event_name == 'workflow_dispatch' || needs.check_commit.outputs.should_release == 'true'
- runs-on: ubuntu-latest
-
- permissions:
- contents: write
-
- steps:
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
-
- - name: Get version from Cargo.toml if not provided
- id: get_version
- run: |
- if [ -z "${{ github.event.inputs.version }}" ]; then
- VERSION=$(grep '^version = ' screenpipe-app-tauri/src-tauri/Cargo.toml | sed 's/version = "\(.*\)"/\1/')
- echo "VERSION=$VERSION" >> $GITHUB_ENV
- else
- echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- fi
-
- - name: Generate Changelog
- env:
- OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- CN_API_KEY: ${{ secrets.CN_API_KEY }}
- run: .github/scripts/generate_changelog_md.sh ${{ env.VERSION }} ${{ github.event.inputs.commit_hash }}
-
- - name: Commit and push changelog files
- if: env.CHANGELOG_GENERATED == 1
- run: |
- git config user.name "GitHub Actions Bot"
- git config user.email "github-actions[bot]@users.noreply.github.com"
- git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
- git add .
- git commit -m "docs: add changelog for ${{ env.VERSION }}"
- git pull origin main
- git push origin main
-
draft:
- needs: [check_commit, generate_changelog]
+ needs: [check_commit]
if: github.event_name == 'workflow_dispatch' || needs.check_commit.outputs.should_release == 'true'
runs-on: ubuntu-latest
steps:
diff --git a/screenpipe-app-tauri/app/layout.tsx b/screenpipe-app-tauri/app/layout.tsx
index 789a6b5ee..381df5152 100644
--- a/screenpipe-app-tauri/app/layout.tsx
+++ b/screenpipe-app-tauri/app/layout.tsx
@@ -6,7 +6,6 @@ import { Toaster } from "@/components/ui/toaster";
import { useEffect } from "react";
import { DeeplinkHandler } from "@/components/deeplink-handler";
import { ShortcutTracker } from "@/components/shortcut-reminder";
-import { ScreenpipeChat } from "@/components/screenpipe-chat";
const inter = Inter({ subsets: ["latin"] });
@@ -89,7 +88,6 @@ export default function RootLayout({
<DeeplinkHandler />
<ShortcutTracker />
{children}
- <ScreenpipeChat />
<Toaster />
</body>
</Providers>
diff --git a/screenpipe-app-tauri/components/rewind/search-command.tsx b/screenpipe-app-tauri/components/rewind/search-command.tsx
index 73fa0a850..99bdeb76c 100644
--- a/screenpipe-app-tauri/components/rewind/search-command.tsx
+++ b/screenpipe-app-tauri/components/rewind/search-command.tsx
@@ -2,8 +2,7 @@
import * as React from "react";
import { listen } from "@tauri-apps/api/event";
-
-import { useState } from "react";
+import { useState, useRef, useEffect } from "react";
import {
Tooltip,
TooltipContent,
@@ -15,15 +14,83 @@ import { useSqlAutocomplete } from "@/lib/hooks/use-sql-autocomplete";
import { Dialog, DialogTitle } from "./ui/dialog";
import { Input } from "./ui/input";
import { DatePickerWithRange } from "./date-range-picker";
-import { queryParser, QueryParser, querySerializer } from "@/lib/utils";
+import { queryParser, QueryParser, querySerializer, cn } from "@/lib/utils";
import { CustomDialogContent } from "./custom-dialog-content";
-import { ArrowRight, XIcon } from "lucide-react";
+import { ArrowRight, XIcon, Search, Loader2, Send, Square, Bot, User, Sparkles } from "lucide-react";
import { useQueryStates } from "nuqs";
import { CommandShortcut } from "./ui/command";
import { commands } from "@/lib/utils/tauri";
+import { Button } from "@/components/ui/button";
+import { useSettings } from "@/lib/hooks/use-settings";
+import { Badge } from "./ui/badge";
+import ReactMarkdown from "react-markdown";
+
+const SCREENPIPE_API = "http://localhost:3030";
+const VERTEX_PROXY = "https://ai-proxy.i-f9f.workers.dev";
+
+// Tool definitions for Claude
+const TOOLS = [
+ {
+ name: "search_screenpipe",
+ description:
+ "Search through the user's screen recordings, audio transcriptions, and UI elements. " +
+ "Returns timestamped results with app context. Use this to find what the user was doing, " +
+ "what they saw on screen, what was said in meetings, etc.",
+ input_schema: {
+ type: "object" as const,
+ properties: {
+ q: {
+ type: "string",
+ description: "Search query text. Optional - omit to get recent activity.",
+ },
+ content_type: {
+ type: "string",
+ enum: ["all", "ocr", "audio", "ui"],
+ description: "Type of content to search. 'ocr' for screen text, 'audio' for transcriptions, 'ui' for UI elements. Default: 'all'",
+ },
+ limit: {
+ type: "integer",
+ description: "Maximum number of results to return. Default: 10",
+ },
+ start_time: {
+ type: "string",
+ description: "ISO 8601 UTC start time filter (e.g., 2024-01-15T10:00:00Z)",
+ },
+ end_time: {
+ type: "string",
+ description: "ISO 8601 UTC end time filter (e.g., 2024-01-15T18:00:00Z)",
+ },
+ app_name: {
+ type: "string",
+ description: "Filter by application name (e.g., 'Google Chrome', 'Slack', 'zoom.us')",
+ },
+ },
+ },
+ },
+];
+
+interface SearchResult {
+ type: "OCR" | "Audio" | "UI";
+ content: {
+ text?: string;
+ transcription?: string;
+ timestamp: string;
+ app_name?: string;
+ window_name?: string;
+ device_name?: string;
+ };
+}
+
+interface Message {
+ id: string;
+ role: "user" | "assistant";
+ content: string;
+}
export function SearchCommand() {
const [open, setOpen] = React.useState(false);
+ const { settings } = useSettings();
+ const user = settings.user;
const [state] = useQueryStates(queryParser);
const [options, setOptions] = useState<QueryParser>(
@@ -37,6 +104,20 @@ export function SearchCommand() {
: state,
);
+ // Search results state
+ const [results, setResults] = useState<SearchResult[]>([]);
+ const [isSearching, setIsSearching] = useState(false);
+ const [hasSearched, setHasSearched] = useState(false);
+
+ // AI Chat state
+ const [aiInput, setAiInput] = useState("");
+ const [messages, setMessages] = useState<Message[]>([]);
+ const [isAiLoading, setIsAiLoading] = useState(false);
+ const [isStreaming, setIsStreaming] = useState(false);
+ const abortControllerRef = useRef<AbortController | null>(null);
+ const messagesEndRef = useRef<HTMLDivElement>(null);
+ const inputRef = useRef<HTMLInputElement>(null);
+
// Listen for Rust-level open-search event (Cmd+K / Ctrl+K global shortcut)
React.useEffect(() => {
const unlisten = listen("open-search", () => {
@@ -59,62 +140,447 @@ export function SearchCommand() {
};
}, [open]);
+ // Reset state when dialog closes
+ useEffect(() => {
+ if (!open) {
+ setResults([]);
+ setHasSearched(false);
+ setMessages([]);
+ setAiInput("");
+ }
+ }, [open]);
+
+ // Scroll to bottom when messages change
+ useEffect(() => {
+ messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
+ }, [messages]);
+
+ // Execute search
+ async function handleSearch() {
+ if (!options.query?.trim()) return;
+
+ setIsSearching(true);
+ setHasSearched(true);
+ setResults([]);
+
+ try {
+ const params = new URLSearchParams();
+ params.append("q", options.query);
+ params.append("limit", "10");
+
+ if (options.apps && options.apps.length > 0) {
+ params.append("app_name", options.apps[0]);
+ }
+ if (options.start_time) {
+ params.append("start_time", options.start_time.toISOString());
+ }
+ if (options.end_time) {
+ params.append("end_time", options.end_time.toISOString());
+ }
+
+ const response = await fetch(`${SCREENPIPE_API}/search?${params.toString()}`);
+ if (!response.ok) throw new Error(`Search failed: ${response.status}`);
+
+ const data = await response.json();
+ setResults(data.data || []);
+ } catch (error) {
+ console.error("Search error:", error);
+ } finally {
+ setIsSearching(false);
+ }
+ }
+
+ // Execute search tool for AI
+ async function executeSearchTool(args: Record<string, unknown>): Promise<string> {
+ try {
+ const params = new URLSearchParams();
+ if (args.q) params.append("q", String(args.q));
+ if (args.content_type && args.content_type !== "all") {
+ params.append("content_type", String(args.content_type));
+ }
+ if (args.limit) params.append("limit", String(args.limit));
+ else params.append("limit", "10");
+ if (args.start_time) params.append("start_time", String(args.start_time));
+ if (args.end_time) params.append("end_time", String(args.end_time));
+ if (args.app_name) params.append("app_name", String(args.app_name));
+
+ const response = await fetch(`${SCREENPIPE_API}/search?${params.toString()}`);
+ if (!response.ok) throw new Error(`Search failed: ${response.status}`);
+
+ const data = await response.json();
+ const searchResults = data.data || [];
+
+ if (searchResults.length === 0) {
+ return "No results found. Try broader search terms or a wider time range.";
+ }
+
+ const formatted = searchResults.map((result: SearchResult) => {
+ const content = result.content;
+ if (!content) return null;
+
+ if (result.type === "OCR") {
+ return `[Screen - ${content.app_name || "Unknown"}] ${content.timestamp}\n${content.text || ""}`;
+ } else if (result.type === "Audio") {
+ return `[Audio - ${content.device_name || "Unknown"}] ${content.timestamp}\n${content.transcription || ""}`;
+ } else if (result.type === "UI") {
+ return `[UI - ${content.app_name || "Unknown"}] ${content.timestamp}\n${content.text || ""}`;
+ }
+ return null;
+ }).filter(Boolean);
+
+ return `Found ${searchResults.length} results:\n\n${formatted.join("\n\n---\n\n")}`;
+ } catch (error) {
+ console.error("Search error:", error);
+ return `Search failed: ${error instanceof Error ? error.message : "Unknown error"}`;
+ }
+ }
+
+ // Send message to Claude via Vertex proxy
+ async function sendAiMessage(userMessage: string) {
+ if (!user?.token) {
+ setMessages((prev) => [
+ ...prev,
+ {
+ id: Date.now().toString(),
+ role: "assistant",
+ content: "Please sign in to use the AI chat feature.",
+ },
+ ]);
+ return;
+ }
+
+ const newUserMessage: Message = {
+ id: Date.now().toString(),
+ role: "user",
+ content: userMessage,
+ };
+ setMessages((prev) => [...prev, newUserMessage]);
+ setAiInput("");
+ setIsAiLoading(true);
+ setIsStreaming(true);
+
+ abortControllerRef.current = new AbortController();
+
+ try {
+ const conversationMessages = [
+ ...messages.map((m) => ({
+ role: m.role,
+ content: m.content,
+ })),
+ { role: "user" as const, content: userMessage },
+ ];
+
+ let response = await fetch(`${VERTEX_PROXY}/v1/messages`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${user.token}`,
+ },
+ body: JSON.stringify({
+ model: "claude-sonnet-4@20250514",
+ max_tokens: 4096,
+ system: `You are a helpful AI assistant that can search through the user's Screenpipe data - their screen recordings, audio transcriptions, and UI interactions.
+
+When users ask about what they did, saw, or heard, use the search_screenpipe tool to find relevant information. Be concise in your responses and cite timestamps when relevant.
+
+Current time: ${new Date().toISOString()}`,
+ messages: conversationMessages,
+ tools: TOOLS,
+ }),
+ signal: abortControllerRef.current.signal,
+ });
+
+ if (!response.ok) {
+ const error = await response.text();
+ throw new Error(`API error: ${error}`);
+ }
+
+ let result = await response.json();
+
+ // Handle tool use loop
+ while (result.stop_reason === "tool_use") {
+ const toolUseBlocks = result.content.filter(
+ (block: any) => block.type === "tool_use"
+ );
+
+ const toolResults = [];
+ for (const toolUse of toolUseBlocks) {
+ if (toolUse.name === "search_screenpipe") {
+ const searchResult = await executeSearchTool(toolUse.input);
+ toolResults.push({
+ type: "tool_result",
+ tool_use_id: toolUse.id,
+ content: searchResult,
+ });
+ }
+ }
+
+ response = await fetch(`${VERTEX_PROXY}/v1/messages`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${user.token}`,
+ },
+ body: JSON.stringify({
+ model: "claude-sonnet-4@20250514",
+ max_tokens: 4096,
+ system: `You are a helpful AI assistant that can search through the user's Screenpipe data. Current time: ${new Date().toISOString()}`,
+ messages: [
+ ...conversationMessages,
+ { role: "assistant", content: result.content },
+ { role: "user", content: toolResults },
+ ],
+ tools: TOOLS,
+ }),
+ signal: abortControllerRef.current.signal,
+ });
+
+ if (!response.ok) {
+ const error = await response.text();
+ throw new Error(`API error: ${error}`);
+ }
+
+ result = await response.json();
+ }
+
+ const textContent = result.content
+ ?.filter((block: any) => block.type === "text")
+ .map((block: any) => block.text)
+ .join("\n");
+
+ setMessages((prev) => [
+ ...prev,
+ {
+ id: Date.now().toString(),
+ role: "assistant",
+ content: textContent || "I couldn't generate a response.",
+ },
+ ]);
+ } catch (error) {
+ if (error instanceof Error && error.name === "AbortError") {
+ return;
+ }
+ console.error("Chat error:", error);
+ setMessages((prev) => [
+ ...prev,
+ {
+ id: Date.now().toString(),
+ role: "assistant",
+ content: `Error: ${error instanceof Error ? error.message : "Something went wrong"}`,
+ },
+ ]);
+ } finally {
+ setIsAiLoading(false);
+ setIsStreaming(false);
+ abortControllerRef.current = null;
+ }
+ }
const handleKeyDown = (e: React.KeyboardEvent) => {
- if (e.key === "Enter") {
+ if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
- //window.location.href = `/search${querySerializer(options)}`;
- commands.openSearchWindow(querySerializer(options));
+ handleSearch();
+ }
+ };
+
+ const handleAiSubmit = (e: React.FormEvent) => {
+ e.preventDefault();
+ if (!aiInput.trim() || isAiLoading) return;
+ sendAiMessage(aiInput.trim());
+ };
+
+ const handleStop = () => {
+ if (abortControllerRef.current) {
+ abortControllerRef.current.abort();
+ setIsAiLoading(false);
+ setIsStreaming(false);
+ }
+ };
+
+ // Format result for display
+ const formatResult = (result: SearchResult) => {
+ const content = result.content;
+ let text = "";
+ if (result.type === "OCR" || result.type === "UI") {
+ text = content.text || "";
+ } else if (result.type === "Audio") {
+ text = content.transcription || "";
}
+ // Truncate to 100 chars
+ return text.length > 100 ? text.substring(0, 100) + "..." : text;
};
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTitle className="sr-only">Search Command</DialogTitle>
<CustomDialogContent
- className="p-2 max-w-screen-sm"
+ className={cn(
+ "p-0 max-w-screen-sm transition-all duration-200",
+ (hasSearched || messages.length > 0) ? "max-h-[80vh]" : ""
+ )}
customClose={
options.query ? (
- <a href={`/search${querySerializer(options)}`}>
+ <button onClick={() => commands.openSearchWindow(querySerializer(options))}>
<ArrowRight className="w-4 h-4" />
- </a>
+ </button>
) : (
<XIcon className="w-4 h-4" />
)
}
>
- <Input
- value={options?.query || ""}
- className="focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0 ring-0 outline-none border-0"
- placeholder="Search..."
- onChange={(e) => {
- setOptions((prev) => ({ ...prev, query: e.target.value }));
- }}
- onKeyDown={handleKeyDown}
- />
- <div className="flex w-full gap-10">
- <div className="w-1/2">
- <AppSelect
- apps={options.apps || []}
- setApps={(values) => {
- setOptions((prev) => ({ ...prev, apps: values }));
+ {/* Search Input */}
+ <div className="p-2 border-b">
+ <div className="flex items-center gap-2">
+ <Search className="h-4 w-4 text-muted-foreground shrink-0" />
+ <Input
+ ref={inputRef}
+ value={options?.query || ""}
+ className="focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0 ring-0 outline-none border-0 h-10"
+ placeholder="Search your screen activity..."
+ onChange={(e) => {
+ setOptions((prev) => ({ ...prev, query: e.target.value }));
}}
+ onKeyDown={handleKeyDown}
/>
+ {isSearching && <Loader2 className="h-4 w-4 animate-spin" />}
</div>
- <div className="w-1/2">
- <DatePickerWithRange
- start_time={options.start_time}
- end_time={options.end_time}
- setDateRange={(range) => {
- setOptions((prev) => ({
- ...prev,
- start_time: range?.from ?? null,
- end_time: range?.to ?? null,
- }));
- }}
- />
+ <div className="flex w-full gap-2 mt-2">
+ <div className="w-1/2">
+ <AppSelect
+ apps={options.apps || []}
+ setApps={(values) => {
+ setOptions((prev) => ({ ...prev, apps: values }));
+ }}
+ />
+ </div>
+ <div className="w-1/2">
+ <DatePickerWithRange
+ start_time={options.start_time}
+ end_time={options.end_time}
+ setDateRange={(range) => {
+ setOptions((prev) => ({
+ ...prev,
+ start_time: range?.from ?? null,
+ end_time: range?.to ?? null,
+ }));
+ }}
+ />
+ </div>
</div>
</div>
+
+ {/* Search Results */}
+ {hasSearched && (
+ <div className="max-h-[200px] overflow-y-auto border-b">
+ {results.length === 0 && !isSearching ? (
+ <p className="text-center text-muted-foreground py-4 text-sm">No results found</p>
+ ) : (
+ <div className="divide-y">
+ {results.slice(0, 5).map((result, index) => (
+ <div key={index} className="p-2 hover:bg-muted/50">
+ <div className="flex items-center gap-2">
+ <Badge variant="outline" className="text-xs shrink-0">
+ {result.type}
+ </Badge>
+ <span className="text-xs text-muted-foreground shrink-0">
+ {result.content.app_name || result.content.device_name || "Unknown"}
+ </span>
+ </div>
+ <p className="text-sm mt-1 line-clamp-2">{formatResult(result)}</p>
+ </div>
+ ))}
+ {results.length > 5 && (
+ <button
+ onClick={() => commands.openSearchWindow(querySerializer(options))}
+ className="w-full p-2 text-sm text-muted-foreground hover:bg-muted/50 text-center"
+ >
+ +{results.length - 5} more results - click to view all
+ </button>
+ )}
+ </div>
+ )}
+ </div>
+ )}
+
+ {/* AI Chat Section */}
+ <div className="flex flex-col">
+ {/* Messages */}
+ {messages.length > 0 && (
+ <div className="max-h-[200px] overflow-y-auto p-3 space-y-3">
+ {messages.map((message) => (
+ <div
+ key={message.id}
+ className={cn(
+ "flex gap-2",
+ message.role === "user" ? "flex-row-reverse" : "flex-row"
+ )}
+ >
+ <div
+ className={cn(
+ "flex h-6 w-6 shrink-0 items-center justify-center rounded-full",
+ message.role === "user"
+ ? "bg-primary text-primary-foreground"
+ : "bg-muted text-muted-foreground"
+ )}
+ >
+ {message.role === "user" ? (
+ <User className="h-3 w-3" />
+ ) : (
+ <Bot className="h-3 w-3" />
+ )}
+ </div>
+ <div
+ className={cn(
+ "flex-1 rounded-lg px-3 py-2 text-sm",
+ message.role === "user"
+ ? "bg-primary text-primary-foreground"
+ : "bg-muted"
+ )}
+ >
+ <ReactMarkdown className="prose prose-sm max-w-none dark:prose-invert">
+ {message.content}
+ </ReactMarkdown>
+ </div>
+ </div>
+ ))}
+ {isAiLoading && (
+ <div className="flex items-center gap-2 text-muted-foreground">
+ <Loader2 className="h-4 w-4 animate-spin" />
+ <span className="text-sm">Searching your data...</span>
+ </div>
+ )}
+ <div ref={messagesEndRef} />
+ </div>
+ )}
+
+ {/* AI Input */}
+ <form onSubmit={handleAiSubmit} className="p-2 border-t bg-muted/30">
+ <div className="flex items-center gap-2">
+ <Sparkles className="h-4 w-4 text-muted-foreground shrink-0" />
+ <Input
+ value={aiInput}
+ onChange={(e) => setAiInput(e.target.value)}
+ placeholder={user?.token ? "Ask AI about your screen activity..." : "Sign in to use AI"}
+ disabled={isAiLoading || !user?.token}
+ className="flex-1 h-9 border-0 bg-transparent focus-visible:ring-0"
+ />
+ <Button
+ type={isStreaming ? "button" : "submit"}
+ size="icon"
+ variant="ghost"
+ className="h-8 w-8"
+ disabled={(!aiInput.trim() && !isStreaming) || !user?.token}
+ onClick={isStreaming ? handleStop : undefined}
+ >
+ {isStreaming ? (
+ <Square className="h-4 w-4" />
+ ) : (
+ <Send className="h-4 w-4" />
+ )}
+ </Button>
+ </div>
+ </form>
+ </div>
</CustomDialogContent>
</Dialog>
);
diff --git a/screenpipe-app-tauri/components/screenpipe-chat/chat-message.tsx b/screenpipe-app-tauri/components/screenpipe-chat/chat-message.tsx
deleted file mode 100644
index e2f3f5596..000000000
--- a/screenpipe-app-tauri/components/screenpipe-chat/chat-message.tsx
+++ /dev/null
@@ -1,84 +0,0 @@
-"use client";
-
-import { cn } from "@/lib/utils";
-import ReactMarkdown from "react-markdown";
-import { User, Bot } from "lucide-react";
-
-interface Message {
- id: string;
- role: "user" | "assistant";
- content: string;
-}
-
-interface ChatMessageProps {
- message: Message;
-}
-
-export function ChatMessage({ message }: ChatMessageProps) {
- const isUser = message.role === "user";
-
- return (
- <div
- className={cn(
- "flex gap-3",
- isUser ? "flex-row-reverse" : "flex-row"
- )}
- >
- <div
- className={cn(
- "flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-full",
- isUser
- ? "bg-primary text-primary-foreground"
- : "bg-muted text-muted-foreground"
- )}
- >
- {isUser ? <User className="h-4 w-4" /> : <Bot className="h-4 w-4" />}
- </div>
- <div
- className={cn(
- "flex-1 space-y-2 overflow-hidden rounded-lg px-4 py-3",
- isUser
- ? "bg-primary text-primary-foreground"
- : "bg-muted"
- )}
- >
- <ReactMarkdown
- className={cn(
- "prose prose-sm max-w-none break-words",
- isUser
- ? "prose-invert"
- : "dark:prose-invert"
- )}
- components={{
- pre: ({ children }) => (
- <pre className="overflow-x-auto rounded bg-background/50 p-2 text-xs">
- {children}
- </pre>
- ),
- code: ({ children, className }) => {
- const isInline = !className;
- return isInline ? (
- <code className="rounded bg-background/50 px-1 py-0.5 text-xs">
- {children}
- </code>
- ) : (
- <code className="text-xs">{children}</code>
- );
- },
- p: ({ children }) => (
- <p className="mb-2 last:mb-0">{children}</p>
- ),
- ul: ({ children }) => (
- <ul className="mb-2 ml-4 list-disc last:mb-0">{children}</ul>
- ),
- ol: ({ children }) => (
- <ol className="mb-2 ml-4 list-decimal last:mb-0">{children}</ol>
- ),
- }}
- >
- {message.content}
- </ReactMarkdown>
- </div>
- </div>
- );
-}
diff --git a/screenpipe-app-tauri/components/screenpipe-chat/index.tsx b/screenpipe-app-tauri/components/screenpipe-chat/index.tsx
deleted file mode 100644
index fb2d2b62d..000000000
--- a/screenpipe-app-tauri/components/screenpipe-chat/index.tsx
+++ /dev/null
@@ -1,421 +0,0 @@
-"use client";
-
-import { useState, useRef, useEffect } from "react";
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import { Card } from "@/components/ui/card";
-import {
- Send,
- Loader2,
- Square,
- MessageSquare,
- X,
- Minimize2,
- Maximize2,
-} from "lucide-react";
-import { ChatMessage } from "./chat-message";
-import { useSettings } from "@/lib/hooks/use-settings";
-import { cn } from "@/lib/utils";
-
-const SCREENPIPE_API = "http://localhost:3030";
-const VERTEX_PROXY = "https://ai-proxy.i-f9f.workers.dev";
-
-// Tool definitions for Claude
-const TOOLS = [
- {
- name: "search_screenpipe",
- description:
- "Search through the user's screen recordings, audio transcriptions, and UI elements. " +
- "Returns timestamped results with app context. Use this to find what the user was doing, " +
- "what they saw on screen, what was said in meetings, etc.",
- input_schema: {
- type: "object" as const,
- properties: {
- q: {
- type: "string",
- description: "Search query text. Optional - omit to get recent activity.",
- },
- content_type: {
- type: "string",
- enum: ["all", "ocr", "audio", "ui"],
- description: "Type of content to search. 'ocr' for screen text, 'audio' for transcriptions, 'ui' for UI elements. Default: 'all'",
- },
- limit: {
- type: "integer",
- description: "Maximum number of results to return. Default: 10",
- },
- start_time: {
- type: "string",
- description: "ISO 8601 UTC start time filter (e.g., 2024-01-15T10:00:00Z)",
- },
- end_time: {
- type: "string",
- description: "ISO 8601 UTC end time filter (e.g., 2024-01-15T18:00:00Z)",
- },
- app_name: {
- type: "string",
- description: "Filter by application name (e.g., 'Google Chrome', 'Slack', 'zoom.us')",
- },
- },
- },
- },
-];
-
-interface Message {
- id: string;
- role: "user" | "assistant";
- content: string;
-}
-
-interface ScreenpipeChatProps {
- className?: string;
- defaultOpen?: boolean;
-}
-
-export function ScreenpipeChat({ className, defaultOpen = false }: ScreenpipeChatProps) {
- const { settings } = useSettings();
- const user = settings.user;
- const [isOpen, setIsOpen] = useState(defaultOpen);
- const [isMinimized, setIsMinimized] = useState(false);
- const [messages, setMessages] = useState<Message[]>([]);
- const [input, setInput] = useState("");
- const [isLoading, setIsLoading] = useState(false);
- const [isStreaming, setIsStreaming] = useState(false);
- const messagesEndRef = useRef<HTMLDivElement>(null);
- const inputRef = useRef<HTMLInputElement>(null);
- const abortControllerRef = useRef<AbortController | null>(null);
-
- // Scroll to bottom when messages change
- useEffect(() => {
- messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
- }, [messages]);
-
- // Focus input when opening
- useEffect(() => {
- if (isOpen && !isMinimized) {
- setTimeout(() => inputRef.current?.focus(), 100);
- }
- }, [isOpen, isMinimized]);
-
- // Execute search tool
- async function executeSearchTool(args: Record<string, unknown>): Promise<string> {
- try {
- const params = new URLSearchParams();
- if (args.q) params.append("q", String(args.q));
- if (args.content_type && args.content_type !== "all") {
- params.append("content_type", String(args.content_type));
- }
- if (args.limit) params.append("limit", String(args.limit));
- else params.append("limit", "10");
- if (args.start_time) params.append("start_time", String(args.start_time));
- if (args.end_time) params.append("end_time", String(args.end_time));
- if (args.app_name) params.append("app_name", String(args.app_name));
-
- const response = await fetch(`${SCREENPIPE_API}/search?${params.toString()}`);
- if (!response.ok) {
- throw new Error(`Search failed: ${response.status}`);
- }
-
- const data = await response.json();
- const results = data.data || [];
-
- if (results.length === 0) {
- return "No results found. Try broader search terms or a wider time range.";
- }
-
- // Format results
- const formatted = results.map((result: any) => {
- const content = result.content;
- if (!content) return null;
-
- if (result.type === "OCR") {
- return `[Screen - ${content.app_name || "Unknown"}] ${content.timestamp}\n${content.text || ""}`;
- } else if (result.type === "Audio") {
- return `[Audio - ${content.device_name || "Unknown"}] ${content.timestamp}\n${content.transcription || ""}`;
- } else if (result.type === "UI") {
- return `[UI - ${content.app_name || "Unknown"}] ${content.timestamp}\n${content.text || ""}`;
- }
- return null;
- }).filter(Boolean);
-
- return `Found ${results.length} results:\n\n${formatted.join("\n\n---\n\n")}`;
- } catch (error) {
- console.error("Search error:", error);
- return `Search failed: ${error instanceof Error ? error.message : "Unknown error"}`;
- }
- }
-
- // Send message to Claude via Vertex proxy
- async function sendMessage(userMessage: string) {
- if (!user?.token) {
- setMessages((prev) => [
- ...prev,
- {
- id: Date.now().toString(),
- role: "assistant",
- content: "Please sign in to use the AI chat feature.",
- },
- ]);
- return;
- }
-
- const newUserMessage: Message = {
- id: Date.now().toString(),
- role: "user",
- content: userMessage,
- };
- setMessages((prev) => [...prev, newUserMessage]);
- setInput("");
- setIsLoading(true);
- setIsStreaming(true);
-
- abortControllerRef.current = new AbortController();
-
- try {
- // Build conversation history
- const conversationMessages = [
- ...messages.map((m) => ({
- role: m.role,
- content: m.content,
- })),
- { role: "user" as const, content: userMessage },
- ];
-
- // Initial request with tools
- let response = await fetch(`${VERTEX_PROXY}/v1/messages`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${user.token}`,
- },
- body: JSON.stringify({
- model: "claude-sonnet-4@20250514",
- max_tokens: 4096,
- system: `You are a helpful AI assistant that can search through the user's Screenpipe data - their screen recordings, audio transcriptions, and UI interactions.
-
-When users ask about what they did, saw, or heard, use the search_screenpipe tool to find relevant information. Be concise in your responses and cite timestamps when relevant.
-
-Current time: ${new Date().toISOString()}`,
- messages: conversationMessages,
- tools: TOOLS,
- }),
- signal: abortControllerRef.current.signal,
- });
-
- if (!response.ok) {
- const error = await response.text();
- throw new Error(`API error: ${error}`);
- }
-
- let result = await response.json();
-
- // Handle tool use loop
- while (result.stop_reason === "tool_use") {
- const toolUseBlocks = result.content.filter(
- (block: any) => block.type === "tool_use"
- );
-
- const toolResults = [];
- for (const toolUse of toolUseBlocks) {
- if (toolUse.name === "search_screenpipe") {
- const searchResult = await executeSearchTool(toolUse.input);
- toolResults.push({
- type: "tool_result",
- tool_use_id: toolUse.id,
- content: searchResult,
- });
- }
- }
-
- // Continue conversation with tool results
- response = await fetch(`${VERTEX_PROXY}/v1/messages`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${user.token}`,
- },
- body: JSON.stringify({
- model: "claude-sonnet-4@20250514",
- max_tokens: 4096,
- system: `You are a helpful AI assistant that can search through the user's Screenpipe data. Current time: ${new Date().toISOString()}`,
- messages: [
- ...conversationMessages,
- { role: "assistant", content: result.content },
- { role: "user", content: toolResults },
- ],
- tools: TOOLS,
- }),
- signal: abortControllerRef.current.signal,
- });
-
- if (!response.ok) {
- const error = await response.text();
- throw new Error(`API error: ${error}`);
- }
-
- result = await response.json();
- }
-
- // Extract text response
- const textContent = result.content
- ?.filter((block: any) => block.type === "text")
- .map((block: any) => block.text)
- .join("\n");
-
- setMessages((prev) => [
- ...prev,
- {
- id: Date.now().toString(),
- role: "assistant",
- content: textContent || "I couldn't generate a response.",
- },
- ]);
- } catch (error) {
- if (error instanceof Error && error.name === "AbortError") {
- return;
- }
- console.error("Chat error:", error);
- setMessages((prev) => [
- ...prev,
- {
- id: Date.now().toString(),
- role: "assistant",
- content: `Error: ${error instanceof Error ? error.message : "Something went wrong"}`,
- },
- ]);
- } finally {
- setIsLoading(false);
- setIsStreaming(false);
- abortControllerRef.current = null;
- }
- }
-
- const handleSubmit = (e: React.FormEvent) => {
- e.preventDefault();
- if (!input.trim() || isLoading) return;
- sendMessage(input.trim());
- };
-
- const handleStop = () => {
- if (abortControllerRef.current) {
- abortControllerRef.current.abort();
- setIsLoading(false);
- setIsStreaming(false);
- }
- };
-
- if (!isOpen) {
- return (
- <Button
- onClick={() => setIsOpen(true)}
- className={cn(
- "fixed bottom-4 right-4 h-14 w-14 rounded-full shadow-lg z-50",
- className
- )}
- size="icon"
- >
- <MessageSquare className="h-6 w-6" />
- </Button>
- );
- }
-
- return (
- <Card
- className={cn(
- "fixed bottom-4 right-4 flex flex-col shadow-2xl border-border bg-background z-50",
- isMinimized ? "w-80 h-14" : "w-96 h-[500px]",
- className
- )}
- >
- {/* Header */}
- <div className="flex items-center justify-between p-3 border-b border-border">
- <div className="flex items-center gap-2">
- <MessageSquare className="h-5 w-5 text-primary" />
- <span className="font-medium">Ask Screenpipe</span>
- </div>
- <div className="flex items-center gap-1">
- <Button
- variant="ghost"
- size="icon"
- className="h-8 w-8"
- onClick={() => setIsMinimized(!isMinimized)}
- >
- {isMinimized ? (
- <Maximize2 className="h-4 w-4" />
- ) : (
- <Minimize2 className="h-4 w-4" />
- )}
- </Button>
- <Button
- variant="ghost"
- size="icon"
- className="h-8 w-8"
- onClick={() => {
- setIsOpen(false);
- setMessages([]);
- }}
- >
- <X className="h-4 w-4" />
- </Button>
- </div>
- </div>
-
- {!isMinimized && (
- <>
- {/* Messages */}
- <div className="flex-1 overflow-y-auto p-4 space-y-4">
- {messages.length === 0 && (
- <div className="text-center text-muted-foreground py-8">
- <p className="text-sm">Ask me anything about your Screenpipe data!</p>
- <p className="text-xs mt-2">
- Try: &quot;What did I do in the last hour?&quot; or &quot;Find my Slack messages&quot;
- </p>
- </div>
- )}
- {messages.map((message) => (
- <ChatMessage key={message.id} message={message} />
- ))}
- {isLoading && (
- <div className="flex items-center gap-2 text-muted-foreground">
- <Loader2 className="h-4 w-4 animate-spin" />
- <span className="text-sm">Searching your data...</span>
- </div>
- )}
- <div ref={messagesEndRef} />
- </div>
-
- {/* Input */}
- <form onSubmit={handleSubmit} className="p-3 border-t border-border">
- <div className="flex gap-2">
- <Input
- ref={inputRef}
- value={input}
- onChange={(e) => setInput(e.target.value)}
- placeholder="Ask about your screen activity..."
- disabled={isLoading}
- className="flex-1"
- />
- <Button
- type={isStreaming ? "button" : "submit"}
- size="icon"
- disabled={!input.trim() && !isStreaming}
- onClick={isStreaming ? handleStop : undefined}
- >
- {isStreaming ? (
- <Square className="h-4 w-4" />
- ) : (
- <Send className="h-4 w-4" />
- )}
- </Button>
- </div>
- {!user?.token && (
- <p className="text-xs text-muted-foreground mt-2">
- Sign in to use AI chat
- </p>
- )}
- </form>
- </>
- )}
- </Card>
- );
-}