Skip to content

fix(agent): reapply volatile settings after macOS resume - #506

Merged
davidbudnick merged 1 commit into
AprilNEA:masterfrom
LuciusChen:fix/macos-resume-reapply
Aug 10, 2026
Merged

fix(agent): reapply volatile settings after macOS resume#506
davidbudnick merged 1 commit into
AprilNEA:masterfrom
LuciusChen:fix/macos-resume-reapply

Conversation

@LuciusChen

Copy link
Copy Markdown
Contributor

Summary

  • Observe native macOS workspace notifications for system wake, display wake, and returning user sessions.
  • Coalesce overlapping notifications into one pending volatile-settings replay.
  • Consume that replay at the existing inventory snapshot boundary and reuse Orchestrator::reapply_volatile_on_next_refresh().

Why

The portable inventory watcher infers a wake only from a polling gap longer than one minute. Short system sleeps, display wakes, and session reactivation can therefore leave firmware-native reverse scroll and SmartShift settings reset even though the device remains online.

The AppKit callback only sets an atomic flag; it performs no HID I/O. The next inventory snapshot runs the existing replay path for online devices, so this adds no timer or second settings implementation.

Addresses #405.

This does not re-arm programmable-control capture. #348 and #450 cover that separate capture/diversion recovery path.

Testing

  • Packaged-agent hardware smoke test on macOS arm64: reverse scroll remained active after a 30-minute sleep. The existing long-gap heuristic also covers that duration; the short-wake notification path is covered by the regression test below.
  • cargo fmt --all -- --check
  • cargo clippy -p openlogi-agent --all-targets --locked -- -D warnings
  • cargo test -p openlogi-agent --all-targets --locked (11 passed, including all three workspace notifications and burst coalescing)
  • cargo clippy --workspace --all-targets --exclude openlogi-gui --locked -- -D warnings
  • cargo test --workspace --exclude openlogi-gui --locked (471 passed, 1 ignored)
  • cargo check -p openlogi-agent --all-targets --locked --target x86_64-unknown-linux-gnu
  • cargo check -p openlogi-agent --all-targets --locked --target x86_64-pc-windows-msvc

Full local workspace Clippy reached gpui_macos but could not compile its Metal shader because the local Xcode beta installation reports a missing Metal Toolchain. GitHub CI is left to provide the complete GUI-inclusive macOS gate.

@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds native macOS resume detection and replays volatile device settings at the next inventory refresh.

  • Registers for system wake, display wake, and session-reactivation workspace notifications.
  • Coalesces notifications through a shared atomic flag without performing HID I/O in AppKit callbacks.
  • Extends the macOS objc2 feature set and adds notification-forwarding and coalescing coverage.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
crates/openlogi-agent/Cargo.toml Enables the NSWorkspace and NSNotification bindings needed by the macOS observer implementation.
crates/openlogi-agent/src/main.rs Shares a coalesced resume flag with AppKit and consumes it immediately before an inventory refresh.
crates/openlogi-agent/src/tray.rs Adds process-lifetime workspace notification observers and regression coverage for forwarding and coalescing.

Sequence Diagram

sequenceDiagram
  participant macOS as macOS Workspace
  participant AppKit as AppKit ResumeTarget
  participant Flag as Atomic resume_pending
  participant Core as Agent select loop
  participant Orch as Orchestrator
  participant Device as Online devices
  macOS->>AppKit: Wake/display/session notification
  AppKit->>Flag: store(true)
  Core->>Core: Receive inventory snapshot
  Core->>Flag: swap(false)
  Core->>Orch: reapply_volatile_on_next_refresh()
  Core->>Orch: refresh_inventory(snapshot)
  Orch->>Device: Replay volatile settings
Loading

Reviews (2): Last reviewed commit: "fix(agent): reapply volatile settings af..." | Re-trigger Greptile

@davidbudnick davidbudnick added type: bug Something is broken or behaves incorrectly platform: macos macOS-specific issue labels Aug 4, 2026
@davidbudnick davidbudnick added this to the v0.6.24 milestone Aug 10, 2026
@davidbudnick
davidbudnick force-pushed the fix/macos-resume-reapply branch from 4a850f7 to 99714ac Compare August 10, 2026 03:19
@davidbudnick
davidbudnick merged commit befb5c5 into AprilNEA:master Aug 10, 2026
17 checks passed
davidbudnick added a commit to davidbudnick/OpenLogi that referenced this pull request Aug 16, 2026
DPI, SmartShift, wheel mode, and lighting live in device RAM and clear
when devices power-cycle across a system sleep, but the first post-wake
inventory snapshot can look identical to the last pre-sleep one, so the
per-device reapply triggers never fire. macOS got a native resume hook
(AprilNEA#506); Windows still relied on the inventory watcher's >1-minute
polling-gap heuristic, which misses most sleep/hibernate wakes (AprilNEA#527,
and the wake-from-sleep reports in AprilNEA#393).

- resume_windows.rs: RegisterSuspendResumeNotification with
  DEVICE_NOTIFY_CALLBACK sets the shared resume flag on
  PBT_APMRESUMEAUTOMATIC / PBT_APMRESUMESUSPEND — no message pump
  needed, and independent of the tray preference (the tray window only
  exists when show_in_menu_bar is on).
- main.rs: the core consumes the coalesced flag at the same seam the
  macOS observer feeds and replays volatile settings on the next
  inventory snapshot.
- orchestrator: wake-flagged reapply targets now get the same bounded
  confirm-retry run as first sightings — post-wake, a receiver can
  enumerate while its mouse link is still re-establishing, so a
  one-shot write can time out just like the cold-boot race (AprilNEA#449).

Fixes AprilNEA#527
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: macos macOS-specific issue type: bug Something is broken or behaves incorrectly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants