Skip to content

Pause desktop synchronization while macOS is inactive - #44

Merged
qeude merged 3 commits into
mainfrom
t3code/diagnose-unlock-performance-issues
Aug 28, 2026
Merged

Pause desktop synchronization while macOS is inactive#44
qeude merged 3 commits into
mainfrom
t3code/diagnose-unlock-performance-issues

Conversation

@qeude

@qeude qeude commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • Pause hotkeys, input handling, snapshots, animations, and desktop synchronization while the system, displays, or user session is inactive.
  • Seed the normalized activity state from public display and GUI-session probes when the daemon starts.
  • Reset Accessibility observers on deactivation and force a complete desktop refresh on reactivation.
  • Run the Defi filtering tap after session remappers while still consuming configured shortcuts before they reach the foreground app.
  • Invalidate the event-tap Mach port during cleanup.
  • Add deterministic session-startup and hotkey-routing tests plus configurable debug/release builds to build_and_run.sh.

Testing

  • swift build
  • swift test, 703 tests passed
  • ./script/build_and_run.sh --verify
  • ./script/test_desktop.sh, 17 passed and 1 skipped because a second visible window was unavailable
  • Installed smoke test with Accessibility available; one daemon and one active Defi event tap

- Normalize sleep, display, and session wake notifications
- Invalidate stale Accessibility work and refresh after reactivation
- Build debug or release explicitly in build_and_run.sh
@greptile-apps

greptile-apps Bot commented Aug 28, 2026

Copy link
Copy Markdown

Greptile Summary

The PR pauses desktop-related work across inactive macOS sessions and refreshes state upon reactivation, but its startup activity probe still cannot detect system sleep.

  • Normalizes sleep, display, and user-session notifications into activity transitions.
  • Cancels transient daemon and Accessibility state when the desktop becomes inactive.
  • Guards snapshots, hotkeys, gestures, and periodic processing while inactive.
  • Adds lifecycle normalization tests and configurable debug/release builds.

Confidence Score: 4/5

The PR is not yet safe to merge because a daemon starting while macOS is asleep can remain incorrectly active and miss the required wake refresh.

The startup state probe always records the system as awake, so the normalizer may begin active and treat the subsequent wake as a no-op instead of pausing work and forcing complete desktop reconciliation.

Files Needing Attention: Sources/DefiMacOS/PlatformEventNormalization.swift and Sources/DefiMacOS/PlatformEventMonitor.swift

Important Files Changed

Filename Overview
Sources/DefiMacOS/PlatformEventNormalization.swift Adds normalized desktop-session state, but the startup probe cannot represent a sleeping system and may suppress the later reactivation refresh.
Sources/DefiMacOS/PlatformEventMonitor.swift Observes and normalizes macOS lifecycle notifications, initializes activity from the startup probe, and resets Accessibility observers while inactive.
Sources/DefiDaemon/DefiDaemon.swift Gates daemon work on session activity and performs a complete synchronization when an active transition is received.
Sources/DefiDaemon/DaemonDesktopSynchronization.swift Rejects snapshot completions from inactive or superseded session generations and schedules a fresh snapshot when appropriate.
script/build_and_run.sh Builds and stages release binaries by default while retaining an explicit debug mode.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[PlatformEventMonitor starts] --> B[currentDesktopSessionState]
    B --> C{Combined state active?}
    C -- No --> D[Emit becameInactive]
    D --> E[Pause desktop work]
    C -- Yes --> F[Continue desktop work]
    G[Wake and session notifications] --> H[DesktopSessionEventNormalizer]
    H --> I{Inactive to active transition?}
    I -- Yes --> J[Force complete desktop refresh]
    I -- No --> K[No refresh]
    B -. systemAwake is always true .-> C
Loading

Reviews (2): Last reviewed commit: "fix(hotkeys): filter remapped shortcuts ..." | Re-trigger Greptile

Comment thread Sources/DefiMacOS/PlatformEventNormalization.swift Outdated
Comment thread Sources/DefiDaemon/DefiDaemon.swift
Comment thread Sources/DefiMacOS/PlatformEventNormalization.swift
@qeude
qeude merged commit 5433cc7 into main Aug 28, 2026
2 checks passed
@qeude
qeude deleted the t3code/diagnose-unlock-performance-issues branch August 28, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant