Skip to content

Improve autocomplete behaviour #8669

Open
aibrahim- wants to merge 5 commits into
developfrom
aibrahim/bugfix/improve-autocomplete-behaviour
Open

Improve autocomplete behaviour #8669
aibrahim- wants to merge 5 commits into
developfrom
aibrahim/bugfix/improve-autocomplete-behaviour

Conversation

@aibrahim-
Copy link
Copy Markdown
Contributor

@aibrahim- aibrahim- commented May 22, 2026

Task/Issue URL: https://app.asana.com/1/137249556945/project/1214157224317277/task/1214964760144656?focus=true

Description

Three related fixes around the native-input widget's autocomplete:

  1. Avoid spurious "loading from scratch" on widget re-open with same text. showNativeInput dropped the onClearAutocomplete call that emptied searchResults and re-triggered a fetch; restores the suggestions list visibility from the adapter when the cache matches the prefill.

  2. Reveal the browser behind the closing widget earlier. hideNtp now runs at the start of hideNativeInput so the webpage is visible during the exit animation, instead of after the 200ms exit + 150ms fade leaves the NTP background filling the screen.

  3. Always keep an autocomplete cache for the omnibar's text so in-widget typing never permanently displaces the omnibar's results. Adds an always-on parallel pipeline in BrowserTabViewModel (omnibarAutocompleteCache) fed by onOmnibarTextChanged; the widget restores from it on close (non-navigation) and on open if the cache matches the prefill.

Steps to test this PR

  • enable native input widget
  • start a search by typing on the keyboard
  • observe autocomplete
  • going back should immediately display the web page.
  • lauching the keyboard again should immediately display the autocomplete list.

UI changes

Before After
before after

Note

Medium Risk
Touches autocomplete flow logic and native-input widget lifecycle/teardown, which could cause regressions in suggestions rendering or keyboard/tab-switch behavior if the new caching and backgrounding hooks misfire.

Overview
Improves native-input widget autocomplete so reopening the widget with the same text can immediately reuse cached omnibar suggestions instead of clearing state and refetching.

Adds an always-on (setting-gated) omnibar autocomplete cache in BrowserTabViewModel, feeds it from rendered omnibar text, and exposes a restore path used when the widget opens/closes to prevent in-widget typing from permanently displacing omnibar results.

Tightens widget lifecycle behavior: reveals the live page earlier during exit (moves hideNtp), adds onTabBackgrounded to synchronously dismiss IME/tear down the widget on tab hide/swipe, guards enter-complete focus against detached views, and updates enter-animation preview to apply correct per-tab state for top/bottom layouts. Tests cover cache gating, restore behavior, and pixel implications.

Reviewed by Cursor Bugbot for commit 16e361d. Bugbot is set up for automated code reviews on this repo. Configure here.

aibrahim- and others added 2 commits May 22, 2026 13:58
Three related fixes around the native-input widget's autocomplete:

1. Avoid spurious "loading from scratch" on widget re-open with same text.
   showNativeInput dropped the onClearAutocomplete call that emptied
   searchResults and re-triggered a fetch; restores the suggestions list
   visibility from the adapter when the cache matches the prefill.

2. Reveal the browser behind the closing widget earlier. hideNtp now runs
   at the start of hideNativeInput so the webpage is visible during the
   exit animation, instead of after the 200ms exit + 150ms fade leaves
   the NTP background filling the screen.

3. Always keep an autocomplete cache for the omnibar's text so in-widget
   typing never permanently displaces the omnibar's results. Adds an
   always-on parallel pipeline in BrowserTabViewModel (omnibarAutocompleteCache)
   fed by onOmnibarTextChanged; the widget restores from it on close
   (non-navigation) and on open if the cache matches the prefill.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Dismiss the IME and cancel any in-flight enter animation when the hosting
tab is backgrounded so the keyboard does not leak onto the next tab, and
seed beginEnterAnimationPreview's state locally instead of reading from
NativeInputStateProvider — ViewScope injection isn't guaranteed to be in
place by the time it runs on a tab-switch attach.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@aibrahim- aibrahim- changed the title Aibrahim/bugfix/improve autocomplete behaviour Improve autocomplete behaviour May 22, 2026
Comment thread app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt
Comment thread app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fbc586b. Configure here.

Comment thread app/src/main/java/com/duckduckgo/app/browser/BrowserWebViewClient.kt Outdated
@aibrahim- aibrahim- force-pushed the aibrahim/bugfix/improve-autocomplete-behaviour branch from fbc586b to 16e361d Compare May 22, 2026 12:42
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