Skip to content

Commit f29f84d

Browse files
mxvshclaude
andcommitted
fix: restart hotkey service when accessibility permission is granted
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bf1ac31 commit f29f84d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Wave/AppState.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ final class AppState {
151151

152152
// MARK: - Private
153153
private var isKeyHeld = false
154+
private var accessibilityWasGranted = false
154155

155156
var shortcutDisplayString: String {
156157
KeyCodeMapping.displayString(
@@ -217,12 +218,31 @@ final class AppState {
217218
showOnboarding = true
218219
}
219220

221+
accessibilityWasGranted = PermissionService.isAccessibilityGranted()
222+
220223
Task {
221224
await loadSelectedModel()
222225
if !groqAPIKey.isEmpty { await verifyAndFetchGroqModels() }
223226
setupHotkey()
224227
await MainActor.run { startPersistentOverlay() }
225228
}
229+
230+
startAccessibilityMonitor()
231+
}
232+
233+
private func startAccessibilityMonitor() {
234+
Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { [weak self] timer in
235+
guard let self else { timer.invalidate(); return }
236+
let granted = PermissionService.isAccessibilityGranted()
237+
if granted && !self.accessibilityWasGranted {
238+
DispatchQueue.main.async {
239+
self.hotkeyService.stop()
240+
self.aiHotkeyService.stop()
241+
self.setupHotkey()
242+
}
243+
}
244+
self.accessibilityWasGranted = granted
245+
}
226246
}
227247

228248
func setupHotkey() {

0 commit comments

Comments
 (0)