Skip to content

fix(web): improve prediction whitespace-input, backspace-input edge case handling 🚂 - #16273

Open
jahorton wants to merge 7 commits into
epic/autocorrectfrom
fix/web/empty-prediction-cases
Open

fix(web): improve prediction whitespace-input, backspace-input edge case handling 🚂#16273
jahorton wants to merge 7 commits into
epic/autocorrectfrom
fix/web/empty-prediction-cases

Conversation

@jahorton

@jahorton jahorton commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Fixes: #16271
Fixes: #16272

Build-bot: skip release:web,android,ios

User Testing

Perform all tests with the sil_euro_latin keyboard and an English-language lexical model active within this PR's artifact for Keyman for Android.

TEST_SUGGESTIONS_ON_BKSP: Verify that reasonable suggestions are displayed for text after using BKSP to reach the end of a previous word.

  • Type part of a word.
  • Hit the spacebar once.
  • Tap backspace once.
  • Multiple suggestions should be displayed, all based on the remaining word.

TEST_PERIOD_OVERWRITE_REVERSION: Check if punctuation typed immediately after applying a suggestion erases the whitespace.

  • Type the following, depending on active keyboard:
    • sil_euro_latin: Type searchi.
    • gff_amharic: Type ውስጥል. (Positionally, QWERTY xskl.)
  • Tap the automatically-highlighted suggestion.
  • Then tap a punctuation mark.
    • sil_euro_latin: . will do nicely.
    • gff_amharic: the base-layer ! key will work nicely.
  • Verify that the suggestion-inserted space is removed - that no whitespace between the suggested text and the punctuation mark.
  • Backspace over the punctuation mark and verify that a proper reversion is displayed (either searchi or ጽሕ depending on the test's keyboard.)
  • Apply the reversion and verify that no errors result.
  • Clear the context and type 3 words, then a space, and then repeat this test until reaching this line.

TEST_PERIOD_APPLICATION_DELAYED_REVERSION: Check if punctuation typed immediately after applying a suggestion erases the whitespace.

  • Type the following, depending on active keyboard:
    • sil_euro_latin: Type searchi.
    • gff_amharic: Type ውስጥል. (Positionally, QWERTY xskl.)
  • Then tap a punctuation mark.
    • sil_euro_latin: . will do nicely.
    • gff_amharic: the base-layer ! key will work nicely.
  • Verify that no whitespace exists between the suggestion and the punctuation mark.
  • Tap the punctuation mark again and verify that it outputs a new copy.
  • Backspace over the newest copy of the punctuation mark and verify that a proper reversion is displayed.
  • Apply the reversion and verify that no errors result.
  • Clear the context and type 3 words, then a space, and then repeat this test until reaching this line.

TEST_DELAYED_ON_WORD: Check if deleting characters up to the end of an applied suggestion's main body displays a reversion.

  1. Tap one of the default suggestions.
  2. Type the following, depending on active keyboard:
    • sil_euro_latin: Type searchi.
    • gff_amharic: Type ውስጥል. (Positionally, QWERTY xskl.)
  3. Apply the automatically-highlighted suggestion with the space key. Note the full context obtained here, as it will be relevant later.
  4. Tap an additional suggestion.
  5. Type two additional letters after the tapped suggestion.
  6. Delete text until the text insertion point is immediately after the end of the suggestion applied in step 3.
  7. Verify that an appropriate reversion is displayed.
  8. Apply it and verify that the full text reverts to the "full context" you noted at the end of step 3.
  9. Verify that the original suggestions are displayed, but no suggestion is automatically selected / highlighted.
  10. Type a random character on the keyboard and verify that no errors, notifications, or warnings are displayed.

TEST_DELAYED_ON_SPACE: Check if deleting characters up to the end of an applied suggestion's main body displays a reversion.

  1. Tap one of the default suggestions.
  2. Type the following, depending on active keyboard:
    • sil_euro_latin: Type searchi.
    • gff_amharic: Type ውስጥል. (Positionally, QWERTY xskl.)
  3. Apply the automatically-highlighted suggestion with the space key. Note the full context obtained here, as it will be relevant later.
  4. Tap an additional suggestion.
  5. Type two additional letters after the tapped suggestion.
  6. Delete text until the text insertion point is immediately after the whitespace after the end of the suggestion applied in step 3.
  7. Verify that an appropriate reversion is displayed.
  8. Apply it and verify that the full text reverts to the "full context" you noted at the end of step 3.
  9. Verify that the original suggestions are displayed, but no suggestion is automatically selected / highlighted.
  10. Type a random character on the keyboard and verify that no errors, notifications, or warnings are displayed.

TEST_REVERT_MATCHING_KEEP: Check if applied 'keep' suggestions display both a 'revert' and 'keep' in reversion-triggering contexts.

  1. Tap one of the default suggestions.
  2. Type the following, depending on active keyboard:
    • sil_euro_latin: Type searchi.
    • gff_amharic: Type ውስጥል. (Positionally, QWERTY xskl.)
  3. Apply the automatically-highlighted suggestion with the space key. Note the full context obtained here, as it will be relevant later.
  4. Type two additional letters after the tapped suggestion.
  5. Delete text until the text insertion point is immediately after the end of the suggestion applied in step 3.
  6. Verify that only one suggestion for "searchi" is displayed - not two.

@keymanapp-test-bot

keymanapp-test-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

User Test Results

Test specification and instructions

Test Artifacts

@keymanapp-test-bot keymanapp-test-bot Bot changed the title fix(web): improve prediction whitespace-input, backspace-input edge case handling fix(web): improve prediction whitespace-input, backspace-input edge case handling 🚂 Jul 21, 2026
@keymanapp-test-bot keymanapp-test-bot Bot added this to the A19S34 milestone Jul 21, 2026
@Meng-Heng

Meng-Heng commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Test Specs

  1. Keyman v19.0.252-alpha-test-16273
  2. Enable "Predictions with auto-corrections"
  3. Dismiss "Get Started" instructions

Test Results

  • TEST_SUGGESTIONS_ON_BKSP (PASSED):
  1. Type part of a word
  2. Hit the spacebar once
  3. VERIFIED:
    • Multiple suggestions displayed
  4. Tap backspace once
  5. VERIFIED:
    • Multiple suggestions displayed, all based on the remaining word.
  • TEST_PERIOD_OVERWRITE_REVERSION (FAILED):
  1. Clear all pre-existing text
  2. Type searchi
  3. Tap the automatically-highlighted suggestion
  4. Then tap the punctuation mark .
  5. VERIFIED:
    • The suggestion-inserted space is removed - that no whitespace between the suggested text and the punctuation mark.
    • Text result: searching.
  6. Backspace over the punctuation mark, text result: searching
  7. VERIFIED:
    • The prediction bar is blank.
  • TEST_PERIOD_APPLICATION_DELAYED_REVERSION (PASSED):
  1. Clear all pre-existing text
  2. Type searchi
  3. Then tap the punctuation mark .
  4. VERIFIED: No whitespace exists between the suggestion and the punctuation mark.
  5. Tap the punctuation mark again
  6. VERIFIED: Text result: searching..
  7. Backspace over the newest copy of the punctuation mark
  8. VERIFIED: that a proper reversion is "searchi"
  9. Apply the reversion
  10. VERIFIED: No errors result
  11. Clear the context and type 3 words, then a space, and then repeat this test until reaching this line
  12. Text result: This is a searchi.
  • TEST_DELAYED_ON_WORD (FAILED):
  1. Clear all pre-existing text
  2. Tap The from the default suggestion
  3. Type searchi
  4. Apply the "searchi" suggestion
  5. Tap "the" additional suggestion
  6. Type aa after the tapped suggestion.
  7. Delete text until the text insertion point is immediately after the end of the suggestion applied in step 3.
  8. VERIFIED: The "searchi" and other suggestions displayed
  9. Apply "searchi"
  10. VERIFIED: the full text reverts to the searchi (at the end of step 3)
  11. FAILED: No suggestion, and the prediction bar becomes blank.
  • TEST_DELAYED_ON_SPACE (FAILED):
  1. Clear all pre-existing text
  2. Tap The from the default suggestion
  3. Type searchi
  4. Apply the "searchi" suggestion
  5. Tap "the" additional suggestion
  6. Type aa after the tapped suggestion.
  7. Delete text until the text insertion point is immediately after the whitespace of the suggestion applied in step 3.
  8. VERIFIED: The "searchi" and other suggestions displayed
  9. Apply "searchi"
  10. VERIFIED: the full text reverts to the searchi (at the end of step 3)
  11. FAILED: No suggestion, and the prediction bar becomes blank.

@keymanapp-test-bot keymanapp-test-bot Bot added user-test-failed and removed user-test-required User tests have not been completed labels Jul 22, 2026
This will help in cases where a user wishes to revert a suggestion after numerous other edits.
import { RewindableCache } from "keyman/common/web-utils";

const TRANSCRIPTION_BUFFER_SIZE = 10;
const TRANSCRIPTION_BUFFER_SIZE = 20;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old user tests specs no longer pass as-is without this change - in part because English suggestions now apply two separate Transforms in sequence. This leads to a greater required rewind / backspace length within the main engine.

@jahorton

Copy link
Copy Markdown
Contributor Author

I believe that the latest commit should address two of the user tests:

Test-bot: retest TEST_DELAYED_ON_WORD TEST_DELAYED_ON_SPACE

@keymanapp-test-bot keymanapp-test-bot Bot added the user-test-required User tests have not been completed label Jul 22, 2026
@Meng-Heng

Meng-Heng commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Test Prerequisite

  1. Enable "Predictions with auto-corrections"

Test Results

  • TEST_DELAYED_ON_WORD (FAILED):
  1. Clear all pre-existing text
  2. Tap The from the default suggestion
  3. Type searchi
  4. Apply the "searchi" suggestion
  5. Tap the additional suggestion
  6. Type aa after the tapped suggestion
  7. Then delete text until the text insertion point is immediately after the end of the suggestion applied in step 3.
  8. FAILED: Two "searchi" and other suggestions displayed
    Screenshot 2026-07-23 at 1 02 11 in the afternoon
  9. Apply the first "searchi"
  10. The text result The searchi (with no space at the end)
  11. Apply the second "searchi"
  12. The text result The searchi (with a space at the end)
  13. VERIFIED: The full text reverts to the searchi (at the end of step 3)
  14. VERIFIED: Suggestion related to the word appears
  15. VERIFIED: No suggestion is automatically selected / highlighted
  16. Type a
  17. VERIFIED: No error.
  • TEST_DELAYED_ON_SPACE (PASSED):
  1. Clear all pre-existing text
  2. Tap You from the default suggestion
  3. Type searchi
  4. Apply the "searchi" suggestion
  5. Tap of additional suggestion
  6. Type vv after the tapped suggestion
  7. Then delete text until the text insertion point is immediately after the whitespace of the suggestion applied in step 3
  8. VERIFIED: The "searchi" and other suggestions displayed
  9. Apply "searchi"
  10. The text result You searchi
  11. VERIFIED: The full text reverts to the searchi (at the end of step 3)
  12. VERIFIED: Suggestion related to the word appears
  13. VERIFIED: No suggestion is automatically selected / highlighted
  14. Type n
  15. VERIFIED: No error.

@keymanapp-test-bot keymanapp-test-bot Bot removed the user-test-required User tests have not been completed label Jul 23, 2026
@jahorton

jahorton commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

TEST_DELAYED_ON_WORD (FAILED):

Could you capture a video for this? I'm not clear on exactly what you're doing here, as that screenshot is for a very unexpected state.

Also, are the failing tests failing on the first try, or only some of the time after retries?

@Meng-Heng

Copy link
Copy Markdown
Contributor

Also, are the failing tests failing on the first try, or only some of the time after retries?

The two failed tests in this PR has been consistent for me. It failed on the first try, and keep failing on the retries.

This is the video for applying the left-most "searchi" suggestion:

Screen.Recording.2026-07-24.at.3.01.53.in.the.afternoon.mov

This is the video for applying the second-left-most "searchi" suggestion:

Screen.Recording.2026-07-24.at.3.10.27.in.the.afternoon.mov

Please let me know where I went wrong with this.

@jahorton

Copy link
Copy Markdown
Contributor Author

Also, are the failing tests failing on the first try, or only some of the time after retries?

The two failed tests in this PR has been consistent for me. It failed on the first try, and keep failing on the retries.

This is the video for applying the left-most "searchi" suggestion:
Screen.Recording.2026-07-24.at.3.01.53.in.the.afternoon.mov

This is the video for applying the second-left-most "searchi" suggestion:
Screen.Recording.2026-07-24.at.3.10.27.in.the.afternoon.mov

Please let me know where I went wrong with this.

On the "left-most" case: note how the searching suggestion is auto-highlighted. That (searching) is the suggestion to apply at that stage in the test.

That does highlight the cause of the duplicate suggestion you reported, which is helpful - I hadn't thought to check for duplicated "keep" suggestions in such a scenario. Thanks for catching that!

@Meng-Heng

Copy link
Copy Markdown
Contributor

Test Result

  • TEST_DELAYED_ON_WORD (PASSED):
  1. Tap The from the default suggestion
  2. Type searchi
  3. Apply the auto searching highlighted suggestion by pressing SPACEBAR
  4. Tap the additional suggestion
  5. Type aa after the tapped suggestion
  6. Then delete text until the text insertion point is immediately after the end of the suggestion applied in step 3.
  7. Apply the "searchi" from the suggestion
  8. The text result is The searchi (with no space at the end)
  9. VERIFIED:
    • The full text reverts to the searchi (at the end of step 3)
    • Suggestion related to the word appears
    • No suggestion is automatically selected / highlighted
  10. Type a
  11. Text result is The searchia
  12. VERIFIED: No error.

Note

Apply the auto searching highlighted suggestion by pressing SPACEBAR does not produce two "searchi" suggestions.

@keymanapp-test-bot keymanapp-test-bot Bot added the user-test-required User tests have not been completed label Jul 27, 2026
@jahorton

Copy link
Copy Markdown
Contributor Author

Test-bot: retest TEST_PERIOD_OVERWRITE_REVERSION

There's a chance the latest fixes may have also addressed the previously-detected user-test failure.

@jahorton
jahorton requested a review from ermshiperete July 27, 2026 13:02
@Meng-Heng

Copy link
Copy Markdown
Contributor

Test Specs

  1. Android Emulator Pixel 9
  2. Keyman for Android v19.0.252-alpha-test-16273

Test Results

  • TEST_PERIOD_OVERWRITE_REVERSION (FAILED):
  1. Enable "Predictions and auto-suggestions"

  2. Type searchi

  3. Tap the automatically-highlighted searching suggestion

  4. Then tap the punctuation mark .

  5. VERIFIED: The suggestion-inserted space is removed. No whitespace between the suggested text and the punctuation mark

  6. Text result: searching.

  7. Backspace over the punctuation mark, text result: searching

  8. FAILED:

    • The prediction bar is blank:
    Screen.Recording.2026-07-28.at.2.07.09.in.the.afternoon.mov
  • TEST_REVERT_MATCHING_KEEP (PASSED):
  1. Tap The.
  2. Type searchi
  3. Apply the automatically-highlighted searching suggestion with the space key
  4. Type aa additional letters after the tapped suggestion
  5. Delete text until the text insertion point is immediately after the end of the suggestion applied in step 3
  6. VERIFIED: Only one suggestion for "searchi" is displayed - not two.

@keymanapp-test-bot keymanapp-test-bot Bot added user-test-failed and removed user-test-required User tests have not been completed labels Jul 28, 2026
@jahorton

Copy link
Copy Markdown
Contributor Author

OK, that one's on me. Somehow thought it was a slightly different test.

Pushing up a fix now that should address the remaining failing test, so...

Test-bot: retest TEST_PERIOD_OVERWRITE_REVERSION

@keymanapp-test-bot keymanapp-test-bot Bot added user-test-required User tests have not been completed and removed user-test-failed labels Jul 28, 2026
@Meng-Heng

Copy link
Copy Markdown
Contributor

Test Results

  • TEST_PERIOD_OVERWRITE_REVERSION (PASSED):
  1. Enable "Predictions and auto-suggestions"
  2. Type searchi
  3. Tap the automatically-highlighted searching suggestion
  4. Then tap the punctuation mark .
  5. VERIFIED:
    • The suggestion-inserted space is removed
    • No whitespace between the suggested text and the punctuation mark
  6. Text result: searching.
  7. Backspace over the punctuation mark, text result: searching
  8. VERIFIED:
    • Only the proper "searchi" reversion is displayed
  9. Apply the suggestion result in searchi with no error
  10. Erase all text
  11. Type 3 words, then a space, and then repeat this test until reaching this line
  12. VERIFIED:
    • Final text result Important of test searchi.
    • The prediction applied with no error.

@keymanapp-test-bot keymanapp-test-bot Bot removed the user-test-required User tests have not been completed label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants