Skip to content

Add long-press activation to Auto Scroll toggle mode - #1348

Merged
lujjjh merged 1 commit into
mainfrom
feature/autoscroll-long-press
Aug 9, 2026
Merged

lujjjh merged 1 commit into
mainfrom
feature/autoscroll-long-press

Conversation

@lujjjh

@lujjjh lujjjh commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add short-press and long-press activation options for Auto Scroll toggle mode
  • Reuse the existing button mapping long-press threshold
  • Keep Hold to Scroll independent and activated only after crossing the dead zone
  • Preserve short clicks when the long-press threshold is not reached
  • Support both regular mouse buttons and Logitech controls
  • Add the configuration schema, settings UI, and localized copy

Testing

  • All 550 unit tests pass
  • SwiftFormat and SwiftLint pass with no serious violations

@lujjjh lujjjh added the enhancement New feature or request label Aug 9, 2026
@lujjjh
lujjjh merged commit b7056cf into main Aug 9, 2026
1 check passed
@lujjjh
lujjjh deleted the feature/autoscroll-long-press branch August 9, 2026 05:08
lujjjh added a commit that referenced this pull request Aug 9, 2026
## Summary

- Avoid unnecessary cross-process accessibility queries while
classifying native UI elements.
- Replace nearby-point sampling with a single retry at the original
click position.
- Retry only for browser accessibility signals or recoverable AX errors
(`cannotComplete` and `notImplemented`).
- Lazily collect expensive action, geometry, child, and scrollbar
information only when required.

## Background

PR #1340 first identified that
`AutoScrollAccessibilityActivationClassifier`
performed nearby-point resampling for every non-pressable hit. Because
Auto Scroll
normally starts on non-pressable areas, native views such as Finder
could perform up
to nine additional synchronous AX hit tests before showing the Auto
Scroll indicator.

#1340 addressed the latency by restricting nearby sampling to web
content and stopping
ancestor traversal at list containers. This PR supersedes that approach
with a more
targeted implementation:

- Native non-pressable elements return immediately without additional
hit tests.
- Full ancestor traversal is preserved so list containers do not change
classification
  semantics.
- Expensive AX attributes are queried lazily instead of truncating the
ancestor walk.
- Nearby coordinates are no longer sampled, avoiding decisions based on
adjacent
  controls.
- Browser uncertainty is handled by waiting 5 ms and retrying the
original position
  once.

Chromium documents that its first synchronous accessibility hit test can
be an
approximate bounding-box result while the renderer resolves the precise
result
asynchronously. Its regression test likewise expects the first cached
hit test to miss
and the second hit test at the same point to succeed.

- Architecture documentation:

https://chromium.googlesource.com/chromium/src/+/main/docs/accessibility/browser/how_a11y_works_3.md#Hit-testing
- Chromium regression test:

https://chromium.googlesource.com/chromium/src/+/HEAD/content/browser/accessibility/hit_testing_browsertest.cc#710

Safari was also observed returning a transient `kAXErrorNotImplemented`
during a cold
web accessibility hit test. The retry is therefore limited to browser
signals and
recoverable AX errors. Permanent errors such as `invalidUIElement`
retain their
diagnostics and return immediately.

The `activateOverPressableElements` option proposed by #1340 is
intentionally not
included. The press-and-drag workflow from #1339 has since been
addressed separately
by #1348 using long-press activation, without restoring a native
middle-click override.

Thanks to @gilang-gunawan for identifying the unconditional AX
resampling bottleneck,
providing measurements, and proposing the original fix in #1340.

## Testing

- Verified Auto Scroll classification in the current Finder list view.
- Steady-state classification decreased from approximately 480–500 ms to
1.2–1.4 ms.
- Native non-pressable elements perform one hit test without the retry
delay.
- Verified a cold Chrome hit changes from a generic non-pressable
container to an
  `AXLink` after retrying the same position.
- Verified a cold Safari hit changes from `hitTest.notImplemented` to an
`AXLink`
  after retrying the same position.
- Verified `cannotComplete` and `notImplemented` retry.
- Verified permanent AX errors do not retry.
- All 557 unit tests pass.
- Strict SwiftLint passes with no violations.

Closes #1340

Co-authored-by: Gilang Gunawan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant