Repository navigation
iOS: two-thumb selection on the space bar (experiment, off by default) - #2265
Merged
Merged
Conversation
thdxr
force-pushed
the
ios-two-thumb-selection
branch
15 times, most recently
from
November 22, 2026 01:21
c5f8f1f to
848d06a
Compare
While the space bar is the trackpad, a second finger can pick a range the keyboard can't set in the host: each thumb moves one end with its own TrackpadCursor.State, the strip shows the text with the selected part highlighted, and both thumbs up offers Delete, Cut, Copy, Dictate and Cancel. Off, a second finger is ignored exactly as before. Settings > Experiments > Two-thumb selection, experiments.twoThumbSelection, off by default. Idea from @sieversjosua in #2255.
thdxr
force-pushed
the
ios-two-thumb-selection
branch
from
November 22, 2026 01:44
848d06a to
e9afd45
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.
While the space bar is the trackpad, a second finger can pick a range. The finger further left moves the start and the other the end, each with its own
TrackpadCursor.State, both seeded from the trackpad's own settled state (any settle moving the host cursor first). A keyboard can't set a selection in the host, so the strip shows the text around the range with the selected part highlighted. The range is clamped to the text the host shares around the cursor when the selection starts; if the host context hasn't caught up yet, the whole span is kept. After that, the host cursor doesn't move while selecting.Both thumbs up shows Delete · Cut · Copy · Dictate · Cancel. Delete moves to the range's end with
adjustTextPositionand deletes its characters one by one (a 👍🏽 is one); Cut copies then deletes; Copy copies and puts the cursor at the end; Cancel changes nothing. Cut and Copy appear only with Full Access. Any other key dismisses the actions without typing, and an empty range ends like a normal trackpad lift. An action runs only while the host still shares the whole range: the overlap of the host's current context and the session's text must cover it, otherwise the action dismisses without touching the text and logs aselection_actionwith a reason. Refreshing the strip never changes its visibility unless a selection starts or ends, so the emoji panel and the recording bar keep it as they left it; turning the experiment off mid-selection ends it.Dictate removes nothing up front. It records the range and the field it was picked in, dismisses the actions, and starts the keyboard's warm or in-keyboard dictation there. When the result is about to insert, the same verification as Delete runs: if the field still shows the range unchanged, the range is deleted and the words go in there; otherwise the words insert at the cursor as any dictation would and the text is left alone. Either way it logs
selection_actionwithresult: replacedorinsertedand a reason. A cancel, empty result, failure, timeout, key or text edit, field change, new selection, or another dictation simply clears the pending replacement — nothing was removed, so nothing is ever lost or needs restoring. Where dictation would open Hex instead (no Full Access, or the keyboard can't dictate here), tapping Dictate dismisses the actions and opens Hex or shows the Full Access hint, leaving the text.Off by default under Settings › Experiments › Two-thumb selection (
experiments.twoThumbSelection, App Group), with zh-Hans strings like the rest of the Experiments page. Off, a second finger is ignored exactly as it is today and the existing test for that is unchanged.Limits: the range is shown only in the strip and only within the shared text; the host's selection itself can't be made. Delete and Cut call the host's delete once per Character, so a host that removes one code point per call (some Devanagari and Thai clusters) can leave fragments.
Tests:
ios/HEXMobileTests/TwoThumbSelectionTests.swiftcovers off = ignored; one end per thumb with a normalized range; the ends seeded from the trackpad; Delete including an emoji; Cut; Copy moving the cursor (including UTF-16 offsets past an emoji); Cancel; an empty range; another key dismissing without typing; stale-text and beyond-the-shared-line guards; the range and strip clamped to the shared text; the strip's visibility with and without a selection and behind the emoji panel; the space bar's finger lifting first; a cancelled touch; a third finger; and the new Dictate: the range stays until the words arrive and then it is replaced exactly (plain, emoji/UTF-16, windowed multi-line, and a range covering the whole shared text); a cancel leaves text and cursor untouched; changed text or another field inserts the result at the cursor and keeps the range; a field change or key edit clears the pending replacement; and a later dictation inserts normally. No workflow in the repo compiles iOS, so this was verified on a throwaway macOS runner branch: run 44971059333,Executed 723 tests, with 3 tests skipped and 0 failures (0 unexpected), ** TEST SUCCEEDED **. The skips are pre-existing:AppleSpeechClipTests.testTranscribesEachClipInItsLanguage(needsHEX_SPEECH_CLIPS) andTypingReplayTests.testReplaysRecordedSwipes/testReplaysRecordedTaps(recorded fixtures). The throwaway branch is deleted and is not part of this PR.Idea from @sieversjosua in #2255.
Refs #2255