diff --git a/src-tauri/src/commands/mod.rs b/src-tauri/src/commands/mod.rs index 2432567..95384bd 100644 --- a/src-tauri/src/commands/mod.rs +++ b/src-tauri/src/commands/mod.rs @@ -2,4 +2,5 @@ pub mod claude; pub mod agents; pub mod sandbox; pub mod usage; -pub mod mcp; \ No newline at end of file +pub mod mcp; +pub mod screenshot; \ No newline at end of file diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index d24a1b7..0f7b3c3 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -35,6 +35,9 @@ use commands::sandbox::{ list_sandbox_violations, log_sandbox_violation, clear_sandbox_violations, get_sandbox_violation_stats, export_sandbox_profile, export_all_sandbox_profiles, import_sandbox_profiles, }; +use commands::screenshot::{ + capture_url_screenshot, cleanup_screenshot_temp_files, +}; use commands::usage::{ get_usage_stats, get_usage_by_date_range, get_usage_details, get_session_stats, }; @@ -178,7 +181,9 @@ fn main() { mcp_reset_project_choices, mcp_get_server_status, mcp_read_project_config, - mcp_save_project_config + mcp_save_project_config, + capture_url_screenshot, + cleanup_screenshot_temp_files ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); diff --git a/src/lib/api.ts b/src/lib/api.ts index ba5e7fc..b809ce9 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -1760,4 +1760,37 @@ export const api = { throw error; } }, + + /** + * Captures a screenshot of a specific region in the window + * @param url - The URL to capture + * @param selector - Optional selector to capture + * @param fullPage - Whether to capture the full page + * @returns Promise resolving to the path of the saved screenshot + */ + async captureUrlScreenshot( + url: string, + selector?: string | null, + fullPage: boolean = false + ): Promise { + return await invoke("capture_url_screenshot", { + url, + selector, + fullPage, + }); + }, + + /** + * Cleans up old screenshot files from the temporary directory + * @param olderThanMinutes - Remove files older than this many minutes (default: 60) + * @returns Promise resolving to the number of files deleted + */ + async cleanupScreenshotTempFiles(olderThanMinutes?: number): Promise { + try { + return await invoke("cleanup_screenshot_temp_files", { olderThanMinutes }); + } catch (error) { + console.error("Failed to cleanup screenshot files:", error); + throw error; + } + }, }; \ No newline at end of file