Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

feat(tools): implement the screenshot tool on macOS (screencapture)

purple76b036c9d8c2
diff --git a/GOAL-mac-local.md b/GOAL-mac-local.md
index 9581f276..49bcc414 100644
--- a/GOAL-mac-local.md
+++ b/GOAL-mac-local.md
@@ -17,7 +17,7 @@ Legende: [ ] offen · [~] in Arbeit · [x] grün (verifiziert) · [!] blockiert/
- [x] 1.2 tsc (`tsconfig.app.json`) Baseline-Diff = 0 neue Fehler (331 Baseline unverändert); vitest berührte Stores 108 grün
- [ ] 1.3 e2e-Specs an neuen Zustand angepasst, grün
- [~] 1.4 App startet lokal (`tauri:dev` läuft, v2.5.7); Local-Onboarding rendert (UI-Smoke :5173); Switch/Local live noch zu bestätigen
-- [ ] 1.5 Local-Onboarding: Starter-Modell (Qwen2.5-0.5B) lädt, Engine bootet 127.0.0.1:8127 (Ollama-Modelle lokal schon da)
+- [~] 1.5 Local-Inferenz bewiesen: Ollama :11434 (qwen2.5:0.5b) → „LOCAL OK". Nach Rust-Restart bootet App in local (kein `[Offload] cloud`). Builtin-Engine-GGUF-Download noch (Phase 2.4)
- [ ] 1.6 ComfyUI auf Mac überall aus (harte Regel), keine Crashes/Dead-Ends
## Phase 2 — Local Chat
@@ -34,7 +34,7 @@ terminal: [ ] shell_execute · [ ] code_execute · [ ] shell_execute_background
git: [ ] git_status · [ ] git_commit · [ ] git_push · [ ] git_log · [ ] git_diff
dev: [ ] project_init · [ ] pr_resume · [ ] gh_pr_create · [ ] run_tests
system: [ ] system_info · [ ] process_list · [ ] get_current_time
-desktop: [ ] screenshot (Rust Mac-Impl NEU, war Windows-only)
+desktop: [~] screenshot — macOS-Impl NEU (`/usr/sbin/screencapture`), kompiliert; live-grün braucht Screen-Recording-Grant für LU (OS-TCC)
workflow: [ ] run_workflow · [ ] delegate_task
extern: [ ] MCP-Tool (mind. 1 externer Server)
media-Tools (in Phase 6): [ ] image_generate · [ ] video_generate (via MLX)
diff --git a/src-tauri/src/commands/system.rs b/src-tauri/src/commands/system.rs
index 24765f0f..05732c08 100644
--- a/src-tauri/src/commands/system.rs
+++ b/src-tauri/src/commands/system.rs
@@ -90,7 +90,30 @@ pub fn screenshot() -> Result<serde_json::Value, String> {
Ok(serde_json::json!({ "image": b64, "format": "png", "encoding": "base64" }))
}
- #[cfg(not(target_os = "windows"))]
+ // macOS: the native `screencapture` CLI. `-x` = silent (no shutter sound),
+ // `-t png` = PNG. Needs the app to hold Screen Recording permission (TCC);
+ // without it macOS returns a desktop-only capture rather than erroring.
+ #[cfg(target_os = "macos")]
+ {
+ let tmp = std::env::temp_dir().join("lu-screenshot.png");
+ let status = std::process::Command::new("/usr/sbin/screencapture")
+ .args(["-x", "-t", "png"])
+ .arg(&tmp)
+ .status()
+ .map_err(|e| format!("Screenshot failed: {}", e))?;
+ // screencapture fails (non-zero, "could not create image from display")
+ // when the app lacks Screen Recording permission — give an actionable hint.
+ if !status.success() || !tmp.exists() {
+ let _ = std::fs::remove_file(&tmp);
+ return Err("Screenshot failed — grant LU the Screen Recording permission in System Settings ▸ Privacy & Security ▸ Screen Recording, then try again.".to_string());
+ }
+ let bytes = std::fs::read(&tmp).map_err(|e| format!("Read screenshot: {}", e))?;
+ let _ = std::fs::remove_file(&tmp);
+ let b64 = base64::engine::general_purpose::STANDARD.encode(&bytes);
+ Ok(serde_json::json!({ "image": b64, "format": "png", "encoding": "base64" }))
+ }
+
+ #[cfg(not(any(target_os = "windows", target_os = "macos")))]
{
Err("Screenshot not implemented for this platform yet".to_string())
}