Skip to content

Commit db2d939

Browse files
committed
Show error if Input Monitoring not enabled when toggling real-time suggestions state
1 parent 6019536 commit db2d939

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Core/Sources/Service/XPCService.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,15 @@ public class XPCService: NSObject, XPCServiceProtocol {
246246
}
247247

248248
public func setAutoSuggestion(enabled: Bool, withReply reply: @escaping (Error?) -> Void) {
249+
struct NoInputMonitoringPermission: Error, LocalizedError {
250+
var errorDescription: String? {
251+
"Permission for Input Monitoring is not granted to make real-time suggestions work. Please turn in on in System Settings.app and try again later."
252+
}
253+
}
254+
guard AXIsProcessTrusted() else {
255+
reply(NoInputMonitoringPermission())
256+
return
257+
}
249258
Task { @ServiceActor in
250259
let fileURL = try await Environment.fetchCurrentFileURL()
251260
let workspace = try await fetchOrCreateWorkspaceIfNeeded(fileURL: fileURL)

0 commit comments

Comments
 (0)