Repository navigation
feat(ios): disambiguate double-letter swipes and speed up path scan - #3138
Merged
Merged
Conversation
kitlangton
force-pushed
the
feat/ios-swipe-double-letters-and-fast-scan
branch
from
December 1, 2026 05:45
8dd61e0 to
e697a8a
Compare
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.
Swiping a small loop or lingering on a repeated letter now distinguishes double-letter words like
too,off,poll,reed, andfeedon iPhone, while cutting swipe decode time by 37%.Plain fast swipes without loops keep their existing behavior, 240 Hz coalesced sub-frame touches reach the swipe stroke, and 11-column layouts use the drawn character pitch.
❌ Before
SwipeDecodercollapsed consecutive identical keys (k == last) without recording which key repeated, giving"to"/"too","of"/"off","pool"/"poll", and"red"/"reed"identical spatial scores; drawing a loop also stretchedgesture.lengthand warped the 32-sample template alignment, while stationary end-key holds before lift were dropped onstep <= 1e-4.KeyboardKeyPlaneViewignoredUIEvent.coalescedTouches(for:), clipping 240 Hz sub-frame corners and loops, andKeyboardLayout.swipePitchused 10-columnletterWidthon 11-column layouts.Set<Int>hash lookups, ~20,000sqrtcalls across candidate scans, and sorted all 1,500 prefiltered candidates when only the top 80 entered aligned scoring.✅ After
repeatMasksbitmask;Gestureextracts single-key micro-loops out ofrawand preserves stationary corner/end-key holds asRepeatSitemarkers so matching repeated letters earnrepeatBonuswithout penalizing straight swipes.KeyboardKeyPlaneViewforwards intermediatecoalescedTouchesintoSwipeTyping.recordCoalesced,slidTapLetterchecks the top two readings for return-to-start words, andswipePitchusescharacterWidth + metrics.gap.SwipeDecoderprecomputes a compact[UInt64]skip bitset (~12.5 KB), a pairwiseKeyGriddistance table, hoisted pointer resampling/DTW buffers, and a bounded top-80 shortlist.📊 Numbers:
SwipeBenchmarkTests(560 everyday, collinear pause, double-letter loop/hold, multilingual, and return-to-start swipes on iOS Simulator, Debug build)[UInt64]skip bitsetThe new tests in
SwipeDecoderTestsandSwipeBenchmarkTestsfail without the change; all 1,049 unit tests pass.👀 Read:
extractLoopsandappendDwellRepeatsinSwipeDecoder.swift(interior holds require a>= 30°corner so straight-through pauses likerintiredanduinputkeep their single-letter disambiguation role). The rest is buffer and touch plumbing.🔍 Found in a swipe path-matching audit · measured with deterministic
SwipeBenchmarkTestson iOS SimulatorChecks run
python3 scripts/code-shape.py --check: passxcodebuild test -project HEXMobile.xcodeproj -scheme HEXMobile: 1,049 executed, 0 failures