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 cli monitor default, add monitor selection ui to app, improve empty screen prompt based on feedback, improve search

Louis Beaumontd36e891fe1dd
diff --git a/examples/apps/screenpipe-app-tauri/components/empty-screen.tsx b/examples/apps/screenpipe-app-tauri/components/empty-screen.tsx
index 775634969..7e6f68219 100644
--- a/examples/apps/screenpipe-app-tauri/components/empty-screen.tsx
+++ b/examples/apps/screenpipe-app-tauri/components/empty-screen.tsx
@@ -6,11 +6,11 @@ interface EmptyScreenProps {
}
const suggestions = [
- "Turn my recent conversations with my customers about my product into a table. Use 5 queries. Use 6 hours from now.",
- "Show me my recent Slack conversations with john about dog food. Only use screen text",
- "Read my coding stuff (python) and tell me how i can write better python code",
- "Summarize my recent email activity, only use screen text",
- "Turn my audio conversations with Lisa into a table, do use 2-3 queries",
+ "Summarize last hour audio conversation with action items",
+ "Read my data from last 60 mins and list apps i spent the most time on, with duration, list of topics, etc. (be creative), as a table",
+ "Look at my data from last hour and tell me how i can become a better programmer",
+ "Create a table of everything I did in the last hour",
+ "Create a bullet list of everything I did in the last hour with timestamps and path to the video",
"Show me a video of what i was doing at 8.11 am (take file_path and put it in an inline code block)",
];
diff --git a/examples/apps/screenpipe-app-tauri/components/recording-settings.tsx b/examples/apps/screenpipe-app-tauri/components/recording-settings.tsx
index 4132ff815..681beba63 100644
--- a/examples/apps/screenpipe-app-tauri/components/recording-settings.tsx
+++ b/examples/apps/screenpipe-app-tauri/components/recording-settings.tsx
@@ -66,6 +66,8 @@ export function RecordingSettings({
}) {
const { settings, updateSettings } = useSettings();
const [openAudioDevices, setOpenAudioDevices] = React.useState(false);
+ const [openMonitors, setOpenMonitors] = React.useState(false);
+
const [availableMonitors, setAvailableMonitors] = useState<MonitorDevice[]>(
[]
);
@@ -76,6 +78,9 @@ export function RecordingSettings({
const [isUpdating, setIsUpdating] = useState(false);
const { health } = useHealthCheck();
const isDisabled = health?.status_code === 500;
+ console.log("localSettings", localSettings);
+ console.log("settings", settings);
+ console.log("availableMonitors", availableMonitors);
useEffect(() => {
const loadDevices = async () => {
try {
@@ -106,10 +111,16 @@ export function RecordingSettings({
console.log("localSettings", localSettings);
// Update local settings if current values are default
- if (localSettings.monitorId === "default" && monitors.length > 0) {
+ if (
+ localSettings.monitorIds.length === 1 &&
+ localSettings.monitorIds[0] === "default" &&
+ monitors.length > 0
+ ) {
setLocalSettings({
...localSettings,
- monitorId: monitors.find((monitor) => monitor.is_default)?.id!,
+ monitorIds: [
+ monitors.find((monitor) => monitor.is_default)!.id!.toString(),
+ ],
});
}
if (
@@ -145,7 +156,7 @@ export function RecordingSettings({
const settingsToUpdate = {
audioTranscriptionEngine: localSettings.audioTranscriptionEngine,
ocrEngine: localSettings.ocrEngine,
- monitorId: localSettings.monitorId,
+ monitorIds: localSettings.monitorIds,
audioDevices: localSettings.audioDevices,
usePiiRemoval: localSettings.usePiiRemoval,
restartInterval: localSettings.restartInterval,
@@ -218,8 +229,12 @@ export function RecordingSettings({
setLocalSettings({ ...localSettings, ocrEngine: value });
};
- const handleMonitorChange = (value: string) => {
- setLocalSettings({ ...localSettings, monitorId: value });
+ const handleMonitorChange = (currentValue: string) => {
+ const updatedMonitors = localSettings.monitorIds.includes(currentValue)
+ ? localSettings.monitorIds.filter((id) => id !== currentValue)
+ : [...localSettings.monitorIds, currentValue];
+
+ setLocalSettings({ ...localSettings, monitorIds: updatedMonitors });
};
const handleAudioDeviceChange = (currentValue: string) => {
@@ -325,29 +340,72 @@ export function RecordingSettings({
<div className="flex flex-col space-y-2">
<Label
- htmlFor="monitorId"
+ htmlFor="monitorIds"
className="flex items-center space-x-2"
>
<Monitor className="h-4 w-4" />
- <span>monitor</span>
+ <span>monitors</span>
</Label>
- <Select
- onValueChange={handleMonitorChange}
- defaultValue={localSettings.monitorId}
- >
- <SelectTrigger>
- <SelectValue placeholder="select monitor" />
- </SelectTrigger>
- <SelectContent>
- {availableMonitors.map((monitor) => (
- <SelectItem key={monitor.id} value={monitor.id}>
- {monitor.id}. {monitor.name}{" "}
- {monitor.is_default ? "(default)" : ""} - {monitor.width}x
- {monitor.height}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
+ <Popover open={openMonitors} onOpenChange={setOpenMonitors}>
+ <PopoverTrigger asChild>
+ <Button
+ variant="outline"
+ role="combobox"
+ aria-expanded={openMonitors}
+ className="w-full justify-between"
+ >
+ {localSettings.monitorIds.length > 0
+ ? `${localSettings.monitorIds.length} monitor(s) selected`
+ : "select monitors"}
+ <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent className="w-full p-0">
+ <Command>
+ <CommandInput placeholder="search monitors..." />
+ <CommandList>
+ <CommandEmpty>no monitor found.</CommandEmpty>
+ <CommandGroup>
+ {availableMonitors.map((monitor) => (
+ <CommandItem
+ key={monitor.id}
+ value={monitor.id}
+ onSelect={() =>
+ handleMonitorChange(monitor.id.toString())
+ }
+ >
+ <div className="flex items-center">
+ <Check
+ className={cn(
+ "mr-2 h-4 w-4",
+ localSettings.monitorIds.includes(
+ monitor.id.toString()
+ )
+ ? "opacity-100"
+ : "opacity-0"
+ )}
+ />
+ {/* not selectable */}
+ <span
+ style={{
+ userSelect: "none",
+ WebkitUserSelect: "none",
+ MozUserSelect: "none",
+ msUserSelect: "none",
+ }}
+ >
+ {monitor.id}. {monitor.name}{" "}
+ {monitor.is_default ? "(default)" : ""} -{" "}
+ {monitor.width}x{monitor.height}
+ </span>
+ </div>
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ </CommandList>
+ </Command>
+ </PopoverContent>
+ </Popover>
</div>
<div className="flex flex-col space-y-2">
<Label
@@ -397,7 +455,14 @@ export function RecordingSettings({
: "opacity-0"
)}
/>
- <span>
+ <span
+ style={{
+ userSelect: "none",
+ WebkitUserSelect: "none",
+ MozUserSelect: "none",
+ msUserSelect: "none",
+ }}
+ >
{device.name}{" "}
{device.is_default ? "(default)" : ""}
</span>
@@ -523,14 +588,15 @@ export function RecordingSettings({
<TooltipTrigger>
<HelpCircle className="h-4 w-4" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent side="right">
<p>
windows to ignore during screen recording
(case-insensitive), example:
<br />
- - &quot;bit&quot; will ignore &quot;Bitwarden&quot; and &quot;bittorrent&quot;
- <br />
- - &quot;incognito&quot; will ignore tabs, windows that contains the word &quot;incognito&quot;
+ - &quot;bit&quot; will ignore &quot;Bitwarden&quot; and
+ &quot;bittorrent&quot;
+ <br />- &quot;incognito&quot; will ignore tabs, windows
+ that contains the word &quot;incognito&quot;
</p>
</TooltipContent>
</Tooltip>
@@ -587,14 +653,15 @@ export function RecordingSettings({
<TooltipTrigger>
<HelpCircle className="h-4 w-4" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent side="right">
<p>
windows to include during screen recording
(case-insensitive), example:
<br />
- - &quot;chrome&quot; will match &quot;Google Chrome&quot;
- <br />
- - &quot;bitwarden&quot; will match &quot;Bitwarden&quot; and &quot;bittorrent&quot;
+ - &quot;chrome&quot; will match &quot;Google
+ Chrome&quot;
+ <br />- &quot;bitwarden&quot; will match
+ &quot;Bitwarden&quot; and &quot;bittorrent&quot;
</p>
</TooltipContent>
</Tooltip>
diff --git a/examples/apps/screenpipe-app-tauri/components/ui/scroll-area.tsx b/examples/apps/screenpipe-app-tauri/components/ui/scroll-area.tsx
new file mode 100644
index 000000000..0b4a48d87
--- /dev/null
+++ b/examples/apps/screenpipe-app-tauri/components/ui/scroll-area.tsx
@@ -0,0 +1,48 @@
+"use client"
+
+import * as React from "react"
+import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"
+
+import { cn } from "@/lib/utils"
+
+const ScrollArea = React.forwardRef<
+ React.ElementRef<typeof ScrollAreaPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
+>(({ className, children, ...props }, ref) => (
+ <ScrollAreaPrimitive.Root
+ ref={ref}
+ className={cn("relative overflow-hidden", className)}
+ {...props}
+ >
+ <ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
+ {children}
+ </ScrollAreaPrimitive.Viewport>
+ <ScrollBar />
+ <ScrollAreaPrimitive.Corner />
+ </ScrollAreaPrimitive.Root>
+))
+ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName
+
+const ScrollBar = React.forwardRef<
+ React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
+ React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
+>(({ className, orientation = "vertical", ...props }, ref) => (
+ <ScrollAreaPrimitive.ScrollAreaScrollbar
+ ref={ref}
+ orientation={orientation}
+ className={cn(
+ "flex touch-none select-none transition-colors",
+ orientation === "vertical" &&
+ "h-full w-2.5 border-l border-l-transparent p-[1px]",
+ orientation === "horizontal" &&
+ "h-2.5 flex-col border-t border-t-transparent p-[1px]",
+ className
+ )}
+ {...props}
+ >
+ <ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
+ </ScrollAreaPrimitive.ScrollAreaScrollbar>
+))
+ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName
+
+export { ScrollArea, ScrollBar }
diff --git a/examples/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/examples/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
index 2412e30e7..dcbe01cc7 100644
--- a/examples/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
+++ b/examples/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
@@ -28,10 +28,10 @@ const defaultSettings: Settings = {
devMode: false,
audioTranscriptionEngine: "whisper-large",
ocrEngine: "default",
- monitorId: "default",
+ monitorIds: ["default"],
audioDevices: ["default"],
usePiiRemoval: false,
- restartInterval: 60,
+ restartInterval: 0,
port: 3030,
dataDir: "default",
disableAudio: false,
@@ -51,7 +51,7 @@ export interface Settings {
devMode: boolean;
audioTranscriptionEngine: string;
ocrEngine: string;
- monitorId: string;
+ monitorIds: string[];
audioDevices: string[];
usePiiRemoval: boolean;
restartInterval: number;
@@ -120,8 +120,8 @@ export function useSettings() {
"whisper-large";
const savedOcrEngine =
((await store!.get("ocrEngine")) as string) || ocrModel;
- const savedMonitorId =
- ((await store!.get("monitorId")) as string) || "default";
+ const savedMonitorIds =
+ ((await store!.get("monitorIds")) as string[]) || ["default"];
const savedAudioDevices = ((await store!.get(
"audioDevices"
)) as string[]) || ["default"];
@@ -149,7 +149,7 @@ export function useSettings() {
devMode: savedDevMode,
audioTranscriptionEngine: savedAudioTranscriptionEngine,
ocrEngine: savedOcrEngine,
- monitorId: savedMonitorId,
+ monitorIds: savedMonitorIds,
audioDevices: savedAudioDevices,
usePiiRemoval: savedUsePiiRemoval,
restartInterval: savedRestartInterval,
diff --git a/examples/apps/screenpipe-app-tauri/lib/screenpipe.ts b/examples/apps/screenpipe-app-tauri/lib/screenpipe.ts
index a32c35ff4..c13f0c8fa 100644
--- a/examples/apps/screenpipe-app-tauri/lib/screenpipe.ts
+++ b/examples/apps/screenpipe-app-tauri/lib/screenpipe.ts
@@ -23,9 +23,9 @@ export const screenpipeQuery = z.object({
),
limit: z
.number()
- .default(20)
+ .default(50)
.describe(
- "Number of results to return (default: 20). Don't return more than 50 results as it will be fed to an LLM"
+ "Number of results to return (default: 50). Be mindful of the length of the response as it will be fed to an LLM"
),
offset: z.number().default(0).describe("Offset for pagination (default: 0)"),
start_time: z
diff --git a/examples/apps/screenpipe-app-tauri/package-lock.json b/examples/apps/screenpipe-app-tauri/package-lock.json
index fbed0eeff..9a11a8c4c 100644
--- a/examples/apps/screenpipe-app-tauri/package-lock.json
+++ b/examples/apps/screenpipe-app-tauri/package-lock.json
@@ -16,6 +16,7 @@
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-popover": "^1.1.1",
+ "@radix-ui/react-scroll-area": "^1.1.0",
"@radix-ui/react-select": "^2.1.1",
"@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-slot": "^1.1.0",
@@ -2156,6 +2157,36 @@
}
}
},
+ "node_modules/@radix-ui/react-scroll-area": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-scroll-area/-/react-scroll-area-1.1.0.tgz",
+ "integrity": "sha512-9ArIZ9HWhsrfqS765h+GZuLoxaRHD/j0ZWOWilsCvYTpYJp8XwCqNG7Dt9Nu/TItKOdgLGkOPCodQvDc+UMwYg==",
+ "dependencies": {
+ "@radix-ui/number": "1.1.0",
+ "@radix-ui/primitive": "1.1.0",
+ "@radix-ui/react-compose-refs": "1.1.0",
+ "@radix-ui/react-context": "1.1.0",
+ "@radix-ui/react-direction": "1.1.0",
+ "@radix-ui/react-presence": "1.1.0",
+ "@radix-ui/react-primitive": "2.0.0",
+ "@radix-ui/react-use-callback-ref": "1.1.0",
+ "@radix-ui/react-use-layout-effect": "1.1.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@radix-ui/react-select": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.1.1.tgz",
diff --git a/examples/apps/screenpipe-app-tauri/package.json b/examples/apps/screenpipe-app-tauri/package.json
index f711a3dc4..38d6281fa 100644
--- a/examples/apps/screenpipe-app-tauri/package.json
+++ b/examples/apps/screenpipe-app-tauri/package.json
@@ -20,6 +20,7 @@
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-popover": "^1.1.1",
+ "@radix-ui/react-scroll-area": "^1.1.0",
"@radix-ui/react-select": "^2.1.1",
"@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-slot": "^1.1.0",
diff --git a/examples/apps/screenpipe-app-tauri/src-tauri/src/sidecar.rs b/examples/apps/screenpipe-app-tauri/src-tauri/src/sidecar.rs
index fea813b64..4dbfacfe7 100644
--- a/examples/apps/screenpipe-app-tauri/src-tauri/src/sidecar.rs
+++ b/examples/apps/screenpipe-app-tauri/src-tauri/src/sidecar.rs
@@ -100,13 +100,14 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {
.map_err(|e| e.to_string())?
.unwrap_or(String::from("default"));
- let monitor_id = with_store(app.clone(), stores.clone(), path.clone(), |store| {
+ let monitor_ids = with_store(app.clone(), stores.clone(), path.clone(), |store| {
Ok(store
- .get("monitorId")
- .and_then(|v| v.as_str().map(String::from)))
+ .get("monitorIds")
+ .and_then(|v| v.as_array())
+ .map(|arr| arr.to_vec()))
})
.map_err(|e| e.to_string())?
- .unwrap_or(String::from("default"));
+ .unwrap_or_default();
let audio_devices = with_store(app.clone(), stores.clone(), path.clone(), |store| {
Ok(store
@@ -188,10 +189,17 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {
let model = ocr_engine.as_str();
args.push(model);
}
- if monitor_id != "default" {
- args.push("--monitor-id");
- let id = monitor_id.as_str();
- args.push(id);
+ // if monitor_id != "default" {
+ // args.push("--monitor-id");
+ // let id = monitor_id.as_str();
+ // args.push(id);
+ // }
+
+ if !monitor_ids.is_empty() && monitor_ids[0] != Value::String("default".to_string()) {
+ for monitor in &monitor_ids {
+ args.push("--monitor-id");
+ args.push(monitor.as_str().unwrap());
+ }
}
if !audio_devices.is_empty() && audio_devices[0] != Value::String("default".to_string()) {
diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rs
index e114b7de7..aad5137b0 100644
--- a/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/screenpipe-server/src/bin/screenpipe-server.rs
@@ -284,8 +284,8 @@ async fn main() -> anyhow::Result<()> {
let output_path_clone = Arc::new(local_data_dir.join("data").to_string_lossy().into_owned());
let vision_control_clone = Arc::clone(&vision_control);
let shutdown_tx_clone = shutdown_tx.clone();
- let friend_wearable_uid_clone = friend_wearable_uid.clone(); // Clone here
- let monitor_ids_clone = cli.monitor_id.clone();
+ let friend_wearable_uid_clone: Option<String> = friend_wearable_uid.clone(); // Clone here
+ let monitor_ids_clone = monitor_ids.clone();
let fps = if cli.fps.is_finite() && cli.fps > 0.0 {
cli.fps
diff --git a/screenpipe-server/src/core.rs b/screenpipe-server/src/core.rs
index a312ed82d..f9afff832 100644
--- a/screenpipe-server/src/core.rs
+++ b/screenpipe-server/src/core.rs
@@ -67,6 +67,7 @@ pub async fn start_continuous_recording(
));
}
+ debug!("Starting video recording for monitor {:?}", monitor_ids);
let video_tasks = if !vision_disabled {
monitor_ids
.iter()
@@ -79,6 +80,7 @@ pub async fn start_continuous_recording(
let ignored_windows_video = ignored_windows.to_vec();
let include_windows_video = include_windows.to_vec();
+ debug!("Starting video recording for monitor {}", monitor_id);
vision_handle.spawn(async move {
record_video(
db_manager_video,
diff --git a/screenpipe-server/src/video.rs b/screenpipe-server/src/video.rs
index 1299f50ff..d6be18144 100644
--- a/screenpipe-server/src/video.rs
+++ b/screenpipe-server/src/video.rs
@@ -13,6 +13,7 @@ use tokio::io::AsyncWriteExt;
use tokio::io::{AsyncBufReadExt, BufReader};
use tokio::process::{Child, ChildStdin, Command};
use tokio::sync::mpsc::{channel, Receiver, Sender};
+use tokio::time::sleep;
const MAX_FPS: f64 = 30.0; // Adjust based on your needs
const MAX_QUEUE_SIZE: usize = 10;
@@ -126,6 +127,7 @@ impl VideoCapture {
&output_path,
fps,
new_chunk_callback_clone,
+ monitor_id,
)
.await;
});
@@ -141,6 +143,7 @@ async fn save_frames_as_video(
output_path: &str,
fps: f64,
new_chunk_callback: Arc<dyn Fn(&str) + Send + Sync>,
+ monitor_id: u32,
) {
debug!("Starting save_frames_as_video function");
let frames_per_video = 30; // Adjust this value as needed
@@ -186,7 +189,7 @@ async fn save_frames_as_video(
let formatted_time = time.format("%Y-%m-%d_%H-%M-%S").to_string();
// Start new FFmpeg process with a new output file
let output_file = PathBuf::from(output_path)
- .join(format!("{}.mp4", formatted_time))
+ .join(format!("monitor_{}_{}.mp4", monitor_id, formatted_time))
.to_str()
.expect("Failed to create valid path")
.to_string();
@@ -260,12 +263,38 @@ async fn save_frames_as_video(
tokio::time::sleep(Duration::from_millis(10)).await;
}
+ const MAX_RETRIES: usize = 3;
+ const RETRY_DELAY: Duration = Duration::from_millis(100);
+
// Write encoded frames to FFmpeg
while let Ok(buffer) = receiver.try_recv() {
if let Some(stdin) = current_stdin.as_mut() {
- if let Err(e) = stdin.write_all(buffer.as_slice()).await {
- error!("Failed to write frame to ffmpeg: {}", e);
- break;
+ let mut retries = 0;
+ while retries < MAX_RETRIES {
+ match stdin.write_all(buffer.as_slice()).await {
+ Ok(_) => {
+ frame_count += 1;
+ debug!("Wrote frame {} to FFmpeg", frame_count);
+ break;
+ }
+ Err(e) => {
+ retries += 1;
+ if retries >= MAX_RETRIES {
+ error!(
+ "Failed to write frame to ffmpeg after {} retries: {}",
+ MAX_RETRIES, e
+ );
+ // Consider breaking the outer loop or handling this failure
+ break;
+ } else {
+ warn!(
+ "Failed to write frame to ffmpeg (attempt {}): {}. Retrying...",
+ retries, e
+ );
+ sleep(RETRY_DELAY).await;
+ }
+ }
+ }
}
frame_count += 1;
debug!("Wrote frame {} to FFmpeg", frame_count);