Skip to content

Avoid redundant settings updates with scheme diffs - #1422

Merged
lujjjh merged 1 commit into
mainfrom
optimize-scheme-pointer-updates
Oct 3, 2026
Merged

lujjjh merged 1 commit into
mainfrom
optimize-scheme-pointer-updates

Conversation

@lujjjh

@lujjjh lujjjh commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Compare scheme snapshots to apply only changed pointer and Logitech hardware settings. Preserve event transformers and focus-follows-mouse state when unrelated settings change.

Keep wake/reconnect recovery and hardware retries intact, and retry software pointer updates after failed writes or system-value reads.

Validation: targeted device, scheme, event and focus tests passed, along with all 14 PointerKit tests. Manual hardware validation remains outstanding.

Summary by CodeRabbit

  • Bug Fixes
    • Pointer acceleration and speed settings now retry when system writes fail, improving reliability when applying or restoring pointer schemes.
    • Logitech DPI and high-resolution scrolling settings are reapplied when they haven’t been confirmed, including after device or system changes.
    • Unrelated configuration changes no longer unnecessarily reset event-processing behavior.

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bafdee19-595e-4b0a-a352-9b858aaccbdb
📥 Commits

Reviewing files that changed from the base of the PR and between f830b73 and 1129819.

📒 Files selected for processing (19)
  • LinearMouse/Device/Device.swift
  • LinearMouse/Device/DeviceManager.swift
  • LinearMouse/Device/LogitechSettings/Device+LogitechDPI.swift
  • LinearMouse/Device/LogitechSettings/Device+LogitechHiResWheel.swift
  • LinearMouse/Device/LogitechSettings/HardwareSettingApplyCoordinator.swift
  • LinearMouse/Device/LogitechSettings/LogitechDeviceSession.swift
  • LinearMouse/Device/LogitechSettings/LogitechDeviceSettingsReconciler.swift
  • LinearMouse/Device/PointerSchemeApplication.swift
  • LinearMouse/EventTransformer/EventTransformerManager.swift
  • LinearMouse/Model/Configuration/ConfigurationDiff.swift
  • LinearMouse/Model/Configuration/Scheme/SchemeDiff.swift
  • LinearMouseUnitTests/Device/LogitechSettings/LogitechDeviceSessionTests.swift
  • LinearMouseUnitTests/Device/LogitechSettings/LogitechDeviceSettingsReconcilerTests.swift
  • LinearMouseUnitTests/Device/PointerSchemeApplicationTests.swift
  • LinearMouseUnitTests/EventTransformer/EventTransformerManagerTests.swift
  • LinearMouseUnitTests/Model/Scheme/ConfigurationDiffTests.swift
  • LinearMouseUnitTests/Model/Scheme/SchemeDiffTests.swift
  • Modules/PointerKit/Sources/PointerKit/Extensions/IOHIDServiceClient+Property.swift
  • Modules/PointerKit/Sources/PointerKit/PointerDevice.swift

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The change adds result-reporting pointer writes and cached scheme application, updates Logitech reconciliation to use full schemes, and filters configuration updates so only affected consumers are reconfigured or invalidated.

Changes

Pointer scheme application

Layer / File(s) Summary
Pointer write results
Modules/PointerKit/Sources/PointerKit/PointerDevice.swift, Modules/PointerKit/Sources/PointerKit/Extensions/IOHIDServiceClient+Property.swift, LinearMouse/Device/Device.swift
Pointer-setting methods now return write results. Acceleration restoration attempts a write with the system value or fallback and reports success only when the system read and write succeed.
Pointer scheme state and application
LinearMouse/Device/PointerSchemeApplication.swift, LinearMouse/Device/Device.swift, LinearMouse/Device/DeviceManager.swift, LinearMouseUnitTests/Device/PointerSchemeApplicationTests.swift
Devices compare normalized schemes with the last successful snapshot. DeviceManager applies schemes and invalidates cached state after pointer-related property changes and wake. Tests cover retries, changed settings, acceleration-mode transitions, and invalidation.

Logitech scheme reconciliation

Layer / File(s) Summary
Scheme-based Logitech reconciliation
LinearMouse/Device/LogitechSettings/*, LinearMouse/Device/DeviceManager.swift, LinearMouse/Model/Configuration/Scheme/SchemeDiff.swift, LinearMouseUnitTests/Device/LogitechSettings/*
The reconciler accepts full schemes and uses scheme differences, apply-running state, and confirmed DPI to decide when to apply or restore Logitech settings. DeviceManager passes configured schemes to the reconciler.

Configuration change filtering

Layer / File(s) Summary
Selective configuration updates
LinearMouse/Model/Configuration/ConfigurationDiff.swift, LinearMouse/EventTransformer/EventTransformerManager.swift, LinearMouse/Model/Configuration/Scheme/SchemeDiff.swift, LinearMouseUnitTests/Model/Scheme/*, LinearMouseUnitTests/EventTransformer/EventTransformerManagerTests.swift
ConfigurationDiff compares projected scheme settings for event transformers and focus-follows-mouse. EventTransformerManager reconfigures or invalidates state only when the corresponding settings change. Tests cover relevant and unrelated changes.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Configuration
  participant EventTransformerManager
  participant ConfigurationDiff
  participant FocusFollowsMouse
  participant EventTransformers
  Configuration->>EventTransformerManager: Send configuration update
  EventTransformerManager->>ConfigurationDiff: Compare previous and current configuration
  ConfigurationDiff-->>EventTransformerManager: Return affected-consumer flags
  opt Focus-follows-mouse settings changed
    EventTransformerManager->>FocusFollowsMouse: Reconfigure
  end
  opt Event-transformer settings changed
    EventTransformerManager->>EventTransformers: Invalidate transformer state
  end
Loading

Merge Risk: ⚪ Minimal · up to 11298

No identified issue needs to be fixed before merging. Manual hardware validation remains outstanding as a normal validation step.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 11298

The changes remain within existing device-setting capabilities and preserve the inspected identity and recovery controls. No introduced security weakness was established. Residual risk is concentrated in hardware recovery behavior, which still awaits manual validation.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The traced change affects pointer properties and Logitech settings for devices managed by the local application. Configuration and process/display context continue to select pointer schemes, while Logitech work remains vendor- and discovery-gated. The inspected changes do not establish a new remote entrypoint or broader write authority.

Trust Boundaries and Controls

  • observed — Logitech restoration retains cancellation-token, route, baseline and read-back checks before committing restored state. Receiver publications and timeout callbacks enter through the main queue, resolving the inspected ordering question between rediscovery and configuration-driven reconciliation.

Resilience and Maintainability Implications

  • observed — Requested Logitech settings are not treated as confirmed hardware state. Unchanged requests avoid restarting running work, unconfirmed settings can be retried, and exhausted restoration retains baseline ownership and a retry-needed state rather than declaring cleanup complete.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.19% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 97 functions across 19 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: using scheme diffs to avoid redundant settings updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@lujjjh
lujjjh merged commit fc2742f into main Oct 3, 2026
2 checks passed
@lujjjh
lujjjh deleted the optimize-scheme-pointer-updates branch October 3, 2026 12:32
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