Skip to content

iOS: two-thumb selection on the space bar (experiment, off by default) - #2265

Merged
thdxr merged 1 commit into
devfrom
ios-two-thumb-selection
Nov 22, 2026
Merged

thdxr merged 1 commit into
devfrom
ios-two-thumb-selection

Conversation

@thdxr

@thdxr thdxr commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

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 adjustTextPosition and 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 a selection_action with 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_action with result: replaced or inserted and 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.swift covers 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 (needs HEX_SPEECH_CLIPS) and TypingReplayTests.testReplaysRecordedSwipes / testReplaysRecordedTaps (recorded fixtures). The throwaway branch is deleted and is not part of this PR.

Idea from @sieversjosua in #2255.

Refs #2255

@thdxr
thdxr force-pushed the ios-two-thumb-selection branch 15 times, most recently from c5f8f1f to 848d06a Compare November 22, 2026 01:21
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
thdxr force-pushed the ios-two-thumb-selection branch from 848d06a to e9afd45 Compare November 22, 2026 01:44
@thdxr
thdxr merged commit 2d52c72 into dev Nov 22, 2026
@thdxr
thdxr deleted the ios-two-thumb-selection branch November 22, 2026 01:44
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