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: ui overflow + lags, typescript build

Louis Beaumont75ca945ba998
diff --git a/screenpipe-app-tauri/components/search-chat.tsx b/screenpipe-app-tauri/components/search-chat.tsx
index 81da8e8d6..e69854a3c 100644
--- a/screenpipe-app-tauri/components/search-chat.tsx
+++ b/screenpipe-app-tauri/components/search-chat.tsx
@@ -81,8 +81,6 @@ import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";
import { useHealthCheck } from "@/lib/hooks/use-health-check";
import { SearchHistory } from "@/lib/types/history";
-
-
interface SearchChatProps {
currentSearchId: string | null;
onAddSearch: (searchParams: any, results: any[]) => Promise<string>;
@@ -161,13 +159,18 @@ const AGENTS: Agent[] = [
// Add this helper function to highlight keywords in text
const highlightKeyword = (text: string, keyword: string): JSX.Element => {
if (!keyword || !text) return <>{text}</>;
-
- const parts = text.split(new RegExp(`(${keyword})`, 'gi'));
+
+ const parts = text.split(new RegExp(`(${keyword})`, "gi"));
return (
<>
- {parts.map((part, i) =>
+ {parts.map((part, i) =>
part.toLowerCase() === keyword.toLowerCase() ? (
- <span key={i} className="bg-yellow-200 dark:bg-yellow-800 rounded px-0.5">{part}</span>
+ <span
+ key={i}
+ className="bg-yellow-200 dark:bg-yellow-800 rounded px-0.5"
+ >
+ {part}
+ </span>
) : (
part
)
@@ -177,23 +180,31 @@ const highlightKeyword = (text: string, keyword: string): JSX.Element => {
};
// Update the getContextAroundKeyword function to return both text and positions
-const getContextAroundKeyword = (text: string, keyword: string, contextLength: number = 40): string => {
+const getContextAroundKeyword = (
+ text: string,
+ keyword: string,
+ contextLength: number = 40
+): string => {
if (!keyword || !text) return text;
-
+
const index = text.toLowerCase().indexOf(keyword.toLowerCase());
if (index === -1) return text;
const start = Math.max(0, index - contextLength);
const end = Math.min(text.length, index + keyword.length + contextLength);
-
+
let result = text.slice(start, end);
- if (start > 0) result = '...' + result;
- if (end < text.length) result = result + '...';
-
+ if (start > 0) result = "..." + result;
+ if (end < text.length) result = result + "...";
+
return result;
};
-export function SearchChat({ currentSearchId, onAddSearch, searches }: SearchChatProps) {
+export function SearchChat({
+ currentSearchId,
+ onAddSearch,
+ searches,
+}: SearchChatProps) {
// Search state
const { health } = useHealthCheck();
const [query, setQuery] = useState("");
@@ -262,27 +273,27 @@ export function SearchChat({ currentSearchId, onAddSearch, searches }: SearchCha
});
// Update content type when checkboxes change
- const handleContentTypeChange = (type: 'ocr' | 'audio' | 'ui') => {
+ const handleContentTypeChange = (type: "ocr" | "audio" | "ui") => {
const newTypes = { ...selectedTypes, [type]: !selectedTypes[type] };
setSelectedTypes(newTypes);
-
+
// Convert checkbox state to content type
if (!newTypes.ocr && !newTypes.audio && !newTypes.ui) {
- setContentType('all'); // fallback to all if nothing selected
+ setContentType("all"); // fallback to all if nothing selected
} else if (newTypes.audio && newTypes.ui && !newTypes.ocr) {
- setContentType('audio+ui');
+ setContentType("audio+ui");
} else if (newTypes.ocr && newTypes.ui && !newTypes.audio) {
- setContentType('ocr+ui');
+ setContentType("ocr+ui");
} else if (newTypes.audio && newTypes.ocr && !newTypes.ui) {
- setContentType('audio+ocr');
+ setContentType("audio+ocr");
} else if (newTypes.audio) {
- setContentType('audio');
+ setContentType("audio");
} else if (newTypes.ocr) {
- setContentType('ocr');
+ setContentType("ocr");
} else if (newTypes.ui) {
- setContentType('ui'); // This was missing - single UI type
+ setContentType("ui"); // This was missing - single UI type
} else {
- setContentType('all');
+ setContentType("all");
}
};
@@ -649,7 +660,8 @@ export function SearchChat({ currentSearchId, onAddSearch, searches }: SearchCha
content_type: overrides.contentType || contentType,
limit: overrides.limit || limit,
offset: newOffset,
- start_time: overrides.startDate?.toISOString() || startDate.toISOString(),
+ start_time:
+ overrides.startDate?.toISOString() || startDate.toISOString(),
end_time: endDate.toISOString(),
app_name: overrides.appName || appName || undefined,
window_name: overrides.windowName || windowName || undefined,
@@ -778,25 +790,17 @@ export function SearchChat({ currentSearchId, onAddSearch, searches }: SearchCha
<AccordionTrigger className="flex items-center">
<div className="flex items-center w-full">
<Badge className="mr-2">{item.type}</Badge>
- <span className="flex-grow truncate">
- {item.type === "UI" && highlightKeyword(
- getContextAroundKeyword(item.content.text, query),
- query
- )}
- {item.type === "OCR" && highlightKeyword(
- getContextAroundKeyword(item.content.text, query),
- query
- )}
- {item.type === "Audio" && highlightKeyword(
- getContextAroundKeyword(item.content.transcription, query),
- query
- )}
- {item.type === "FTS" && highlightKeyword(
- getContextAroundKeyword(item.content.matched_text, query),
- query
- )}
- </span>
</div>
+ <span className="flex-grow text-center truncate w-full">
+ {item.type === "OCR" &&
+ item.content.text.substring(0, 50)}
+ {item.type === "Audio" &&
+ item.content.transcription.substring(0, 50)}
+ {item.type === "FTS" &&
+ item.content.matched_text.substring(0, 50)}
+ {item.type === "UI" && item.content.text.substring(0, 50)}
+ ...
+ </span>
</AccordionTrigger>
<AccordionContent>
{item.type === "UI" && (
@@ -824,7 +828,10 @@ export function SearchChat({ currentSearchId, onAddSearch, searches }: SearchCha
<Badge
className="text-xs cursor-pointer"
onClick={() =>
- handleBadgeClick(item.content.window_name, "window")
+ handleBadgeClick(
+ item.content.window_name,
+ "window"
+ )
}
>
{item.content.window_name}
@@ -867,7 +874,9 @@ export function SearchChat({ currentSearchId, onAddSearch, searches }: SearchCha
<HelpCircle className="h-4 w-4 text-gray-400 ml-2 cursor-help" />
</TooltipTrigger>
<TooltipContent>
- <p>this is the frame where the text appeared</p>
+ <p>
+ this is the frame where the text appeared
+ </p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
@@ -879,7 +888,10 @@ export function SearchChat({ currentSearchId, onAddSearch, searches }: SearchCha
<>
<div className="max-h-[400px] overflow-y-auto rounded border border-gray-100 dark:border-gray-800 p-4">
<p className="whitespace-pre-line">
- {highlightKeyword(item.content.transcription, query)}
+ {highlightKeyword(
+ item.content.transcription,
+ query
+ )}
</p>
</div>
{item.content.file_path &&
@@ -952,33 +964,35 @@ export function SearchChat({ currentSearchId, onAddSearch, searches }: SearchCha
// Add effect to restore search when currentSearchId changes
useEffect(() => {
if (currentSearchId) {
- const selectedSearch = searches.find(s => s.id === currentSearchId);
+ const selectedSearch = searches.find((s) => s.id === currentSearchId);
if (selectedSearch) {
// Restore search parameters
- setQuery(selectedSearch.searchParams.q || '');
+ setQuery(selectedSearch.searchParams.q || "");
setContentType(selectedSearch.searchParams.content_type);
setLimit(selectedSearch.searchParams.limit);
setStartDate(new Date(selectedSearch.searchParams.start_time));
setEndDate(new Date(selectedSearch.searchParams.end_time));
- setAppName(selectedSearch.searchParams.app_name || '');
- setWindowName(selectedSearch.searchParams.window_name || '');
+ setAppName(selectedSearch.searchParams.app_name || "");
+ setWindowName(selectedSearch.searchParams.window_name || "");
setIncludeFrames(selectedSearch.searchParams.include_frames);
setMinLength(selectedSearch.searchParams.min_length);
setMaxLength(selectedSearch.searchParams.max_length);
-
+
// Restore results
setResults(selectedSearch.results);
setTotalResults(selectedSearch.results.length);
setHasSearched(true);
setShowExamples(false);
-
+
// Restore messages if any
if (selectedSearch.messages) {
- setChatMessages(selectedSearch.messages.map(msg => ({
- id: msg.id,
- role: msg.type === 'ai' ? 'assistant' : 'user',
- content: msg.content
- })));
+ setChatMessages(
+ selectedSearch.messages.map((msg) => ({
+ id: msg.id,
+ role: msg.type === "ai" ? "assistant" : "user",
+ content: msg.content,
+ }))
+ );
}
}
}
@@ -990,13 +1004,15 @@ export function SearchChat({ currentSearchId, onAddSearch, searches }: SearchCha
<div className="flex items-center justify-between mb-2">
<div className="flex items-center space-x-1">
<div className="flex items-center space-x-1">
- <Checkbox
+ <Checkbox
id="audio-type"
checked={selectedTypes.audio}
- onCheckedChange={() => handleContentTypeChange('audio')}
+ onCheckedChange={() => handleContentTypeChange("audio")}
className="h-4 w-4"
/>
- <Label htmlFor="audio-type" className="text-xs">speech</Label>
+ <Label htmlFor="audio-type" className="text-xs">
+ speech
+ </Label>
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
@@ -1010,40 +1026,49 @@ export function SearchChat({ currentSearchId, onAddSearch, searches }: SearchCha
</div>
{settings.platform === "macos" && (
<div className="flex items-center space-x-1">
- <Checkbox
+ <Checkbox
id="ui-type"
checked={selectedTypes.ui}
- onCheckedChange={() => handleContentTypeChange('ui')}
+ onCheckedChange={() => handleContentTypeChange("ui")}
className="h-4 w-4"
/>
- <Label htmlFor="ui-type" className="text-xs">screen UI</Label>
+ <Label htmlFor="ui-type" className="text-xs">
+ screen UI
+ </Label>
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<HelpCircle className="h-3 w-3 text-muted-foreground ml-0.5" />
</TooltipTrigger>
<TooltipContent>
- <p>text emitted directly from the source code of the desktop applications</p>
+ <p>
+ text emitted directly from the source code of the desktop
+ applications
+ </p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
)}
<div className="flex items-center space-x-1">
- <Checkbox
+ <Checkbox
id="ocr-type"
checked={selectedTypes.ocr}
- onCheckedChange={() => handleContentTypeChange('ocr')}
+ onCheckedChange={() => handleContentTypeChange("ocr")}
className="h-4 w-4"
/>
- <Label htmlFor="ocr-type" className="text-xs">screen capture</Label>
+ <Label htmlFor="ocr-type" className="text-xs">
+ screen capture
+ </Label>
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<HelpCircle className="h-3 w-3 text-muted-foreground ml-0.5" />
</TooltipTrigger>
<TooltipContent>
- <p>recognized text from screenshots taken every 5s by default</p>
+ <p>
+ recognized text from screenshots taken every 5s by default
+ </p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
@@ -1053,10 +1078,7 @@ export function SearchChat({ currentSearchId, onAddSearch, searches }: SearchCha
<Dialog open={isCurlDialogOpen} onOpenChange={setIsCurlDialogOpen}>
<DialogTrigger asChild>
<Button variant="outline" className="text-sm">
- <span className="flex items-center">
- <IconCode className="h-4 w-4 mr-2" />
- code
- </span>
+ <IconCode className="h-4 w-4 mx-2" />
</Button>
</DialogTrigger>
<DialogContent className="max-w-2xl">
@@ -1099,7 +1121,7 @@ export function SearchChat({ currentSearchId, onAddSearch, searches }: SearchCha
placeholder="filter by window"
className="w-[300px]"
icon={<Layout className="h-4 w-4" />}
- />
+ />
{/* Advanced button */}
<Button
@@ -1230,7 +1252,7 @@ export function SearchChat({ currentSearchId, onAddSearch, searches }: SearchCha
</Label>
... query input ...
</div> */}
-
+
{/* Keep other advanced search options */}
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="app-name" className="text-right">
diff --git a/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/screenpipe-app-tauri/lib/hooks/use-settings.tsx
index 07db5e8ae..af410e0d1 100644
--- a/screenpipe-app-tauri/lib/hooks/use-settings.tsx
+++ b/screenpipe-app-tauri/lib/hooks/use-settings.tsx
@@ -141,16 +141,16 @@ export function useSettings() {
}
try {
- const currentPlatform = await platform();
+ const currentPlatform = platform();
console.log("Current platform:", currentPlatform);
const ocrModel =
- currentPlatform === "darwin"
+ currentPlatform === "macos"
? "apple-native"
- : currentPlatform === "win32"
+ : currentPlatform === "windows"
? "windows-native"
: "tesseract";
-
+
console.log("loading settings", store);
// no need to call load() as it's done automatically
const savedKey = (await store!.get<string>("openaiApiKey")) || "";
@@ -199,7 +199,7 @@ export function useSettings() {
(await store!.get<number>("aiMaxContextChars")) || 30000;
const savedFps =
(await store!.get<number>("fps")) ||
- (currentPlatform === "darwin" ? 0.2 : 1);
+ (currentPlatform === "macos" ? 0.2 : 1);
const savedVadSensitivity =
(await store!.get<VadSensitivity>("vadSensitivity")) || "high";
let savedAnalyticsEnabled = await store!.get<boolean>(
@@ -242,7 +242,7 @@ export function useSettings() {
"OBS Studio",
];
const defaultIgnoredWindows =
- currentPlatform === "darwin"
+ currentPlatform === "macos"
? [
...ignoredWindowsInAllOS,
".env",
@@ -256,7 +256,7 @@ export function useSettings() {
"Dock",
"DeepL",
]
- : currentPlatform === "win32"
+ : currentPlatform === "windows"
? [
...ignoredWindowsInAllOS,
"Nvidia",
diff --git a/screenpipe-app-tauri/lib/screenpipe.ts b/screenpipe-app-tauri/lib/screenpipe.ts
index f7789396d..2850ef0b8 100644
--- a/screenpipe-app-tauri/lib/screenpipe.ts
+++ b/screenpipe-app-tauri/lib/screenpipe.ts
@@ -37,10 +37,21 @@ export type FTSContent = {
tags: string[];
};
+export type UIContent = {
+ frame_id: number;
+ timestamp: string;
+ file_path: string;
+ text: string;
+ app_name: string;
+ window_name: string;
+ tags: string[];
+};
+
export type ContentItem =
| { type: "OCR"; content: OCRContent }
| { type: "Audio"; content: AudioContent }
- | { type: "FTS"; content: FTSContent };
+ | { type: "FTS"; content: FTSContent }
+ | { type: "UI"; content: UIContent };
export type PaginationInfo = {
limit: number;
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.lock b/screenpipe-app-tauri/src-tauri/Cargo.lock
index 053e3c991..7f027898b 100755
--- a/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -3777,7 +3777,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "screenpipe-app"
-version = "0.9.4"
+version = "0.9.5"
dependencies = [
"anyhow",
"axum",
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.toml
index 899b37183..79151366f 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.9.5"
+version = "0.9.6"
description = ""
authors = ["you"]
license = ""
diff --git a/screenpipe-app-tauri/src-tauri/src/commands.rs b/screenpipe-app-tauri/src-tauri/src/commands.rs
index 974d4baae..339c384e0 100644
--- a/screenpipe-app-tauri/src-tauri/src/commands.rs
+++ b/screenpipe-app-tauri/src-tauri/src/commands.rs
@@ -209,7 +209,7 @@ pub fn check_accessibility_permissions() -> bool {
#[cfg(target_os = "macos")]
{
// Check if the app has accessibility permissions
- let options = unsafe {
+ let options = {
let key = CFString::new("AXTrustedCheckOptionPrompt");
let value = CFBoolean::false_value();
let pairs = &[(key, value)];