feat: use PowerAssertionDetector for meeting detection#30
Merged
Conversation
Introduce MeetingDetecting protocol with checkOnce(), isMeetingActive(), and reset() methods. Move DetectedMeeting struct to dedicated file. MeetingDetector now conforms to the protocol, WatchLoop depends on the abstraction. Prepares for alternative detector implementations.
Uses IOPMCopyAssertionsByProcess() to detect active meetings via power assertions. Meeting apps create PreventUserIdleDisplaySleep assertions during calls (e.g. "Microsoft Teams Call in progress"). Sandbox-safe, no entitlement needed. Supports Teams, Zoom, and Webex. Adds AppMeetingPattern.forAppName() lookup helper.
APPSTORE build uses PowerAssertionDetector (sandbox-safe), Homebrew build uses MeetingDetector (CGWindowList). Screen Recording permission check and UI row hidden in App Store variant.
18 tests covering Teams/Zoom/Webex detection, non-meeting assertion filtering, confirmation threshold, cooldown, isMeetingActive, case insensitivity, and reset behavior. Uses injected assertionProvider.
Real-world testing revealed: - Teams new client uses process name "MSTeams" (not "Microsoft Teams") - "Microsoft Teams Call in progress" is the reliable assertion (only during calls) - "Video Wake Lock" persists after call ends (Electron artifact) — removed - "Playing audio" is intermittent — removed Also: wrap Accessibility permission check with #if !APPSTORE (not needed in sandbox), remove debug logging added during testing.
Screen Recording is still needed for CATapDescription (app audio capture) in both variants. Only the meeting detection method differs: - Homebrew: CGWindowList (needs Screen Recording) - App Store: PowerAssertionDetector (no Screen Recording needed) Adjust permission detail text per variant.
Uses CGWindowListCopyWindowInfo to look up the actual window title for detected meeting apps, so protocol filenames use the real meeting name instead of the power assertion name. Falls back to assertion name when no matching window is found. Injects windowListProvider closure for testability.
PowerAssertionDetector works reliably and is sandbox-safe. Remove the #if APPSTORE/#else split — both build variants now use power assertion detection. Removes accessibility check (only needed for AX DOM verification) and MeetingSimulator pattern setup.
The Electron AX DOM parsing (verifyTeamsMeeting, findMeetingControl, meetingDOMIdentifiers) was fragile and no longer needed — power assertion detection has no false positives from chat windows. Removes the meetingVerifier closure and ApplicationServices import.
Tests for PowerAssertionDetector window title lookup: - Title found via CGWindowList → used as windowTitle - No matching window → assertion name as fallback - Empty/app-name-only titles skipped Also removes meetingVerifier from WatchLoopE2ETests (AX verification was removed in previous commit).
- Reuse MeetingDetector.systemWindowList() instead of duplicating it - Remove unused lastDetectedAppName property - Remove duplicate MARK comment in tests
Replace MeetingDetector with PowerAssertionDetector in all WatchLoop and E2E tests to match the new default detector. Uses injected assertionProvider instead of windowListProvider for mock control.
dae981f to
bbbc74a
Compare
MeetingSimulator now creates a PreventUserIdleDisplaySleep power assertion with keyword "Simulator Meeting Call in progress", so PowerAssertionDetector can detect it. Added matching AssertionPattern for process name "meeting-simulator". - Reference AppMeetingPattern.simulator.appName instead of duplicating the "MeetingSimulator" string literal - Release power assertion in applicationWillTerminate
d86fbf5 to
b514c54
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MeetingDetectingprotocol fromMeetingDetectorfor testability and build variant flexibilityPowerAssertionDetectorthat detects meetings via IOKit power assertions + window title lookup — works in sandbox without Screen RecordingPowerAssertionDetectoras default detector for both Homebrew and App Store variantsMeetingDetector(redundant with power assertion approach)MeetingSimulatorfor end-to-end testingPowerAssertionDetectorTest plan
swift buildpasses (Homebrew variant)swift build -Xswiftc -DAPPSTOREpasses (App Store variant)