hex/ios/HEXMobileTests
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Ryan Vogel f11913272e
iOS: text replacements fire like the system's and stay put, and no stray capitals from suggestions (#2173)
* iOS: text replacements go in as on Apple's keyboard, and backspace no longer undoes them

TestFlight (Jason, build 56, iPhone 18 Pro Max, iOS 27.3, with a screen
recording): "Text replacement doesn't seem to work accurately. At the times
where it does, tapping the backspace immediately undoes whatever replacement
was done." In the video his shortcut "myem" (his email address) stays as
typed on space and on return with Hex, while Apple's keyboard replaces it.

Apple's keyboard, black box on the iOS 27.2 simulator (Settings > Text
Replacement: myem, tyvm, home, ad2, s.o):
- Delete right after a replacement takes only the space; no revert bubble,
  and the strip shows completions of the last fragment ("com"). After an
  autocorrection it also takes only the space and shows a "teh" revert
  bubble above the word. (Hex keeps its deliberate one-backspace undo for
  autocorrections; only replacements change.)
- A replacement goes in on space, "." and return; after "(" or a comma
  ("hi,myem"); for a shortcut with a digit ("ad2") or a dot ("s.o"); for a
  shortcut that is a word ("home"). Settings refuses shortcuts with spaces.
- Tapping the quoted shortcut keeps it once; typed again it is replaced
  again, however often it was kept.
- After a swipe, space leaves the swiped word, and the strip offers the
  replacement of a reading that is a shortcut.

Changes:
- AutocorrectEngine.textReplacement(before:) finds the longest shortcut
  ending the text at a word boundary, digits and punctuation included.
  Space, a closing mark and return (FullKeyboardEngine.applyTextReplacement)
  put it in before any autocorrection; the new line on return still goes in
  on its own, so Send/Search fields see just "\n".
- Removed: the one-backspace undo of a replacement, which also suppressed the
  shortcut for the session and, after two undos, taught it as a kept word
  that turned the replacement off for good (the likely reason his "myem"
  stopped working). Replacements now ignore kept/learned/rejected words.
- The strip shows a shortcut with digits or punctuation, also without a
  dictionary for the language; picking it replaces the whole shortcut.
- After a swipe, a reading that is a shortcut shows as its replacement.
- Moved the built-in word lists to AutocorrectEngine+Dictionaries.swift
  (no change) so AutocorrectEngine.swift stays under the 1,500-line cap.

Verified on the Mac Studio, iPhone 18 Pro (iOS 27.2 simulator):
- xcodebuild test -only-testing AutocorrectEngineTests,
  FullKeyboardEngineTests: 149 tests, 0 failures (new:
  testTextReplacementsGoInAsOnApplesKeyboard,
  testASwipedShortcutOffersItsReplacementAndATappedOneGoesIn; two tests
  updated from "one backspace puts back the shortcut").
- Live Release build in a hosted field on an iPhone 18 Pro Max simulator:
  "hello there myem" + space -> "hello there jason@example.com ", delete
  takes the space then "m"; "ad2" shows "second address" in the strip and
  goes in on space; "s.o " and "myem" + return go in.

* iOS: a fix or a swiped word brings no capital of its own mid-sentence

TestFlight (Jason, build 56): "Swipe typing keeps auto capitalising in most
cases, even when it shouldn't. It doesn't work how Apple's keyboard does,
where it capitalises only after a full stop." His screen recording also
shows "helli" typed mid-sentence ("myem helli") going in as "Hello", with
"Hello" highlighted in the strip.

Reproduced on dev with the swipe HID tool (iPhone 18 Pro Max simulator, iOS
27.2): shift and auto-capitalisation around swipes are already right after
a comma, a swipe, a strip pick, a delete, a tapped word, a sentence-start
capital turned off, "?" and "!" (#2144, #2159). What still capitalised
mid-sentence was the casing of the candidates:
- Your own words: a Contacts name that is also a common word ("Bell",
  "Will", "Young") is a UILexicon term, and the swipe decoder reads the
  model's "bell" only as that own word, so it went in as "Bell" wherever
  it was swiped. The strip's completions offered it capitalised too.
- Fixes learned at the start of a sentence ("Helli" picked as "Hello"
  twice is learned as "Hello"), and guesses iOS returns capitalised, kept
  that capital mid-sentence (matchCase keeps a target's own capitals).
Apple's keyboard, black box (iOS 27.2, the simulator's contact Kate Bell):
swiping "the bell rang" gives lowercase "bell"; "taylor" and "kate" come out
"Taylor" and "Kate".

AutocorrectEngine.withoutStrayCapital writes such a word in lowercase when
you didn't type a capital and the dictionary knows it in lowercase. Names
the dictionary knows only capitalised ("Taylor", "Monday"), "I" and its
contractions, words with more capitals ("iPhone"), a capital you typed or
the sentence start gives, and German (nouns) keep theirs. Used for space's
fix (learned typos, Spatial readings, spelling guesses), the strip's
candidates and completions, and swipeCased.

Verified on the Mac Studio, iPhone 18 Pro (iOS 27.2 simulator):
- New tests testAFixBringsNoCapitalOfItsOwnMidSentence and
  testSwipedWordsTakeACapitalOnlyWhereApplesKeyboardGivesOne fail on the
  previous commit ("hello there's the Bell Will", "Hello" for "helli") and
  pass now.
- xcodebuild test -only-testing AutocorrectEngineTests,
  FullKeyboardEngineTests, SwipeDecoderTests: 158 tests, 0 failures.
2026-11-21 06:10:45 -05:00
..
Fixtures iOS: emoji panel with on-device suggestions (Experiments › Emoji) (#2051) 2026-11-20 15:53:24 +00:00
AutocorrectEngineTests.swift iOS: text replacements fire like the system's and stay put, and no stray capitals from suggestions (#2173) 2026-11-21 06:10:45 -05:00
CleanupTaggerTests.swift iOS: Clean up what I say keeps names, and is on by default (#2132) 2026-11-21 03:12:53 +00:00
CustomVocabularyTests.swift ios: custom vocabulary experiment (#1547) 2026-11-08 12:15:00 -05:00
DictationControllerTests.swift iOS: model preparation loads once, keeps moving, and survives the background (#2171) 2026-11-21 10:39:38 +00:00
DictationLearningTests.swift ios: learn dictation and typing fixes from edits (Learn how I type) (#2022) 2026-11-20 01:04:58 +00:00
DotScopeTests.swift fix(ios): eliminate handoff frame stalls and add overlapping ballistic swipe throw (t1153) (#757) 2026-10-31 22:14:22 -07:00
EmojiSuggesterTests.swift iOS: emoji panel memory, category taps, an eight-column Frequently used, and the system's look (#2142) 2026-11-21 04:31:34 +00:00
FullKeyboardEngineTests.swift iOS: text replacements fire like the system's and stay put, and no stray capitals from suggestions (#2173) 2026-11-21 06:10:45 -05:00
HexKeyGestureTests.swift iOS: fewer paste prompts, and a translate switch in the keyboard (#2134) 2026-11-21 03:24:58 +00:00
KeyboardBridgeTests.swift iOS: a handoff to Hex can't leave the keyboard stuck, and dismissed dictations still deliver (#2163) 2026-11-21 08:31:48 +00:00
KeyboardLayoutTests.swift iOS: choose QWERTY, QWERTZ, AZERTY or Dvorak per keyboard language (#2172) 2026-11-21 10:41:12 +00:00
ShiftStateMachineTests.swift iOS: full keyboard experiment flag, key layout and shift model (#910) 2026-11-01 12:43:35 -08:00
SwipeDecoderTests.swift iOS: swipe typing for English and Spanish (Experiment, off by default) (#2106) 2026-11-20 22:30:53 +00:00
TranscriptCleanupTests.swift iOS: text replacements without autocorrect, End with a period, and emoji and symbols on the Dictation bar (#2147) 2026-11-21 06:24:16 +00:00
TypingLogTests.swift iOS: opaque keyboard panel so stale system layers can't show through, and a nil-safe field ID (#2139) 2026-11-21 03:45:47 +00:00