feat: highlight autocomplete suggestion when it matches typed word#648
feat: highlight autocomplete suggestion when it matches typed word#648Mounil2005 wants to merge 8 commits into
Conversation
Thank you for the pull request! 💙🩵The Scribe-Android team will do our best to address your contribution as soon as we can. The following are some important points:
Note Scribe uses Conventional Comments in reviews to make sure that communication is as clear as possible. |
Maintainer ChecklistThe following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :)
|
|
praise: Thanks so much for the PR, @Mounil2005! We'll try to get to the review in the coming days :) note: For UI changes like this, would you be able to send along a screenshot that includes the change? If it's something like this, then maybe there's no need for a screenshot of the state before the change, but before and after screenshots are also quite helpful as a reviewer in knowing that the work has been completed before going into the code. Just suggesting! 😊 |
2ec0e10 to
e19e0a1
Compare
|
note @Mounil2005, @@Priyanshikaa1111: I'm thinking that it might be for the best if we move the word that the user is typing to the first autocompletion sole and just change the background to be highlighted rather than the text being blue. This at least is a common behavior in iOS keyboards. Specifically what this allows us to do is also have a space functionality where when the word is highlighted, pressing space will insert it. The way that this works in Scribe-iOS is the following:
The example above of "do" -> "dolphin" would never happen, so this example is mainly for larger words where once a user types enough of it, then it's obvious that they're typing it and we might as well insert the rest on space for them. The indication that this is going to happen is the autosuggestion being highlighted :) How does this sound to the both of you? CC @angrezichatterbox for this discussion 👋 |
That sounds great, thanks for the detailed writeup! I've implemented all three pieces:
I'll be attaching images shortly to show this working end-to-end. |
While testing the highlighting behavior across different word lengths, I found something worth flagging separately: the native suggestion engine's completions become increasingly unrelated to the actual typed prefix as the word gets longer, across all languages (not German-specific). Example: typing dolp in English returns mol, DSL, Sol, AOL....none of which start with "dolp" and Dolphin never shows up as a candidate at all, despite being the obvious match. Shorter prefixes (dol) still look reasonable; the divergence grows with length. Root cause: ComposedData.createForWord() generates random touch coordinates (Random.nextBits(2)) for every typed character instead of real ones, and this gets paired with a completely empty ProximityInfo (keyCount=0, no real key geometry). The underlying native engine is a spatial/gesture-typing correction algorithm, it ranks candidates partly by touch-point proximity, so feeding it random noise corrupts the ranking, with more accumulated noise (longer words) causing more drift from the actual prefix. This predates this PR....it just wasn't visible before since the raw completions were only ever used for background suggestion chips. Step 3 of this PR (highlighting the single unambiguous candidate) depends on completion precision, which is what surfaced it. Fixing it properly likely needs either real per-key coordinates for each keyboard layout or a suggest-mode that bypasses spatial correction for pure prefix lookup,both feel out of scope for #410, so flagging it here for a separate issue rather than trying to fix it in this PR. Happy to file it as its own issue if that's preferred. |
|
As a mitigation for the above (while the deeper fix is still open), I added a startsWith(prefix, ignoreCase = true) filter to NativeSuggestionEngine.getAutocompletions(), so any suggestion shown or highlighted is now guaranteed to actually extend what the user typed. This specifically matters for the "single unambiguous candidate" highlight, which would otherwise have trusted and potentially auto-inserted (via space) an off-prefix candidate. Verified on-device: dolphi now correctly returns dolphin's, dolphin, dolphins instead of the earlier junk. |
Co-authored-by: Priyanshikaa1111 <Priyanshikaa1111@gmail.com> Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
Co-authored-by: Priyanshikaa1111 <Priyanshikaa1111@gmail.com> Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
…blue text Co-authored-by: Priyanshikaa1111 <Priyanshikaa1111@gmail.com> Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
Co-authored-by: Priyanshikaa1111 <Priyanshikaa1111@gmail.com> Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
Co-authored-by: Priyanshikaa1111 <Priyanshikaa1111@gmail.com> Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
Co-authored-by: Priyanshikaa1111 <Priyanshikaa1111@gmail.com> Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
Co-authored-by: Priyanshikaa1111 <Priyanshikaa1111@gmail.com> Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
Co-authored-by: Priyanshikaa1111 <Priyanshikaa1111@gmail.com> Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
dfa1ec1 to
48e7fae
Compare
|
Hey @Mounil2005 and @Priyanshikaa1111 👋 Looks like we're also doing the work for #407 here :) A few points:
CC @angrezichatterbox for the conversation here 😊 |
|
@andrewtavis We wouldn't have a lot of suggestions right that follow this pattern as we are using autosuggestions in the android keyboard. |
|
So for every word we type we would be checking the autosuggestion data and doing a query to see the word gender right. We would have to make sure that the keyboard doesn't have to do a lot of db operations as well. |
I think there is already a pure prefix based check in the codebase. We would have to make slight changes to the exising autosuggestions to be more deterministic. |
Yes, this is true. We should be using this instead of something new.
Very true! This needs to be optimized.
This highlight is specifically for autocompletions. Is it possible to have the autocompletions be a bit more alphabetical and then use the autosuggestions from the current implementation? |







Contributor checklist
./gradlew lintKotlin detekt testcommand as directed in the testing section of the contributing guideDescription
Once the user has typed enough of a word that the first autocomplete suggestion exactly matches it (e.g. typing "Buch" when "Buch" is itself a suggestion), that suggestion chip is now highlighted (bold, accent blue text) to indicate that tapping it is effectively a no-op, matching the existing Scribe-iOS behavior described in the issue.
app/src/keyboards/java/be/scri/services/GeneralKeyboardIME.kt:setSuggestionButtonandsetAutocompleteButtonnow accept the word currently being typed. If a suggestion's text exactly matches it (case-insensitive), the button is rendered bold usingR.color.theme_scribe_blueinstead of the default text color. Tap behavior is unchanged — it still deletes the current word and re-inserts the suggestion (a no-op when they're equal).app/src/keyboards/java/be/scri/helpers/AutocompletionHandler.kt: passes the current word through toupdateAutocompleteSuggestionsso the exact-match check has what it needs.Tested by running
./gradlew lintKotlin detekt test(all green) and./gradlew :app:compileKeyboardsDebugKotlin.Related issue