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

release-app-publish remove dev code, allow python3 for mcp, release screenpipe mcp setup CLI for setting up claude MCP thing easily

Louis Beaumont8800b87b4c9c
diff --git a/.github/workflows/test-bounty.yml b/.github/workflows/test-bounty.yml
index 297acb128..f0c6fe5ed 100644
--- a/.github/workflows/test-bounty.yml
+++ b/.github/workflows/test-bounty.yml
@@ -2,10 +2,11 @@ name: Create Test Bounty
on:
pull_request_target:
- types: [opened, reopened]
+ types: [opened, reopened, closed]
jobs:
create-test-bounty:
+ if: github.event.action != 'closed'
runs-on: ubuntu-latest
permissions:
issues: write
@@ -75,4 +76,48 @@ jobs:
repo: context.repo.repo,
issue_number: prNumber,
body: comment
- });
+ });
+
+ close-test-bounty:
+ if: github.event.action == 'closed'
+ runs-on: ubuntu-latest
+ permissions:
+ issues: write
+ pull-requests: read
+ contents: read
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ - name: Find and close test bounty issue
+ uses: actions/github-script@v6
+ with:
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+ script: |
+ const prNumber = context.payload.pull_request.number;
+
+ // Search for issues with the bounty label and PR number in title
+ const issues = await github.rest.issues.listForRepo({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ labels: 'bounty',
+ state: 'open'
+ });
+
+ const bountyIssue = issues.data.find(issue =>
+ issue.title.includes(`PR #${prNumber}`)
+ );
+
+ if (bountyIssue) {
+ await github.rest.issues.update({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: bountyIssue.number,
+ state: 'closed'
+ });
+
+ console.log(`Closed test bounty issue #${bountyIssue.number}`);
+ } else {
+ console.log('No matching test bounty issue found');
+ }
diff --git a/Cargo.lock b/Cargo.lock
index a3492ba63..3dc9339b4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5877,7 +5877,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "screenpipe-audio"
-version = "0.2.66"
+version = "0.2.67"
dependencies = [
"anyhow",
"bytemuck",
@@ -5930,7 +5930,7 @@ dependencies = [
[[package]]
name = "screenpipe-core"
-version = "0.2.66"
+version = "0.2.67"
dependencies = [
"accessibility",
"accessibility-sys 0.2.0",
@@ -5972,7 +5972,7 @@ dependencies = [
[[package]]
name = "screenpipe-db"
-version = "0.2.66"
+version = "0.2.67"
dependencies = [
"anyhow",
"chrono",
@@ -5994,7 +5994,7 @@ dependencies = [
[[package]]
name = "screenpipe-events"
-version = "0.2.66"
+version = "0.2.67"
dependencies = [
"anyhow",
"chrono",
@@ -6012,7 +6012,7 @@ dependencies = [
[[package]]
name = "screenpipe-integrations"
-version = "0.2.66"
+version = "0.2.67"
dependencies = [
"anyhow",
"image",
@@ -6027,7 +6027,7 @@ dependencies = [
[[package]]
name = "screenpipe-server"
-version = "0.2.66"
+version = "0.2.67"
dependencies = [
"anyhow",
"axum",
@@ -6089,7 +6089,7 @@ dependencies = [
[[package]]
name = "screenpipe-vision"
-version = "0.2.66"
+version = "0.2.67"
dependencies = [
"accessibility-sys 0.1.3",
"anyhow",
diff --git a/Cargo.toml b/Cargo.toml
index ac879b762..a12c8cfcf 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,7 +12,7 @@ exclude = ["screenpipe-app-tauri/src-tauri"]
resolver = "2"
[workspace.package]
-version = "0.2.66"
+version = "0.2.67"
authors = ["louis030195 <[email protected]>"]
description = ""
repository = "https://github.com/mediar-ai/screenpipe"
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.toml
index e57804946..0e346bfa2 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.42.11"
+version = "0.43.0"
description = ""
authors = ["you"]
license = ""
diff --git a/screenpipe-core/src/bin/test_click_by_role.rs b/screenpipe-core/src/bin/test_click_by_role.rs
deleted file mode 100644
index 493a6a0f3..000000000
--- a/screenpipe-core/src/bin/test_click_by_role.rs
+++ /dev/null
@@ -1,117 +0,0 @@
-use screenpipe_core::operator::{Selector, UIElement};
-use screenpipe_core::operator::platforms::AccessibilityEngine;
-use screenpipe_core::operator::platforms::macos::{MacOSEngine, ClickMethodSelection};
-use anyhow::Result;
-use tracing::{debug, info};
-
-fn main() -> Result<()> {
- // Add direct console output
- println!("program starting...");
-
- // Initialize tracing/logging with more verbosity
- tracing_subscriber::fmt()
- .with_max_level(tracing::Level::TRACE)
- .init();
-
- println!("tracing initialized");
-
- println!("creating accessibility engine...");
- info!("creating accessibility engine...");
- let engine = MacOSEngine::new(true, true)?;
-
- // Find Arc browser and focus it (similar to test_role.rs)
- info!("finding arc browser and focusing it...");
-
- let arc_app = match engine.get_application_by_name("Arc") {
- Ok(app) => {
- info!("found arc with direct search");
- app
- },
- Err(_) => {
- info!("direct search failed, trying app list");
-
- // Method 2: get all applications and filter
- let apps = engine.get_applications()?;
- info!("found {} applications", apps.len());
-
- // Find arc in the app list
- let arc = apps.into_iter().find(|app| {
- app.attributes().label.as_ref().map_or(false, |label|
- label.contains("Arc"))
- });
-
- match arc {
- Some(app) => {
- info!("found arc in app list");
-
- // Try to bring it to focus
- engine.refresh_accessibility_tree(Some("Arc"))?;
- app
- },
- None => {
- return Err(anyhow::anyhow!("couldn't find arc browser"));
- }
- }
- }
- };
-
- info!("looking for first element containing 'whatsapp2llm'...");
-
- // Create a selector for any element with text
- let selector = Selector::Text("whatsapp2llm".to_string());
-
- // Find elements and take only the first match
- let elements = engine.find_elements(&selector, Some(&arc_app))?;
- info!("search found {} elements, using first match", elements.len());
-
- // Click the first matching element if found
- if let Some(element) = elements.first() {
- let attrs = element.attributes();
- info!("Found match: role={}, label={:?}", attrs.role, attrs.label);
-
- // Get position info if available
- if let Ok((x, y, width, height)) = element.bounds() {
- info!(" position: ({}, {}), size: ({}, {})", x, y, width, height);
- }
-
- info!("attempting to click element with text 'whatsapp2llm' using mouse simulation...");
-
- // Use mouse simulation specifically
- match element.click_with_method(ClickMethodSelection::MouseSimulation) {
- Ok(result) => {
- info!("mouse simulation click successful");
- info!("click details: {}", result.details);
-
- if let Some((x, y)) = result.coordinates {
- info!("clicked at coordinates: ({:.1}, {:.1})", x, y);
- }
-
- // Add delay between clicks
- info!("waiting 500ms before second click...");
- std::thread::sleep(std::time::Duration::from_millis(500));
-
- // Second click also with mouse simulation
- match element.click_with_method(ClickMethodSelection::MouseSimulation) {
- Ok(result2) => {
- info!("second mouse simulation click successful");
- info!("click details: {}", result2.details);
-
- if let Some((x, y)) = result2.coordinates {
- info!("second clicked at coordinates: ({:.1}, {:.1})", x, y);
- }
- },
- Err(e) => {
- info!("second click failed: {:?}", e);
- }
- }
- },
- Err(e) => {
- info!("first click failed: {:?}", e);
- }
- }
- } else {
- info!("no elements with 'whatsapp2llm' text found to click");
- }
-
- Ok(())
-}
diff --git a/screenpipe-core/src/bin/test_example.rs b/screenpipe-core/src/bin/test_example.rs
deleted file mode 100644
index 87465721a..000000000
--- a/screenpipe-core/src/bin/test_example.rs
+++ /dev/null
@@ -1,110 +0,0 @@
-use screenpipe_core::operator::{Selector, UIElement};
-use screenpipe_core::operator::platforms::AccessibilityEngine;
-use screenpipe_core::operator::platforms::macos::MacOSEngine;
-
-fn print_element_tree(element: &UIElement, depth: usize) {
- let attrs = element.attributes();
- let indent = " ".repeat(depth);
- let label = attrs.label.unwrap_or_default();
-
- println!("{}role: {}, label: {}", indent, attrs.role, label);
-
- if depth < 3 { // limit depth for readability
- if let Ok(children) = element.children() {
- for child in children.iter().take(3) { // limit to 3 children
- print_element_tree(child, depth + 1);
- }
- }
- }
-}
-
-fn main() -> Result<(), Box<dyn std::error::Error>> {
- // create engine with default settings
- println!("creating accessibility engine...");
- let engine = MacOSEngine::new(true, true)?;
-
- // specifically find and focus the Arc browser
- println!("finding arc browser and focusing it...");
-
- // method 1: direct application search + focus
- let arc_app = match engine.get_application_by_name("Arc") {
- Ok(app) => {
- println!("found arc with direct search");
- app
- },
- Err(_) => {
- println!("direct search failed, trying app list");
-
- // method 2: get all applications and filter
- let apps = engine.get_applications()?;
- println!("found {} applications", apps.len());
-
- // find arc in the app list
- let arc = apps.into_iter().find(|app| {
- app.attributes().label.as_ref().map_or(false, |label|
- label.contains("Arc"))
- });
-
- match arc {
- Some(app) => {
- println!("found arc in app list");
-
- // try to bring it to focus
- engine.refresh_accessibility_tree(Some("Arc"))?;
- app
- },
- None => {
- return Err("couldn't find arc browser".into());
- }
- }
- }
- };
-
- println!("arc app info: {:?}", arc_app.attributes());
-
- // test with wildcard role
- let selector = Selector::Role {
- role: "*".to_string(),
- name: None
- };
-
- println!("finding elements with wildcard role in arc...");
-
- // find elements within arc
- let elements = engine.find_elements(&selector, Some(&arc_app))?;
- println!("found {} elements with wildcard role", elements.len());
-
- // print info about first few
- for (i, element) in elements.iter().take(10).enumerate() {
- let attrs = element.attributes();
- println!("{}: role={}, label={:?}", i, attrs.role, attrs.label);
- }
-
- // get direct children as a comparison
- println!("\ngetting direct children of arc...");
- if let Ok(children) = arc_app.children() {
- println!("arc has {} direct children", children.len());
-
- // print first few children
- for (i, child) in children.iter().take(10).enumerate() {
- let attrs = child.attributes();
- println!("child {}: role={}, label={:?}", i, attrs.role, attrs.label);
-
- // try to get grandchildren for first couple of children
- if i < 2 {
- if let Ok(grandchildren) = child.children() {
- println!(" child {} has {} children", i, grandchildren.len());
-
- // print first few grandchildren
- for (j, grandchild) in grandchildren.iter().take(3).enumerate() {
- let gc_attrs = grandchild.attributes();
- println!(" grandchild {}.{}: role={}, label={:?}",
- i, j, gc_attrs.role, gc_attrs.label);
- }
- }
- }
- }
- }
-
- Ok(())
-}
\ No newline at end of file
diff --git a/screenpipe-core/src/bin/test_get_all_apps.rs b/screenpipe-core/src/bin/test_get_all_apps.rs
deleted file mode 100644
index 0ad3fc205..000000000
--- a/screenpipe-core/src/bin/test_get_all_apps.rs
+++ /dev/null
@@ -1,53 +0,0 @@
-use tracing::{info, Level};
-use tracing_subscriber::FmtSubscriber;
-
-use screenpipe_core::operator::platforms::macos::MacOSEngine;
-use screenpipe_core::operator::platforms::AccessibilityEngine;
-
-fn main() -> Result<(), Box<dyn std::error::Error>> {
- // initialize logging
- let subscriber = FmtSubscriber::builder()
- .with_max_level(Level::INFO)
- .finish();
- tracing::subscriber::set_global_default(subscriber)?;
-
- info!("fetching all running applications...");
-
- // create accessibility engine - true for use_background_apps, false for activate_app
- let engine = MacOSEngine::new(true, false)?;
-
- // get all applications
- let apps = engine.get_applications()?;
-
- info!("found {} applications", apps.len());
-
- // collect app details
- let mut app_details = Vec::new();
- for app in apps {
- let attrs = app.attributes();
-
- // get process id if available
- let pid = if let Some(Some(pid_value)) = attrs.properties.get("AXPid") {
- if let Some(pid_str) = pid_value.as_str() {
- pid_str.parse::<i32>().ok()
- } else {
- None
- }
- } else {
- None
- };
-
- app_details.push((attrs.label.unwrap_or_default(), pid, attrs.role));
- }
-
- // sort by name for easier viewing
- app_details.sort_by(|a, b| a.0.to_lowercase().cmp(&b.0.to_lowercase()));
-
- // print application details
- info!("application details:");
- for (i, (name, pid, role)) in app_details.iter().enumerate() {
- info!("{}. '{}' (pid: {:?}, role: {})", i+1, name, pid, role);
- }
-
- Ok(())
-}
diff --git a/screenpipe-core/src/bin/test_get_arc_all_elements_custom.rs b/screenpipe-core/src/bin/test_get_arc_all_elements_custom.rs
deleted file mode 100644
index 4965b0c9d..000000000
--- a/screenpipe-core/src/bin/test_get_arc_all_elements_custom.rs
+++ /dev/null
@@ -1,176 +0,0 @@
-use screenpipe_core::operator::{Selector, UIElement};
-use screenpipe_core::operator::platforms::AccessibilityEngine;
-use screenpipe_core::operator::platforms::macos::MacOSEngine;
-use std::collections::VecDeque;
-use std::time::Instant;
-
-// Recursive function to collect all UI elements using breadth-first traversal
-fn collect_all_elements(root: &UIElement) -> Vec<UIElement> {
- let mut all_elements = Vec::new();
- let mut queue = VecDeque::new();
- queue.push_back(root.clone());
-
- let mut processed = 0;
- let start_time = Instant::now();
-
- while let Some(element) = queue.pop_front() {
- all_elements.push(element.clone());
-
- processed += 1;
- if processed % 100 == 0 {
- println!("processed {} elements so far ({:?} elapsed)",
- processed, start_time.elapsed());
- }
-
- if let Ok(children) = element.children() {
- for child in children {
- queue.push_back(child);
- }
- }
- }
-
- println!("collected {} total elements in {:?}",
- all_elements.len(), start_time.elapsed());
- all_elements
-}
-
-// Print summary of collected elements
-fn print_element_stats(elements: &[UIElement]) {
- println!("\nelement statistics:");
-
- let mut role_counts = std::collections::HashMap::new();
-
- for element in elements {
- let attrs = element.attributes();
- let role = attrs.role.clone();
- *role_counts.entry(role).or_insert(0) += 1;
- }
-
- println!("found {} unique element roles", role_counts.len());
-
- // Sort roles by count (most frequent first)
- let mut roles: Vec<_> = role_counts.into_iter().collect();
- roles.sort_by(|a, b| b.1.cmp(&a.1));
-
- println!("top 10 element roles:");
- for (i, (role, count)) in roles.iter().take(10).enumerate() {
- println!(" {}: {} - {} instances", i+1, role, count);
- }
-}
-
-fn main() -> Result<(), Box<dyn std::error::Error>> {
- // create engine with default settings
- println!("creating accessibility engine...");
- let engine = MacOSEngine::new(true, true)?;
-
- // find arc browser
- println!("finding arc browser...");
- let arc_app = match engine.get_application_by_name("Arc") {
- Ok(app) => {
- println!("found arc with direct search");
- app
- },
- Err(_) => {
- println!("direct search failed, trying app list");
-
- // get all applications and filter
- let apps = engine.get_applications()?;
- println!("found {} applications", apps.len());
-
- // find arc in the app list
- let arc = apps.into_iter().find(|app| {
- app.attributes().label.as_ref().map_or(false, |label|
- label.contains("Arc"))
- });
-
- match arc {
- Some(app) => {
- println!("found arc in app list");
-
- // try to bring it to focus
- engine.refresh_accessibility_tree(Some("Arc"))?;
- app
- },
- None => {
- return Err("couldn't find arc browser".into());
- }
- }
- }
- };
-
- println!("arc app info: {:?}", arc_app.attributes());
-
- // Get all elements from Arc
- println!("collecting all elements from arc (this may take a while)...");
- let all_elements = collect_all_elements(&arc_app);
-
- // Print statistics about the elements
- print_element_stats(&all_elements);
-
- // Sample some elements to explore their structure
- println!("\nsampling elements by depth:");
-
- // Some elements at different depth levels
- let depths = [0, 1, 2, 3, 5, 10]; // different depths to explore
-
- // Build depth map
- let mut elements_by_depth = std::collections::HashMap::new();
- let mut queue = VecDeque::new();
- queue.push_back((arc_app.clone(), 0)); // (element, depth)
-
- while let Some((element, depth)) = queue.pop_front() {
- elements_by_depth.entry(depth).or_insert_with(Vec::new).push(element.clone());
-
- if let Ok(children) = element.children() {
- for child in children {
- queue.push_back((child, depth + 1));
- }
- }
- }
-
- // Display elements at each sample depth
- for &depth in &depths {
- if let Some(elements) = elements_by_depth.get(&depth) {
- println!("\n--- depth {} ({} elements) ---", depth, elements.len());
-
- // Show first few elements at this depth
- for (i, element) in elements.iter().take(3).enumerate() {
- let attrs = element.attributes();
- println!(" {}: role={}, label={:?}", i, attrs.role, attrs.label);
-
- }
- } else {
- println!("\n--- depth {} (no elements) ---", depth);
- }
- }
-
- // Show elements with specific roles
- println!("\nsearching for interesting element roles:");
- let interesting_roles = ["AXButton", "AXTextField", "AXLink", "AXWebArea", "AXStaticText"];
-
- for role in interesting_roles {
- let matching = all_elements.iter()
- .filter(|e| e.attributes().role == role)
- .collect::<Vec<_>>();
-
- println!("\nfound {} elements with role '{}'", matching.len(), role);
-
- // Show sample of these elements
- for (i, element) in matching.iter().take(3).enumerate() {
- let attrs = element.attributes();
- println!(" {}: label={:?}", i, attrs.label);
-
- // Try to show description if available
- if let Some(desc) = &attrs.description {
- println!(" description: {}", desc);
- }
-
- // Try to show value if available
- if let Some(val) = &attrs.value {
- println!(" value: {:?}", val);
- }
- }
- }
-
- Ok(())
-}
\ No newline at end of file
diff --git a/screenpipe-core/src/bin/test_get_arc_all_elements_sdk_count.rs b/screenpipe-core/src/bin/test_get_arc_all_elements_sdk_count.rs
deleted file mode 100644
index 489a12eb8..000000000
--- a/screenpipe-core/src/bin/test_get_arc_all_elements_sdk_count.rs
+++ /dev/null
@@ -1,46 +0,0 @@
-use std::time::Instant;
-use tracing::{debug, info, Level};
-use tracing_subscriber::FmtSubscriber;
-
-use screenpipe_core::operator::platforms::macos::MacOSEngine;
-use screenpipe_core::operator::platforms::AccessibilityEngine;
-use screenpipe_core::operator::Selector;
-
-fn main() -> Result<(), Box<dyn std::error::Error>> {
- // Initialize logging with DEBUG level to see all logs
- let subscriber = FmtSubscriber::builder()
- .with_max_level(Level::DEBUG) // Changed from INFO to DEBUG
- .finish();
- tracing::subscriber::set_global_default(subscriber)?;
-
- debug!("debug logging enabled");
- info!("looking for arc browser...");
-
- // Create accessibility engine
- let engine = MacOSEngine::new(true, false)?;
-
- // Get Arc browser application
- let arc_app = match engine.get_application_by_name("Arc") {
- Ok(app) => {
- info!("found arc browser!");
- app
- }
- Err(e) => {
- info!("error finding arc browser: {:?} - is it running?", e);
- return Ok(());
- }
- };
-
- info!("starting element collection...");
- let start = Instant::now();
-
- // Use String::from("") for the text selector
- debug!("calling find_elements with empty text selector");
- let elements = engine.find_elements(&Selector::Text(String::from("")), Some(&arc_app))?;
-
- let duration = start.elapsed();
-
- info!("found {} elements in arc browser in {:?}", elements.len(), duration);
-
- Ok(())
-}
diff --git a/screenpipe-core/src/bin/test_get_arc_interactable_elements.rs b/screenpipe-core/src/bin/test_get_arc_interactable_elements.rs
deleted file mode 100644
index fdc08befd..000000000
--- a/screenpipe-core/src/bin/test_get_arc_interactable_elements.rs
+++ /dev/null
@@ -1,128 +0,0 @@
-use std::collections::{HashMap, HashSet};
-use std::time::Instant;
-use tracing::{debug, info, Level};
-use tracing_subscriber::FmtSubscriber;
-
-use screenpipe_core::operator::platforms::macos::MacOSEngine;
-use screenpipe_core::operator::platforms::AccessibilityEngine;
-use screenpipe_core::operator::Selector;
-
-fn main() -> Result<(), Box<dyn std::error::Error>> {
- // Initialize logging with DEBUG level to see all logs
- let subscriber = FmtSubscriber::builder()
- .with_max_level(Level::DEBUG)
- .finish();
- tracing::subscriber::set_global_default(subscriber)?;
-
- debug!("debug logging enabled");
- info!("looking for arc browser...");
-
- // Define interactivity categories with original macOS casing
- let definitely_interactable: HashSet<&str> = [
- "AXButton", "AXMenuItem", "AXMenuBarItem", "AXCheckBox", "AXPopUpButton",
- "AXTextField", "AXTextArea", "AXComboBox", "AXLink", "AXScrollBar",
- "AXSlider", "AXRadioButtonGroup", "AXRadioButton", "AXSearchField",
- "AXTabGroup", "AXTabButton", "AXDisclosureButton", "AXStepper",
- "AXDisclosureTriangle", "AXIncrementor", "AXProgressIndicator"
- ].iter().cloned().collect();
-
- let sometimes_interactable: HashSet<&str> = [
- "AXImage", "AXCell", "AXSplitter", "AXRow", "AXStatusItem",
- "AXLevelIndicator", "AXColumnHeader", "AXRowHeader", "AXDocument",
- "AXDrawer", "AXOutline", "AXOutlineRow", "AXHandleElementProxy",
- "AXBrowser", "AXColumn", "AXGrid", "AXWebArea", "AXGenericElementProxy",
- "AXValueIndicator"
- ].iter().cloned().collect();
-
- // Create accessibility engine
- let engine = MacOSEngine::new(true, false)?;
-
- // Get Arc browser application
- let arc_app = match engine.get_application_by_name("Arc") {
- Ok(app) => {
- info!("found arc browser!");
- app
- }
- Err(e) => {
- info!("error finding arc browser: {:?} - is it running?", e);
- return Ok(());
- }
- };
-
- info!("starting element collection...");
- let start = Instant::now();
-
- // Use String::from("") for the text selector to get all elements
- debug!("calling find_elements with empty text selector");
- let elements = engine.find_elements(&Selector::Text(String::from("")), Some(&arc_app))?;
-
- let duration = start.elapsed();
-
- info!("found {} elements in arc browser in {:?}", elements.len(), duration);
-
- // Now organize elements by role
- let mut role_counts: HashMap<String, usize> = HashMap::new();
-
- // Count elements by role - keep original casing
- for element in &elements {
- let role = element.role(); // Remove .to_lowercase() to preserve original casing
- *role_counts.entry(role).or_insert(0) += 1;
- }
-
- // Create category counts
- let mut definitely_interactable_count = 0;
- let mut sometimes_interactable_count = 0;
- let mut non_interactable_count = 0;
-
- // Prepare categorized data for display
- let mut definitely_interactable_roles: Vec<(String, usize)> = Vec::new();
- let mut sometimes_interactable_roles: Vec<(String, usize)> = Vec::new();
- let mut non_interactable_roles: Vec<(String, usize)> = Vec::new();
-
- // Categorize each role and its count
- for (role, count) in &role_counts {
- if definitely_interactable.contains(role.as_str()) {
- definitely_interactable_roles.push((role.clone(), *count));
- definitely_interactable_count += count;
- } else if sometimes_interactable.contains(role.as_str()) {
- sometimes_interactable_roles.push((role.clone(), *count));
- sometimes_interactable_count += count;
- } else {
- non_interactable_roles.push((role.clone(), *count));
- non_interactable_count += count;
- }
- }
-
- // Sort each category by count (highest first)
- definitely_interactable_roles.sort_by(|a, b| b.1.cmp(&a.1));
- sometimes_interactable_roles.sort_by(|a, b| b.1.cmp(&a.1));
- non_interactable_roles.sort_by(|a, b| b.1.cmp(&a.1));
-
- // Display counts by category
- info!("element interactivity breakdown:");
- info!(" definitely interactable: {} elements ({:.1}%)",
- definitely_interactable_count,
- (definitely_interactable_count as f64 / elements.len() as f64) * 100.0);
-
- for (role, count) in &definitely_interactable_roles {
- info!(" {}: {}", role, count);
- }
-
- info!(" sometimes interactable: {} elements ({:.1}%)",
- sometimes_interactable_count,
- (sometimes_interactable_count as f64 / elements.len() as f64) * 100.0);
-
- for (role, count) in &sometimes_interactable_roles {
- info!(" {}: {}", role, count);
- }
-
- info!(" non-interactable: {} elements ({:.1}%)",
- non_interactable_count,
- (non_interactable_count as f64 / elements.len() as f64) * 100.0);
-
- for (role, count) in &non_interactable_roles {
- info!(" {}: {}", role, count);
- }
-
- Ok(())
-}
\ No newline at end of file
diff --git a/screenpipe-core/src/bin/test_get_arc_interactable_elements_list.rs b/screenpipe-core/src/bin/test_get_arc_interactable_elements_list.rs
deleted file mode 100644
index 49c91a8e7..000000000
--- a/screenpipe-core/src/bin/test_get_arc_interactable_elements_list.rs
+++ /dev/null
@@ -1,493 +0,0 @@
-// USAGE: cargo run --bin test_get_arc_interactable_elements_list with-text interactable
-// cargo run --bin test_get_arc_interactable_elements_list with-text
-// cargo run --bin test_get_arc_interactable_elements_list with-text interactable click:10 method:mouse
-
-
-
-
-use std::collections::{HashMap, HashSet};
-use std::time::Instant;
-use tracing::{debug, info, Level};
-use tracing_subscriber::FmtSubscriber;
-use std::env;
-use std::path::PathBuf;
-use std::fs::OpenOptions;
-use std::io::{self, Write};
-
-use screenpipe_core::operator::platforms::macos::MacOSEngine;
-use screenpipe_core::operator::platforms::AccessibilityEngine;
-use screenpipe_core::operator::Selector;
-use screenpipe_core::operator::platforms::macos::ClickMethodSelection;
-
-// Replace the PrintFilter enum with a struct of filter flags
-#[derive(Default)]
-struct FilterOptions {
- with_text: bool, // Only show elements with text
- interactable_only: bool, // Only show definitely interactable elements
- include_sometimes: bool, // Include sometimes interactable elements
-}
-
-fn main() -> Result<(), Box<dyn std::error::Error>> {
- // Initialize logging with INFO level for console only
- let subscriber = FmtSubscriber::builder()
- .with_max_level(Level::INFO)
- .finish();
- tracing::subscriber::set_global_default(subscriber)?;
-
- // Remove the early log file setup and keep logs in memory instead
- // We'll create a vector to store all log messages
- let mut log_messages: Vec<String> = Vec::new();
-
- // Helper function to log to console and store for later file writing
- let log_both = |message: &str, log_store: &mut Vec<String>| {
- // Log to console
- info!("{}", message);
- // Store for later file writing
- log_store.push(message.to_string());
- };
-
- // Parse command line arguments with multiple filter support
- let args: Vec<String> = env::args().collect();
-
- // Initialize default filter options (show all)
- let mut filter_options = FilterOptions::default();
-
- // Variable to store element index to click
- let mut click_element_index: Option<usize> = None;
-
- // Variable to store click method if specified
- let mut click_method = ClickMethodSelection::Auto;
-
- // Process all arguments after the program name
- if args.len() > 1 {
- for arg in args.iter().skip(1) {
- // Check if argument is a click command
- if arg.starts_with("click:") {
- if let Some(index_str) = arg.split(':').nth(1) {
- if let Ok(index) = index_str.parse::<usize>() {
- click_element_index = Some(index);
- info!("will click element #{}", index);
- } else {
- info!("invalid element index: {}", index_str);
- }
- }
- } else if arg.starts_with("method:") {
- if let Some(method_str) = arg.split(':').nth(1) {
- click_method = match method_str.to_lowercase().as_str() {
- "axpress" => ClickMethodSelection::AXPress,
- "axclick" => ClickMethodSelection::AXClick,
- "mouse" => ClickMethodSelection::MouseSimulation,
- _ => {
- info!("unknown click method: {}, using auto", method_str);
- ClickMethodSelection::Auto
- }
- };
- info!("using click method: {:?}", click_method);
- }
- } else {
- match arg.as_str() {
- "with-text" => filter_options.with_text = true,
- "interactable" => filter_options.interactable_only = true,
- "possibly-interactable" => {
- filter_options.interactable_only = true;
- filter_options.include_sometimes = true;
- },
- _ => {
- info!("unknown filter option: {}", arg);
- }
- }
- }
- }
- }
-
- // Log the active filters
- let mut active_filters = Vec::new();
- if filter_options.with_text {
- active_filters.push("with text");
- }
- if filter_options.interactable_only {
- if filter_options.include_sometimes {
- active_filters.push("definitely or sometimes interactable");
- } else {
- active_filters.push("definitely interactable");
- }
- }
-
- if active_filters.is_empty() {
- info!("print filter: all elements");
- } else {
- info!("print filter: only elements that are {}", active_filters.join(" AND "));
- }
-
- debug!("debug logging enabled");
- info!("looking for arc browser...");
-
- // Define interactivity categories with original macOS casing
- let definitely_interactable: HashSet<&str> = [
- "AXButton", "AXMenuItem", "AXMenuBarItem", "AXCheckBox", "AXPopUpButton",
- "AXTextField", "AXTextArea", "AXComboBox", "AXLink", "AXScrollBar",
- "AXSlider", "AXRadioButtonGroup", "AXRadioButton", "AXSearchField",
- "AXTabGroup", "AXTabButton", "AXDisclosureButton", "AXStepper",
- "AXDisclosureTriangle", "AXIncrementor", "AXProgressIndicator"
- ].iter().cloned().collect();
-
- let sometimes_interactable: HashSet<&str> = [
- "AXImage", "AXCell", "AXSplitter", "AXRow", "AXStatusItem",
- "AXLevelIndicator", "AXColumnHeader", "AXRowHeader", "AXDocument",
- "AXDrawer", "AXOutline", "AXOutlineRow", "AXHandleElementProxy",
- "AXBrowser", "AXColumn", "AXGrid", "AXWebArea", "AXGenericElementProxy",
- "AXValueIndicator"
- ].iter().cloned().collect();
-
- // Create accessibility engine
- let engine = MacOSEngine::new(true, false)?;
-
- // Get Arc browser application
- let arc_app = match engine.get_application_by_name("Arc") {
- Ok(app) => {
- info!("found arc browser!");
- app
- }
- Err(e) => {
- info!("error finding arc browser: {:?} - is it running?", e);
- return Ok(());
- }
- };
-
- info!("starting element collection...");
- let start = Instant::now();
-
- // Use String::from("") for the text selector to get all elements
- debug!("calling find_elements with empty text selector");
- let elements = engine.find_elements(&Selector::Text(String::from("")), Some(&arc_app))?;
-
- let duration = start.elapsed();
-
- info!("found {} elements in arc browser in {:?}", elements.len(), duration);
-
- // Store the indexes of printed elements to reference them later
- let mut printed_element_indices = Vec::new();
-
- // Print only the elements that match our filter
- for (i, element) in elements.iter().enumerate() {
- // Get the role
- let role = element.role();
-
- // Determine interactability
- let interactability_marker = if definitely_interactable.contains(role.as_str()) {
- "[i]"
- } else if sometimes_interactable.contains(role.as_str()) {
- "[~i~]"
- } else {
- ""
- };
-
- // Get all attributes
- let attributes = element.attributes();
-
- // Collect text from multiple fields
- let mut element_text = String::new();
-
- // Check direct attribute fields
- if let Some(text) = &attributes.value {
- if !text.is_empty() && !element_text.contains(text) {
- element_text.push_str(text);
- }
- }
- if let Some(text) = &attributes.label {
- if !text.is_empty() && !element_text.contains(text) {
- if !element_text.is_empty() {
- element_text.push_str(" | ");
- }
- element_text.push_str(text);
- }
- }
- if let Some(text) = &attributes.description {
- if !text.is_empty() && !element_text.contains(text) {
- if !element_text.is_empty() {
- element_text.push_str(" | ");
- }
- element_text.push_str(text);
- }
- }
-
- // Check all requested attributes from properties
- for attr_name in &["AXValue", "AXTitle", "AXDescription", "AXHelp", "AXLabel", "AXText"] {
- if let Some(Some(value)) = attributes.properties.get(*attr_name) {
- if let Some(text) = value.as_str() {
- if !text.is_empty() && !element_text.contains(text) {
- if !element_text.is_empty() {
- element_text.push_str(" | ");
- }
- element_text.push_str(text);
- }
- }
- }
- }
-
- // Apply filters based on multiple criteria
- let has_text = !element_text.is_empty();
- let is_definitely_interactable = definitely_interactable.contains(role.as_str());
- let is_sometimes_interactable = sometimes_interactable.contains(role.as_str());
-
- // Check if the element meets all the active filter criteria
- let mut should_print = true;
-
- // Apply text filter if active
- if filter_options.with_text && !has_text {
- should_print = false;
- }
-
- // Apply interactability filter if active
- if filter_options.interactable_only {
- let passes_interactable = is_definitely_interactable ||
- (filter_options.include_sometimes && is_sometimes_interactable);
- if !passes_interactable {
- should_print = false;
- }
- }
-
- // Print only if it matches our filters
- if should_print {
- info!("#{} [{}] {} {}", i, role, interactability_marker, element_text);
- printed_element_indices.push(i);
- }
- }
-
- // If click_element_index is specified, attempt to click that element
- if let Some(index) = click_element_index {
- if index < elements.len() {
- let element = &elements[index];
- let attributes = element.attributes();
-
- // Print detailed information about the element
- info!("element #{} details:", index);
- info!(" role: {}", element.role());
-
- // Print bounds information
- if let Ok((x, y, width, height)) = element.bounds() {
- info!(" bounds: x={:.1}, y={:.1}, width={:.1}, height={:.1}", x, y, width, height);
- } else {
- info!(" bounds: unknown");
- }
-
- // Print label/text information
- if let Some(label) = &attributes.label {
- info!(" label: {}", label);
- }
- if let Some(value) = &attributes.value {
- info!(" value: {}", value);
- }
- if let Some(description) = &attributes.description {
- info!(" description: {}", description);
- }
-
- // Print interactability information
- let role_str = element.role();
- let is_definitely_interactable = definitely_interactable.contains(role_str.as_str());
- let is_sometimes_interactable = sometimes_interactable.contains(role_str.as_str());
-
- if is_definitely_interactable {
- info!(" interactability: definitely interactable");
- } else if is_sometimes_interactable {
- info!(" interactability: sometimes interactable");
- } else {
- info!(" interactability: non-interactable");
- }
-
- // Print hierarchy information
- if let Ok(children) = element.children() {
- info!(" children count: {}", children.len());
- }
- if let Ok(Some(parent)) = element.parent() {
- info!(" parent role: {}", parent.role());
- }
-
- // Print additional properties if any
- if !attributes.properties.is_empty() {
- info!(" additional properties:");
- // Print only a subset of important properties to avoid too much output
- let important_props = ["AXEnabled", "AXFocused", "AXSelected", "AXRequired", "AXEditable"];
- for prop in important_props.iter() {
- if let Some(Some(value)) = attributes.properties.get(*prop) {
- info!(" {}: {}", prop, value);
- }
- }
- }
-
- // Now attempt to click the element
- info!("attempting to click element #{}", index);
-
- match element.click_with_method(click_method) {
- Ok(result) => {
- info!("successfully clicked element: {}", result.details);
- if let Some(coords) = result.coordinates {
- info!("clicked at coordinates: ({:.1}, {:.1})", coords.0, coords.1);
- }
- info!("click method used: {}", result.method);
- },
- Err(e) => {
- info!("failed to click element: {:?}", e);
- }
- }
- } else {
- info!("element index {} is out of range (0-{})", index, elements.len() - 1);
- }
- }
-
- // Now organize elements by role
- let mut role_counts: HashMap<String, usize> = HashMap::new();
-
- // Count elements by role - keep original casing
- for element in &elements {
- let role = element.role();
- *role_counts.entry(role).or_insert(0) += 1;
- }
-
- // Create category counts
- let mut definitely_interactable_count = 0;
- let mut sometimes_interactable_count = 0;
- let mut non_interactable_count = 0;
-
- // Prepare categorized data for display
- let mut definitely_interactable_roles: Vec<(String, usize)> = Vec::new();
- let mut sometimes_interactable_roles: Vec<(String, usize)> = Vec::new();
- let mut non_interactable_roles: Vec<(String, usize)> = Vec::new();
-
- // Categorize each role and its count
- for (role, count) in &role_counts {
- if definitely_interactable.contains(role.as_str()) {
- definitely_interactable_roles.push((role.clone(), *count));
- definitely_interactable_count += count;
- } else if sometimes_interactable.contains(role.as_str()) {
- sometimes_interactable_roles.push((role.clone(), *count));
- sometimes_interactable_count += count;
- } else {
- non_interactable_roles.push((role.clone(), *count));
- non_interactable_count += count;
- }
- }
-
- // Sort each category by count (highest first)
- definitely_interactable_roles.sort_by(|a, b| b.1.cmp(&a.1));
- sometimes_interactable_roles.sort_by(|a, b| b.1.cmp(&a.1));
- non_interactable_roles.sort_by(|a, b| b.1.cmp(&a.1));
-
- // Display counts by category
- info!("element interactivity breakdown:");
- info!(" definitely interactable: {} elements ({:.1}%)",
- definitely_interactable_count,
- (definitely_interactable_count as f64 / elements.len() as f64) * 100.0);
-
- for (role, count) in &definitely_interactable_roles {
- info!(" {}: {}", role, count);
- }
-
- info!(" sometimes interactable: {} elements ({:.1}%)",
- sometimes_interactable_count,
- (sometimes_interactable_count as f64 / elements.len() as f64) * 100.0);
-
- for (role, count) in &sometimes_interactable_roles {
- info!(" {}: {}", role, count);
- }
-
- info!(" non-interactable: {} elements ({:.1}%)",
- non_interactable_count,
- (non_interactable_count as f64 / elements.len() as f64) * 100.0);
-
- for (role, count) in &non_interactable_roles {
- info!(" {}: {}", role, count);
- }
-
- // Now write all collected log messages to file
- let exe_path = env::current_exe()?;
- let exe_dir = exe_path.parent().map(PathBuf::from).unwrap_or_else(|| PathBuf::from("."));
- let log_path = exe_dir.join("arc_elements_log.txt");
-
- info!("saving logs to: {}", log_path.display());
-
- let mut log_file = OpenOptions::new()
- .create(true)
- .write(true)
- .truncate(true) // Overwrites file if it exists
- .open(&log_path)?;
-
- // Write header
- writeln!(log_file, "--- ARC ELEMENTS LOG ({}) ---", chrono::Local::now())?;
- writeln!(log_file, "Total elements found: {}", elements.len())?;
- writeln!(log_file, "")?;
-
- // Write interactivity breakdown
- writeln!(log_file, "ELEMENT INTERACTIVITY BREAKDOWN:")?;
- writeln!(log_file, " Definitely interactable: {} elements ({:.1}%)",
- definitely_interactable_count,
- (definitely_interactable_count as f64 / elements.len() as f64) * 100.0)?;
-
- for (role, count) in &definitely_interactable_roles {
- writeln!(log_file, " {}: {}", role, count)?;
- }
-
- writeln!(log_file, " Sometimes interactable: {} elements ({:.1}%)",
- sometimes_interactable_count,
- (sometimes_interactable_count as f64 / elements.len() as f64) * 100.0)?;
-
- for (role, count) in &sometimes_interactable_roles {
- writeln!(log_file, " {}: {}", role, count)?;
- }
-
- writeln!(log_file, " Non-interactable: {} elements ({:.1}%)",
- non_interactable_count,
- (non_interactable_count as f64 / elements.len() as f64) * 100.0)?;
-
- for (role, count) in &non_interactable_roles {
- writeln!(log_file, " {}: {}", role, count)?;
- }
-
- // Write filtered element details
- writeln!(log_file, "\nFILTERED ELEMENTS:")?;
- for &idx in &printed_element_indices {
- let element = &elements[idx];
- let role = element.role();
- let attributes = element.attributes();
-
- // Build text representation similar to what was shown in console
- let interactability_marker = if definitely_interactable.contains(role.as_str()) {
- "[i]"
- } else if sometimes_interactable.contains(role.as_str()) {
- "[~i~]"
- } else {
- ""
- };
-
- // Collect text from multiple fields (similar to existing code)
- let mut element_text = String::new();
-
- if let Some(text) = &attributes.value {
- if !text.is_empty() && !element_text.contains(text) {
- element_text.push_str(text);
- }
- }
- if let Some(text) = &attributes.label {
- if !text.is_empty() && !element_text.contains(text) {
- if !element_text.is_empty() {
- element_text.push_str(" | ");
- }
- element_text.push_str(text);
- }
- }
- if let Some(text) = &attributes.description {
- if !text.is_empty() && !element_text.contains(text) {
- if !element_text.is_empty() {
- element_text.push_str(" | ");
- }
- element_text.push_str(text);
- }
- }
-
- writeln!(log_file, "#{} [{}] {} {}", idx, role, interactability_marker, element_text)?;
- }
-
- info!("log file written to: {}", log_path.display());
-
- Ok(())
-}
\ No newline at end of file
diff --git a/screenpipe-core/src/bin/test_get_arc_text_sdk.rs b/screenpipe-core/src/bin/test_get_arc_text_sdk.rs
deleted file mode 100644
index 744f8d89b..000000000
--- a/screenpipe-core/src/bin/test_get_arc_text_sdk.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-use std::time::Instant;
-use tracing::{info, Level};
-use tracing_subscriber::FmtSubscriber;
-
-use screenpipe_core::operator::platforms::macos::MacOSEngine;
-use screenpipe_core::operator::platforms::AccessibilityEngine;
-
-fn main() -> Result<(), Box<dyn std::error::Error>> {
- // Initialize logging
- let subscriber = FmtSubscriber::builder()
- .with_max_level(Level::INFO)
- .finish();
- tracing::subscriber::set_global_default(subscriber)?;
-
- info!("looking for arc browser...");
-
- // Create accessibility engine
- let engine = MacOSEngine::new(true, false)?;
-
- // Get Arc browser application
- let arc_app = match engine.get_application_by_name("Arc") {
- Ok(app) => {
- info!("found arc browser!");
- app
- }
- Err(e) => {
- info!("error finding arc browser: {:?} - is it running?", e);
- return Ok(());
- }
- };
-
- info!("extracting text from arc browser...");
- let start = Instant::now();
-
- // Get text directly using our improved method
- let text = arc_app.text(10)?;
-
- let duration = start.elapsed();
-
- info!("extracted text from arc browser in {:?}", duration);
- info!("text length: {} characters", text.len());
- info!("text content:\n{}", text);
-
- Ok(())
-}
\ No newline at end of file
diff --git a/screenpipe-core/src/bin/test_get_messages_and_send_message.rs b/screenpipe-core/src/bin/test_get_messages_and_send_message.rs
deleted file mode 100644
index c16ad03ee..000000000
--- a/screenpipe-core/src/bin/test_get_messages_and_send_message.rs
+++ /dev/null
@@ -1,165 +0,0 @@
-use std::time::Instant;
-use tracing::{debug, info, Level};
-use tracing_subscriber::FmtSubscriber;
-
-use screenpipe_core::operator::platforms::macos::MacOSEngine;
-use screenpipe_core::operator::platforms::AccessibilityEngine;
-use screenpipe_core::operator::Selector;
-
-fn main() -> Result<(), Box<dyn std::error::Error>> {
- // Initialize logging with DEBUG level to see all logs
- let subscriber = FmtSubscriber::builder()
- .with_max_level(Level::DEBUG)
- .finish();
- tracing::subscriber::set_global_default(subscriber)?;
-
- debug!("debug logging enabled");
- info!("looking for messages app...");
-
- // Create accessibility engine with activate_app set to true
- // This helps refresh the accessibility tree and ensures app focus
- let engine = MacOSEngine::new(true, true)?;
-
- // Get Messages application
- let messages_app = match engine.get_application_by_name("Messages") {
- Ok(app) => {
- info!("found messages app!");
- app
- }
- Err(e) => {
- info!("error finding messages app: {:?} - is it running?", e);
- return Ok(());
- }
- };
-
- info!("getting all elements from messages app...");
- let start = Instant::now();
-
- // Get all elements
- let all_elements = engine.find_elements(&Selector::Text(String::from("")), Some(&messages_app))?;
-
- info!("found {} total elements in messages app in {:?}", all_elements.len(), start.elapsed());
-
- // Define sets of definitely and sometimes interactable roles
- let definitely_interactable = [
- "AXButton", "AXMenuItem", "AXMenuBarItem", "AXCheckBox", "AXPopUpButton",
- "AXTextField", "AXTextArea", "AXComboBox", "AXLink", "AXScrollBar",
- ];
-
- let sometimes_interactable = [
- "AXImage", "AXCell", "AXSplitter", "AXRow", "AXStatusItem",
- ];
-
- // Filter for interactable elements with text
- let interactable_elements: Vec<_> = all_elements.iter()
- .enumerate()
- .filter(|(_, element)| {
- let role = element.role();
- let text = element.text(10).unwrap_or_default();
-
- // Check if it has text
- let has_text = !text.is_empty();
-
- // Check if it's interactable
- let is_interactable = definitely_interactable.contains(&role.as_str()) ||
- sometimes_interactable.contains(&role.as_str());
-
- has_text && is_interactable
- })
- .collect();
-
- info!("found {} interactable elements with text", interactable_elements.len());
-
- // Log the first 10 interactable elements
- for (i, (original_index, element)) in interactable_elements.iter().take(10).enumerate() {
- let role = element.role();
- let text = element.text(10).unwrap_or_default();
-
- // Truncate text if it's too long for logging
- let text_preview = if text.len() > 50 {
- format!("{}...", &text[..47])
- } else {
- text
- };
-
- info!("[{}] index={}, role={}, text={}", i, original_index, role, text_preview);
- }
-
- // Look for text input field specifically with "Message" text
- info!("looking for text field with 'Message' text...");
- let message_text_field = interactable_elements.iter()
- .find(|(_, element)| {
- let role = element.role();
- let text = element.text(10).unwrap_or_default();
-
- // Check if it's a text field/area containing "Message"
- (role == "textfield" || role == "textarea" || role == "AXTextField" || role == "AXTextArea")
- && text.contains("Message")
- });
-
- if let Some((original_index, element)) = message_text_field {
- info!("found message text field at original index: {}", original_index);
-
- // Type "hello world" with smile emoji
- info!("typing message into text field...");
- match element.type_text("hello world 😊") {
- Ok(_) => info!("successfully typed message"),
- Err(e) => info!("failed to type message: {:?}", e),
- }
-
- // Brief pause to see the text
- std::thread::sleep(std::time::Duration::from_millis(500));
-
- // Press return key to send the message
- info!("pressing return key to send message...");
- match element.press_key("return") {
- Ok(_) => info!("successfully pressed return key"),
- Err(e) => info!("failed to press return key: {:?}", e),
- }
- } else {
- info!("no message text field found. trying another approach...");
-
- // Try using selector to find message text field directly
- info!("searching for message text field using selector...");
- match engine.find_element(&Selector::Text(String::from("Message")), Some(&messages_app)) {
- Ok(element) => {
- info!("found message text field using selector");
- info!("typing message into text field...");
- match element.type_text("hello world 😊") {
- Ok(_) => info!("successfully typed message"),
- Err(e) => info!("failed to type message: {:?}", e),
- }
-
- std::thread::sleep(std::time::Duration::from_millis(500));
-
- info!("pressing return key to send message...");
- match element.press_key("return") {
- Ok(_) => info!("successfully pressed return key"),
- Err(e) => info!("failed to press return key: {:?}", e),
- }
- },
- Err(e) => {
- info!("failed to find message text field using selector: {:?}", e);
-
- // Fall back to original behavior if needed
- // Check if we have enough elements to access index 60 (original functionality)
- let target_index = 63;
- if interactable_elements.len() > target_index {
- let (original_index, element) = &interactable_elements[target_index];
- info!("pressing Return key on element at index {} (original index: {})", target_index, original_index);
-
- // Try to press Return key on the element
- match element.press_key("return") {
- Ok(_) => info!("successfully pressed Return key on element"),
- Err(e) => info!("failed to press Return key: {:?}", e),
- }
- } else {
- info!("not enough elements to access index {}, only have {}", target_index, interactable_elements.len());
- }
- }
- }
- }
-
- info!("test completed successfully");
- Ok(())
-}
\ No newline at end of file
diff --git a/screenpipe-core/src/bin/test_get_messages_text_sdk.rs b/screenpipe-core/src/bin/test_get_messages_text_sdk.rs
deleted file mode 100644
index bdf7d3f29..000000000
--- a/screenpipe-core/src/bin/test_get_messages_text_sdk.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-use std::time::Instant;
-use tracing::{info, Level};
-use tracing_subscriber::FmtSubscriber;
-
-use screenpipe_core::operator::platforms::macos::MacOSEngine;
-use screenpipe_core::operator::platforms::AccessibilityEngine;
-
-fn main() -> Result<(), Box<dyn std::error::Error>> {
- // Initialize logging
- let subscriber = FmtSubscriber::builder()
- .with_max_level(Level::INFO)
- .finish();
- tracing::subscriber::set_global_default(subscriber)?;
-
- info!("looking for messages app...");
-
- // Create accessibility engine
- let engine = MacOSEngine::new(true, false)?;
-
- // Get Messages application
- let messages_app = match engine.get_application_by_name("Messages") {
- Ok(app) => {
- info!("found messages app!");
- app
- }
- Err(e) => {
- info!("error finding messages app: {:?} - is it running?", e);
- return Ok(());
- }
- };
-
- info!("extracting text from messages app...");
- let start = Instant::now();
-
- // Get text directly using our improved method
- let text = messages_app.text(10)?;
-
- let duration = start.elapsed();
-
- info!("extracted text from messages app in {:?}", duration);
- info!("text length: {} characters", text.len());
- info!("text content:\n{}", text);
-
- Ok(())
-}
\ No newline at end of file
diff --git a/screenpipe-core/src/operator/platforms/macos.rs b/screenpipe-core/src/operator/platforms/macos.rs
index 550344a7e..9723ff633 100644
--- a/screenpipe-core/src/operator/platforms/macos.rs
+++ b/screenpipe-core/src/operator/platforms/macos.rs
@@ -1672,7 +1672,7 @@ impl UIElementImpl for MacOSUIElement {
})?;
// Key down event with modifiers
- let mut key_down = CGEvent::new_keyboard_event(source.clone(), key_code as CGKeyCode, true)
+ let key_down = CGEvent::new_keyboard_event(source.clone(), key_code as CGKeyCode, true)
.map_err(|_| {
AutomationError::PlatformError("Failed to create key down event".to_string())
})?;
@@ -1688,8 +1688,8 @@ impl UIElementImpl for MacOSUIElement {
std::thread::sleep(std::time::Duration::from_millis(50));
// Key up event with same modifiers
- let mut key_up = CGEvent::new_keyboard_event(source, key_code as CGKeyCode, false)
- .map_err(|_| {
+ let key_up =
+ CGEvent::new_keyboard_event(source, key_code as CGKeyCode, false).map_err(|_| {
AutomationError::PlatformError("Failed to create key up event".to_string())
})?;
@@ -1860,34 +1860,6 @@ impl UIElementImpl for MacOSUIElement {
}
}
-// Helper function to extract children from an array attribute
-fn extract_children_from_array(value: core_foundation::base::CFType) -> Option<Vec<AXUIElement>> {
- use core_foundation::array::{CFArrayGetCount, CFArrayGetTypeID, CFArrayGetValueAtIndex};
- use core_foundation::base::{CFGetTypeID, TCFType};
-
- unsafe {
- let value_ref = value.as_CFTypeRef();
- let type_id = CFGetTypeID(value_ref);
-
- if type_id == CFArrayGetTypeID() {
- let array_ref = value_ref as *const __CFArray;
- let count = CFArrayGetCount(array_ref);
-
- let mut children = Vec::with_capacity(count as usize);
- for i in 0..count {
- let item = CFArrayGetValueAtIndex(array_ref, i as isize);
- if !item.is_null() {
- let ax_element = AXUIElement::wrap_under_get_rule(item as *mut _);
- children.push(ax_element);
- }
- }
- return Some(children);
- }
- }
-
- None
-}
-
// Helper function to parse AXUIElement attribute values into appropriate types
fn parse_ax_attribute_value(
name: &str,
diff --git a/screenpipe-core/src/operator/platforms/tree_search.rs b/screenpipe-core/src/operator/platforms/tree_search.rs
index db08369ae..7ae8bfaa3 100644
--- a/screenpipe-core/src/operator/platforms/tree_search.rs
+++ b/screenpipe-core/src/operator/platforms/tree_search.rs
@@ -1,15 +1,15 @@
/// TLDR: default TreeWalker does not traverse windows, so we need to traverse windows manually
use accessibility::{AXAttribute, AXUIElement, AXUIElementAttributes, Error};
use core_foundation::array::CFArray;
+use core_foundation::base::TCFType;
use std::{
cell::{Cell, RefCell},
- thread,
- time::{Duration, Instant},
collections::HashSet,
hash::{Hash, Hasher},
+ thread,
+ time::{Duration, Instant},
};
use tracing::debug;
-use core_foundation::base::TCFType;
pub trait TreeVisitor {
fn enter_element(&self, element: &AXUIElement) -> TreeWalkerFlow;
@@ -53,27 +53,19 @@ impl TreeWalkerWithWindows {
let element_wrapper = AXUIElementWrapper {
element: root.clone(),
};
-
+
// Check if already visited
if self.visited.borrow().contains(&element_wrapper) {
// Increment cycle counter
let mut count = self.cycle_count.borrow_mut();
*count += 1;
-
- // Log when we detect a cycle
- let role = root.role().map_or("unknown".to_string(), |r| r.to_string());
- let title = root.title().map_or("".to_string(), |t| t.to_string());
- // debug!(target: "operator", "Cycle detected! Skipping already visited element: {}{}. Total cycles: {}",
- // role,
- // if !title.is_empty() { format!(" ({})", title) } else { "".to_string() },
- // *count);
-
+
return TreeWalkerFlow::SkipSubtree;
}
-
+
// Mark as visited
self.visited.borrow_mut().insert(element_wrapper);
-
+
let mut flow = visitor.enter_element(root);
// debug!(target: "operator", "Walking element: {:?}", root.role());
@@ -236,13 +228,13 @@ impl ElementsCollectorWithWindows {
pub fn find_all(&self) -> Vec<AXUIElement> {
let walker = TreeWalkerWithWindows::new();
walker.walk(&self.root, self);
-
+
// After traversal is done, log how many cycles were detected
let cycles = walker.get_cycle_count();
if cycles > 0 {
debug!(target: "operator", "UI traversal complete - detected {} cycles in the accessibility tree", cycles);
}
-
+
self.matches.borrow().clone()
}
@@ -275,7 +267,7 @@ impl TreeVisitor for ElementsCollectorWithWindows {
if (self.predicate)(element) {
self.matches.borrow_mut().push(element.clone());
-
+
if let Some(max_results) = self.max_results {
if self.matches.borrow().len() >= max_results {
debug!(target: "operator", "Reached max_results limit of {}", max_results);
@@ -303,7 +295,7 @@ impl PartialEq for AXUIElementWrapper {
unsafe {
let self_ref = self.element.as_concrete_TypeRef();
let other_ref = other.element.as_concrete_TypeRef();
-
+
// CFEqual returns a Boolean (u8), convert to bool
core_foundation::base::CFEqual(self_ref as _, other_ref as _) != 0
}
diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rs
index f30a607a6..57de32445 100644
--- a/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/screenpipe-server/src/bin/screenpipe-server.rs
@@ -1414,7 +1414,7 @@ pub async fn handle_mcp_command(command: &McpCommand, local_data_dir: &PathBuf)
let client = Client::new();
// Check if Python is installed
- if !is_command_available("python") {
+ if !is_command_available("python") || !is_command_available("python3") {
warn!("note: python is not installed. please install it from the official website: https://www.python.org/");
}
@@ -1676,4 +1676,4 @@ fn is_command_available(command: &str) -> bool {
.output()
.map(|output| output.status.success())
.unwrap_or(false)
-}
\ No newline at end of file
+}