From e16c84e1ed9a40fd6e3ec5eca27266a90d2fc91b Mon Sep 17 00:00:00 2001 From: Beingpax Date: Thu, 20 Nov 2025 22:44:45 +0545 Subject: [PATCH] Add accessibility permission check to prevent pop-up when calling SelectedTextService --- .../AIEnhancement/AIEnhancementService.swift | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/VoiceInk/Services/AIEnhancement/AIEnhancementService.swift b/VoiceInk/Services/AIEnhancement/AIEnhancementService.swift index e42213b..48df532 100644 --- a/VoiceInk/Services/AIEnhancement/AIEnhancementService.swift +++ b/VoiceInk/Services/AIEnhancement/AIEnhancementService.swift @@ -140,12 +140,15 @@ class AIEnhancementService: ObservableObject { } private func getSystemMessage(for mode: EnhancementPrompt) async -> String { - let selectedText = await SelectedTextService.fetchSelectedText() - - let selectedTextContext = if let selectedText = selectedText, !selectedText.isEmpty { - "\n\n\n\(selectedText)\n" + let selectedTextContext: String + if AXIsProcessTrusted() { + if let selectedText = await SelectedTextService.fetchSelectedText(), !selectedText.isEmpty { + selectedTextContext = "\n\n\n\(selectedText)\n" + } else { + selectedTextContext = "" + } } else { - "" + selectedTextContext = "" } let clipboardContext = if useClipboardContext,