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
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
chore: make audio device and monitor list in app through cub command instead of api
Louis Beaumonta007e9f1eba7
diff --git a/screenpipe-app-tauri/components/settings/recording-settings.tsx b/screenpipe-app-tauri/components/settings/recording-settings.tsxindex 7b0e25c51..0fdb9b3a9 100644--- a/screenpipe-app-tauri/components/settings/recording-settings.tsx+++ b/screenpipe-app-tauri/components/settings/recording-settings.tsx@@ -39,6 +39,8 @@ import {CommandGroup,CommandItem,} from "@/components/ui/command";+import { Command as TauriCommand } from "@tauri-apps/plugin-shell";+import {Settings,useSettings,@@ -201,25 +203,44 @@ export function RecordingSettings() {useEffect(() => {const loadDevices = async () => {try {- // Fetch monitors- const monitorsResponse = await fetch(- "http://localhost:3030/vision/list"- );- if (!monitorsResponse.ok) {- throw new Error("Failed to fetch monitors");+ // Use sidecar command to fetch monitors+ const monitorCommand = TauriCommand.sidecar("screenpipe", [+ "vision",+ "list",+ "-o",+ "json",+ ]);++ const monitorOutput = await monitorCommand.execute();+ if (monitorOutput.code !== 0) {+ throw new Error(`Failed to fetch monitors: ${monitorOutput.stderr}`);}- const monitors: MonitorDevice[] = await monitorsResponse.json();++ // Parse the JSON response which might be in {data: [...], success: true} format+ const monitorResponse = JSON.parse(monitorOutput.stdout);+ const monitors: MonitorDevice[] =+ monitorResponse.data || monitorResponse;console.log("monitors", monitors);setAvailableMonitors(monitors);- // Fetch audio devices- const audioDevicesResponse = await fetch(- "http://localhost:3030/audio/list"- );- if (!audioDevicesResponse.ok) {- throw new Error("Failed to fetch audio devices");+ // Use sidecar command to fetch audio devices+ const audioCommand = TauriCommand.sidecar("screenpipe", [+ "audio",+ "list",+ "-o",+ "json",+ ]);++ const audioOutput = await audioCommand.execute();+ if (audioOutput.code !== 0) {+ throw new Error(+ `Failed to fetch audio devices: ${audioOutput.stderr}`+ );}- const audioDevices: AudioDevice[] = await audioDevicesResponse.json();++ // Parse the JSON response which might be in {data: [...], success: true} format+ const audioResponse = JSON.parse(audioOutput.stdout);+ const audioDevices: AudioDevice[] = audioResponse.data || audioResponse;console.log("audioDevices", audioDevices);setAvailableAudioDevices(audioDevices);@@ -677,9 +698,9 @@ export function RecordingSettings() {<></>)}<div- className={cn(- isDisabled && "opacity-50 pointer-events-none cursor-not-allowed"- )}+ // className={cn(+ // isDisabled && "opacity-50 pointer-events-none cursor-not-allowed"+ // )}><h4 className="text-lg font-semibold my-4">video</h4><div className="space-y-6">diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rsindex 8424e2bef..0b3ca37ee 100644--- a/screenpipe-server/src/bin/screenpipe-server.rs+++ b/screenpipe-server/src/bin/screenpipe-server.rs@@ -234,12 +234,19 @@ async fn main() -> anyhow::Result<()> {match command {Command::Audio { subcommand } => match subcommand {AudioCommand::List { output } => {+ let default_input = default_input_device().unwrap();+ let default_output = default_output_device().unwrap();let devices = list_audio_devices().await?;match output {OutputFormat::Json => println!("{}",serde_json::to_string_pretty(&json!({- "data": devices,+ "data": devices.iter().map(|d| {+ json!({+ "name": d.name,+ "is_default": d.name == default_input.name || d.name == default_output.name+ })+ }).collect::<Vec<_>>(),"success": true}))?),@@ -265,7 +272,10 @@ async fn main() -> anyhow::Result<()> {"data": monitors.iter().map(|m| {json!({"id": m.id(),- "name": m.name()+ "name": m.name(),+ "width": m.width(),+ "height": m.height(),+ "is_default": m.is_primary(),})}).collect::<Vec<_>>(),"success": true