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: use dynamic app suggestions and stabilize tests

Louis Beaumont4b96ecdd08ff
diff --git a/screenpipe-app-tauri/components/__tests__/global-chat-mentions.test.ts b/screenpipe-app-tauri/components/__tests__/global-chat-mentions.test.ts
new file mode 100644
index 000000000..659650009
--- /dev/null
+++ b/screenpipe-app-tauri/components/__tests__/global-chat-mentions.test.ts
@@ -0,0 +1,43 @@
+import { describe, it, expect } from "vitest";
+import "../../vitest.setup";
+import { buildAppMentionSuggestions, parseMentions } from "../global-chat";
+
+describe("global chat mentions", () => {
+ it("builds app suggestions from most-used apps", () => {
+ const items = [
+ { name: "Google Chrome", count: 120 },
+ { name: "Slack", count: 80 },
+ ];
+
+ const suggestions = buildAppMentionSuggestions(items, 10);
+
+ expect(suggestions).toHaveLength(2);
+ expect(suggestions[0]).toMatchObject({
+ tag: "@googlechrome",
+ description: "Google Chrome",
+ category: "app",
+ appName: "Google Chrome",
+ });
+ expect(suggestions[1].tag).toBe("@slack");
+ });
+
+ it("dedupes app tags when normalized names collide", () => {
+ const items = [
+ { name: "VS Code", count: 10 },
+ { name: "VS-Code", count: 9 },
+ ];
+
+ const suggestions = buildAppMentionSuggestions(items, 10);
+
+ expect(suggestions.map((item) => item.tag)).toEqual(["@vscode", "@vscode2"]);
+ });
+
+ it("parses dynamic app mentions using autocomplete tags", () => {
+ const mentions = parseMentions("@googlechrome find notes", {
+ appTagMap: { googlechrome: "Google Chrome" },
+ });
+
+ expect(mentions.appName).toBe("Google Chrome");
+ expect(mentions.cleanedInput).toBe("find notes");
+ });
+});
diff --git a/screenpipe-app-tauri/components/__tests__/text-overlay.test.tsx b/screenpipe-app-tauri/components/__tests__/text-overlay.test.tsx
index 2dc81517f..aaa0a09da 100644
--- a/screenpipe-app-tauri/components/__tests__/text-overlay.test.tsx
+++ b/screenpipe-app-tauri/components/__tests__/text-overlay.test.tsx
@@ -1,4 +1,5 @@
import { describe, it, expect, vi } from "vitest";
+import "../../vitest.setup";
import { render, screen, fireEvent } from "@testing-library/react";
import { TextOverlay, isUrl, normalizeUrl } from "../text-overlay";
import type { TextPosition } from "@/lib/hooks/use-frame-ocr-data";
@@ -38,7 +39,7 @@ describe("TextOverlay", () => {
createTextPosition("World", 0.2, 0.05, 0.1, 0.02),
];
- render(
+ const { getByText } = render(
<TextOverlay
textPositions={positions}
originalWidth={1920}
@@ -48,8 +49,8 @@ describe("TextOverlay", () => {
/>
);
- expect(screen.getByText("Hello")).toBeInTheDocument();
- expect(screen.getByText("World")).toBeInTheDocument();
+ expect(getByText("Hello")).toBeInTheDocument();
+ expect(getByText("World")).toBeInTheDocument();
});
it("should scale normalized coordinates correctly", () => {
@@ -81,7 +82,7 @@ describe("TextOverlay", () => {
createTextPosition("LowConf", 0.2, 0.05, 0.08, 0.02, 0.3),
];
- render(
+ const { getByText, queryByText } = render(
<TextOverlay
textPositions={positions}
originalWidth={1920}
@@ -92,8 +93,8 @@ describe("TextOverlay", () => {
/>
);
- expect(screen.getByText("HighConf")).toBeInTheDocument();
- expect(screen.queryByText("LowConf")).not.toBeInTheDocument();
+ expect(getByText("HighConf")).toBeInTheDocument();
+ expect(queryByText("LowConf")).not.toBeInTheDocument();
});
it("should render nothing when displayed dimensions are invalid", () => {
@@ -119,7 +120,7 @@ describe("TextOverlay", () => {
createTextPosition("ZeroHeight", 0.3, 0.05, 0.08, 0),
];
- render(
+ const { getByText, queryByText } = render(
<TextOverlay
textPositions={positions}
originalWidth={1920}
@@ -129,9 +130,9 @@ describe("TextOverlay", () => {
/>
);
- expect(screen.getByText("Valid")).toBeInTheDocument();
- expect(screen.queryByText("ZeroWidth")).not.toBeInTheDocument();
- expect(screen.queryByText("ZeroHeight")).not.toBeInTheDocument();
+ expect(getByText("Valid")).toBeInTheDocument();
+ expect(queryByText("ZeroWidth")).not.toBeInTheDocument();
+ expect(queryByText("ZeroHeight")).not.toBeInTheDocument();
});
it("should filter out positions outside the display bounds", () => {
@@ -140,7 +141,7 @@ describe("TextOverlay", () => {
createTextPosition("Outside", 1.5, 0.05, 0.08, 0.02), // Beyond normalized 1.0
];
- render(
+ const { getByText, queryByText } = render(
<TextOverlay
textPositions={positions}
originalWidth={1920}
@@ -150,8 +151,8 @@ describe("TextOverlay", () => {
/>
);
- expect(screen.getByText("Inside")).toBeInTheDocument();
- expect(screen.queryByText("Outside")).not.toBeInTheDocument();
+ expect(getByText("Inside")).toBeInTheDocument();
+ expect(queryByText("Outside")).not.toBeInTheDocument();
});
it("should apply debug styles when debug prop is true", () => {
diff --git a/screenpipe-app-tauri/components/global-chat.tsx b/screenpipe-app-tauri/components/global-chat.tsx
index 22562100d..143b8e9a7 100644
--- a/screenpipe-app-tauri/components/global-chat.tsx
+++ b/screenpipe-app-tauri/components/global-chat.tsx
@@ -25,6 +25,7 @@ import { ChatCompletionTool } from "openai/resources/chat/completions";
import { open as openUrl } from "@tauri-apps/plugin-shell";
import { usePlatform } from "@/lib/hooks/use-platform";
import { useTimelineSelection } from "@/lib/hooks/use-timeline-selection";
+import { useSqlAutocomplete } from "@/lib/hooks/use-sql-autocomplete";
import { commands } from "@/lib/utils/tauri";
const SCREENPIPE_API = "http://localhost:3030";
@@ -50,6 +51,7 @@ interface ParsedMentions {
interface ParseMentionsOptions {
selectionRange?: { start: Date; end: Date } | null;
+ appTagMap?: Record<string, string>;
}
// Common app name mappings (user-friendly -> actual app name patterns)
@@ -82,7 +84,7 @@ const APP_MAPPINGS: Record<string, string[]> = {
"warp": ["Warp"],
};
-function parseMentions(input: string, options?: ParseMentionsOptions): ParsedMentions {
+export function parseMentions(input: string, options?: ParseMentionsOptions): ParsedMentions {
const now = new Date();
const timeRanges: TimeRange[] = [];
let cleanedInput = input;
@@ -178,13 +180,28 @@ function parseMentions(input: string, options?: ParseMentionsOptions): ParsedMen
// === APP MENTIONS ===
- // Check for @appname patterns
- for (const [shortName, actualNames] of Object.entries(APP_MAPPINGS)) {
- const appPattern = new RegExp(`@${shortName}\\b`, "gi");
+ const appTagMap = options?.appTagMap || {};
+ const appTagEntries = Object.entries(appTagMap);
+
+ // Check for dynamic @appname patterns from autocomplete
+ for (const [tag, actualName] of appTagEntries) {
+ const appPattern = new RegExp(`@${tag.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}\\b`, "gi");
if (appPattern.test(cleanedInput)) {
- appName = actualNames[0]; // Use first (primary) name
+ appName = actualName;
cleanedInput = cleanedInput.replace(appPattern, "").trim();
- break; // Only match first app
+ break;
+ }
+ }
+
+ // Check for @appname patterns (common aliases)
+ if (!appName) {
+ for (const [shortName, actualNames] of Object.entries(APP_MAPPINGS)) {
+ const appPattern = new RegExp(`@${shortName}\\b`, "gi");
+ if (appPattern.test(cleanedInput)) {
+ appName = actualNames[0]; // Use first (primary) name
+ cleanedInput = cleanedInput.replace(appPattern, "").trim();
+ break; // Only match first app
+ }
}
}
@@ -205,7 +222,8 @@ function parseMentions(input: string, options?: ParseMentionsOptions): ParsedMen
// Check if it's not a known app or time tag
const knownTags = [
"today", "yesterday", "selection", "audio", "screen", "ocr",
- ...Object.keys(APP_MAPPINGS).map(k => k.toLowerCase())
+ ...Object.keys(APP_MAPPINGS).map(k => k.toLowerCase()),
+ ...Object.keys(appTagMap).map(k => k.toLowerCase()),
];
if (!knownTags.includes(potentialName.toLowerCase())) {
speakerName = potentialName;
@@ -225,6 +243,42 @@ interface MentionSuggestion {
tag: string;
description: string;
category: "time" | "content" | "app" | "speaker";
+ appName?: string;
+}
+
+const APP_SUGGESTION_LIMIT = 10;
+
+type AppAutocompleteItem = {
+ name: string;
+ count: number;
+};
+
+export function normalizeAppTag(name: string) {
+ const base = name.toLowerCase().replace(/[^a-z0-9]/g, "");
+ return base || "app";
+}
+
+export function buildAppMentionSuggestions(
+ items: AppAutocompleteItem[],
+ limit: number
+): MentionSuggestion[] {
+ const usedTags = new Set<string>();
+ return items.slice(0, limit).map((item) => {
+ const baseTag = normalizeAppTag(item.name);
+ let tag = baseTag;
+ let suffix = 2;
+ while (usedTags.has(tag)) {
+ tag = `${baseTag}${suffix}`;
+ suffix += 1;
+ }
+ usedTags.add(tag);
+ return {
+ tag: `@${tag}`,
+ description: item.name,
+ category: "app" as const,
+ appName: item.name,
+ };
+ });
}
// Static suggestions - speakers are loaded dynamically
@@ -238,17 +292,6 @@ const STATIC_MENTION_SUGGESTIONS: MentionSuggestion[] = [
// Content type
{ tag: "@audio", description: "audio/meetings only", category: "content" },
{ tag: "@screen", description: "screen text only", category: "content" },
- // Apps (common ones)
- { tag: "@chrome", description: "Google Chrome", category: "app" },
- { tag: "@slack", description: "Slack", category: "app" },
- { tag: "@vscode", description: "VS Code", category: "app" },
- { tag: "@zoom", description: "Zoom meetings", category: "app" },
- { tag: "@terminal", description: "Terminal", category: "app" },
- { tag: "@discord", description: "Discord", category: "app" },
- { tag: "@figma", description: "Figma", category: "app" },
- { tag: "@notion", description: "Notion", category: "app" },
- { tag: "@arc", description: "Arc browser", category: "app" },
- { tag: "@cursor", description: "Cursor", category: "app" },
];
// Speaker interface for dynamic suggestions
@@ -376,6 +419,7 @@ export function GlobalChat() {
const pathname = usePathname();
const { isMac } = usePlatform();
const { selectionRange, setSelectionRange } = useTimelineSelection();
+ const { items: appItems } = useSqlAutocomplete("app");
// Only show floating button on timeline page, but keep dialog available everywhere
// pathname can be null during initial hydration
@@ -400,6 +444,26 @@ export function GlobalChat() {
const [isExporting, setIsExporting] = useState(false);
const [exportProgress, setExportProgress] = useState(0);
+ const appMentionSuggestions = React.useMemo(
+ () => buildAppMentionSuggestions(appItems, APP_SUGGESTION_LIMIT),
+ [appItems]
+ );
+
+ const appTagMap = React.useMemo(() => {
+ const map: Record<string, string> = {};
+ for (const suggestion of appMentionSuggestions) {
+ if (suggestion.appName) {
+ map[suggestion.tag.slice(1).toLowerCase()] = suggestion.appName;
+ }
+ }
+ return map;
+ }, [appMentionSuggestions]);
+
+ const baseMentionSuggestions = React.useMemo(
+ () => [...STATIC_MENTION_SUGGESTIONS, ...appMentionSuggestions],
+ [appMentionSuggestions]
+ );
+
// Handle video export
const handleExport = async () => {
if (!selectionRange?.frameIds?.length) {
@@ -568,10 +632,10 @@ export function GlobalChat() {
}
// Check if filter matches any static suggestion - if so, don't search speakers
- const matchesStatic = STATIC_MENTION_SUGGESTIONS.some(
+ const matchesBase = baseMentionSuggestions.some(
s => s.tag.toLowerCase().includes(`@${mentionFilter.toLowerCase()}`)
);
- if (matchesStatic && mentionFilter.length < 3) {
+ if (matchesBase && mentionFilter.length < 3) {
setSpeakerSuggestions([]);
return;
}
@@ -603,20 +667,20 @@ export function GlobalChat() {
const debounceTimeout = setTimeout(searchSpeakers, 300);
return () => clearTimeout(debounceTimeout);
- }, [mentionFilter]);
+ }, [mentionFilter, baseMentionSuggestions]);
// Filter suggestions based on what user is typing after @
const filteredMentions = React.useMemo(() => {
- const staticSuggestions = !mentionFilter
- ? STATIC_MENTION_SUGGESTIONS
- : STATIC_MENTION_SUGGESTIONS.filter(
+ const suggestions = !mentionFilter
+ ? baseMentionSuggestions
+ : baseMentionSuggestions.filter(
s => s.tag.toLowerCase().includes(mentionFilter.toLowerCase()) ||
s.description.toLowerCase().includes(mentionFilter.toLowerCase())
);
- // Combine static and dynamic speaker suggestions
- return [...staticSuggestions, ...speakerSuggestions];
- }, [mentionFilter, speakerSuggestions]);
+ // Combine base suggestions and dynamic speaker suggestions
+ return [...suggestions, ...speakerSuggestions];
+ }, [mentionFilter, speakerSuggestions, baseMentionSuggestions]);
// Handle input changes and detect @ mentions
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
@@ -888,7 +952,7 @@ export function GlobalChat() {
if (!openai) return;
// Parse @mentions from input (time, content type, apps)
- const mentions = parseMentions(userMessage, { selectionRange });
+ const mentions = parseMentions(userMessage, { selectionRange, appTagMap });
const displayMessage = userMessage; // Show original message with tags to user
const processedMessage = mentions.cleanedInput || userMessage; // Use cleaned version for AI
diff --git a/screenpipe-app-tauri/components/rewind/timeline.tsx b/screenpipe-app-tauri/components/rewind/timeline.tsx
index 8a7e45042..3c99a3100 100644
--- a/screenpipe-app-tauri/components/rewind/timeline.tsx
+++ b/screenpipe-app-tauri/components/rewind/timeline.tsx
@@ -501,7 +501,7 @@ export default function Timeline() {
<div className="absolute bottom-0 left-0 right-0 h-16 bg-gradient-to-t from-black/10 via-black/2 to-transparent z-30 pointer-events-none" />
{/* Top Controls */}
- <div className="absolute top-0 left-0 right-0 z-40 p-4">
+ <div className="absolute top-0 left-0 right-0 z-40 px-4 pb-4 pt-[calc(env(safe-area-inset-top)+16px)]">
<TimelineControls
currentDate={currentDate}
startAndEndDates={startAndEndDates}
@@ -511,7 +511,7 @@ export default function Timeline() {
{/* Refresh button - top right */}
<button
onClick={handleRefresh}
- className="absolute top-4 right-4 p-2 bg-background/80 hover:bg-background border border-border rounded-md transition-colors"
+ className="absolute top-[calc(env(safe-area-inset-top)+16px)] right-4 p-2 bg-background/80 hover:bg-background border border-border rounded-md transition-colors"
title="Refresh timeline"
>
<RotateCcw className="w-4 h-4 text-muted-foreground" />
@@ -712,4 +712,3 @@ export default function Timeline() {
</TimelineProvider>
);
}
-
diff --git a/screenpipe-app-tauri/e2e/terminator-e2e/mocha.global.js b/screenpipe-app-tauri/e2e/terminator-e2e/mocha.global.js
deleted file mode 100644
index 8228e44f5..000000000
--- a/screenpipe-app-tauri/e2e/terminator-e2e/mocha.global.js
+++ /dev/null
@@ -1,51 +0,0 @@
-const { spawn, execSync } = require('child_process');
-const fs = require('fs');
-const path = require('path');
-
-let appProcess;
-let terminatorProcess;
-
-function findExecutablePath() {
- const paths = [
- path.join(__dirname, '../../src-tauri/target/release/screenpipe-app.exe'),
- path.join(__dirname, '../../src-tauri/target/x86_64-pc-windows-msvc/release/screenpipe-app.exe')
- ];
- for (const p of paths) {
- if (fs.existsSync(p)) return p;
- }
- throw new Error('could not find screenpipe-app.exe in any of the expected locations');
-}
-
-function findTerminatorServerPath() {
- const serverPath = path.join(__dirname, 'terminator-server-windows-x86_64', 'server.exe');
- if (fs.existsSync(serverPath)) return serverPath;
- throw new Error('could not find terminator server exe in expected location');
-}
-
-function killProcess(proc) {
- if (!proc) return;
- const pid = proc.pid;
- if (process.platform === 'win32') {
- try {
- execSync(`taskkill /PID ${pid} /T /F`);
- } catch (e) { /* ignore */ }
- } else {
- try {
- process.kill(-pid);
- } catch (e) { /* ignore */ }
- }
-}
-
-exports.mochaHooks = {
- async beforeAll() {
- const exePath = findExecutablePath();
- const terminatorPath = findTerminatorServerPath();
- appProcess = spawn(exePath, [], { stdio: 'ignore', detached: true });
- terminatorProcess = spawn(terminatorPath, [], { stdio: 'ignore', detached: true });
- await new Promise(res => setTimeout(res, 4000));
- },
- afterAll() {
- killProcess(appProcess);
- killProcess(terminatorProcess);
- }
-};
\ No newline at end of file
diff --git a/screenpipe-app-tauri/e2e/terminator-e2e/screenpipe.spec.js b/screenpipe-app-tauri/e2e/terminator-e2e/screenpipe.spec.js
deleted file mode 100644
index 5c79fb661..000000000
--- a/screenpipe-app-tauri/e2e/terminator-e2e/screenpipe.spec.js
+++ /dev/null
@@ -1,66 +0,0 @@
-const { DesktopUseClient, ApiError} = require('desktop-use');
-
-function delay(ms) {
- return new Promise(resolve => setTimeout(resolve, ms));
-}
-
-describe('Screenpipe App Health Status', function() {
- this.timeout(150000); // Models download can take a while
-
- let client;
-
- before(() => {
- client = new DesktopUseClient();
- });
-
- it('should open Screenpipe and verify health status', async () => {
- try {
-
- const mainWindow = client.locator('window:Screenpipe');
- const rootWebArea = mainWindow.locator('role:Document');
-
- const skipOnboarding = rootWebArea.locator('Name:skip');
- await skipOnboarding.click();
- await delay(3000);
-
- const closeChangelogs = rootWebArea.locator('Name:Close');
- await closeChangelogs.click();
- await delay(3000);
-
- // const healthMenu = rootWebArea.locator('classname:inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 border-transparent cursor-pointer bg-transparent text-foreground hover:bg-accent hover:text-accent-foreground');
- const healthMenu = rootWebArea.locator('Name:health-status-badge');
- await healthMenu.click();
- await delay(3000);
-
- async function getHealthStatusText() {
- // const textGroup = rootWebArea.locator('Name:text-sm mb-4 font-semibold');
- const textGroup = rootWebArea.locator('Name:status-message-text');
- const text_element = textGroup.locator('role:Text');
- const attributes = await text_element.getAttributes();
- return attributes.properties?.Name || '';
- }
-
- const desiredText = 'STRING(screenpipe is running smoothly)';
- let healthStatusText = null;
- for (let i = 0; i < 30; i++) { // Try for up to 30 seconds
- healthStatusText = await getHealthStatusText();
- if (healthStatusText === desiredText) {
- console.log(healthStatusText);
- break;
- }
- await delay(1000);
- }
-
- if (healthStatusText !== desiredText) {
- throw new Error(`Health status did not match. Got: ${healthStatusText}`);
- }
-
- } catch (e) {
- if (e instanceof ApiError) {
- throw new Error(`API Status: ${e}`);
- } else {
- throw new Error(`Unexpected error: ${e}`);
- }
- }
- });
-});
diff --git a/screenpipe-app-tauri/lib/hooks/__tests__/use-frame-ocr-data.test.ts b/screenpipe-app-tauri/lib/hooks/__tests__/use-frame-ocr-data.test.ts
index 3151b9e8e..5c84641ed 100644
--- a/screenpipe-app-tauri/lib/hooks/__tests__/use-frame-ocr-data.test.ts
+++ b/screenpipe-app-tauri/lib/hooks/__tests__/use-frame-ocr-data.test.ts
@@ -1,4 +1,5 @@
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
+import "../../../vitest.setup";
import { renderHook, waitFor, act } from "@testing-library/react";
import { useFrameOcrData, clearOcrCache } from "../use-frame-ocr-data";
diff --git a/screenpipe-app-tauri/package.json b/screenpipe-app-tauri/package.json
index 864e2a3b7..d1a32716f 100644
--- a/screenpipe-app-tauri/package.json
+++ b/screenpipe-app-tauri/package.json
@@ -3,10 +3,9 @@
"private": true,
"scripts": {
"dev": "next dev",
- "test": "bunx vitest run",
- "test:watch": "bunx vitest",
+ "test": "bunx vitest run --config vitest.config.ts",
+ "test:watch": "bunx vitest --config vitest.config.ts",
"test:e2e": "wdio run wdio.conf.js",
- "test:e2e:terminator": "mocha",
"build": "next build",
"predev": "bun scripts/pre_build.js",
"prebuild": "bun scripts/pre_build.js",
diff --git a/screenpipe-app-tauri/vitest.setup.ts b/screenpipe-app-tauri/vitest.setup.ts
index f149f27ae..ed6f4bec8 100644
--- a/screenpipe-app-tauri/vitest.setup.ts
+++ b/screenpipe-app-tauri/vitest.setup.ts
@@ -1 +1,22 @@
import "@testing-library/jest-dom/vitest";
+import { JSDOM } from "jsdom";
+
+if (typeof window === "undefined") {
+ const dom = new JSDOM("<!doctype html><html><body></body></html>", {
+ url: "http://localhost",
+ });
+
+ const globalWithDom = globalThis as typeof globalThis & {
+ window: Window;
+ document: Document;
+ navigator: Navigator;
+ location: Location;
+ HTMLElement: typeof HTMLElement;
+ };
+
+ globalWithDom.window = dom.window as unknown as Window;
+ globalWithDom.document = dom.window.document;
+ globalWithDom.navigator = dom.window.navigator as Navigator;
+ globalWithDom.location = dom.window.location;
+ globalWithDom.HTMLElement = dom.window.HTMLElement;
+}