refactor(ios): gesture-response factory + performGesture wrapper#659
Merged
Conversation
…ommandExecution Collapse the gesture-command boilerplate in the executeOnMain switch behind two seams: - performGesture(app, idleTimeout:) -> (timing, outcome): folds measureGesture + the scroll idle-timeout/quiescence-skip wrap. Parameterized: touch gestures wrap (idleTimeout: true, default); synthesis gestures (pinch/rotate/transform) pass idleTimeout: false because RunnerSynthesizedGesture governs its own timing — a distinction that was previously implicit. - gestureResponse(message:timing:frame:) over a GestureFrame (none/touch/drag): one factory for the success DataPayload (message + gesture timing + optional touch/drag visualization frame). The 13 gesture cases (tap x3, tapSeries x2, longPress, drag, dragSeries, swipe, mouseClick, pinch, rotateGesture, transformGesture) now use the seams; ~120 lines of repeated quartet (measureGesture + idle-wrap + unsupported check + 8-field DataPayload) collapse. CommandExecution.swift 949 -> 867. Behavior-preserving: identical outcomes, timing capture, DataPayload fields/messages, and the same touch-wrapped vs synthesis-unwrapped distinction. No wire change (the factory emits the already wire-locked DataPayload internally). mouseClick (throws) and swipe (returns an optional frame) keep their bespoke measure/wrap but route the success payload through gestureResponse. Verified: xcodebuild build-for-testing -> TEST BUILD SUCCEEDED (no warnings).
Size Report
Startup median (7 runs, lower is better):
Top changed chunks: no changes in the largest emitted chunks. |
|
Member
Author
|
Thanks — applied the doc nits (
On the gesture-lab recommendation: agreed it's the residual risk. This is a field-for-field preserving refactor (timing window, idle-wrap on/off, |
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.
What
Collapse the repeated gesture-command boilerplate in
CommandExecution.swift'sexecuteOnMainswitch behind two small seams:performGesture(app, idleTimeout:) → (timing, outcome)— foldsmeasureGesture+ the scroll idle-timeout/quiescence-skip wrap. Parameterized: touch gestures wrap (default); synthesis gestures (pinch/rotate/transform) passidleTimeout: falsebecauseRunnerSynthesizedGesturegoverns its own timing (this distinction was previously implicit/easy to get wrong).gestureResponse(message:timing:frame:)over aGestureFrame(none/touch/drag) — one factory for the successDataPayload(message + gesture timing + optional visualization frame).13 gesture cases now use the seams; ~120 lines of the repeated quartet (
measureGesture+ idle-wrap +unsupportedResponse+ 8-fieldDataPayload) collapse.CommandExecution.swift949 → 867.Why
Each new gesture command re-derived the same 8-field payload + timing/idle quartet by hand — drift-prone and ~9× of the file's bulk. One factory + one wrapper make the switch far cheaper to read and make the timing/idle distinction explicit.
Behavior-preserving
Identical outcomes, timing capture,
DataPayloadfields/messages, and the same touch-wrapped vs synthesis-unwrapped distinction. No wire change — the factory emits the already wire-lockedDataPayload.mouseClick(throws) andswipe(optional frame) keep their bespoke measure/wrap but route the success payload throughgestureResponse.Verification
xcodebuild build-for-testing→ TEST BUILD SUCCEEDED (no warnings).examples/test-app/replays/gesture-lab.ad(pinch/rotate/pan/fling) — happy to run it on a sim for extra confidence if wanted; the gesture-payload shape is unchanged by construction.Scope
This was the #1 candidate from the post-merge refactor re-scan (verified deep: complexity concentrates behind two seams serving every gesture). Steers clear of the gesture synthesis (already consolidated in #645) and the
Command/DataPayloadwire-lock.