Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
665 changes: 647 additions & 18 deletions apps/desktop/src-tauri/Cargo.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions apps/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ clipboard-rs = "0.3.4"
html5gum = { version = "0.8.3", default-features = false }
sha2 = "0.10"
velopack = { version = "=0.0.1589-ga2c5a97", features = ["public-utils"] }
xcap = "0.9.6"

[dev-dependencies]
tempfile = "3"
Expand Down Expand Up @@ -101,6 +102,11 @@ windows = { version = "0.58", features = [
"Data_Xml_Dom",
"Foundation",
"Foundation_Collections",
"Globalization",
"Graphics_Imaging",
"Media_Ocr",
"Storage",
"Storage_Streams",
"UI_Notifications",
"Win32_Graphics_Dwm",
"Win32_Graphics_Gdi",
Expand All @@ -109,6 +115,7 @@ windows = { version = "0.58", features = [
"Win32_System_Com",
"Win32_System_Threading",
"Win32_UI_Controls_Dialogs",
"Win32_UI_Accessibility",
"Win32_UI_Input_KeyboardAndMouse",
"Win32_UI_Shell",
"Win32_UI_Shell_Common",
Expand Down
67 changes: 67 additions & 0 deletions apps/desktop/src-tauri/src/commands/desktop_context.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright (c) 2026. Qian Cheng. Licensed under GPL v3.

//! Desktop context commands.

use tauri::{AppHandle, Runtime, State};

use crate::core::system::desktop_context::{
BoundDesktopContext, DesktopContextCapsule, DesktopContextRuntime,
};

#[tauri::command]
pub fn desktop_context_get_capsule(
runtime: State<'_, DesktopContextRuntime>,
capsule_id: String,
) -> Result<Option<DesktopContextCapsule>, String> {
runtime.get_capsule(&capsule_id)
}

#[tauri::command]
pub fn desktop_context_bind_capsule(
runtime: State<'_, DesktopContextRuntime>,
capsule_id: String,
) -> Result<Option<BoundDesktopContext>, String> {
runtime.bind_capsule(&capsule_id)
}

#[tauri::command]
pub fn desktop_context_capture_sensitive<R: Runtime>(
app: AppHandle<R>,
runtime: State<'_, DesktopContextRuntime>,
capsule_id: String,
include: Vec<String>,
screenshot_target: Option<String>,
) -> Result<Option<DesktopContextCapsule>, String> {
runtime.capture_sensitive(&app, &capsule_id, &include, screenshot_target.as_deref())
}

#[tauri::command]
pub fn desktop_context_persist_screenshot(
turn_id: i64,
capsule_id: String,
) -> Result<String, String> {
crate::core::system::desktop_context::persist_screenshot_artifact_copy(turn_id, &capsule_id)
}

#[tauri::command]
pub fn desktop_context_clear_persisted_screenshots() -> Result<(), String> {
crate::core::system::desktop_context::clear_persisted_screenshots()
}

#[tauri::command]
pub fn desktop_context_set_capture_enabled(
runtime: State<'_, DesktopContextRuntime>,
enabled: bool,
) {
runtime.set_capture_enabled(enabled);
}

#[tauri::command]
pub fn desktop_context_set_capture_config(
runtime: State<'_, DesktopContextRuntime>,
capture_selected_text: bool,
capture_browser_url: bool,
enable_screenshot_ocr: bool,
) {
runtime.set_capture_config(capture_selected_text, capture_browser_url, enable_screenshot_ocr);
}
8 changes: 8 additions & 0 deletions apps/desktop/src-tauri/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod autostart;
pub mod built_in_tools;
pub mod clipboard;
pub mod database;
pub mod desktop_context;
pub mod mcp;
pub mod paths;
pub mod quick_search;
Expand Down Expand Up @@ -42,6 +43,13 @@ pub fn invoke_handler<R: tauri::Runtime>(
clipboard::read_clipboard_payload,
clipboard::consume_shortcut_auto_paste_payload,
clipboard::write_clipboard_text,
desktop_context::desktop_context_get_capsule,
desktop_context::desktop_context_bind_capsule,
desktop_context::desktop_context_capture_sensitive,
desktop_context::desktop_context_persist_screenshot,
desktop_context::desktop_context_clear_persisted_screenshots,
desktop_context::desktop_context_set_capture_enabled,
desktop_context::desktop_context_set_capture_config,
autostart::enable_autostart,
autostart::disable_autostart,
autostart::is_autostart_enabled,
Expand Down
3 changes: 3 additions & 0 deletions apps/desktop/src-tauri/src/core/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ pub fn setup_app(app: &mut tauri::App) -> Result<(), String> {
app.manage(clipboard_runtime);
info!("Clipboard runtime initialized.");

crate::core::system::desktop_context::cleanup_temp_screenshots();
info!("Desktop context temp screenshots cleaned up.");

let app_handle = app.handle().clone();
if crate::core::system::runtime::is_e2e_test_mode() {
info!("Skipping font initialization in E2E test mode.");
Expand Down
Loading