Skip to content

Commit 36744f1

Browse files
committed
feat(api): integrate screenshot commands and link detection
- Add captureUrlScreenshot() API endpoint - Add cleanupScreenshotTempFiles() for maintenance - Register screenshot commands in Tauri backend - Update command module exports
1 parent a44e9a3 commit 36744f1

3 files changed

Lines changed: 41 additions & 2 deletions

File tree

src-tauri/src/commands/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ pub mod claude;
22
pub mod agents;
33
pub mod sandbox;
44
pub mod usage;
5-
pub mod mcp;
5+
pub mod mcp;
6+
pub mod screenshot;

src-tauri/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ use commands::sandbox::{
3535
list_sandbox_violations, log_sandbox_violation, clear_sandbox_violations, get_sandbox_violation_stats,
3636
export_sandbox_profile, export_all_sandbox_profiles, import_sandbox_profiles,
3737
};
38+
use commands::screenshot::{
39+
capture_url_screenshot, cleanup_screenshot_temp_files,
40+
};
3841
use commands::usage::{
3942
get_usage_stats, get_usage_by_date_range, get_usage_details, get_session_stats,
4043
};
@@ -178,7 +181,9 @@ fn main() {
178181
mcp_reset_project_choices,
179182
mcp_get_server_status,
180183
mcp_read_project_config,
181-
mcp_save_project_config
184+
mcp_save_project_config,
185+
capture_url_screenshot,
186+
cleanup_screenshot_temp_files
182187
])
183188
.run(tauri::generate_context!())
184189
.expect("error while running tauri application");

src/lib/api.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,4 +1760,37 @@ export const api = {
17601760
throw error;
17611761
}
17621762
},
1763+
1764+
/**
1765+
* Captures a screenshot of a specific region in the window
1766+
* @param url - The URL to capture
1767+
* @param selector - Optional selector to capture
1768+
* @param fullPage - Whether to capture the full page
1769+
* @returns Promise resolving to the path of the saved screenshot
1770+
*/
1771+
async captureUrlScreenshot(
1772+
url: string,
1773+
selector?: string | null,
1774+
fullPage: boolean = false
1775+
): Promise<string> {
1776+
return await invoke<string>("capture_url_screenshot", {
1777+
url,
1778+
selector,
1779+
fullPage,
1780+
});
1781+
},
1782+
1783+
/**
1784+
* Cleans up old screenshot files from the temporary directory
1785+
* @param olderThanMinutes - Remove files older than this many minutes (default: 60)
1786+
* @returns Promise resolving to the number of files deleted
1787+
*/
1788+
async cleanupScreenshotTempFiles(olderThanMinutes?: number): Promise<number> {
1789+
try {
1790+
return await invoke<number>("cleanup_screenshot_temp_files", { olderThanMinutes });
1791+
} catch (error) {
1792+
console.error("Failed to cleanup screenshot files:", error);
1793+
throw error;
1794+
}
1795+
},
17631796
};

0 commit comments

Comments
 (0)