From f3c3cbb0737b7061ab44e7418d763b4a3fa534e6 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 8 Jun 2025 06:57:34 +0100 Subject: [PATCH] fix: Improve permission error detection and add debug logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added debug logging to PermissionsChecker when screen recording check fails - Updated CHANGELOG with details about the permission error fixes - This complements the previous commit that fixed overly broad error detection 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- CHANGELOG.md | 9 +++++++++ peekaboo-cli/Sources/peekaboo/PermissionsChecker.swift | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bd38e3..154f106 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Fixed overly broad permission error detection that incorrectly reported file I/O errors as screen recording permission issues + - File permission errors (e.g., writing to `/System/`) now correctly report as `FILE_IO_ERROR` + - Directory not found errors provide clear messages about missing parent directories + - Added specific error code checking for ScreenCaptureKit and CoreGraphics APIs + - Only errors containing both "permission" and capture-related terms are now considered screen recording issues +- Enhanced file write error handling with pre-emptive directory checks +- Added debug logging to permission checker for diagnosing intermittent failures + ## [1.0.0-beta.19] - 2025-06-08 ### Added diff --git a/peekaboo-cli/Sources/peekaboo/PermissionsChecker.swift b/peekaboo-cli/Sources/peekaboo/PermissionsChecker.swift index 26fdb16..66d816e 100644 --- a/peekaboo-cli/Sources/peekaboo/PermissionsChecker.swift +++ b/peekaboo-cli/Sources/peekaboo/PermissionsChecker.swift @@ -9,6 +9,7 @@ class PermissionsChecker { // We check by attempting to get shareable content let semaphore = DispatchSemaphore(value: 0) var hasPermission = false + var capturedError: Error? Task { do { @@ -17,12 +18,18 @@ class PermissionsChecker { hasPermission = true } catch { // If we get an error, we don't have permission + capturedError = error hasPermission = false } semaphore.signal() } semaphore.wait() + + if let error = capturedError { + Logger.shared.debug("Screen recording permission check failed: \(error)") + } + return hasPermission }