cotabby icon indicating copy to clipboard operation
cotabby copied to clipboard

Event-driven focus via AXObservers (replace 200ms poll)

Open Jam-Cai opened this issue 7 months ago • 0 comments

FocusTracker.swift polls via a Timer(timeInterval: pollInterval, repeats: true) around ~200ms. That costs battery and delays focus acquisition. Switch to AXObserverAddNotification for AXFocusedUIElementChanged, AXFocusedWindowChanged, AXValueChanged, AXSelectedTextChanged, AXUIElementDestroyed, AXApplicationDeactivated. Keep polling behind a fallback flag for apps that don't fire notifications reliably.

Acceptance

  • [ ] Focus changes propagate via AXObserver notifications without polling in the happy path.
  • [ ] Automatic fallback to polling for apps where observer install fails or fires inconsistently.
  • [ ] Idle CPU measured and compared against current baseline.
  • [ ] Existing focus-snapshot tests still pass.

Parent: #16

Jam-Cai avatar Apr 22 '26 17:04 Jam-Cai